Created
October 31, 2016 19:32
-
-
Save mubix/ac94ee331b55b5e6d7335325cc0c2154 to your computer and use it in GitHub Desktop.
Reverse HTTPS Handler Checker
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'net/smtp' | |
def issue_alert | |
thetimeitfailed = Time.now | |
message = <<MESSAGE_END | |
From: HANDLERCHECKIN <root@metasploithandler> | |
To: Rob Fuller <mubix@hak5.org> | |
Subject: Handler Checkin | |
The handler failed at #{thetimeitfailed} | |
MESSAGE_END | |
Net::SMTP.start('localhost') do |smtp| | |
smtp.send_message message, 'root@metasploithandler', | |
'mubix@hak5.org' | |
end | |
puts "[-] Handler failed at #{thetimeitfailed}" | |
end | |
def do_test | |
result = %x[timeout 3 openssl s_client -showcerts -connect MyHandlerIPAddressHere:443 2>&1] | |
if result =~ /MetasploitCertificateOutputRegexHere/ | |
print "[*] Handler still active - #{Time.now}\r" | |
$stdout.flush | |
return true | |
else | |
issue_alert | |
return false | |
end | |
end | |
test = true | |
puts "[*] Beginning Test..." | |
loop do | |
test = do_test | |
break if test == false | |
select(nil,nil,nil,5) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment