for i inrange(1, 80): # 先假设 flag 长度不超过 80 query = f"SELECT substr(record, {i}, 1) FROM details;" p = subprocess.run( ["/challenge/sql"], input=query + "\n", text=True, capture_output=True )
out = p.stdout
if"No results returned!"in out: break
# 解析输出里的结果 # 例如: - {'substr(record, 5, 1)': 'c'} for line in out.splitlines(): if line.startswith("- "): val = line.split(": ", 1)[1].strip() if val.endswith("'}"): ch = val[:-2].strip("'") result += ch print(f"{i}: {ch} => {result}") break
print("FINAL:", result)
8
1
SELECT resource FROM storage WHERE flag_tag =1337AND substr(resource, 1, 12) ='pwn.college{';
9
1
SELECT note FROM items WHERE substr(note, 1, 12) ='pwn.college{' LIMIT 1;
10
1 2 3 4 5
SELECT name FROM sqlite_master WHERE type ='table'; Got 1 rows. - {'name': 'OEwzaGbV'}