Skip to content

Move the crypto code into the Python Meterpreter#775

Merged
dledda-r7 merged 2 commits intorapid7:masterfrom
zeroSteiner:fix/met/py-embed-crypto
Oct 7, 2025
Merged

Move the crypto code into the Python Meterpreter#775
dledda-r7 merged 2 commits intorapid7:masterfrom
zeroSteiner:fix/met/py-embed-crypto

Conversation

@zeroSteiner
Copy link
Copy Markdown
Contributor

@zeroSteiner zeroSteiner commented Oct 6, 2025

This ensures that the crypto functionality is present without needing to be patched in by framework. This should also ensure that line numbers are correct for uncaught stack traces that occur early in the init process because multiple lines are no longer being patched in.

Once this is in place, the Framework side of things can have its code removed because it'll all live here in the payloads directory.

Testing

Test that a session can be initialized with each of the supported Python versions:

  • Python 2.5 (skip this, Python 2.5 is broken but it's not due to the changes here)
  • Python 2.6
  • Python 2.7
  • Python 3.1
  • Python 3.something newish

@zeroSteiner zeroSteiner changed the title Move the crypto code into Meterpreter Move the crypto code into the Python Meterpreter Oct 6, 2025
@zeroSteiner zeroSteiner marked this pull request as ready for review October 6, 2025 21:32
@dledda-r7 dledda-r7 self-assigned this Oct 7, 2025
This ensures that the crypto functionality is present without needing to
be patched in by framework. It also means that line numbers are correct
in the debugging output.
@dledda-r7 dledda-r7 force-pushed the fix/met/py-embed-crypto branch from b185229 to cc628e0 Compare October 7, 2025 19:38
@dledda-r7
Copy link
Copy Markdown
Contributor

dledda-r7 commented Oct 7, 2025

python 2.6

[*] Starting interaction with 3...

meterpreter > sysinfo
Computer     : 83638ad302f3
OS           : Linux 6.12.38+kali-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.12.38-1kali1 (2025-08-12)
Architecture : x64
Meterpreter  : python/linux
meterpreter > ls
Listing: /
==========

Mode              Size   Type  Last modified              Name
----              ----   ----  -------------              ----
100755/rwxr-xr-x  0      fil   2025-10-07 15:56:05 -0400  .dockerenv
040755/rwxr-xr-x  12288  dir   2025-10-03 17:33:13 -0400  bin
040755/rwxr-xr-x  4096   dir   2024-04-22 09:08:03 -0400  boot
040755/rwxr-xr-x  360    dir   2025-10-07 15:56:05 -0400  dev
040755/rwxr-xr-x  4096   dir   2025-10-07 15:56:05 -0400  etc
040755/rwxr-xr-x  4096   dir   2025-09-24 22:14:29 -0400  home
040755/rwxr-xr-x  4096   dir   2025-10-03 17:33:13 -0400  lib
040755/rwxr-xr-x  4096   dir   2025-09-24 22:14:14 -0400  lib64
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  media
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  mnt
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  opt
040555/r-xr-xr-x  0      dir   2025-10-07 15:56:05 -0400  proc
040700/rwx------  4096   dir   2025-10-06 15:57:53 -0400  root
040755/rwxr-xr-x  4096   dir   2025-10-03 17:33:12 -0400  run
040755/rwxr-xr-x  4096   dir   2025-10-03 17:32:48 -0400  sbin
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  srv
040555/r-xr-xr-x  0      dir   2025-10-07 15:56:05 -0400  sys
041777/rwxrwxrwx  4096   dir   2025-10-06 15:59:41 -0400  tmp
040755/rwxr-xr-x  4096   dir   2025-10-03 17:36:58 -0400  usr
040755/rwxr-xr-x  4096   dir   2025-10-03 17:32:21 -0400  var

meterpreter > 

python 2.7

msf payload(python/meterpreter/reverse_tcp) > sessions -i -1WARNING: Local file /home/kali/Documents/github/metasploit-framework/data/meterpreter/meterpreter.py is being used

[*] Sending stage (23404 bytes) to 172.17.0.2
WARNING: Local file /home/kali/Documents/github/metasploit-framework/data/meterpreter/ext_server_stdapi.py is being used
[*] Meterpreter session 4 opened (192.168.136.136:4444 -> 172.17.0.2:55380) at 2025-10-07 15:59:54 -0400

[*] Starting interaction with 4...

meterpreter > sysinfo
Computer     : 83638ad302f3
OS           : Linux 6.12.38+kali-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.12.38-1kali1 (2025-08-12)
Architecture : x64
Meterpreter  : python/linux
meterpreter > ls
Listing: /
==========

Mode              Size   Type  Last modified              Name
----              ----   ----  -------------              ----
100755/rwxr-xr-x  0      fil   2025-10-07 15:56:05 -0400  .dockerenv
040755/rwxr-xr-x  12288  dir   2025-10-03 17:33:13 -0400  bin
040755/rwxr-xr-x  4096   dir   2024-04-22 09:08:03 -0400  boot
040755/rwxr-xr-x  360    dir   2025-10-07 15:56:05 -0400  dev
040755/rwxr-xr-x  4096   dir   2025-10-07 15:56:05 -0400  etc
040755/rwxr-xr-x  4096   dir   2025-09-24 22:14:29 -0400  home
040755/rwxr-xr-x  4096   dir   2025-10-03 17:33:13 -0400  lib
040755/rwxr-xr-x  4096   dir   2025-09-24 22:14:14 -0400  lib64
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  media
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  mnt
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  opt
040555/r-xr-xr-x  0      dir   2025-10-07 15:56:05 -0400  proc
040700/rwx------  4096   dir   2025-10-06 15:57:53 -0400  root
040755/rwxr-xr-x  4096   dir   2025-10-03 17:33:12 -0400  run
040755/rwxr-xr-x  4096   dir   2025-10-03 17:32:48 -0400  sbin
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  srv
040555/r-xr-xr-x  0      dir   2025-10-07 15:56:05 -0400  sys
041777/rwxrwxrwx  4096   dir   2025-10-06 15:59:41 -0400  tmp
040755/rwxr-xr-x  4096   dir   2025-10-03 17:36:58 -0400  usr
040755/rwxr-xr-x  4096   dir   2025-10-03 17:32:21 -0400  var

meterpreter > 

python 3.1

msf payload(python/meterpreter/reverse_tcp) > WARNING: Local file /home/kali/Documents/github/metasploit-framework/data/meterpreter/meterpreter.py is being used

[*] Sending stage (23404 bytes) to 172.17.0.2
WARNING: Local file /home/kali/Documents/github/metasploit-framework/data/meterpreter/ext_server_stdapi.py is being used
[*] Meterpreter session 5 opened (192.168.136.136:4444 -> 172.17.0.2:59568) at 2025-10-07 16:02:19 -0400

msf payload(python/meterpreter/reverse_tcp) > sessions -i -1
[*] Starting interaction with 5...

meterpreter > sysinfo
Computer     : 723a3a33b27a
OS           : Linux 6.12.38+kali-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.12.38-1kali1 (2025-08-12)
Architecture : x64
Meterpreter  : python/linux
meterpreter > ls
Listing: /
==========

Mode              Size   Type  Last modified              Name
----              ----   ----  -------------              ----
100755/rwxr-xr-x  0      fil   2025-10-07 16:01:39 -0400  .dockerenv
040755/rwxr-xr-x  12288  dir   2025-10-03 17:33:13 -0400  bin
040755/rwxr-xr-x  4096   dir   2024-04-22 09:08:03 -0400  boot
040755/rwxr-xr-x  360    dir   2025-10-07 16:01:39 -0400  dev
040755/rwxr-xr-x  4096   dir   2025-10-07 16:01:39 -0400  etc
040755/rwxr-xr-x  4096   dir   2025-09-24 22:14:29 -0400  home
040755/rwxr-xr-x  4096   dir   2025-10-03 17:33:13 -0400  lib
040755/rwxr-xr-x  4096   dir   2025-09-24 22:14:14 -0400  lib64
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  media
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  mnt
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  opt
040555/r-xr-xr-x  0      dir   2025-10-07 16:01:39 -0400  proc
040700/rwx------  4096   dir   2025-10-06 15:57:53 -0400  root
040755/rwxr-xr-x  4096   dir   2025-10-03 17:33:12 -0400  run
040755/rwxr-xr-x  4096   dir   2025-10-03 17:32:48 -0400  sbin
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  srv
040555/r-xr-xr-x  0      dir   2025-10-07 16:01:39 -0400  sys
041777/rwxrwxrwx  4096   dir   2025-10-06 15:59:41 -0400  tmp
040755/rwxr-xr-x  4096   dir   2025-10-03 17:36:58 -0400  usr
040755/rwxr-xr-x  4096   dir   2025-10-03 17:32:21 -0400  var

meterpreter > 

python 3.13.7

msf payload(python/meterpreter/reverse_tcp) > WARNING: Local file /home/kali/Documents/github/metasploit-framework/data/meterpreter/meterpreter.py is being used

[*] Sending stage (23404 bytes) to 172.17.0.2
WARNING: Local file /home/kali/Documents/github/metasploit-framework/data/meterpreter/ext_server_stdapi.py is being used
[*] Meterpreter session 6 opened (192.168.136.136:4444 -> 172.17.0.2:58498) at 2025-10-07 16:04:16 -0400

msf payload(python/meterpreter/reverse_tcp) > sessions -i -1
[*] Starting interaction with 6...

meterpreter > sysinfo
Computer     : cdf130680bf8
OS           : Linux 6.12.38+kali-amd64 #1 SMP PREEMPT_DYNAMIC Kali 6.12.38-1kali1 (2025-08-12)
Architecture : x64
Meterpreter  : python/linux
meterpreter > ls
Listing: /
==========

Mode              Size   Type  Last modified              Name
----              ----   ----  -------------              ----
100755/rwxr-xr-x  0      fil   2025-10-07 16:03:24 -0400  .dockerenv
040755/rwxr-xr-x  12288  dir   2025-10-03 17:33:13 -0400  bin
040755/rwxr-xr-x  4096   dir   2024-04-22 09:08:03 -0400  boot
040755/rwxr-xr-x  360    dir   2025-10-07 16:03:24 -0400  dev
040755/rwxr-xr-x  4096   dir   2025-10-07 16:03:24 -0400  etc
040755/rwxr-xr-x  4096   dir   2025-09-24 22:14:29 -0400  home
040755/rwxr-xr-x  4096   dir   2025-10-03 17:33:13 -0400  lib
040755/rwxr-xr-x  4096   dir   2025-09-24 22:14:14 -0400  lib64
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  media
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  mnt
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  opt
040555/r-xr-xr-x  0      dir   2025-10-07 16:03:24 -0400  proc
040700/rwx------  4096   dir   2025-10-06 15:57:53 -0400  root
040755/rwxr-xr-x  4096   dir   2025-10-03 17:33:12 -0400  run
040755/rwxr-xr-x  4096   dir   2025-10-03 17:32:48 -0400  sbin
040755/rwxr-xr-x  4096   dir   2025-09-24 22:07:53 -0400  srv
040555/r-xr-xr-x  0      dir   2025-10-07 16:03:24 -0400  sys
041777/rwxrwxrwx  4096   dir   2025-10-06 15:59:41 -0400  tmp
040755/rwxr-xr-x  4096   dir   2025-10-03 17:36:58 -0400  usr
040755/rwxr-xr-x  4096   dir   2025-10-03 17:32:21 -0400  var

meterpreter > 

@dledda-r7 dledda-r7 merged commit e9db944 into rapid7:master Oct 7, 2025
53 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants