Skip to content

Instantly share code, notes, and snippets.

@presidentbeef
Created July 22, 2010 17:30
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 presidentbeef/486293 to your computer and use it in GitHub Desktop.
Save presidentbeef/486293 to your computer and use it in GitHub Desktop.
#Have a site that is compromised somehow.
#Someone is able to upload malicious .htaccess files that
#redirect based on User Agent being Windows and a whole list
#of possible referers, including Google.com.
#
#This script periodically checks the site and then emails if it gets
#anything other than a 200
require 'net/smtp'
site = "example.com"
sender_email = "someone@example.com"
receiver_email = "someoneelse@example.com"
smtp_server = "localhost"
wait_time = 3600
loop do
#Net::HTTP what?
headers = `curl -s -I -A Windows -e google.com #{site}`
if headers !~ /^HTTP\/1.1 200 OK\r\n/
message = <<-MAIL
From: <#{sender_email}>
To: <#{receiver_email}>
Subject: Website Problem
Headers:
#{headers}
MAIL
Net::SMTP.start(smtp_server) do |smtp|
smtp.send_message message, sender_email, receiver_email
end
end
sleep wait_time
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment