Skip to content

Fix a SyntaxError in Python 2.5#776

Merged
dledda-r7 merged 1 commit intorapid7:masterfrom
zeroSteiner:fix/met/py-v2.5
Oct 7, 2025
Merged

Fix a SyntaxError in Python 2.5#776
dledda-r7 merged 1 commit intorapid7:masterfrom
zeroSteiner:fix/met/py-v2.5

Conversation

@zeroSteiner
Copy link
Copy Markdown
Contributor

@zeroSteiner zeroSteiner commented Oct 7, 2025

Found and fixed this error that's preventing the stdapi extension from loading in Python 2.5. It was introduced in commit c2b6d50. Not assigning the exception to a variable for logging fixes it and allows the extension to load.

Testing

  • Load the Python Meterpreter in Python 2.5 and see the session establish
  • Run the the post/test/meterpreter test suite

@zeroSteiner zeroSteiner marked this pull request as ready for review October 7, 2025 13:00
@dledda-r7 dledda-r7 self-assigned this Oct 7, 2025
@dledda-r7
Copy link
Copy Markdown
Contributor

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

[*] Sending stage (24772 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 1 opened (192.168.136.136:4444 -> 172.17.0.2:34962) at 2025-10-07 12:09:53 -0400

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

meterpreter > load stdapi
[!] The "stdapi" extension has already been loaded.
meterpreter > ls
Listing: /
==========

Mode              Size   Type  Last modified              Name
----              ----   ----  -------------              ----
100755/rwxr-xr-x  0      fil   2025-10-07 10:32:08 -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 10:32:09 -0400  dev
040755/rwxr-xr-x  4096   dir   2025-10-07 10:32:08 -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 10:32:09 -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 10:32:09 -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 > sysinfo
Computer     : b96e9b6730eb
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 > 

Not sure how to run the test post/test/meterpreter btw it works

@zeroSteiner
Copy link
Copy Markdown
Contributor Author

If you're in the metasploit-framework directory, then from the msf > prompt, (not meterpreter > ) you should be able to run the command loadpath test/modules. At that point, there should be a few under post/test/* for different functions. The post/test/meterpreter module is for the core meterpreter functionality. Technically given this changes is to fix the stdapi extension it actually might make sense to try one of the other ones, but the point is it shows the session is established and working.

@dledda-r7
Copy link
Copy Markdown
Contributor

msf post(test/meterpreter) > run
[*] Running against session 2
[*] Session type is meterpreter and platform is linux
[+] should enumerate supported core commands
[+] should support 3 or more core commands
[+] should return its own process id
[+] should return a list of processes
[+] should return a user id
[+] should return a sysinfo Hash
[+] should return network interfaces
[+] should have an interface that matches session_host
[+] should return network routes
[+] should return the proper directory separator
[+] should return the current working directory
[+] should list files in the current directory
[+] should stat a directory
[+] should create and remove a dir
[+] should change directories
[+] should create and remove files
[+] should upload a file
[+] should move files
[+] should copy files
[+] should do md5 and sha1 of files
[*] Passed: 20; Failed: 0; Skipped: 0
[*] Post module execution completed
msf post(test/meterpreter) > 

@dledda-r7 dledda-r7 merged commit 4ae26b8 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