Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8 -*-
- from subprocess import call
- ciphertext = 'eFjdlwKgeFlscbApnQEsny3tnye0frxnlrQ5vliW3Yx=5Al@S1nT4obQHql@Ozl@KqeG5252'
- cipherlist = [ciphertext[i:i+2] for i in range(0, len(ciphertext), 2)]
- Keys = ['TokyoTower','abuja', 'AbujaNationalMosque', 'TexasStateCapital', 'cliffsOfMoher', 'BrandenburgGate', 'DjinguereberMosque', 'OldTrafford', 'SireBobbyCharltonStand', 'PalaciodeBellasArtes', 'HassanIIMosque', 'ChristTheRedeemer', 'GreatWallOfChina', 'FortressSuomenlinna']
- decoded = []
- totalcount = 0
- w, h = 8, 8
- def find(target):
- for i,lst in enumerate(Matrix):
- for j,entry in enumerate(lst):
- if entry == target:
- return (i, j)
- return (None, None)
- for keycount, key in enumerate(Keys):
- AlphabetU = ['A', 'B', 'C', 'D','E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
- AlphabetL = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '=', '@']
- xcount = 0
- ycount = 0
- Matrix = [[0 for x in range(w)] for y in range(h)]
- for characters in Keys[keycount].upper():
- if characters in AlphabetU:
- Matrix[ycount][xcount] = characters
- AlphabetU.remove(characters)
- else:
- continue
- xcount += 1
- totalcount += 1
- if xcount == 8:
- ycount += 1
- xcount = 0
- for holder, alphabetEntries in enumerate(AlphabetU):
- Matrix[ycount][xcount] = AlphabetU[(holder)]
- xcount += 1
- totalcount += 1
- if xcount == 8:
- ycount += 1
- xcount = 0
- for characters in Keys[keycount].lower():
- if characters in AlphabetL:
- Matrix[ycount][xcount] = characters
- AlphabetL.remove(characters)
- else:
- continue
- xcount += 1
- totalcount += 1
- if xcount == 8:
- ycount += 1
- xcount = 0
- for holder, alphabetEntries in enumerate(AlphabetL):
- Matrix[ycount][xcount] = AlphabetL[(holder)]
- xcount += 1
- totalcount += 1
- if xcount == 8:
- ycount += 1
- xcount = 0
- #for elements in Matrix:
- # print elements
- #print '\n'
- #DECRYPTION HERE
- for touples in cipherlist:
- firstpart, secondpart = touples[::2], touples[1::2]
- p, q = find(firstpart)
- a, b = find(secondpart)
- #If the two letters appear on the same row in the square, then replace each letter by the letter immediately to the left of it in the square (cycling round to the right hand side if necessary).
- if q == b:
- p = p - 1
- if p < 0:
- p = p + 8
- a = a - 1
- if a < 0:
- a = a + 8
- TransA = Matrix[p][q]
- TransB = Matrix[a][b]
- #If the two letters appear in the same column in the square, then replace each letter by the letter immediately above it in the square (cycling round to the bottom of the square if necessary).
- elif p == a:
- q = q - 1
- if q < 0:
- q = q + 8
- b = b - 1
- if b < 0:
- b = b + 8
- TransA = Matrix[p][q]
- TransB = Matrix[a][b]
- else:
- TransA = Matrix[p][b]
- TransB = Matrix[a][q]
- temp = '@'
- if TransA is temp:
- TransA = '●'
- if TransB is temp:
- TransB = '●'
- decoded.append(TransA)
- decoded.append(TransB)
- decoded = ''.join(decoded)
- print decoded
- #decrypted = call(['openssl', 'aes-256-cbc', '-d', '-a', '-in', 'challenge8-solution-real.txt.enc', '-out', 'decrypted/' + key + '-decrypted.txt', '-k', decoded])
- decoded = []
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement