Skip to content

Instantly share code, notes, and snippets.

@mubix
Created October 31, 2016 19:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mubix/ac94ee331b55b5e6d7335325cc0c2154 to your computer and use it in GitHub Desktop.
Save mubix/ac94ee331b55b5e6d7335325cc0c2154 to your computer and use it in GitHub Desktop.
Reverse HTTPS Handler Checker
#!/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