Skip to content

Instantly share code, notes, and snippets.

@mouseroot
Created August 23, 2012 01:39
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 mouseroot/3431151 to your computer and use it in GitHub Desktop.
Save mouseroot/3431151 to your computer and use it in GitHub Desktop.
sniff popups
import socket
import os
def copyfile():
host_path = "C:\Windows\System32\drivers\etc\hosts"
host_repl = "myhosts"
os.system("copy %s %s" % (host_repl,host_path))
def main():
print "Hosts File/localhost Http Sniffer"
print "By: Mouseroot"
print "Windows Only!"
print "----------------------"
print "\n"
copyfile()
http_data = "HTTP/1.0 200 OK\r\n"
http_data +="Connection: close\r\n"
http_data +="Server: Localhost http Sniffer\r\n"
http_data += "Content-Type: text/html\r\n\r\n"
http_data += "%3Cscript%3Ewindow.close();%3C/script%3E"
count = 0
myServ = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
myServ.bind(("localhost",80))
myServ.listen(100)
while count != 100:
cli,addr = myServ.accept()
msg = cli.recv(2024).decode()
spl = msg.split(" ")
req = msg.split("?")
#print "Request: ", req[1], "\n"
#print "Url: ",spl[1], "\n"
print "Msg: ",msg,"\n"
count = count + 1
cli.send(http_data.encode());
cli.close()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment