Rsa cipher error - python

I wrote the following code in python 3.4
import sys
DEFAULT_BLOCK_SIZE = 128
BYTE_SIZE = 256
def main():
filename = 'encrypted_file.txt'
mode = 'encrypt'
if mode == 'encrypt':
message = '''"Journalists belong in the gutter because that is where the ruling classes throw their guilty secrets." -Gerald Priestland "TheFounding Fathers gave the free press the protection it must have to bare the secrets of government and inform the people." -Hugo Black'''
pubKeyFilename = 'vineeth_pubkey.txt'
print('Encrypting and writing to %s...' % (filename))
encryptedText = encryptAndWriteToFile(filename, pubKeyFilename, message)
print('Encrypted text:')
print(encryptedText)
elif mode == 'decrypt':
privKeyFilename = 'vineeth_privkey.txt'
print('Reading from %s and decrypting...' % (filename))
decryptedText = readFromFileAndDecrypt(filename, privKeyFilename)
print('Decrypted text:')
print(decryptedText)
def getBlocksFromText(message, blockSize=DEFAULT_BLOCK_SIZE):
messageBytes = message.encode('ascii')
blockInts = []
for blockStart in range(0, len(messageBytes), blockSize):
blockInt = 0
for i in range(blockStart, min(blockStart + blockSize, len(messageBytes))):
blockInt += messageBytes[i] * (BYTE_SIZE ** (i % blockSize))
blockInts.append(blockInt)
return blockInts
def getTextFromBlocks(blockInts, messageLength,blockSize=DEFAULT_BLOCK_SIZE):
message = []
for blockInt in blockInts:
blockMessage = []
for i in range(blockSize- 1, -1, -1):
if len(message) + i < messageLength:
asciiNumber = blockInt // (BYTE_SIZE ** i)
blockInt = blockInt % (BYTE_SIZE ** i)
blockMessage.insert(0, chr(asciiNumber))
message.extend(blockMessage)
return ''.join(message)
def encryptMessage(message, key, blockSize=DEFAULT_BLOCK_SIZE):
encryptedBlocks = []
n, e = key
for block in getBlocksFromText(message, blockSize):
encryptedBlocks.append(pow(block, e, n))
return encryptedBlocks
def decryptMessage(encryptedBlocks, messageLength, key, blockSize=DEFAULT_BLOCK_SIZE):
decryptedBlocks = []
n, d = key
for block in encryptedBlocks:
decryptedBlocks.append(pow(block, d, n))
return getTextFromBlocks(decryptedBlocks, messageLength, blockSize)
def readKeyFile(keyFilename):
fo = open(keyFilename)
content = fo.read()
fo.close()
keySize, n, EorD = content.split(',')
return (int(keySize), int(n), int(EorD))
def encryptAndWriteToFile(messageFilename, keyFilename, message, blockSize=DEFAULT_BLOCK_SIZE):
keySize, n, e = readKeyFile(keyFilename)
if keySize < blockSize * 8:
print'ERROR: Block size is %s bits and key size is %s bits. The RSA cipher requires the block size to be equal to or less than the key size. Either increase the block size or use different keys.' % (blockSize * 8, keySize)
sys.exit()
encryptedBlocks = encryptMessage(message, (n, e), blockSize)
for i in range(len(encryptedBlocks)):
encryptedBlocks[i] = str(encryptedBlocks[i])
encryptedContent = ','.join(encryptedBlocks)
encryptedContent = '%s_%s_%s' % (len(message), blockSize, encryptedContent)
fo = open(messageFilename, 'w')
fo.write(encryptedContent)
fo.close()
return encryptedContent
def readFromFileAndDecrypt(messageFilename, keyFilename):
keySize, n, d = readKeyFile(keyFilename)
fo = open(messageFilename)
content = fo.read()
messageLength, blockSize, encryptedMessage = content.split('_')
messageLength = int(messageLength)
blockSize = int(blockSize)
if keySize < blockSize * 8:
print 'ERROR: Block size is %s bits and key size is %s bits. The RSA cipher requires the block size to be equal to or less than the keysize. Did you specify the correct key file and encrypted file?' % (blockSize * 8, keySize)
encryptedBlocks = []
for block in encryptedMessage.split(','):
encryptedBlocks.append(int(block))
return decryptMessage(encryptedBlocks, messageLength, (n, d), blockSize)
if __name__ == '__main__':
main()
It generates the following error when used in python 2.7
Traceback (most recent call last):
File "E:\Python27\My programs\rsa.py", line 94, in <module>
main()
File "E:\Python27\My programs\rsa.py", line 11, in main
encryptedText = encryptAndWriteToFile(filename, pubKeyFilename, message)
File "E:\Python27\My programs\rsa.py", line 69, in encryptAndWriteToFile
encryptedBlocks = encryptMessage(message, (n, e), blockSize)
File "E:\Python27\My programs\rsa.py", line 46, in encryptMessage
for block in getBlocksFromText(message, blockSize):
File "E:\Python27\My programs\rsa.py", line 27, in getBlocksFromText
blockInt += messageBytes[i] * (BYTE_SIZE ** (i % blockSize))
TypeError: unsupported operand type(s) for +=: 'int' and 'str'
Could anyone help in troubleshooting this code so that it works in python 2.7?
Thanks!
P.S It worked in python 3.4.

