跳轉到內容

Metasploit/MethodAutofilter

來自華夏公益教科書

Metasploit 提供了透過autopwn命令自動利用的功能[1]。當您編寫模組時,需要滿足某些要求才能在 autopwn 例程中使用它。

  1. 使用通用返回地址。或者
  2. 設定一個 DefaultTarget。或者
  3. 在您的模組中定義一個名為“autofilter”的方法

該方法必須返回真或假。

該方法負責在用於自動利用時確定正確的目標。將來,此方法將能夠查詢資料庫以查詢有關目標的目標特定資訊。autofilter 方法可以設定 TARGET 資料儲存值以及任何其他常用引數。只要最終返回值為真,該模組將在 autopwn 的一部分中執行。

自動篩選示例

[編輯 | 編輯原始碼]
	def autofilter
		false
	end

... 將阻止您的模組在 autopwn 中執行。如果 MSF 有一天能夠透過其他方式確定目標主機,autopwn 將自動確定目標。

	def autofilter
		# Common vulnerability scanning tools report port 445/139
		# due to how they test for the vulnerability. Remap this
		# back to 2103 for automated exploitation
		
		rport = datastore['RPORT'].to_i
		if ( rport == 139 or rport == 445 )
			datastore['RPORT'] = 2103
		end
		
		# The NetBIOS hostname is required to exploit this bug reliably.
		if (not datastore['HNAME'])
			# XXX automatically determine the hostname
			return false
		end
		
		true
	end

... 是一個示例,其中模組包含它自己的檢測機制。

華夏公益教科書