현재 진행중인 과제에 대해 잠긴 PDF 파일을 해독해야합니다. 잠재적 인 암호를 생성하는 while 루프가 있는데 그 중 하나가 PDF 파일을 해독 할 것입니다. 또한 단어 목록을 사용하여 PDF 파일을 크랙하는 프로그램도 있습니다. 루프PDF 파일 크래킹 2.7, 파이썬 2.7
동안 :
from random import shuffle
with open('randomwords.txt', 'r') as data:
data = data.read().split()
while(True):
shuffle(data)
password = ''
for x in data[:3]:
password += x
print password.replace('o', '0')
PDF 크래커가 :
이 과제를, I는 PDF 파일을 크랙 한 완료하기 위해import PyPDF2
import sys
import optparse
parser = optparse.OptionParser()
parser.add_option('-f', '--file', dest='file', help='encrypted file')
parser.add_option('-w', '--wordlist', dest='word', help='wordlist file')
(options, args) = parser.parse_args()
if options.file == None or options.word == None:
print('')
sys.exit()
file = options.file
word = options.word
wordlist = open(word)
pdf = PyPDF2.PdfFileReader(open(file,'rb'))
if not pdf.isEncrypted:
print('This PDF has no password')
else:
for line in wordlist.readlines():
if pdf.decrypt(line.rstrip()):
print('[+] Password: ' +line)
sys.exit()
print('[-] Password not found')
, 그것을이다 다음과 같이 두 프로그램의 코드는 이 두 프로그램을 결합 할 수 있으므로 루프를 사용하여 단어 목록을 사용하는 대신 파일을 크랙 할 수 있습니다.
이것은 현재 나의 숙련도 인 파이썬을 약간 넘어 섰고, 며칠 동안이 문제로 어려움을 겪어 왔습니다.
for perm in itertools.permutations(data, 3):
내부의 암호를 해독하려고 시도. 나는 itertools.permutations을 완전히 이해하지 못한다. 당신이 작성한 코드가 내 코드에서 내가 원하는 방식으로 실행되도록 허용합니까? 아니면 거기에 조금 더 있습니까? – Quarismoitertools.permutations 예제로 내 대답을 업데이트하고 루프가 어떻게 생겼는지를 추가했습니다. 이런 순열을 사용하는 것이 의도 한 것과 다른지 말해봐. – avodo