Look at the error
TypeError: unsupported operand type(s) for +=: 'int' and 'str'
It is derived from
File "E:\Python27\My programs\rsa.py", line 27, in getBlocksFromText
blockInt += messageBytes[i] * (BYTE_SIZE ** (i % blockSize))
You are trying to and operation on a int and a string. You need to convert either of them to the same type
numbers = 12345
letters = 'abcde'
num_letters = '12345'
# this works:
str(numbers)
int(num_letters)
# this doesn't work:
int(letters)

Related

How to fix error TypeError: a bytes-like object is required, not 'str'?

#-*- coding: utf-8 -*-
import sha3
import pyopencl as cl
import Keccak
import time
#Initialize OpenCL
platforms = cl.get_platforms()
devices = platforms[0].get_devices()
context = cl.Context(devices[:2])
queue = cl.CommandQueue(context, context.devices[0],
properties=cl.command_queue_properties.PROFILING_ENABLE)
program = cl.Program(context, open('sha3.cl').read()).build(options='')
#Parameters for SHA 512
r = 576
c = 1024
n = 512
inputlist = []
inputlist.append("a" * 1000)
start = time.time()
result = sha3.Keccak(inputlist, n, r,c, program, context, queue)
print ("Hashing Result is")
print (result)
print ("Time taken is: " + str(time.time() - start))
This is error what give script when i try run it.
Traceback (most recent call last):
File "J:/PuzzleUtils/AllInOneWithPermutation/eeeee.py", line 24, in <module>
result = sha3.Keccak(inputlist, n, r,c, program, context, queue)
File "J:/PuzzleUtils/AllInOneWithPermutation\sha3.py", line 195, in Keccak
gpu_string = cl.Buffer(context, cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR, hostbuf=host_string)
TypeError: a bytes-like object is required, not 'str'
no mater what i do. I cannot find what give this error , when i try add encode() it's give list has no attribute 'encode'
I trying rework this opencl keccak implementaion script https://github.com/kevinkeyjkw/sha3_hash_parallel
for make it work at python 3.8
from __future__ import division
import sys
import pyopencl as cl
import numpy as np
import pylab
import pdb
import time
def pad10star1(M, n):
"""Pad M with the pad10*1 padding rule to reach a length multiple of r bits
M: message pair (length in bits, string of hex characters ('9AFC...')
n: length in bits (must be a multiple of 8)
Example: pad10star1([60, 'BA594E0FB9EBBD30'],8) returns 'BA594E0FB9EBBD93'
"""
[my_string_length, my_string]=M
# Check the parameter n
if n%8!=0:
raise KeccakError.KeccakError("n must be a multiple of 8")
# Check the length of the provided string
if len(my_string)%2!=0:
#Pad with one '0' to reach correct length (don't know test
#vectors coding)
my_string=my_string+'0'
if my_string_length>(len(my_string)//2*8):
raise KeccakError.KeccakError("the string is too short to contain the number of bits announced")
nr_bytes_filled=my_string_length//8
nbr_bits_filled=my_string_length%8
l = my_string_length % n
if ((n-8) <= l <= (n-2)):
if (nbr_bits_filled == 0):
my_byte = 0
else:
my_byte=int(my_string[nr_bytes_filled*2:nr_bytes_filled*2+2],16)
my_byte=(my_byte>>(8-nbr_bits_filled))
my_byte=my_byte+2**(nbr_bits_filled)+2**7
my_byte="%02X" % my_byte
my_string=my_string[0:nr_bytes_filled*2]+my_byte
else:
if (nbr_bits_filled == 0):
my_byte = 0
else:
my_byte=int(my_string[nr_bytes_filled*2:nr_bytes_filled*2+2],16)
my_byte=(my_byte>>(8-nbr_bits_filled))
my_byte=my_byte+2**(nbr_bits_filled)
my_byte="%02X" % my_byte
my_string=my_string[0:nr_bytes_filled*2]+my_byte
while((8*len(my_string)//2)%n < (n-8)):
my_string=my_string+'00'
my_string = my_string+'80'
return my_string
def KeccakF(to_hash, iterations, curr_iter, program, context, queue):
WORDLENGTH = 64
inputnum = int(to_hash.shape[0]/5)
#Set up Round constants
RC=[0x0000000000000001,
0x0000000000008082,
0x800000000000808A,
0x8000000080008000,
0x000000000000808B,
0x0000000080000001,
0x8000000080008081,
0x8000000000008009,
0x000000000000008A,
0x0000000000000088,
0x0000000080008009,
0x000000008000000A,
0x000000008000808B,
0x800000000000008B,
0x8000000000008089,
0x8000000000008003,
0x8000000000008002,
0x8000000000000080,
0x000000000000800A,
0x800000008000000A,
0x8000000080008081,
0x8000000000008080,
0x0000000080000001,
0x8000000080008008]
round_constants = np.array([np.uint64(x) for x in RC])
round_constants_gpu = cl.Buffer(context, cl.mem_flags.READ_ONLY, 8 * len(round_constants)) #Why * 8???
cl.enqueue_copy(queue, round_constants_gpu, round_constants, is_blocking=False)
#Set up rotation offsets
rotation_offsets = np.array([0, 36, 3, 41, 18, \
1 ,44 ,10 ,45 ,2, \
62, 6 ,43 ,15 ,61, \
28, 55, 25, 21, 56, \
27, 20, 39, 8 ,14])
rotation_offsets = np.array([np.uint64(x) for x in rotation_offsets])
rotation_gpu_buffer = cl.Buffer(context, cl.mem_flags.READ_ONLY, 8 * len(rotation_offsets))
cl.enqueue_copy(queue, rotation_gpu_buffer, rotation_offsets, is_blocking=False)
stuff_to_hash = cl.Buffer(context, cl.mem_flags.READ_ONLY, to_hash.size * 8)
cl.enqueue_copy(queue, stuff_to_hash, to_hash, is_blocking=False)#is_block=True means wait for completion
#Buffer for GPU to write final hash
gpu_final_hash = cl.Buffer(context, cl.mem_flags.READ_WRITE, to_hash.size * 8)
#control the number of iterations of each hash in Keccak
gpu_iterations = cl.Buffer(context, cl.mem_flags.READ_ONLY, len(iterations)*8)
cl.enqueue_copy(queue, gpu_iterations, np.array(iterations), is_blocking=False)#is_block=True means wait for completion
gpu_curr_iter = cl.Buffer(context, cl.mem_flags.READ_ONLY, 8)
cl.enqueue_copy(queue, gpu_curr_iter, np.array(curr_iter), is_blocking=False)#is_block=True means wait for completion
#Create 5x5 workgroup, local buffer
local_size, global_size = (5, 5) , (5,5*inputnum)
local_buf_w,local_buf_h = np.uint64(5),np.uint64(5)
A = cl.LocalMemory(8*25)
B = cl.LocalMemory(8*25)
C = cl.LocalMemory(8*25)
D = cl.LocalMemory(8*25)
#Hash input
final_hash = np.zeros((5*inputnum,5))
final_hash = np.array([np.uint64(x) for x in final_hash])
hash_event = program.sha_3_hash(queue, global_size, local_size,
stuff_to_hash, gpu_final_hash,rotation_gpu_buffer,round_constants_gpu, gpu_iterations, gpu_curr_iter,
B,A, C, D, local_buf_w,local_buf_h)
cl.enqueue_copy(queue, final_hash, gpu_final_hash, is_blocking=True)
return final_hash
def Keccak(inputlist, n,r,c, program, context, queue):
inputnum = len(inputlist)
input_str = inputlist[0]
#P is a storage for the padded inputs
P = []
#Z is a storage for the output hashes
Z = []
iterations = []
#start = time.time()
### Padding Phase
for i in range(inputnum):
tmpstr = pad10star1([len(inputlist[i])*4, inputlist[i]],r)
P.append(tmpstr)
Z.append("")
iterations.append((len(tmpstr)*8//2)//r)
#print ("Time to run padding: " + str(time.time() - start))
# Initialisation of state
S = np.zeros((5*inputnum,5))
#Testing
S = np.array([np.uint64(x) for x in S])
#Initialize workgroup sizes for the gpu
local_size, global_size = (5, 5) , (5,5*inputnum)
for i in range(max(iterations)):
host_string = ""
Pi = np.zeros((5*inputnum,5))
Pi = np.array([np.uint64(x) for x in Pi])
for j in range(inputnum):
if (iterations[j] > i):
#Absorbing Phase
host_string = host_string + str(P[j][i*(2*r//8):(i+1)*(2*r//8)]+'00'*(c//8))
else:
#Dummy variables. Won't be used.
host_string = host_string + "0"*400
gpu_string = cl.Buffer(context, cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR, hostbuf=host_string)
gpu_table = cl.Buffer(context, cl.mem_flags.READ_WRITE, 25*8 * inputnum)
part_of_string = cl.LocalMemory(1*16)
program.convert_str_to_table(queue,global_size,local_size, gpu_string, gpu_table, part_of_string, np.uint64(5),np.uint64(5),np.uint64(64))
cl.enqueue_copy(queue, Pi, gpu_table, is_blocking=True)
for x in range(5*inputnum):
for y in range(5):
#print 'type S:',type(S[x][y]),'type P:',type(Pi[x][y])
if (iterations[int(x/5)] > i):
S[x][y] = S[x][y]^Pi[x][y]
S = np.array([np.uint64(x) for x in S])
#start = time.time()
S = KeccakF(S, iterations, i, program, context, queue)
#print ("Time to run KeccakF: " + str(time.time() - start))
#print (S)
#Squeezing phase
outputstring = np.chararray(400 * inputnum)
gpu_table = cl.Buffer(context, cl.mem_flags.READ_ONLY | cl.mem_flags.COPY_HOST_PTR, hostbuf=S)
gpu_string = cl.Buffer(context, cl.mem_flags.READ_WRITE, 144*8 * inputnum)
program.convert_table_to_str(queue,global_size,local_size,gpu_table, gpu_string,np.uint64(5),np.uint64(5),np.uint64(64))
cl.enqueue_copy(queue, outputstring, gpu_string, is_blocking=True)
string = ''.join(outputstring)
for x in range(inputnum):
Z[x] = Z[x] + string[400 * x: 400 * x + r*2//8]
for x in range(inputnum):
Z[x] = Z[x][0:2*n//8]
#output the pre-set number of bits
return Z
if __name__ == '__main__':
# List our platforms
platforms = cl.get_platforms()
# Create a context with all the devices
devices = platforms[0].get_devices()
context = cl.Context(devices[:2])
#print ('This context is associated with ', len(context.devices), 'devices')
# Create a queue for transferring data and launching computations.
# Turn on profiling to allow us to check event times.
queue = cl.CommandQueue(context, context.devices[0],
properties=cl.command_queue_properties.PROFILING_ENABLE)
#print ('The queue is using the device:', queue.device.name)
program = cl.Program(context, open('sha3.cl').read()).build(options='')
#PARAMETERS for SHA 512
r = 576
c = 1024
n = 512
inputlist = []
inputlist.append("")
inputlist.append("abcd")
inputlist.append("abcd")
inputlist.append("abcd")
inputlist.append("a" * 1000)
start = time.time()
result = Keccak(inputlist, n, r,c, program, context, queue)
print ("Hashing Result is")
print (result)
print ("Time taken is: " + str(time.time() - start))
this is functions from sha3
Try this.
The inputlist shall be converted to a bytearray.
result = sha3.Keccak(bytearray(inputlist), n, r,c, program, context, queue)

How can I code in python with a public and private key?

I am trying to code with public and private key. However I keep getting a error when I am trying to encrypt. this is what i have so far:
import random
Primes = [2,3,5,7,9,11,13,15]
p = random.choice(Primes)
q = random.choice(Primes)
n = p*q
z = (p-1)*(q-1)
deck = list(range(1,z))
e = random.choice(deck)
d = (z + 1)/e
a= divmod(d*e,z)
PublicKey = (e,n)
PrivateKey = (d,n)
input = raw_input ('Write text: ')
input = input.lower()
message = []
for character in input:
number = ord(character)
message.append(number)
#Encrypt
for character in message:
c = message**e % n
#Decrypt
for character in c:
decryption = c**d % n
The program is running fine until I get by the encryption part. The error I got is:
Traceback (most recent call last):
File "C:/Python27/rsa2.py", line 30, in <module>
c = message**e % n
TypeError: unsupported operand type(s) for ** or pow(): 'list' and 'int'

Traceback (most recent call last) & TypeError: unsupported operand type(s) for +: 'int' and 'str'

#!/usr/bin/python
import time
import random
import struct
import select
import socket
def chk(data):
x = sum(x << 8 if i % 2 else x for i, x in enumerate(data)) & 0xFFFFFFFF
x = (x >> 16) + (x & 0xFFFF)
x = (x >> 16) + (x & 0xFFFF)
return struct.pack('<H', ~x & 0xFFFF)
def ping(addr, timeout=1, number=1, data=b''):
conn = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_ICMP)
payload = struct.pack('!HH', random.randrange(0, 65536), number) + data
conn.connect((addr, 80))
conn.sendall(b'\x08\0' + chk(b'\x08\0\0\0' + payload) + payload)
start = time.time()
while select.select([conn], [], [], max(0, start + timeout - time.time()))[0]:
data = conn.recv(65536)
if len(data) < 20 or len(data) < struct.unpack_from('!xxH', data)[0]:
continue
if data[20:] == b'\0\0' + chk(b'\0\0\0\0' + payload) + payload:
return time.time() - start
if __name__ == '__main__':
target = raw_input("Please enter a IP Adress: ")
print(ping(target))
I have tried to script which works for creating packet and send to icmp packet. I got the error the result of the script is shown below:
# python Pinger.py
Please enter a IP Adress: 89.1.3.2
Traceback (most recent call last):
File "Pinger.py", line 35, in <module>
print(ping(target))
File "Pinger.py", line 22, in ping
conn.sendall(b'\x08\0' + chk(b'\x08\0\0\0' + payload) + payload)
File "Pinger.py", line 11, in chk
x = sum(x << 8 if i % 2 else x for i, x in enumerate(data)) & 0xFFFFFFFF
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Can you help m to resolve TypeError and Traceback?
checkout this !
data = b'\0\0\0\0'
list(enumerate(data))
>>> [(0, '\x00'), (1, '\x00'), (2, '\x00'), (3, '\x00')]
you missed here
x = sum(x << 8 if i % 2 else x for i, x in enumerate(data)) & 0xFFFFFFFF
^ << also raise TypeError ^ this is str
I guess, the reason of TypeError, function sum may use + operator.

RC4 decryption in python hexadecimal inputs

I have a program that successfully encrypts a piece of plain text information and outputs the encrypted data as hexadecimal. i can decrypt this data on http://www.fyneworks.com/encryption/rc4-encryption/index.asp by putting in the hex data i received from my program and the key i used (in plain text)
the next step i am trying to accomplish is to have two inputs where i can input an encrypted message in hex and the encryption key (also in hex).
i'm having trouble getting the decryption part of my program to work...
If i enter the key as password and the ciphertext as 8c905b7c294a94c30422d81d552e which successfully decrypts on the website above... it doesn't work.
anyone have any ideas how i can get decryption working in RC4 with hexadecimal inputs?
# Global variables
state = [None] * 256
p = q = None
def setKey(key):
##RC4 Key Scheduling Algorithm (KSA)
global p, q, state
state = [n for n in range(256)]
p = q = j = 0
for i in range(256):
if len(key) > 0:
j = (j + state[i] + key[i % len(key)]) % 256
else:
j = (j + state[i]) % 256
state[i], state[j] = state[j], state[i]
def byteGenerator():
##RC4 Pseudo-Random Generation Algorithm (PRGA)
global p, q, state
p = (p + 1) % 256
q = (q + state[p]) % 256
state[p], state[q] = state[q], state[p]
return state[(state[p] + state[q]) % 256]
def encrypt(key,inputString):
##Encrypt input string returning a byte list
setKey(string_to_list(key))
return [ord(p) ^ byteGenerator() for p in inputString]
def decrypt(inputByteList):
##Decrypt input byte list returning a string
return "".join([chr(c ^ byteGenerator()) for c in inputByteList])
def intToList(inputNumber):
##Convert a number into a byte list
inputString = "{:02x}".format(inputNumber)
return [int(inputString[i:i + 2], 16) for i in range(0, len(inputString), 2)]
def string_to_list(inputString):
##Convert a string into a byte list
return [ord(c) for c in inputString]
key = raw_input("Enter Key: ")
ciphertext = raw_input("enter ciphertext: ")
print decrypt(intToList(ciphertext))
Here is general idea of how encryption / decryption can be done using reference implementation of RC4 for python:
def KSA(key):
keylength = len(key)
S = range(256)
j = 0
for i in range(256):
j = (j + S[i] + key[i % keylength]) % 256
S[i], S[j] = S[j], S[i] # swap
return S
def PRGA(S):
i = 0
j = 0
while True:
i = (i + 1) % 256
j = (j + S[i]) % 256
S[i], S[j] = S[j], S[i] # swap
K = S[(S[i] + S[j]) % 256]
yield K
def RC4(key):
S = KSA(key)
return PRGA(S)
if __name__ == '__main__':
# ciphertext should be 9D5AB375EC
key = 'secret'
plaintext = 'plain'
def convert_key(s):
return [ord(c) for c in s]
key = convert_key(key)
keystream = RC4(key)
ciphertext = ''.join([("%02X" % (ord(c) ^ keystream.next())) for c in plaintext])
print ciphertext
keystream = RC4(key)
def convert_ct(s):
import binascii
return [ord(ch) for ch in binascii.unhexlify(s)]
ciphertext = convert_ct(ciphertext)
plaintext = ''.join([chr(c ^ keystream.next()) for c in ciphertext])
print plaintext
With your code base it can be done like so:
import binascii
# Global variables
state = [None] * 256
p = q = None
def setKey(key):
##RC4 Key Scheduling Algorithm (KSA)
global p, q, state
state = [n for n in range(256)]
p = q = j = 0
for i in range(256):
if len(key) > 0:
j = (j + state[i] + key[i % len(key)]) % 256
else:
j = (j + state[i]) % 256
state[i], state[j] = state[j], state[i]
def byteGenerator():
##RC4 Pseudo-Random Generation Algorithm (PRGA)
global p, q, state
p = (p + 1) % 256
q = (q + state[p]) % 256
state[p], state[q] = state[q], state[p]
return state[(state[p] + state[q]) % 256]
def encrypt(key, plaintext):
##Encrypt input string returning a byte list
pt = string_to_list(plaintext)
ct = rc4(key, pt)
return list_to_string(ct, hex=True)
def decrypt(key, ciphertext):
##Decrypt input byte list returning a string
ct = string_to_list(ciphertext, hex=True)
pt = rc4(key, ct)
return list_to_string(pt, hex=False)
def string_to_list(input_srt, hex=False):
##Convert a string into an int list
if hex:
res = [ord(ch) for ch in binascii.unhexlify(input_srt)]
else:
res = [ord(ch) for ch in input_srt]
return res
def list_to_string(lst, hex=True):
##Convert an int list into a string
if hex:
res = ''.join(["%0.2X" % el for el in lst])
else:
res = ''.join([chr(el) for el in lst])
return res
def rc4(key, ints):
"""Xor list of ints with output generated by RC4. Output list of ints"""
setKey(string_to_list(key))
return [x ^ byteGenerator() for x in ints]
# key = raw_input("Enter Key: ")
# ciphertext = raw_input("enter ciphertext: ")
key = 'secret'
plaintext = 'plain'
ciphertext = encrypt(key, plaintext)
print ciphertext
print decrypt(key, ciphertext)
Decryption and encryption are basically the same procedures

Python encryption and decryption

I trying to use a Python script to decrypt a message. I have the cipher text (noted as FLAG in code) and most of the Python code used for encryption. I need to find the original plaintext message. Below I am trying to build a decode function into my Python code but failing (novice to Python). Can any genius help?
Here's the code so far:
import string
import random
from base64 import b64encode, b64decode
FLAG = '313312Mw16RXtNmlF2TVRmU1pIQxxmnTxtV1ZWV2JFOXBSnFwkVTI5o1ZGWxpXmxZWTVZmM1RWWyFwnFZ4Y0ZCWFJYUwjWRxJPVvA1p1NXTxpvRUbUWxROQ1RGoEpXmlxOY0ZWmFbdZDRVMVx4V2fwV2NGWvNmm1bXZUU5VVJdNVpWRVbNVxRJqFIjUzpTnGjVY1tSWFRXODFTMWRVUVpKVE1VWxtWRlsjYxZKV1pgWxZNV2tYV1ZmT1pGm3bwRxZXVvJ4UFZYRvRvnWjXVGfeU2IjWyFUVyRTVEZem1NdpGjvVxbmVTI5p2IjWxZwRXRVVyjipxZGZFNSMVZ2ZEZOnE1gZlBWnTVDTUZNqFRgVy1SqwZVVWfWWxxeWzZuRTViVyjWmFaiVvBWnVZdUyejVw1HmFtWMFbXUy1VqyJGVxpmRxwkVy5CV1IkVzpUnGtUY1tSp1ZeZFNwVxV4YUpWVGJ6RvJUVxV4VwZKWVFeVxpSnFalVxRGVxbHZEZOVlVXY1ZKRVZYQxpwMVJ4U25eVGNFNVBWmwEiWVZmVVNfOVVvRTVZVy5CT2JVMUVSnFbYVwVmVFV6Rw9wMXBJY0ZOnVJUVxbWVlVCWW1WqFZeZFJuM2tXVFo4MU1GVXxNVTxfY0VmWxZYQxNmV2j3U2feVw1GWxtVqwbOWVpmRw5XMVtSnHBUVyfSQ1xVMUpUV1JfUvNSVVZfOWFWVyf5TxZwnFZUVxpmMFZ3V2eiqFpgWxZNVzBQVwtCn2RfWwtvRxZYUxtSTVYkOW9UMU53UyjmnVJFWzVmVEZtZDFWp1Zdp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jaQxxWZFtwRyRVVyjKWVUkNUpVMxb3V2jWWFZFm3ttWEJXZGjKpyVGTxpNRFYjV2jwNGQjTXpPVytYYvNaYVRVUwpNVzBHV2e5T1ZdNVbWVlw0VvAjSVVdpFtWnHB2VvFmS1ZWSzZTnTFfYzbWVxZURxpZVTFHVxpOYVNFWxVmVEbTV1ZiWGQkSxRNnEbZVGjSQ1ZeWxVSm3RmWwU1SFUlQw5ZVTFYY0ZSWFJWoE9WRxbWWW1ap1VdmFZWRxbUVFZaQ1MjWwpVnE'
enc_ciphers = ['rot13', 'b64e', 'caesar']
dec_ciphers = ['rot13', 'b64d', 'caesard']
def rot13(s):
_rot13 = string.maketrans(
"zyxwvutsrqponZYXWVUTSRQPONmlkjihgfedcbaMLKJIHGFEDCBA",
"mlkjihgfedcbaMLKJIHGFEDCBAzyxwvutsrqponZYXWVUTSRQPON")
return string.translate(s, _rot13)
def b64e(s):
return b64encode(s)
def b64d(s):
return b64decode(s)
def caesar(plaintext, shift=4):
alphabet = string.ascii_lowercase
shifted_alphabet = alphabet[shift:] + alphabet[:shift]
table = string.maketrans(alphabet, shifted_alphabet)
return plaintext.translate(table)
def caesard(plaintext, shift=-4):
alphabet = string.ascii_lowercase
shifted_alphabet = alphabet[shift:] + alphabet[:shift]
table = string.maketrans(alphabet, shifted_alphabet)
return plaintext.translate(table)
def encode(pt, cnt=50):
tmp = '2{}'.format(b64encode(pt)) #2.format(b64encode(pt))
for cnt in xrange(cnt):
c = random.choice(enc_ciphers) # choose some enc_cipher
i = enc_ciphers.index(c) + 1 # position in the array + 1
_tmp = globals()[c](tmp)
tmp = '{}{}'.format(i, _tmp)
return tmp
def decode(tmp, cnt=50):
for cnt in xrange(cnt):
i = int(tmp[:1])-1
_tmp = tmp[1:]
c = dec_ciphers[i]
tmp = globals()[c](_tmp)
try:
s = b64decode(tmp[1:])
if s.find("flag") != -1:
return s
except:
pass
return b64decode(tmp[1:])
if __name__ == '__main__':
cnt=70
print "Cnt: %d" % cnt
print decode(FLAG, cnt)
Here is the error message:
/usr/bin/python -u "/media/pc/A8560F93560F6204/Python investigation/transfer_csaw2015 fully MODDED2.py"
Cnt: 70
Traceback (most recent call last):
File "/media/pc/A8560F93560F6204/Python investigation/transfer_csaw2015 fully MODDED2.py", line 64, in <module>
print decode(FLAG, cnt)
File "/media/pc/A8560F93560F6204/Python investigation/transfer_csaw2015 fully MODDED2.py", line 47, in decode
i = int(tmp[:1])-1
ValueError: invalid literal for int() with base 10: 'W'

Categories

Resources