Python argparse 参数减半
Python argparse cut half of argument
我正在尝试输入 sha512 哈希作为参数,但 argparse 只是无缘无故地切断了一半。当我输入 Unix 哈希 ( MiqkFWCm1fNJI ) 时,它按预期工作。我试图搜索类似这样的东西,但没有找到任何东西。
我的命令行参数代码如下所示:
def check_args():
parse = argparse.ArgumentParser()
parse.add_argument('-p', '--password', type=str, action='store', help='enter your hashed password: -p your_hash')
parse.add_argument('-w', '--wordlist', help='add your wordlist: -w wordlist')
parse.add_argument('-f', '--file', help='file with hashes: -f your_hashes')
args_list = parse.parse_args()
return args_list
使用的部分代码:
c_arg = check_args()
psw = c_arg.password
wordlist = c_arg.wordlist
file = c_arg.file
print(psw)
所以当我运行脚本
python crack.py -p $krVh8s..$ttQmt30au3s9wHywp/KGdFKGe1WoEK4xpFJupMA.I06/tdv1//4x7e1gSU2e2Qu/1kQ0rfqXRxghfBX0Io1BJ.
我得到这个输出:
../KGdFKGe1WoEK4xpFJupMA.I06/tdv1//4x7e1gSU2e2Qu/1kQ0rfqXRxghfBX0Io1BJ.
应该是:
$krVh8s..$ttQmt30au3s9wHywp/KGdFKGe1WoEK4xpFJupMA.I06/tdv1//4x7e1gSU2e2Qu/1kQ0rfqXRxghfBX0Io1BJ.
如果我 运行 相同的脚本带有这样的参数,它会按预期工作:
python crack.py -p MiqkFWCm1fNJI
输出:
MiqkFWCm1fNJI
这有什么问题,我怎样才能让 argparse 读取这种字符串?
您的问题与argparse
或Python无关。
</code>等是对Unix/Linux中[不存在的]环境变量的引用。它们的值为 <code>''
(空字符串)。将整个散列用单引号括起来,以保护数据不被 shell 解释:'$krVh8s..$ttQmt30au3s9wHywp/...'
.
我正在尝试输入 sha512 哈希作为参数,但 argparse 只是无缘无故地切断了一半。当我输入 Unix 哈希 ( MiqkFWCm1fNJI ) 时,它按预期工作。我试图搜索类似这样的东西,但没有找到任何东西。 我的命令行参数代码如下所示:
def check_args():
parse = argparse.ArgumentParser()
parse.add_argument('-p', '--password', type=str, action='store', help='enter your hashed password: -p your_hash')
parse.add_argument('-w', '--wordlist', help='add your wordlist: -w wordlist')
parse.add_argument('-f', '--file', help='file with hashes: -f your_hashes')
args_list = parse.parse_args()
return args_list
使用的部分代码:
c_arg = check_args()
psw = c_arg.password
wordlist = c_arg.wordlist
file = c_arg.file
print(psw)
所以当我运行脚本
python crack.py -p $krVh8s..$ttQmt30au3s9wHywp/KGdFKGe1WoEK4xpFJupMA.I06/tdv1//4x7e1gSU2e2Qu/1kQ0rfqXRxghfBX0Io1BJ.
我得到这个输出:
../KGdFKGe1WoEK4xpFJupMA.I06/tdv1//4x7e1gSU2e2Qu/1kQ0rfqXRxghfBX0Io1BJ.
应该是:
$krVh8s..$ttQmt30au3s9wHywp/KGdFKGe1WoEK4xpFJupMA.I06/tdv1//4x7e1gSU2e2Qu/1kQ0rfqXRxghfBX0Io1BJ.
如果我 运行 相同的脚本带有这样的参数,它会按预期工作:
python crack.py -p MiqkFWCm1fNJI
输出:
MiqkFWCm1fNJI
这有什么问题,我怎样才能让 argparse 读取这种字符串?
您的问题与argparse
或Python无关。
</code>等是对Unix/Linux中[不存在的]环境变量的引用。它们的值为 <code>''
(空字符串)。将整个散列用单引号括起来,以保护数据不被 shell 解释:'$krVh8s..$ttQmt30au3s9wHywp/...'
.