update_info
update_info は、モジュールの 名刺と契約 をフレームワークに渡す処理です。info / show options / ペイロード適合 / ranking などに使われます。「動くコード」とは別に、必ず埋めるブロックです。
どこに書くか
Section titled “どこに書くか”def initialize(info = {}) super( update_info( info, 'Name' => 'ExampleApp Ping Command Injection', 'Description' => %q{ ExampleApp の /ping に OS コマンド注入がある。 lab 用の説明。 }, 'Author' => ['you'], 'License' => MSF_LICENSE, 'References' => [ ['CVE', '2024-0000'], ['URL', 'https://example.local/advisory'] ], 'DisclosureDate' => '2024-01-01', 'Platform' => ['linux'], 'Arch' => [ARCH_CMD], 'Privileged' => false, 'Targets' => [ ['Automatic', {}] ], 'DefaultTarget' => 0, 'Notes' => { 'Stability' => [CRASH_SAFE], 'Reliability' => [REPEATABLE_SESSION], 'SideEffects' => [IOC_IN_LOGS] } ) )endsuper(update_info(info, ...)) の形が定石です。info を渡すことで、親や mixin が足したメタデータを壊さずマージします。
フィールドの意味
Section titled “フィールドの意味”| キー | 必須寄り | 意味 |
|---|---|---|
Name | はい | 短い題名。検索されやすい語を入れる |
Description | はい | 何をするか、前提、注意。%q{...} で複数行 |
Author | はい | 配列。'name <mail>' 形式が一般的 |
License | はい | 通常 MSF_LICENSE |
References | 推奨 | ['CVE','...']、['URL','...']、['EDB','...'] など |
DisclosureDate | 推奨 | 'YYYY-MM-DD' |
Platform | exploit で重要 | 'linux' / 'win' / 'unix' / 'python' など。ペイロード適合に効く |
Arch | exploit で重要 | ARCH_CMD / ARCH_X64 / ARCH_X86 / ARCH_PYTHON など |
Privileged | 任意 | 高権限が必要 / 得られるかの目安 |
Payload | exploit | 'Space'、'BadChars' などペイロード制約 |
Targets | exploit | 対象 OS / オフセット / CmdStagerFlavor など |
DefaultTarget | exploit | Targets の index |
SessionTypes | post | 'shell' / 'meterpreter' |
Actions / DefaultAction | auxiliary | 複数モードがあるとき |
Notes | 新規は実質必須 | Stability / Reliability / SideEffects |
Platform / Arch が効く理由
Section titled “Platform / Arch が効く理由”exploit では、ここで宣言した Platform/Arch とペイロードのそれが噛み合わないと、選べるペイロードが空になったり実行時に失敗します。
| 用途 | 例 |
|---|---|
| コマンドそのものを流す | 'Platform' => ['unix','linux'], 'Arch' => [ARCH_CMD] |
| ELF / PE を置く | 'Arch' => [ARCH_X64] + CmdStager |
| Web 言語ペイロード | 'Platform' => ['php'], 'Arch' => [ARCH_PHP] |
Targets
Section titled “Targets”'Targets' => [ [ 'Linux Command', { 'Platform' => 'linux', 'Arch' => [ARCH_CMD] } ], [ 'Linux Dropper', { 'Platform' => 'linux', 'Arch' => [ARCH_X64], 'CmdStagerFlavor' => ['bourne', 'curl', 'wget'] } ]],'DefaultTarget' => 0利用者は set TARGET 1 で切り替えます。モジュール内では target / target.name / target['Arch'] で参照します。
Notes(Stability / Reliability / SideEffects)
Section titled “Notes(Stability / Reliability / SideEffects)”新規モジュールで求められている欄です。定数の意味は同梱 wiki Definition-of-Module-Reliability-Side-Effects-and-Stability.md にあります。
'Notes' => { 'Stability' => [CRASH_SAFE], 'Reliability' => [REPEATABLE_SESSION], 'SideEffects' => [IOC_IN_LOGS, ARTIFACTS_ON_DISK]}| 分類 | 例 |
|---|---|
| Stability | CRASH_SAFE、CRASH_SERVICE_DOWN |
| Reliability | REPEATABLE_SESSION、UNRELIABLE_SESSION、EVENT_DEPENDENT |
| SideEffects | IOC_IN_LOGS、ARTIFACTS_ON_DISK、CONFIG_CHANGES、ACCOUNT_LOCKOUTS |
Rank(exploit)
Section titled “Rank(exploit)”クラス直下に置きます。
Rank = ExcellentRankingExcellentRanking / GreatRanking / GoodRanking / NormalRanking など。信頼性の自己申告です。
auxiliary の Actions
Section titled “auxiliary の Actions”'Actions' => [ ['List', { 'Description' => 'Enumerate items' }], ['Dump', { 'Description' => 'Dump config' }]],'DefaultAction' => 'List'run 内で action.name を見ます。
post の SessionTypes
Section titled “post の SessionTypes”'Platform' => ['linux', 'unix'],'SessionTypes' => ['shell', 'meterpreter']対応しないセッションで run されると失敗しやすいので、本当に動くものだけ書きます。
次は register_options で、利用者が入力する値を定義します。

