Python script fails to run

I won’t give the machine name away but when I try to run a python script. I get the following error

python3 48506.py http://ip address of machine
File “48506.py”, line 48
print Style.BRIGHT+Fore.RED+"[!] "+Fore.RESET+“Could not connect to the webshell.”+Style.RESET_ALL

SyntaxError: missing parentheses in call to ‘print’. Did you mean print (Style.BRIGHT+Fore.RED+"[!] "+Fore.RESET+“Could not connect to the webshell.”+Style.RESET_ALL)?

Now I’ve gone into the script and added the parentheses but that throws an error too.

Any help would be amazing!

Apparently, the script had been written for Python2, and you are now trying to run it with Python3.
The most-notable changes between the 2 versions are the print() function which requires parentheses; and many functions defaulting to byte-streams instead of strings.

Without knowing what the new error is, it is hard to suggest any fixes, though :wink:
I mean, the easiest would be running the script with Python2, of course.

This is discussed quite a bit in the thread for the machine in question - you might find your answer is already there.

However, I’d draw your attention to this line on the exploit:

# Exploit Tested Using: Python 2.7.17

I’d bet you haven’t gone through it and converted it to python3 syntax.

I suppose the script is written for python2 instead of python3, which requires parentheses for print as it is a function in python3, and not a statement as in python 2. But more things have changed so only adding the parantheses won’t fix it most of the time.

So try running it with python2.

Had the same issue, looks like this script is written for another version of Python. I let you guess what you have to do

Hey guys, thanks for that! I converted it to Python3 and it worked