1. 程式人生 > >b2_自動攻擊_db_autopwn

b2_自動攻擊_db_autopwn

目標:實現對目標主機進行自動漏洞攻擊

1 採用db_nmap + db_autopwn

關於db_autopwn:

The db_autopwn command is not officially supported and exists only in a branch.
not well maintained,crashes systems,and crashes itself
use only if you understand it’s current limitations/issues

在使用時造成靶機出現明顯被攻擊問題

This resulted in the removal of file_autopwn and db_autopwn. Both of these modules were easy to use, but were more likely to fall over and crash than produce useful results. The db_autopwn code started off as a joke and never reached a point where it was actually stable.

詳見Six Ways to Automate Metasploit

這是一個被遺棄的且不推薦使用的外掛,目前最新的維護也只停留在2013/4/3。暫且看看能不能達到我們的最低要求吧。

1.1 安裝db_autopwn


新版的msf已經不具備該外掛,你可以直接在msf內

msf > load db_autopwn

或用(檢視返回的資訊):

msf > db_autopwn

外掛程式碼連線:db_autopwn.rb

複製網址提供的程式碼檔案放入如下路徑,
/usr/share/metasploit-framework/plugins/

此時再load db_autopwn後看到載入成功的資訊,輸入db_autopwn可以得到其相關命令

1.2 具體操作


db_nmap -Pn 172.17.16.57  
**加入-Pn解決’but blocking our ping probes'問題**

hosts:檢視資料庫內IP

db_autopwn進行自動攻擊時,依據的是存在於msf連線的資料庫的hosts資訊,
這些資訊是漏洞掃描時存進去的,在這裡你可以用Nmap掃描。

使用hosts 可以檢視當前資料庫中有哪些host
使用hosts -d可以刪除一些不必要的host
使用hosts -a可以新增一些需要加入自動攻擊的host
這一些操作中需要批量操作時,可以使用掩碼,比如打算刪除某個網段的:
hosts -d 192.168.1.0/24
hosts -d 192.168.1.0-45

msf > hosts

漏洞掃描展示

msf > db_autopwn -t -p -r

其中對於自動攻擊時指定模組進行自動攻擊:

msf > db_autopwn -p -m exploit/windows/smb/ms17_010_eternalblue -e

觀察到session由0變1,則可以按ctrl+C進入,因為已經滲透成功一個的意思

使用proxychains + msf + nmap + db_autopwn,可以實現獲得對該目標機器的埠相匹配
的漏洞模組的展示,但不精準,因此後面的攻擊工作還是需要人工操作

1.3 msfconsole + proxychains + db_autopwn


該方案只適合msfconsole,對於metasploit framework會出現外掛載入失敗的問題,目前未找到解決方案。

對於msfconsole的資料庫連線失敗的問題:

failed to connect to the database; could not connect to server:connection
refused.Is the server running on host ‘localhost’(127.0.0.1) and
accepting TCP/IP connections on port 5432?

解決方案:

$ service postgresql start
$ msfdb init
$ msfconsole
$ db_status

如問題依然存在,繼續:
配置"/etc/proxychains.conf",新增:

$ localnet 127.0.0.1 000 255.255.255.255

原因:
When you add that line in the proxychains.conf, proxychains will not tunnel connections made to localhost, in this example proxychains will not tunnel the connection to PostgreSQL

1.4 註解


這個方案是破產的,因此我們轉而實現自己的指令碼自動化,考慮利用python指令碼操作msf攻擊,轉b3