Last active
March 28, 2018 10:11
-
-
Save amane-katagiri/a9ee8686ba56a80637d242fc2a981029 to your computer and use it in GitHub Desktop.
魚拓サービスはIPを書き換えているか?
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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
from http.server import HTTPServer, SimpleHTTPRequestHandler | |
class EchoHandler(SimpleHTTPRequestHandler): | |
def make_response(self): | |
table = str.maketrans("0123456789.:", "〇一二三四五六七八九、:") | |
real_address = "{}:{}".format(*self.client_address) | |
response = "You are: {}\n\n{}".format(real_address, str(self.headers)) | |
response += "REAL IP: {}\n".format(real_address.replace(".", "-")) | |
response += "REAL IP: {}\n".format(real_address.replace(".", "_")) | |
response += "REAL IP: {}\n".format(real_address.replace(".", " ")) | |
response += "REAL IP: {}\n".format(real_address.replace(".", " ")) | |
response += "REAL IP: {}\n".format(real_address.replace(".", "の")) | |
response += "REAL IP: {}\n".format(real_address.translate(table)) | |
print(response) | |
return bytes(response, encoding="utf-8") | |
def do_GET(self): | |
body = self.make_response() | |
self.send_response(200) | |
self.send_header("Content-type", "text/plain; charset=utf-8") | |
self.send_header("Content-length", len(body)) | |
self.end_headers() | |
self.wfile.write(body) | |
def main(*args, **kwargs): | |
host = "0.0.0.0" | |
port = 8000 | |
httpd = HTTPServer((host, port), EchoHandler) | |
print("serving at port", port) | |
httpd.serve_forever() | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment