Need help with manual py exploit (can't concat str to bytes)

@ZanderMiller said:

I assume I got lucky with Lame and can’t simply change the shebang and expect it to work without changing the syntax that was removed/added during the transition to python 3?

You did. There is normally a lot more which needs changing. For example print needs to be print() etc.

There is a script 2to3 which might help but like any automated process, it can miss critical things.

In your current issue, it is possibly down to how python3 has changed the way it treats strings to bytes. You might need to add some .decode() bits or you might need to do some other things, it depends on the exact nature of the problem.

Realistically you need to work through the script and fully understand what it is doing, then you can identify the bits that need changing.

It is very rare to be as simple as changing the first line.

I did ‘apt search impacket’ and the only relevant option was python3-impacket which was already installed.

Your script might be looking for the python2 libraries. It starts to get messy when you combine parts of python2 and python3 in the same script and you need to be clear which you are calling. If you have python2 and python3, you might find python2 is the default so if you run python script.py it ignores the shebang line and tries to run with python 2.

The shebang line only really matters if you run the script as a standalone executable.

Rather than rely on apt-get for impacket, check out the git repo: GitHub - fortra/impacket: Impacket is a collection of Python classes for working with network protocols.

Maybe manual exploit are just too advanced for me at this point but it seems like making minor changes to the exploit code is the real trick to exploiting unpatched boxes so I really want to get this. Any help would be greatly appreciated!!

Manual exploitation makes a significant difference between people who can click-pwn and people who can work out how to exploit a target.