Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am writing an application to do a brute force attack an AES ECB mode. The criteria it to write a function that can get

I am writing an application to do a brute force attack an AES ECB mode. The criteria it to write a function that can get all pemutations of length 4 from the english character set. It is only getting 4 digits since the rest of the string is already predetermined to save time.

The string that is calculated from the permutation needs to get merged with the remaining 12 characters and then get passed into the following function

#include "cryptopp/cryptlib.h"

#include "cryptopp/hex.h"

#include "cryptopp/filters.h"

#include "cryptopp/des.h"

#include "cryptopp/aes.h"

#include "cryptopp/modes.h"

using namespace CryptoPP;

string plain;

try{

ECB_Mode< AES >::Decryption dec;

dec.SetKey(key, AES::DEFAULT_KEYLENGTH);

StringSource s(cipher, true, new StreamTransformationFilter(dec, new StringSink(plain)));

}

catch(const CryptoPP::Exception& e){

}

return plain;

}

So far I have tryed the following code to get the permutations. It worked great in visual studio but fails to run on ubuntu.

include "stdafx.h"

#include

#include

#include

using namespace std;

void print_str(const char*, std::string, const int, const int);

int main()

{

int length = 4;

char str[] = { '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', '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' }; // , '!', '@', '#', '$', '%', '^', '&', '*', ' ', '(', ')', '-', '_', '+', '=', ',', '.', '?', '/', ';', ':', '"'

//};

int n = sizeof str;

print_str(str, "", n, length);

return 0;

}

void print_str(const char str[], std::string prefix, const int n, const int length)

{

if (length == 1)

{

for (int j = 0; j < n; j++)

std::cout << prefix + str[j] << std::endl;

// remove the line above and place code to call the decrypt function here

}

else

{

for (int i = 0; i < n; i++)

print_str(str, prefix + str[i], n, length - 1);

}

}

///////////////////////////////////////////////////////////////////////////////////////////

So I have tryed to come up with another way to create the permutations. However this is very innefficient as it creates every possible permutation of any length that can be made from the string and only displays the ones that are 4 characcters on screen.

#include

#include

using namespace std;

void get(string str, string res)

{

if (res.size() == 4)

cout << res << endl;

for (int i = 0; i < str.length(); i++)

get(string(str).erase(i, 1), res + str[i]);

}

int main(int argc, char **argv)

{

string str = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ`~!@#$%^&*()-_=+[{]}\;:',<.>/?";

//string str = "abc .'";

get(str,"")

return 0;

}

How can I efficiently create the permuations on ubuntu so that I can use the permutation to call the decrypt function to decypt a file on the machine encryptedtext.txt?

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

Understand why empowerment is so important in many frontline jobs.

Answered: 1 week ago