Skip to content

Commit fdca963

Browse files
committed
check if the socket exists before closing
1 parent bb684bb commit fdca963

File tree

1 file changed

+7
-3
lines changed
  • modules/auxiliary/scanner/portscan

1 file changed

+7
-3
lines changed

modules/auxiliary/scanner/portscan/tcp.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,10 @@ def run_host(ip)
8080
'ConnectTimeout' => (timeout / 1000.0)
8181
}
8282
)
83-
print_status("#{ip}:#{port} - TCP OPEN")
84-
r << [ip,port,"open"]
83+
if s
84+
print_status("#{ip}:#{port} - TCP OPEN")
85+
r << [ip,port,"open"]
86+
end
8587
rescue ::Rex::ConnectionRefused
8688
vprint_status("#{ip}:#{port} - TCP closed")
8789
r << [ip,port,"closed"]
@@ -92,7 +94,9 @@ def run_host(ip)
9294
rescue ::Exception => e
9395
print_error("#{ip}:#{port} exception #{e.class} #{e} #{e.backtrace}")
9496
ensure
95-
disconnect(s) rescue nil
97+
if s
98+
disconnect(s) rescue nil
99+
end
96100
end
97101
end
98102
end

0 commit comments

Comments
 (0)