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() |
Create a new File called myhosts and fill it with the DNS redirects you want then run the script
What this does is creates a psuedo web server that responds with a script to close the window
later i will modify it to load in a html script so you can respond with whatever you wish!