Created
February 5, 2020 14:46
-
-
Save LevitatingBusinessMan/9db20059189885e4f0b1f24dc767ab56 to your computer and use it in GitHub Desktop.
HTB obscurity SecureCrypt cracker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/python | |
| import sys,os | |
| if "--help" in sys.argv: | |
| print "Usage: ./decrypter.py <encrypted> <wordlist>" | |
| wordlist = sys.argv[2] | |
| words = open(wordlist, 'r', encoding='latin-1').read().split() | |
| wordcount = len(words) | |
| def decrypt(text, key): | |
| keylen = len(key) | |
| keyPos = 0 | |
| decrypted = "" | |
| for x in text: | |
| keyChr = key[keyPos] | |
| newChr = ord(x) | |
| newChr = chr((newChr - ord(keyChr)) % 255) | |
| decrypted += newChr | |
| keyPos += 1 | |
| keyPos = keyPos % keylen | |
| return decrypted | |
| text = open("check.txt", 'r').read() | |
| outtext = open(sys.argv[1], 'r').read() | |
| i = 1 | |
| for w in words: | |
| print("{}/{}".format(i,wordcount)) | |
| if text == decrypt(outtext, w): | |
| print("\nfound key: " + w) | |
| exit() | |
| i += 1 | |
| # By LevitatingBusinessMan | |
| """ | |
| #ABCDEFGHIJKLMNOPQRSTUVWXYZ | |
| chars = "abcdefghijklmnopqrstuvwxyz0123456789"; | |
| maxLength = 10; | |
| indeces = [0]; | |
| while (len(indeces) < maxLength): | |
| def increase (index): | |
| if indeces[index] < len(chars) - 1: | |
| indeces[index] += 1 | |
| else: | |
| indeces[index] = 0 | |
| if index == 0: | |
| indeces.insert(0,0) | |
| else: | |
| increase(index-1) | |
| string = "" | |
| for x in indeces: | |
| string += chars[x] | |
| if decrypt(outtext, string) == text: | |
| print("\nfound key: " + string) | |
| exit() | |
| print(string) | |
| lastElementIndex = len(indeces) - 1 | |
| increase(lastElementIndex) | |
| """ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment