代码拉取完成,页面将自动刷新
#!/usr/bin/env python
import SimpleHTTPServer
import SocketServer
import hashlib
import time
import sys
'''
this script is supposed to run on the gamebox, it record the flag sent
by the server, and record it to local file system, the normal request
should be looks like /you_should_not_guess_the_key/04df0f74b98693195d93ac695d51e837
'''
PORT = 9999
key = 'you_should_not_guess_the_key'
flag_path = '/flag'
class my_handler(SimpleHTTPServer.SimpleHTTPRequestHandler):
def do_GET(self):
request = self.path.split('/')
self.send_response(200)
self.send_header('Content-type', 'text/html')
self.end_headers()
if len(request) == 3 and request[1] == key and len(request[2]) == 32:
flag = request[2]
open(flag_path, 'w').write(flag)
self.wfile.write('update flag succ!')
else:
self.wfile.write('get out! hacker!')
Handler = my_handler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT
httpd.serve_forever()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。