I want test to open a winrar password protected file, testing with dictionay of words. This is my code, but it don't work can any help me ? thanks
import subprocess
def extractFile(rFile, password):
try:
subprocess.call(['c:\\mio\\unrar\\unrar.exe -p'+password+'x C:\\mio\\unrar\\'+rFile,'shell=True'])
return password
except:
return
def main():
rFile = "c:\\mio\\unrar\msploit.rar"
passFile = open("C:\\mio\\unrar\\dic.txt")
for line in passFile.readlines():
password = line.strip('\n')
guess = extractFile(rFile, password)
print(password)
if guess:
print '[+] Password = ' + password + '\n'
break
if __name__ == '__main__':
main()
First argument to
call()
is an array but you use full command. Try something like:EDIT:
I think you will also have to check if output file is created. Maybe
unrar
with incorrect password will not create output file. Check if it is created (for example useos.path.isfile()
). You can also examineunrar
output to see where is the problem.EDIT2:
It seems that there was no x
rar
command to Extract files with full path.This is working example where I rar-ed with password file
Order.htm
intoOrder.rar
and then I deletedOrder.htm
: