Skip to content

Commit 6b0a98b

Browse files
committed
Resolve rapid7#4408 - bad uncaught nil get_once
1 parent 9de4137 commit 6b0a98b

File tree

8 files changed

+28
-13
lines changed

8 files changed

+28
-13
lines changed

modules/auxiliary/scanner/misc/ib_service_mgr_info.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def run_host(ip)
154154

155155
sock.put(buf)
156156

157-
response = sock.get_once
157+
response = sock.get_once || ''
158158

159159
# print(Rex::Text.to_hex_dump(response))
160160

@@ -198,7 +198,7 @@ def run_host(ip)
198198

199199
sock.put(buf)
200200

201-
response = sock.get_once
201+
response = sock.get_once || ''
202202

203203
res = response.unpack('x28Z*Z*')
204204

modules/auxiliary/scanner/misc/poisonivy_control_scanner.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ def run_host(ip)
6666
)
6767
r << [ip,port,"open",'Unknown']
6868
s.puts("\x00"*0x100,0) #Send 0x100 zeros, wait for answer
69-
data = s.get_once(0x100)
69+
data = s.get_once(0x100) || ''
7070
if data.length == 0x100
71-
data = s.get_once(0x4)
71+
data = s.get_once(0x4) || ''
7272
if data == "\xD0\x15\x00\x00" #Signature for PIVY C&C
7373
print_status("#{ip}:#{port} - C&C Server Found")
7474
r << [ip,port,"open",'Poison Ivy C&C']

modules/auxiliary/scanner/misc/zenworks_preboot_fileaccess.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,20 @@ def run_host(ip)
6363
sock.put(packet)
6464
sock.get_once(4, 1)
6565
length = sock.get_once(4, 1)
66+
67+
unless length
68+
print_error("Unable to get length due to a timeout")
69+
return
70+
end
71+
6672
sock.get_once(0x210-8, 1)
6773
contents = sock.get_once(length.unpack("V").first, 1)
74+
75+
unless contents
76+
print_error("Unable to extract contents due to a timeout")
77+
return
78+
end
79+
6880
disconnect
6981

7082
print_status "File retrieved successfully!"

modules/auxiliary/scanner/rservices/rlogin_login.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ def do_login(user, pass, luser, status = nil)
218218
sock.put("\x00#{luser}\x00#{user}\x00#{datastore['TERM']}/#{datastore['SPEED']}\x00")
219219

220220
# Read the expected nul byte response.
221-
buf = sock.get_once(1)
221+
buf = sock.get_once(1) || ''
222222
return :abort if buf != "\x00"
223223

224224
# NOTE: We report this here, since we are awfully convinced now that this is really

modules/auxiliary/scanner/scada/sielco_winlog_fileaccess.rb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def run_host(ip)
6565
packet << travs # Path traversal
6666
packet << "\x00"
6767
sock.put(packet)
68-
response = sock.get_once(5, 1)
68+
response = sock.get_once(5, 1) || ''
6969

7070
if response.unpack("C").first != 0x78
7171
print_error "#{ip}:#{rport} - Error opening file"
@@ -84,7 +84,7 @@ def run_host(ip)
8484
packet << stream # stream
8585
packet << "\x00" * 7
8686
sock.put(packet)
87-
response = sock.get_once(5, 1)
87+
response = sock.get_once(5, 1) || ''
8888

8989
if response.unpack("C").first != 0x79
9090
print_error "#{ip}:#{rport} - Error getting the file length"
@@ -106,7 +106,7 @@ def run_host(ip)
106106
response = ""
107107

108108
while response.length < 0x7ac # Packets of 0x7ac (header (0x9) + block of data (0x7a3))
109-
response << sock.get_once(0x7ac-response.length, 5)
109+
response << sock.get_once(0x7ac-response.length, 5) || ''
110110
end
111111
if response.unpack("C").first != 0x98
112112
print_error "#{ip}:#{rport} - Error reading the file, anyway we're going to try to finish"
@@ -126,7 +126,7 @@ def run_host(ip)
126126
packet << "\x7B"
127127
packet << "\x00" * 11
128128
sock.put(packet)
129-
response = sock.get_once(-1, 1)
129+
response = sock.get_once(-1, 1) || ''
130130
if response.unpack("C").first != 0x7B
131131
print_error "#{ip}:#{rport} - Error closing file file, anyway we're going to try to finish"
132132
end

modules/auxiliary/scanner/ssh/detect_kippo.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ def initialize(info = {})
2929

3030
def run_host(ip)
3131
connect
32-
banner = sock.get_once
32+
banner = sock.get_once || ''
3333
sock.put(banner + "\n" * 8)
34-
response = sock.get_once
34+
response = sock.get_once || ''
3535

3636
if response =~ /(?:^Protocol mismatch\.\n$|bad packet length)/
3737
print_good("#{ip}:#{rport} - Kippo detected!")

modules/auxiliary/scanner/vmware/vmauthd_version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def run_host(ip)
8484

8585
def do_login(user, pass, nsock=self.sock)
8686
nsock.put("USER #{user}\r\n")
87-
res = nsock.get_once
87+
res = nsock.get_once || ''
8888
unless res.start_with? "331"
8989
ret_msg = "Unexpected reply to the USER command: #{res}"
9090
return ret_msg

modules/auxiliary/scanner/x11/open_x11.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ def run_host(ip)
4545

4646
disconnect
4747

48-
if(response)
48+
if response
4949
success = response[0,1].unpack('C')[0]
50+
else
51+
print_error("No response received due to a timeout")
52+
return
5053
end
5154

5255

0 commit comments

Comments
 (0)