Tcp
Msf::Exploit::Remote::Tcp(コード上は Exploit::Remote::Tcp)は素の TCP 接続を扱います。HTTP でない banner / binary protocol 向けです。雛形は modules/exploits/example.rb です。
include
Section titled “include”include Exploit::Remote::Tcp# またはinclude Msf::Exploit::Remote::Tcp主要 API
Section titled “主要 API”| メソッド | 用途 |
|---|---|
connect | RHOST:RPORT へ接続し sock を用意 |
disconnect | 切断 |
sock.put(data) | 送信 |
sock.get_once / sock.get | 受信 |
handler | ペイロードハンドラとの連携(exploit) |
def exploit connect print_status("Sending #{payload.encoded.length} byte payload...")
buf = rand_text_alpha(1024) buf << [target.ret].pack('V') buf << payload.encoded
sock.put(buf) sock.get_once handlerensure disconnectenddef run_host(ip) connect sock.put("HELP\r\n") banner = sock.get_once(1024, 3) print_status("#{ip}: #{banner}") report_service(host: ip, port: rport, name: 'example', info: banner.to_s)ensure disconnectendHTTP なら Tcp ではなく HttpClient を使います。

