Skip to content

Commit f792af1

Browse files
author
certcc-ghbot
committed
Merge remote-tracking branch 'upstream/master'
2 parents 5398d43 + eefd7c8 commit f792af1

9 files changed

Lines changed: 231 additions & 17 deletions

File tree

.github/copilot-instructions.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Copilot Instructions
2+
3+
Refer to [AGENTS.md](../AGENTS.md) in the repository root for all project conventions, coding standards, and AI agent guidelines.

.kiro/steering/project.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
inclusion: always
3+
---
4+
5+
# Metasploit Framework — Kiro Steering
6+
7+
Follow the project's AI agent instructions and coding conventions defined in the repository root.
8+
9+
## References
10+
- AI agent instructions: #[[file:AGENTS.md]]
11+
- Contributing guide: #[[file:CONTRIBUTING.md]]
12+
- RuboCop config: #[[file:.rubocop.yml]]

AGENTS.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
# AI Agent Instructions for Metasploit Framework
2+
3+
## Project Overview
4+
Metasploit Framework is an open-source penetration testing and exploitation framework written in Ruby. It provides infrastructure for developing, testing, and executing exploit code against remote targets.
5+
6+
## Project Structure
7+
- `modules/` — Metasploit modules (exploits, auxiliary, post, payloads, encoders, evasion, nops)
8+
- `lib/msf/` — Core framework library code
9+
- `lib/rex/` — Rex (Ruby Exploitation) library
10+
- `lib/metasploit/` — Metasploit namespace libraries
11+
- `data/` — Data files used by modules (wordlists, templates, binaries)
12+
- `spec/` — RSpec test suite
13+
- `tools/` — Developer and operational tools
14+
- `plugins/` — msfconsole plugins
15+
- `scripts/` — Example automation scripts
16+
17+
## Coding Conventions
18+
- Ruby (see `.ruby-version` for the current version). Minimum supported: 3.1+
19+
- Follow the project's `.rubocop.yml` configuration — run `rubocop` on changed files before submitting
20+
- Run `msftidy` to catch common module issues
21+
- Add `# frozen_string_literal: true` to new files (the RuboCop cop is disabled project-wide for legacy code, but new files should include it)
22+
- No enforced line length limit, but keep code readable
23+
- Use `%q{}` for long multi-line strings (curly braces preferred for module descriptions)
24+
- Multiline block comments are acceptable for embedded code snippets/payloads
25+
- Don't use `get_`/`set_` prefixes for accessor methods in new code
26+
- Method parameter names must be at least 2 characters (exception for well-known crypto abbreviations)
27+
28+
### Module Development
29+
- Prefer writing modules in Ruby. Go and Python modules are accepted, but their external runtimes don't support the full framework API (e.g. network pivoting). Ruby modules do not have this limitation
30+
- Before writing a new module, check that there is not an existing module or open pull request that already covers the same functionality
31+
- Each module should be in its own file under the appropriate `modules/` subdirectory. In some scenarios adding module actions or targets is preferred.
32+
- Exploits require a `DisclosureDate` field
33+
- Exploits, auxiliary, and post modules require `Notes` with `SideEffects`
34+
- Use the module mixin APIs — don't reinvent the wheel
35+
- Use `create_process(executable, args: [], time_out: 15, opts: {})` instead of the deprecated `cmd_exec` with separate arguments
36+
- License new code with `MSF_LICENSE` (the project default, defined in `lib/msf/core/constants.rb`)
37+
- When overriding `cleanup`, always call `super` to ensure the parent mixin chain cleans up connections and sessions properly
38+
- When possible don't set a default payload (`DefaultOptions` with `'PAYLOAD'`) in modules — let the framework choose the most appropriate payload automatically
39+
- New modules require an associated markdown file in the `documentation/modules` folder with the same structure, including steps to set up the vulnerable environment for testing
40+
- Module descriptions or documentation should list the range of vulnerable versions and the fixed version of the affected software, when known
41+
- `report_service` method called when a service can be reported
42+
- `report_vuln` method called when a vuln can be reported
43+
- When creating a fake account / username use FAKER not `rand_test_alphanumeric`
44+
- Always use `res.get_json_document` to convert an HTTP response to a hash instead of calling `JSON.parse(res.body)`
45+
- If there's only one `ACTION` in the exploit, it can likely be omitted.
46+
- `Msf::Exploit::SQLi` should be used if it's exploiting an SQLi
47+
- All `print_*` calls should start with a capital
48+
- when opening a file, make sure the file exists first
49+
- when checking for a string in a response - will it always be in english?
50+
- Ensure hardcoded strings being regex'ed will be consistent across multiple versions
51+
- Use the TEST-NET-1 range for example / non-routeable IP address: `192.0.2.0`
52+
- Use fetch payload instead of command stagers when only options that request the stage are available (i.e. don’t use a cmd stager and only allow curl/wget).
53+
- Define bad characters instead of explicitly base-64 encoding payloads
54+
- Use `ARCH_CMD` payloads instead of command stagers when only curl/wget and other download mechanisms would be available
55+
- Don’t check the number of sessions at the end of an exploit and report success based on that, not all payloads open sessions
56+
- Don’t submit any kind of opaque binary blob, everything must include source code and build instructions
57+
- Don’t print host information like `#{ip}:#{port}` because it doesn’t handle IPv6 addresses, instead use `#{Rex::Socket.to_authority(ip, port)}`
58+
- Implement a `check` method when possible to allow users to verify vulnerability before exploitation
59+
60+
### Check Methods
61+
62+
- `check` methods must only return `CheckCode` values (e.g. `CheckCode::Vulnerable`, `CheckCode::Safe`) — never raise exceptions or call `fail_with`
63+
- When writing a `check` method, verify it does not produce false positives when run against unrelated software or services
64+
- Use `fail_with(Failure::UnexpectedReply, '...')` (and other `Failure::*` constants) to bail out of `exploit`/`run` methods — don't use `raise` or bare `return` for error conditions
65+
- `get_version` methods should return a REX version
66+
- `CheckCode::Vulnerable` is only used when the vulnerability has been exploited
67+
- `CheckCode::Appears` is only used when the application's versions has been checked`
68+
- Don't use a massive `<href .*` dot star to grab the version, to be more precise.
69+
- Do catch exceptions that may be raised and ensure a valid Check Code is returned
70+
- Do research and determine a minimum version where the application is vulnerable, mark prior versions as safe
71+
- Check helper methods that are used by both `#check` and `#exploit` (or `#run`) and make sure there is no condition (exception, return, etc) where `#check` could return something else than CheckCode.
72+
- Prefer `prepend Msf::Exploit::Remote::AutoCheck` over manually calling `check` inside `exploit` — this lets the framework handle check-before-exploit automatically
73+
74+
### Library Code
75+
- When adding complex binary or protocol parsing (e.g. BinData, RASN1, Rex::Struct2), include a code comment linking to the specification or RFC that defines the format being implemented
76+
- Write RSpec tests for any library changes
77+
- Follow [Better Specs](http://www.betterspecs.org/) conventions
78+
- Write YARD documentation for public methods
79+
- Keep PRs focused — small fixes are easier to review
80+
- Any new hash cracking implementations require adding a test hash to `tools/dev/hash_cracker_validator.rb` and ensuring that passes without error
81+
82+
### Testing
83+
- Tests live in `spec/` mirroring the `lib/` structure
84+
- Run tests with: `rspec spec/path/to/spec.rb`
85+
- Use `bundle exec rspec` to ensure correct gem versions
86+
87+
### Preferred Libraries
88+
- Use the `RubySMB` library for SMB modules
89+
- Use `Rex::Stopwatch.elapsed_time` to track elapsed time
90+
- Use the `Rex::MIME::Message` class for MIME messages instead of hardcoding XML
91+
- When creating random variable names prefer `Rex::RandomIdentifier::Generator` and specify the runtime language used. This avoids generating langauge keywords that would break the script.
92+
93+
## Common Patterns
94+
- Register options with `register_options` and `register_advanced_options`
95+
- Use `SCREAMING_SNAKE_CASE` option names and `CamelCase` advanced option names
96+
- Use `datastore['OPTION_NAME']` to access module options
97+
- Use `print_status`, `print_good`, `print_error`, `print_warning` for console output
98+
- Use `vprint_*` variants for verbose-only output
99+
- Use `send_request_cgi` for HTTP requests in modules
100+
- Use `connect` / `disconnect` for TCP socket operations
101+
102+
## Before Submitting
103+
- Ensure `rubocop` and `msftidy` pass on any changed files with no new offenses
104+
- Ensure `msftidy_docs` passes on any changed documentation markdown docs with no new offenses
105+
106+
## What NOT to Do
107+
- Don't submit untested code — all code must be manually verified
108+
- Don't include sensitive information (IPs, credentials, API keys, hashes of credentials) in code or docs
109+
- Don't include more than one module per pull request
110+
- Don't add new scripts to `scripts/` — use post modules instead
111+
- Don't use `pack`/`unpack` with invalid directives (enforced by linter)
112+

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Before we get into the details of contributing code, you should know there are m
1515

1616

1717
## Code Contributions
18-
For those of you who are looking to add code to Metasploit, your first step is to set up a [development environment]. Once that's done, we recommend beginners start by adding a [proof-of-concept exploit from ExploitDB,](https://www.exploit-db.com/search?verified=true&hasapp=true&nomsf=true) as a new module to the Metasploit framework. These exploits have been verified as recreatable and their ExploitDB page includes a copy of the exploitable software. This makes testing your module locally much simpler, and most importantly the exploits don't have an existing Metasploit implementation. ExploitDB can be slow to update however, so please double check that there isn't an existing module before beginning development! If you're certain the exploit you've chosen isn't already in Metasploit, read our [writing an exploit guide](https://docs.metasploit.com/docs/development/developing-modules/guides/get-started-writing-an-exploit.html). It will help you to get started and avoid some common mistakes.
18+
For those of you who are looking to add code to Metasploit, your first step is to set up a [development environment]. For a detailed reference of our coding conventions, project structure, and preferred patterns, see [AGENTS.md](./AGENTS.md). Once that's done, we recommend beginners start by adding a [proof-of-concept exploit from ExploitDB,](https://www.exploit-db.com/search?verified=true&hasapp=true&nomsf=true) as a new module to the Metasploit framework. These exploits have been verified as recreatable and their ExploitDB page includes a copy of the exploitable software. This makes testing your module locally much simpler, and most importantly the exploits don't have an existing Metasploit implementation. ExploitDB can be slow to update however, so please double check that there isn't an existing module before beginning development! If you're certain the exploit you've chosen isn't already in Metasploit, read our [writing an exploit guide](https://docs.metasploit.com/docs/development/developing-modules/guides/get-started-writing-an-exploit.html). It will help you to get started and avoid some common mistakes.
1919

2020
Once you have finished your new module and tested it locally to ensure it's working as expected, check out our [guide for accepting modules](https://docs.metasploit.com/docs/development/maintainers/process/guidelines-for-accepting-modules-and-enhancements.html#module-additions). This will give you a good idea of how to clean up your code so that it's likely to get accepted.
2121

db/modules_metadata_base.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -134944,7 +134944,8 @@
134944134944
"type": "exploit",
134945134945
"author": [
134946134946
"hdm <x@hdm.io>",
134947-
"MC <mc@metasploit.com>"
134947+
"MC <mc@metasploit.com>",
134948+
"g0tmi1k"
134948134949
],
134949134950
"description": "This module exploits a malicious backdoor that was added to the VSFTPD download\n archive. This backdoor was introduced into the vsftpd-2.3.4.tar.gz archive between\n June 30th 2011 and July 1st 2011 according to the most recent information\n available. This backdoor was removed on July 3rd 2011.",
134950134951
"references": [
@@ -134961,7 +134962,7 @@
134961134962
"targets": [
134962134963
"Linux/Unix Command"
134963134964
],
134964-
"mod_time": "2026-02-20 08:27:06 +0000",
134965+
"mod_time": "2026-03-10 13:09:03 +0000",
134965134966
"path": "/modules/exploits/unix/ftp/vsftpd_234_backdoor.rb",
134966134967
"is_install_path": true,
134967134968
"ref_name": "unix/ftp/vsftpd_234_backdoor",
@@ -136902,7 +136903,8 @@
136902136903
"disclosure_date": "2010-06-12",
136903136904
"type": "exploit",
136904136905
"author": [
136905-
"hdm <x@hdm.io>"
136906+
"hdm <x@hdm.io>",
136907+
"g0tmi1k"
136906136908
],
136907136909
"description": "This module exploits a malicious backdoor that was added to the\n Unreal IRCD 3.2.8.1 download archive. This backdoor was present in the\n Unreal3.2.8.1.tar.gz archive between November 2009 and June 12th 2010.",
136908136910
"references": [
@@ -136918,7 +136920,7 @@
136918136920
"targets": [
136919136921
"Linux/Unix Command"
136920136922
],
136921-
"mod_time": "2026-02-14 09:01:18 +0000",
136923+
"mod_time": "2026-03-10 13:09:03 +0000",
136922136924
"path": "/modules/exploits/unix/irc/unreal_ircd_3281_backdoor.rb",
136923136925
"is_install_path": true,
136924136926
"ref_name": "unix/irc/unreal_ircd_3281_backdoor",
@@ -144408,7 +144410,8 @@
144408144410
"type": "exploit",
144409144411
"author": [
144410144412
"B4dP4nd4",
144411-
"jduck <jduck@metasploit.com>"
144413+
"jduck <jduck@metasploit.com>",
144414+
"g0tmi1k"
144412144415
],
144413144416
"description": "This module exploits a vulnerability in the history component of TWiki.\n By passing a 'rev' parameter containing shell metacharacters,\n an attacker can execute arbitrary OS commands.\n\n Affected versions:\n - 20040902\n - 20040901\n - 20030201\n - 20011201\n - 20001201",
144414144417
"references": [
@@ -144438,7 +144441,7 @@
144438144441
"targets": [
144439144442
"Automatic"
144440144443
],
144441-
"mod_time": "2026-02-25 10:15:41 +0000",
144444+
"mod_time": "2026-03-10 13:09:03 +0000",
144442144445
"path": "/modules/exploits/unix/webapp/twiki_history.rb",
144443144446
"is_install_path": true,
144444144447
"ref_name": "unix/webapp/twiki_history",
@@ -144527,7 +144530,8 @@
144527144530
"disclosure_date": "2004-10-01",
144528144531
"type": "exploit",
144529144532
"author": [
144530-
"jduck <jduck@metasploit.com>"
144533+
"jduck <jduck@metasploit.com>",
144534+
"g0tmi1k"
144531144535
],
144532144536
"description": "This module exploits a vulnerability in the search component of TWiki.\n By passing a 'search' parameter containing shell metacharacters to a\n 'Search' script, an attacker can execute arbitrary OS commands.\n\n Affected versions:\n - 20040901\n - 20030201\n - 20011201\n - 20001201\n - SVN up to and including revision 3224",
144533144537
"references": [
@@ -144557,7 +144561,7 @@
144557144561
"targets": [
144558144562
"Automatic"
144559144563
],
144560-
"mod_time": "2026-02-25 10:24:36 +0000",
144564+
"mod_time": "2026-03-10 13:09:03 +0000",
144561144565
"path": "/modules/exploits/unix/webapp/twiki_search.rb",
144562144566
"is_install_path": true,
144563144567
"ref_name": "unix/webapp/twiki_search",

modules/exploits/unix/ftp/vsftpd_234_backdoor.rb

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class MetasploitModule < Msf::Exploit::Remote
77
Rank = ExcellentRanking
88

9+
include Msf::Auxiliary::Report
910
include Msf::Exploit::Remote::Tcp
1011

1112
def initialize(info = {})
@@ -19,7 +20,11 @@ def initialize(info = {})
1920
June 30th 2011 and July 1st 2011 according to the most recent information
2021
available. This backdoor was removed on July 3rd 2011.
2122
},
22-
'Author' => [ 'hdm', 'MC' ],
23+
'Author' => [
24+
'hdm',
25+
'MC',
26+
'g0tmi1k' # @g0tmi1k // https://blog.g0tmi1k.com/ - additional features
27+
],
2328
'License' => MSF_LICENSE,
2429
'References' => [
2530
[ 'CVE', '2011-2523' ],
@@ -60,6 +65,22 @@ def initialize(info = {})
6065
register_options([ Opt::RPORT(21) ])
6166
end
6267

68+
def get_banner
69+
banner = sock.get_once(-1, 30).to_s
70+
71+
vprint_status("FTP banner: #{banner.strip}")
72+
version = banner[/\((.*?)\)/, 1]
73+
report_service(
74+
host: rhost,
75+
port: rport,
76+
proto: 'tcp',
77+
name: 'ftp',
78+
info: "#{version}"
79+
)
80+
81+
banner
82+
end
83+
6384
def check
6485
# Check for backdoor first, else exploit will fail
6586
vprint_status("Checking if backdoor has already been triggered (else exploit will fail)")
@@ -73,7 +94,7 @@ def check
7394
connect
7495

7596
vprint_status("Checking FTP banner")
76-
banner = sock.get_once(-1, 30).to_s
97+
banner = get_banner
7798

7899
if banner.downcase.include?("vsftpd 2.3.4")
79100
print_status("FTP banner hints its vulnerable: #{banner.strip}")
@@ -126,8 +147,7 @@ def exploit
126147

127148
# Without this, 220 response, rather than 331
128149
vprint_status("Checking FTP banner")
129-
banner = sock.get_once(-1, 30).to_s
130-
vprint_status("FTP banner: #{banner.strip}")
150+
banner = get_banner
131151

132152
ftp_user = "#{rand_text_alphanumeric(rand(6) + 1)}:)"
133153
vprint_status("Trying to log into FTP via backdoor. User: #{ftp_user}")

modules/exploits/unix/irc/unreal_ircd_3281_backdoor.rb

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
class MetasploitModule < Msf::Exploit::Remote
77
Rank = ExcellentRanking
88

9+
include Msf::Auxiliary::Report
910
include Msf::Exploit::Remote::Tcp
1011

1112
def initialize(info = {})
@@ -18,7 +19,10 @@ def initialize(info = {})
1819
Unreal IRCD 3.2.8.1 download archive. This backdoor was present in the
1920
Unreal3.2.8.1.tar.gz archive between November 2009 and June 12th 2010.
2021
},
21-
'Author' => [ 'hdm' ],
22+
'Author' => [
23+
'hdm',
24+
'g0tmi1k' # @g0tmi1k // https://blog.g0tmi1k.com/ - additional features
25+
],
2226
'License' => MSF_LICENSE,
2327
'References' => [
2428
[ 'CVE', '2010-2075' ],
@@ -64,7 +68,18 @@ def initialize(info = {})
6468
end
6569

6670
def unreal_version?(response)
67-
response.match?(/unreal3\.2\.8\.1/i)
71+
if response =~ /unreal3\.2\.8\.1/i
72+
report_service(
73+
host: rhost,
74+
port: rport,
75+
proto: 'tcp',
76+
name: 'irc',
77+
info: "Unreal 3.2.8.1"
78+
)
79+
true
80+
else
81+
false
82+
end
6883
end
6984

7085
def send_irc_command(cmd="")

modules/exploits/unix/webapp/twiki_history.rb

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ def initialize(info = {})
2727
},
2828
'Author' => [
2929
'B4dP4nd4', # original discovery
30-
'jduck' # metasploit version
30+
'jduck', # metasploit version
31+
'g0tmi1k' # @g0tmi1k // https://blog.g0tmi1k.com/ - additional features
3132
],
3233
'License' => MSF_LICENSE,
3334
'References' => [
@@ -64,6 +65,28 @@ def initialize(info = {})
6465
)
6566
end
6667

68+
def report_twiki_service
69+
report_service(
70+
host: rhost,
71+
port: rport,
72+
proto: 'tcp',
73+
name: 'TWiki',
74+
parents: {
75+
name: ssl ? 'https' : 'http',
76+
host: rhost,
77+
port: rport,
78+
proto: 'tcp',
79+
parents: {
80+
name: 'tcp',
81+
host: rhost,
82+
port: rport,
83+
proto: 'tcp',
84+
parents: nil
85+
}
86+
}
87+
)
88+
end
89+
6790
def send_request(uri, timeout = 25)
6891
send_request_cgi({
6992
'uri' => uri
@@ -118,6 +141,7 @@ def check
118141
print_warning("Unable to remove test file (#{test_file})")
119142
end
120143

144+
report_twiki_service
121145
return Exploit::CheckCode::Vulnerable
122146
end
123147

0 commit comments

Comments
 (0)