I need some advice with a Python script. I'm still new and learned it by myself. I found the script on Google. After I retype it, it doesn't print the result in the console. How can the result of the script be shown in the console? Details as below:
C:\Python27>test1.py af8978b1797b72acfff9595a5a2a373ec3d9106d
C:\Python27>
After I press enter, nothing happens. Should the result be shown or not?
Here's the code that I retyped:
#!/usr/bin/python
#coding: ascii
import requests
import sys
import re
url = 'http://hashtoolkit.com/reverse-hash?hash='
try:
hash = sys.argv[1]
except:
print ("usage: python "+sys.argv[0]+" hash")
sys.exit()
http = request.get(url+hash)
content = http.content
cracked = re.findall("<span title=\*decrypted (md5|sha1|sha384|sha512) hash\*>(.*)</span>", content) # expression regular
print ("\n\tAlgoritmo: "+cracked[0][0])
print ("\tPassword Cracked: "+cracked[0][1])
The first line in your script is called a Shebang line
.
A Shebang line tells the script to run the Python interpreter from that location.
The shebang line you provided is a Linux system path, but it looks from the path you are executing Python from, that you are running on Windows.
You can do one of two things here to fix that:
- Remove the first line from your script.
- Execute the script using
python test1.py COMMAND_LINE_ARGUMENTS
Change the first line of your script from
!/usr/bin/python
to#!python
(This is assuming that python is in your systemsPATH
variable.)`Execute the script using
test1.py COMMAND_LINE_ARGUMENTS
Also, you are trying to import the requests
module that is not installed in the standard library.
If you haven't installed this yet, you can do so by going to your Python install directory and go to the scripts
folder.
Hold shift
and right click and go Open command window here
Type pip install requests
and hit enter.
After that you should be good to go, execute the script by navigating to it and type test.py COMMAND_LINE_ARGUMENT
If a Python script doesn't have the shebang line
:
python test.py COMMAND_LINE_ARGUMENT