Created
November 21, 2019 09:18
-
-
Save owyongsk/341581971841084e28dc48ca97fb7d65 to your computer and use it in GitHub Desktop.
Prank Redirect
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 SimpleHTTPServer | |
import SocketServer | |
import random | |
from urlparse import urlparse, parse_qs | |
class Redirect(SimpleHTTPServer.SimpleHTTPRequestHandler): | |
def do_GET(self): | |
term = parse_qs(urlparse(self.path).query)['q'][0] | |
self.send_response(302) | |
if random.randint(1, 101) > 95: | |
self.send_header('Location', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ') | |
# self.send_header('Location', 'https://www.pornhub.com/search?search=%s' % (term)) | |
else: | |
self.send_header('Location', 'https://google.com/search?q=%s' % (term)) | |
self.end_headers() | |
SocketServer.TCPServer(("", 8080), Redirect).serve_forever() | |
# nohup python redirect.py & | |
# http://localhost:8080/q?q=%s |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I think it should be lower than 95, more like 50