Skip to content

Commit a16e370

Browse files
committed
fix HOSTFILE parsing issues
1 parent fedef90 commit a16e370

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

modules/post/windows/recon/resolve_hostname.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def initialize(info={})
2727
], self.class)
2828
end
2929

30-
def resolve_hostname
30+
def resolve_hostname(hostname)
3131

3232
if client.platform =~ /^x64/
3333
size = 64
@@ -37,13 +37,11 @@ def resolve_hostname
3737
addrinfoinmem = 24
3838
end
3939

40-
hostname = datastore['HOSTNAME']
41-
4240
begin
4341
vprint_status("Looking up IP for #{hostname}")
4442
result = client.railgun.ws2_32.getaddrinfo(hostname, nil, nil, 4 )
4543
if result['GetLastError'] == 11001
46-
print_error("Failed to resolve the host")
44+
print_error("Failed to resolve #{hostname}")
4745
return
4846
end
4947
addrinfo = client.railgun.memread( result['ppResult'], size )
@@ -66,7 +64,9 @@ def run
6664

6765
if datastore['HOSTFILE']
6866
::File.open(datastore['HOSTFILE'], "rb").each_line do |hostname|
69-
resolve_hostname(hostname)
67+
if hostname.strip != ""
68+
resolve_hostname(hostname.strip)
69+
end
7070
end
7171
end
7272
end

0 commit comments

Comments
 (0)