Created
August 23, 2012 01:39
-
-
Save mouseroot/3431151 to your computer and use it in GitHub Desktop.
sniff popups
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
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