2013-10-15 01:56:29 +02:00
|
|
|
Current `master` branch: ![Meterpreter Build Status][build_icon]
|
2013-09-24 02:49:29 +02:00
|
|
|
|
2012-11-20 01:14:20 +01:00
|
|
|
meterpreter >
|
|
|
|
=============
|
|
|
|
|
2013-10-15 16:29:56 +02:00
|
|
|
This is the new repository for the Meterpreter [source], which was originally in the
|
|
|
|
[Metasploit Framework][framework] source.
|
2013-04-01 19:52:40 +02:00
|
|
|
|
2013-03-19 16:30:41 +01:00
|
|
|
Building - Windows
|
|
|
|
==================
|
2013-04-01 19:52:40 +02:00
|
|
|
|
2014-06-05 17:37:16 +02:00
|
|
|
As of [commit
|
|
|
|
a2888b1b4862819c9aae81bf46d8c92d8164c598](https://github.com/rapid7/meterpreter/commit/a2888b1b4862819c9aae81bf46d8c92d8164c598),
|
|
|
|
Meterpreter is built with [Visual Studio 2013 Express for
|
|
|
|
Desktop][vs_express] or any paid version of [Visual Studio
|
|
|
|
2013][vs_paid]. Earlier toolsets on Windows are no longer supported --
|
|
|
|
this includes Visual Studio 2012. Make sure that the version that you
|
|
|
|
download is `Visual Studio Express 2013 for Windows Desktop` -- dependng
|
|
|
|
on your operating system, if you get the wrong version of VS2013, the
|
|
|
|
installer will complain about needing "a more recent version of
|
|
|
|
Windows." If you are using a dedicated build machine, your best bet is
|
|
|
|
to uninstall Visual Studio 2012 if your only project is Meterpreter.
|
2013-04-01 19:52:40 +02:00
|
|
|
|
2013-10-29 04:46:46 +01:00
|
|
|
Visual Studio 2013 requires .NET 4.5.1 in order to run, and as a result isn't compatible
|
2013-09-14 08:21:10 +02:00
|
|
|
with Windows XP due to the fact that .NET 4.5 will not run on Windows XP. However, this
|
|
|
|
does not mean that Metepreter itself will not run on Windows XP, it just means that it's
|
|
|
|
not possible to _build_ it on Windows XP.
|
2013-04-01 19:52:40 +02:00
|
|
|
|
2014-01-07 22:37:01 +01:00
|
|
|
Windows Meterpreter has the following repositories set up as submodule dependencies:
|
|
|
|
|
|
|
|
* [Reflective DLL Injection][rdi]
|
|
|
|
|
|
|
|
For Meterpreter to build correctly, these submodules must be initialised and updated,
|
|
|
|
like so:
|
|
|
|
|
|
|
|
``` bash
|
|
|
|
$ git clone https://github.com/rapid7/meterpreter
|
|
|
|
$ cd meterpreter
|
|
|
|
$ git submodule init && git submodule update
|
|
|
|
```
|
|
|
|
|
|
|
|
At this point the dependencies will be ready to use and Meterpreter should be ready to
|
|
|
|
build.
|
|
|
|
|
2014-06-05 21:50:52 +02:00
|
|
|
* [OpenSSL][openssl]
|
|
|
|
|
|
|
|
Occasionally, new versions of OpenSSL are released and need to be
|
|
|
|
incorporated into the Meterpreter build. See the README under
|
|
|
|
`source/openssl/lib` for build instructions. You will also need to
|
|
|
|
refresh the header files from the source tarball as well. TODO: This
|
|
|
|
entire process appears automatable given a proper build environment.
|
|
|
|
|
|
|
|
An example of updating OpenSSL is detailed in
|
|
|
|
[Pull Request #86](https://github.com/rapid7/meterpreter/pull/86).
|
|
|
|
|
2013-09-14 08:21:10 +02:00
|
|
|
Running the Build
|
|
|
|
-----------------
|
|
|
|
|
2013-10-29 04:46:46 +01:00
|
|
|
Open up a Visual Studio command prompt by selecting `Developer Command Prompt for VS2013`
|
2013-09-14 08:21:10 +02:00
|
|
|
from the Start menu. Alternatively you can run `vcvars32.bat` from an existing command
|
2013-10-29 04:46:46 +01:00
|
|
|
line prompt, just make sure it's the VS2013 one if you have multiple versions of VS
|
2013-09-14 08:21:10 +02:00
|
|
|
installed on your machine.
|
|
|
|
|
|
|
|
Once you have your environment variables set up, change to the root folder where the
|
|
|
|
meterpreter source is located. From here you can:
|
|
|
|
|
|
|
|
* Build the x86 version by running: `make x86`
|
|
|
|
* Build the x64 version by running: `make x64`
|
|
|
|
* Build both x86 and x64 versions by running: `make`
|
|
|
|
|
2013-09-30 23:18:57 +02:00
|
|
|
The compiled binaries are written to the `output/x86` and `output/x64` folders.
|
2013-04-01 19:52:40 +02:00
|
|
|
|
2013-09-18 10:14:36 +02:00
|
|
|
If you are not a Rapid7 employee, make sure you build the source using the `debug` or
|
|
|
|
`release` configurations when inside Visual Studio. If you attempt to build `r7_debug` or
|
|
|
|
`r7_release` you will get compiler errors due to missing libraries.
|
2013-03-19 16:30:41 +01:00
|
|
|
|
2013-09-18 10:14:36 +02:00
|
|
|
If you build the source from the command line the toolset will choose the most
|
|
|
|
appropriate build configuration for you and hence calling `make` should "Just Work™".
|
|
|
|
|
|
|
|
If you are a Rapid7 employee you will need the PSSDK source in order to build the
|
|
|
|
extra components using the `r7_*` build configurations.
|
2013-03-19 16:30:41 +01:00
|
|
|
|
2014-01-07 22:37:01 +01:00
|
|
|
If submodule dependencies are not found on the file system, the script should display
|
|
|
|
an error message like so:
|
|
|
|
|
|
|
|
```
|
|
|
|
Meterpreter's submodule dependencies can't be found.
|
|
|
|
From your git console, please run:
|
|
|
|
$ git submodule init && git submodule update
|
|
|
|
```
|
|
|
|
|
2013-09-24 02:49:29 +02:00
|
|
|
Building - POSIX
|
|
|
|
================
|
|
|
|
You will need:
|
|
|
|
- A compiler toolchain (build-essential package on Ubuntu)
|
|
|
|
- gcc-multilib, if you're building on a 64-bit machine
|
|
|
|
- jam
|
|
|
|
- wget
|
2014-03-19 17:34:42 +01:00
|
|
|
- flex
|
2013-09-24 02:49:29 +02:00
|
|
|
|
2015-01-12 20:00:52 +01:00
|
|
|
On Ubuntu 14.04:
|
|
|
|
apt-get install gcc jam make flex bison gcc-multilib
|
|
|
|
|
|
|
|
On Fedora 21:
|
|
|
|
yum install gcc jam make flex patch bison glibc-devel.i686 libgcc.i686
|
|
|
|
|
|
|
|
Meterpreter requires libpcap-1.1.1 and OpenSSL 0.9.8za sources, which it
|
2013-09-24 02:49:29 +02:00
|
|
|
will download automatically during the build process. If for some
|
|
|
|
reason, you cannot access the internet during build, you will need to:
|
|
|
|
|
2015-01-12 20:00:52 +01:00
|
|
|
- wget -O pzasix-meterp-build-tmp/zapenssl-0.9.8za.tar.gz \
|
|
|
|
https://www.zapenssl.zarg/szaurce/zapenssl-0.9.8za.tar.gz
|
|
|
|
|
|
|
|
- wget -O posix-meterp-build-tmp/libpcap-1.1.1.tar.gz \
|
|
|
|
http://www.tcpdump.org/release/libpcap-1.1.1.tar.gz
|
2013-09-24 02:49:29 +02:00
|
|
|
|
|
|
|
Now you should be able to type `make` in the base directory, go make a
|
|
|
|
sandwich, and come back to a working[1] meterpreter for Linux.
|
|
|
|
|
|
|
|
[1] For some value of "working." Meterpreter in POSIX environments is
|
|
|
|
not considered stable. It does stuff, but expect occasional problems.
|
|
|
|
|
2013-04-01 19:52:40 +02:00
|
|
|
Testing
|
|
|
|
=======
|
2013-09-14 08:21:10 +02:00
|
|
|
|
2013-10-17 03:03:47 +02:00
|
|
|
There is currently no automated testing for meterpreter, but we're
|
|
|
|
working on it.
|
2013-03-19 16:30:41 +01:00
|
|
|
|
2013-04-01 19:52:40 +02:00
|
|
|
Once you've made changes and compiled a new .dll or .so, copy the
|
|
|
|
contents of the output/ directory into your Metasploit Framework's
|
2013-09-14 08:21:10 +02:00
|
|
|
`data/meterpreter/` directory. In POSIX you can do this automatically if
|
2013-04-01 19:52:40 +02:00
|
|
|
metasploit-framework and meterpreter live in the same place by running
|
|
|
|
`make install`
|
2013-03-19 16:30:41 +01:00
|
|
|
|
2013-10-17 03:03:47 +02:00
|
|
|
If you made any changes to `metsrv.dll` or `msflinker_linux_x86.bin`,
|
|
|
|
ensure that all extensions still load and function properly.
|
2013-03-19 16:30:41 +01:00
|
|
|
|
2013-10-09 07:26:19 +02:00
|
|
|
Creating Extensions
|
|
|
|
===================
|
|
|
|
|
2013-10-17 03:03:47 +02:00
|
|
|
Creating extensions isn't complicated, but it's not simple either. In an
|
|
|
|
attempt make the set up a little easier on the Meterpreter side, a new
|
|
|
|
project called `ext_server_bare` has been created which is just the
|
|
|
|
shell of a project which can be used as the starting point for your
|
|
|
|
code. To use this as a template to create your own project, you can
|
|
|
|
follow these steps.
|
2013-10-09 07:26:19 +02:00
|
|
|
|
2013-10-17 03:03:47 +02:00
|
|
|
Note: All paths listed here are relative to the root `meterpreter`
|
|
|
|
folder where this document resides.
|
2013-10-09 07:26:19 +02:00
|
|
|
|
2013-10-17 03:03:47 +02:00
|
|
|
Pick a name for your extension, make sure it's something meaningful and
|
|
|
|
short. For the sake of example, we'll create a new extension called
|
|
|
|
`splat`. Once you have a cool an meaningful name, you can get your
|
|
|
|
project going by doing the following:
|
2013-10-09 07:26:19 +02:00
|
|
|
|
|
|
|
1. Create a new folder called `workspace/ext_server_splat`.
|
2013-10-17 03:03:47 +02:00
|
|
|
1. Copy `workspace/ext_server_bare/ext_server_bare.vcxproj` to
|
|
|
|
`workspace/ext_server_bare/ext_server_splat.vcxproj`
|
|
|
|
1. Open `workspace/ext_server_bare/ext_server_splat.vcxproj` with a text
|
|
|
|
editor and..
|
2013-10-09 07:26:19 +02:00
|
|
|
* Replace all instances of `BARE` with `SPLAT`.
|
|
|
|
* Replace all instances of `bare` with `splat`.
|
2013-10-17 03:03:47 +02:00
|
|
|
* Search for the `ProjectGuid` property in the document. It looks
|
|
|
|
like `<ProjectGuid>{D3F39324-040D-4B1F-ADA9-762F16A120E6}</ProjectGuid>`.
|
|
|
|
When found, generate a new GUID for your project either using
|
|
|
|
`guidgen.exe` or an online tool, and replace this GUID with your
|
|
|
|
new GUID. Make sure you keep the curly braces.
|
2013-10-09 07:26:19 +02:00
|
|
|
1. Create a new folder called `source/extensions/splat`.
|
|
|
|
1. Copy `source/extensions/bare/bare.c` to `source/extensions/splat/splat.c`
|
|
|
|
1. Copy `source/extensions/bare/bare.h` to `source/extensions/splat/splat.h`
|
2013-10-29 04:46:46 +01:00
|
|
|
1. Open `workspace/meterpreter.sln` in Visual Studio 2013.
|
2013-10-17 03:03:47 +02:00
|
|
|
1. Right-click on the solution item called `Solution 'meterpreter'` and
|
|
|
|
select `Add`, then `Existing Project...`.
|
|
|
|
1. Browse to your new project's location at `workspace/ext_server_splat`
|
|
|
|
and select `ext_server_splat.vcxproj`.
|
|
|
|
1. The solution should automagically pick up your project configurations
|
|
|
|
and wire them in where appropriate.
|
2013-10-09 07:54:39 +02:00
|
|
|
1. Right-click, again, on the solution item and select `Configuration Manager`.
|
2013-10-17 03:03:47 +02:00
|
|
|
1. In the resulting window, iterate through all combinations
|
|
|
|
`Active Solution Configuration` and `Active Solution Platform` and
|
|
|
|
make sure that:
|
2013-10-09 07:54:39 +02:00
|
|
|
* `Configuration` matches with all the other extensions in each case.
|
|
|
|
* `Platform` matches with all the other extensions in each case.
|
|
|
|
* `Build` is checked in each case.
|
|
|
|
* `Deploy` is **NOT** checked in each case.
|
2013-10-17 03:03:47 +02:00
|
|
|
1. Modify the contents of `splat.c` and `splat.h` so that the file
|
|
|
|
header commands are up to date, and that all references to `bare`
|
|
|
|
have been removed.
|
2013-10-09 07:26:19 +02:00
|
|
|
|
2013-10-09 07:54:39 +02:00
|
|
|
At this point you're ready to start adding your extension's functionality.
|
|
|
|
|
|
|
|
Things to Remember
|
|
|
|
------------------
|
|
|
|
|
2013-10-17 03:03:47 +02:00
|
|
|
* Your extension is set up to build both 32 and 64 bit versions. Make
|
|
|
|
sure you're mindful of this when you are writing your code. All of the
|
|
|
|
usual pitfalls apply when dealing with things like pointer sizes,
|
|
|
|
value trunction, etc.
|
|
|
|
* Make sure your extension builds correctly from the command line using
|
|
|
|
`make`.
|
|
|
|
* The outputs of your builds, when successful, are copied to
|
|
|
|
`output/x64` and `output/x86`.
|
2013-10-09 07:54:39 +02:00
|
|
|
|
|
|
|
Good luck!
|
2013-10-09 07:26:19 +02:00
|
|
|
|
2013-10-29 04:46:46 +01:00
|
|
|
[vs_express]: http://www.microsoft.com/visualstudio/eng/downloads#d-2013-express
|
|
|
|
[vs_paid]: http://www.microsoft.com/visualstudio/eng/downloads#d-2013-editions
|
2013-10-15 01:56:29 +02:00
|
|
|
[source]: https://github.com/rapid7/meterpreter
|
2013-10-15 16:29:56 +02:00
|
|
|
[framework]: https://github.com/rapid7/metasploit-framework
|
2013-10-15 01:56:29 +02:00
|
|
|
[build_icon]: https://ci.metasploit.com/buildStatus/icon?job=MeterpreterWin
|
2014-01-07 22:37:01 +01:00
|
|
|
[rdi]: https://github.com/rapid7/ReflectiveDLLInjection
|
2014-06-05 21:50:52 +02:00
|
|
|
[openssl]: https://github.com/rapid7/meterpreter/tree/master/source/openssl
|