import http.server, socketserver import hashlib import random import subprocess listen_port = 25502 class my_handler(http.server.BaseHTTPRequestHandler): def do_HEAD(self): self.send_response(200) self.send_header("Content-type", "text/plain; charset=utf-8") self.end_headers() def do_GET(self): self.send_response(200) if self.path.startswith('/api/oauth/getaccesstoken?appid='): self.send_header("Server","marco/2.1") self.send_header("Date","Fri, 27 Apr 2018 05:33:31 GMT") self.send_header("Content-Type","text/json; charset=utf-8") self.send_header("Content-Length","171") self.send_header("Connection","keep-alive") self.send_header("X-Source","C/200") self.send_header("Cache-Control","no-cache") self.send_header("X-Aspnet-Version","4.0.30319") self.send_header("Pragma","no-cache") self.send_header("Expires","-1") self.send_header("X-Powered-By","ASP.NET") self.send_header("Accept-Ranges","bytes") self.send_header("X-Request-Id","b345beace43c4b23ecd8cf0ecaeea269") self.send_header("Via","S.mix-js-czx-105, T.107.-, V.mix-js-czx-106, T.196.-, M.ctn-hb-eez-199") self.end_headers() self.wfile.write('{"status":true,"errormsg":"","accesstoken":"eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ1aWQiOm51bGwsInRpbWVzIjoiMTU0MDU2NDc4OCJ9.YiX79467zaCpN3oLeL5h14x-ss2cSzW1iIqhY4Qhmrk"}'.encode('utf-8')) return self.send_response(403) self.send_header("Content-type", "text/plain; charset=utf-8") self.end_headers() self.wfile.write('invalid get query.'.encode('utf-8')) def do_POST(self): self.send_response(200) if self.path.startswith('/api/usewater/Add?accessToken='): self.send_header("Server","marco/2.1") self.send_header("Date","Fri, 27 Apr 2018 05:33:27 GMT") self.send_header("Content-Type","text/json; charset=utf-8") self.send_header("Content-Length","82") self.send_header("Connection","keep-alive") self.send_header("X-Source","C/200") self.send_header("Cache-Control","no-cache") self.send_header("X-Aspnet-Version","4.0.30319") self.send_header("Pragma","no-cache") self.send_header("Expires","-1") self.send_header("X-Powered-By","ASP.NET") self.send_header("Accept-Ranges","bytes") self.send_header("X-Request-Id","21a2827b6e9e720a4fdd63b15faa120e") self.send_header("Via","S.mix-js-czx-099, T.100.-, V.mix-js-czx-104, T.199.-, M.ctn-hb-eez-199") self.end_headers() self.wfile.write('{"status":true,"errormsg":"记录成功!","code":1,"OrderId":"104871845A503324"}'.encode('utf-8')) return if self.path.startswith('/api/cashtopup/UpdateCardUsedAmount?accessToken='): self.send_header("Server","marco/2.1") self.send_header("Date","Fri, 27 Apr 2018 05:33:31 GMT") self.send_header("Content-Type","text/json; charset=utf-8") self.send_header("Content-Length","44") self.send_header("Connection","keep-alive") self.send_header("X-Source","C/200") self.send_header("Cache-Control","no-cache") self.send_header("X-Aspnet-Version","4.0.30319") self.send_header("Pragma","no-cache") self.send_header("Expires","-1") self.send_header("X-Powered-By","ASP.NET") self.send_header("Accept-Ranges","bytes") self.send_header("X-Request-Id","b345beace43c4b23ecd8cf0ecaeea269") self.send_header("Via","S.mix-js-czx-105, T.107.-, V.mix-js-czx-106, T.196.-, M.ctn-hb-eez-199") self.end_headers() self.wfile.write('{"status":true,"errormsg":"记录成功!"}'.encode('utf-8')) return if self.path.startswith('/api/users/MessageNumByMobile?accessToken='): self.send_header("Server","marco/2.1") self.send_header("Date","Fri, 27 Apr 2018 05:33:31 GMT") self.send_header("Content-Type","text/json; charset=utf-8") self.send_header("Content-Length","120") self.send_header("Connection","keep-alive") self.send_header("X-Source","C/200") self.send_header("Cache-Control","no-cache") self.send_header("X-Aspnet-Version","4.0.30319") self.send_header("Pragma","no-cache") self.send_header("Expires","-1") self.send_header("X-Powered-By","ASP.NET") self.send_header("Accept-Ranges","bytes") self.send_header("X-Request-Id","b345beace43c4b23ecd8cf0ecaeea269") self.send_header("Via","S.mix-js-czx-105, T.107.-, V.mix-js-czx-106, T.196.-, M.ctn-hb-eez-199") self.end_headers() self.wfile.write('{"status":true,"errormsg":"","repairMsgTotal":0,"data":-1,"mactime":"2018-10-26 20:32:53","servertime":1540564792787.22}'.encode('utf-8')) return if self.path.startswith('/api/device/addDevice?accessToken='): self.send_header("Server","marco/2.1") self.send_header("Date","Fri, 27 Apr 2018 05:33:31 GMT") self.send_header("Content-Type","text/json; charset=utf-8") self.send_header("Content-Length","120") self.send_header("Connection","keep-alive") self.send_header("X-Source","C/200") self.send_header("Cache-Control","no-cache") self.send_header("X-Aspnet-Version","4.0.30319") self.send_header("Pragma","no-cache") self.send_header("Expires","-1") self.send_header("X-Powered-By","ASP.NET") self.send_header("Accept-Ranges","bytes") self.send_header("X-Request-Id","b345beace43c4b23ecd8cf0ecaeea269") self.send_header("Via","S.mix-js-czx-105, T.107.-, V.mix-js-czx-106, T.196.-, M.ctn-hb-eez-199") self.end_headers() self.wfile.write('{"status":true,"errormsg":""'.encode('utf-8')) return self.send_response(403) self.send_header("Content-type", "text/plain; charset=utf-8") self.end_headers() self.wfile.write('invalid post query.'.encode('utf-8')) try: server = http.server.HTTPServer(('', listen_port), my_handler) print('Listening *:' + str(listen_port)) server.serve_forever() except KeyboardInterrupt: server.socket.close()