Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
魚拓サービスはIPを書き換えているか?
#!/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
You can’t perform that action at this time.