加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
flag.py 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
moxiaoxi 提交于 2020-01-04 21:10 . 调整代码
#!/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()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化