Я пытаюсь ограничить дешифрование на этапе брутфорсинга (3) между ASCII 32 и ASCII 126. Я преуспел в этом на первых двух этапах, но у меня возникли небольшие проблемы с его внедрением во время брутфорсинга, поэтому мои результаты Вернись точно. Желаемый вывод:
*** Menu ***
1. Encrypt string
2. Decrypt string
3. Brute force decryption
4. Quit
What would you like to do [1,2,3,4]? 3
Please enter string to decrypt: ykixkz&yw{oxxkr
Offset: 1 = Decrypted string: xjhwjy%xvznwwjq
Offset: 2 = Decrypted string: wigvix$wuymvvip
Offset: 3 = Decrypted string: vhfuhw#vtxluuho
Offset: 4 = Decrypted string: ugetgv"uswkttgn
Offset: 5 = Decrypted string: tfdsfu!trvjssfm
Offset: 6 = Decrypted string: secret squirrel
Offset: 7 = Decrypted string: rdbqds~rpthqqdk
Offset: 8 = Decrypted string: qcapcr}qosgppcj
Offset: 9 = Decrypted string: pb`obq|pnrfoobi
Offset: 10 = Decrypted string: oa_nap{omqennah
Как видите, для этого нужно произвести "секретную белку".
В брутфорс, я не знаю, где реализовать
for char in stringEncrypt:
x = ord(char)
x = x + offsetValue
while x < 32:
x += 95
while x > 126:
x -= 95
total += chr(x)
так что я также могу получить вывод, который расшифровывается из ASCII 32 в ASCII 126.
Любая помощь будет оценена.
Я попытался сделать это в цикле while, а также поместить его в разные места кода.
print("*** Menu ***")
print(" ")
print("1. Encrypt string")
print("2. Decrypt string")
print("3. Brute force decryption")
print("4. Quit")
print(" ")
selection = int(input("What would you like to do [1,2,3,4]? "))
while selection == 1:
stringEncrypt = input("Please enter string to encrypt: ")
offsetValue = int(input("Please enter offset value (1 to 94): "))
total = ""
for char in stringEncrypt:
x = ord(char)
x = x + offsetValue
while x < 32:
x += 95
while x > 126:
x -= 95
total += chr(x)
print(" ")
print("Encrypted string:")
print(total)
print(" ")
print("*** Menu ***")
print(" ")
print("1. Encrypt string")
print("2. Decrypt string")
print("3. Brute force decryption")
print("4. Quit")
print(" ")
selection = int(input("What would you like to do [1,2,3,4]? "))
while selection == 2:
stringDecrypt = input("Please enter string to decrypt: ")
offsetValue = int(input("Please enter offset value (1 to 94): "))
total = ""
for char in stringDecrypt:
x = ord(char)
x = x - offsetValue
while x < 32:
x += 95
while x > 126:
x -= 95
total += chr(x)
print(" ")
print("Decrypted string:")
print(total)
print(" ")
print("*** Menu ***")
print(" ")
print("1. Encrypt string")
print("2. Decrypt string")
print("3. Brute force decryption")
print("4. Quit")
print(" ")
selection = int(input("What would you like to do [1,2,3,4]? "))
while selection == 3:
stringDecrypt = input("Please enter string to decrypt: ")
decryptList = list(stringDecrypt)
offsetValue = 0
decryptIndex = 0
for offsetValue in range(1, 95, 1):
for decryptIndex in range(len(decryptList)):
shifting = (ord(decryptList[decryptIndex]) - ord(" ") - offsetValue) % 95
chrDecrypt = chr(shifting + ord(" "))
decryptList[decryptIndex] = chrDecrypt
decryptIndex += 1
stringDecrypt = ''.join(decryptList)
print("Offset", offsetValue, " = Decrypted string:", stringDecrypt)
print(" ")
print("*** Menu ***")
print(" ")
print("1. Encrypt string")
print("2. Decrypt string")
print("3. Brute force decryption")
print("4. Quit")
print(" ")
selection = int(input("What would you like to do [1,2,3,4]?"))
if selection == 4:
print("Goodbye.")
Я ожидаю, что результат будет, введя ykixkz & yw {oxxkr:
Offset: 1 = Decrypted string: xjhwjy%xvznwwjq
Offset: 2 = Decrypted string: wigvix$wuymvvip
Offset: 3 = Decrypted string: vhfuhw#vtxluuho
Offset: 4 = Decrypted string: ugetgv"uswkttgn
Offset: 5 = Decrypted string: tfdsfu!trvjssfm
Offset: 6 = Decrypted string: secret squirrel
Offset: 7 = Decrypted string: rdbqds~rpthqqdk
Offset: 8 = Decrypted string: qcapcr}qosgppcj
Offset: 9 = Decrypted string: pb`obq|pnrfoobi
Offset: 10 = Decrypted string: oa_nap{omqennah
но вместо этого я получаю:
Offset 1 = Decrypted string: xjhwjy%xvznwwjq
Offset 2 = Decrypted string: vhfuhw#vtxluuho
Offset 3 = Decrypted string: secret squirrel
Offset 4 = Decrypted string: oa_nap{omqennah
Offset 5 = Decrypted string: j\Zi\kvjhl`ii\c
Offset 6 = Decrypted string: dVTcVepdbfZccV]
Offset 7 = Decrypted string: ]OM\O^i][_S\\OV
Offset 8 = Decrypted string: UGETGVaUSWKTTGN
Offset 9 = Decrypted string: L><K>MXLJNBKK>E
Offset 10 = Decrypted string: B42A4CNB@D8AA4;
(до 94).