# Carrying out a known-plaintext attack on a cipher [closed]

Previously posted here. Someone suggested I could post it here to get some answers.

I am trying to solve a CTF challenge, here. Basically we're given message and key inputs to a cipher and its resulting ciphertext. We're then given a encrypted message we have to decrypt.

I started trying to reverse engineer the algorithm's structure (around what operators its based on, very vaguely)

Input output pairs:

'1', 1 = 2^0
'VKMAP VAcD4', 5 = 54306932426718011115164597401855430^1 247446999007947711814704977^4
'0', 1 = 29^0
'3', 1 = 5^0
'2', 1 = 3^0
'q', 1 = 31^0
'9', 1  = 23^0
'abcd', 13 = 11575382871136615104^11
'e', 1 = 41^0
'W', 1 = 163^0
'VAcD4' 22 = 56237954319988116321523858^13
'Q', 1 = 157^0
'HJ', 13 = 1067796^11
'w', 1 = 37^0
'r' 1 = 43^0
'n' 1 = 149^0
'V' 1 = 277^0
'M' 1 = 293^0
'm' 1 = 151^0
'V' 45 = 6^7
'V' 5 = 55^2
'abcd' 1 = 150479977324775996363^0
'N' 1 = 283^0
'abcd' 1 = 150479977324775996363^0
'V' 13 = 21^4
'R' 1 = 173^0
'E' 1 = 167^0


The string is the message (in single quotes), the second input is the key (an integer always < 12000) the output is the ciphertext.

Interesting things I found:

• Every output with ^0 is a prime number. 173, 167, 283 ...
• Longer the string bigger is the base. (base^exponent)
• The exponent is always smaller than the key and its always 0 if the key is 1. Hints on the use of a mod here?
• The greater the key, smaller is the base in the output.

I have spent around 2-3 hours on this trying to find patterns. How do I go about solving this from here?

## closed as off-topic by yyyyyyy, SEJPM♦, e-sushiOct 22 '15 at 1:36

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "Requests for analyzing or deciphering a block of data are off-topic here, as the results are rarely useful to anyone else." – yyyyyyy, SEJPM, e-sushi
If this question can be reworded to fit the rules in the help center, please edit the question.

• Tada! Hopefully this will fix your problems xD pastebin.com/7e3TiMRk – user28532 Oct 21 '15 at 23:54