Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.