Posts Tagged ‘security’

Cryptographical Analysis Tool

Tuesday, November 24th, 2009

Hello  everyone.
Recently I have “Computer Communication and Security homework” to do. They consist of many problem involving encryption/decryption algorithm. One problem let you try to decipher all the text, it’s an english prose.

vcwpc kwblm smljy glbgu gbtwj jyats
lwsgm lwjjy vcrfc rikwl qjwte fscpw
lbgqm jwscb ktpbc pqats vfwsm dvwpw
lbsfc ktrfu wtlsc brpgk cmdqj wtefs
cpgle vfmjc ncmnj cq

After seeing this kind of problem, I thought to myself, I gonna break its code in no time. Ha ha ha, you know that up until now, I even don’t break it yet.

What I start to take the approach here is as follow.
1. Character/Word analysis
2. Algorithm analysis

Up until now, working on 2 days ago, I am at the first stage.
By trying to catch the pattern of the words that most frequently appear in the english literature such as ‘the’. And similar word that you should be fimilar with. Not quite close to target now, but along the process I have created a tool to analyze the encrypted text. Note that all of programs below will operate on only plaintext.
They are
- charCount, the program to report the frequency of english plaintext character, it can report in absolute value, relative value, or percentage
- patternCountN, the program to report about the pattern found in the encrypted text, the occurrence for each pattern must be at least 2 or above in order to treat that one as significant. Also we can specify the number of maximum number of individual pattern to find in such encrypted text too.
- simpleSwap, the program to swap the character as user defined via config file.
- caesar-d, the program to decrypt the caesar algorithm, it accepts ‘key’ as parameter in order to decrypt differently with each specify key (usually from 0-25)
- testCaesar, the wrapper program to execute caesar-d program to generate report for all 25 keys possible to decrypt.

All of those programs are created with DevC++ 4.9.9.2, under gcc compiler. I use combination of C/C++ to create.
They are tested primarily on Windows 7. But it requires much less modification of codewhen porting into Ubuntu.

When working with C/C++ language I feel the power of them, and the low level in which you must do almost all the task by yourself. So you should know just everything. In fact it can’t be true. But at least it can help us out to build the firm ground right?

I included all the sourcecode which you can look at, modify, and learn by yourself later without any license!

Each program also accepts some parameters too. Just look at the comment above in the sourcecode.
I point out to you below anyway.
- charCount
   charCount [-r, -p] <input file>
   -r, will generate the result in relative frequency
   -p, will generate the result in percentage
   <input file>, is the input text file

- patternCountN
   patternCountN <input file> <output file> <N>
   <input file>, is the input text file to find patterns
   <output file>, is the output file for report to be generated
   <N>, integer number defined the maximum number of character for individual word to be find in pattern

- simpleSwap
   simpleSwap <config file> <input file>
   <config file>, is the user’s config file defined for characters to be swapped
   <input file>, is the input text file

- caesar-d
   caesar-d <input file> <k>
   <input file>, is the input text file
   <k>, is the key used in the caesar decryption algorithm (possible is in range of 0-25)

- testCaesar
  
no parameter for this program.

Okay, I think you might want to have a hand on those tools already.
Please enjoy, and let me know if you like or dislike!!

Download Section
- charCount, sample of output file (copy from stdout)
- patternCountNsample of report file
- simpleSwap, sample of config file
- caesar-d, testCeasar
- sample of encrypted text file (cut out space)