Results 1 to 6 of 6
  1. #1
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty

    TextCracker v.1.0

    Well I think I've done the the most I can do with XOR, and it's time to move on to other encryptions. On realizing how pitifully weak XOR encryption are I have decided to release the full source for my TextCracker as well as the executable. Its time to move on to more advanced encryptions....

    Full Source:
    [PHP]
    #include <iostream>
    #include <fstream>
    using namespace std;

    void start();
    void XOR_char_crack(char* str, bool brute);
    bool encrypt(char *src, char *dest, char k);
    bool filterStrings(unsigned char* str, int l);
    bool brute = true;
    int filter = 0;


    int main()
    {
    start();
    system("pause");
    return 0;
    }

    void start(){
    char filename1[50] = "";
    char filename2[50] = "";
    char key;
    char choice;
    char ch;
    cout << "Would you like to crack a text file?\n" << endl;
    cout << "q.) Quit\n";
    cout << "1.) XOR ASCII Crack\n";
    cout << "2.) Decrypt XOR ASCII with key\n";
    cout << "3.) XOR Encrypt your own file\n";
    cin >> choice;

    switch(choice){
    case 'q':
    break;

    case '1':
    system("cls");
    cout <<"Type the name of the file you want cracked: ";
    cin >> filename1;

    while(true)
    {
    cout <<"Try realistic keys? (keyboard characters) (y/n)\n";
    cin >> ch;
    if(ch == 'y' || ch =='Y'){brute = false; break;}
    if(ch =='n' || ch =='N'){brute = true; break;}
    else cout<<"Not a valid choice.\n";
    }

    for(bool exit = false; !exit; )
    {
    cout <<"Would you like to enable a filter? (y/n)";
    cin >> ch;

    switch(ch){
    case 'y':
    cout << "Select Filtration Level: \n";
    cout << "1. Filter extended ASCII characters\n";
    cout << "2. Target character strings only. (strings of letters)\n";
    cin >> filter;
    exit = true;
    cout<<"\nWARNING: These results have been filtered.\n\n";
    break;
    case 'n':
    filter = 0;
    exit = true;
    break;
    default:
    cout <<"Invalid option. Enter \'y\' for yes or \'n\' for no.\n";
    break;
    }
    }
    XOR_char_crack(filename1, brute);
    system("pause");
    system("cls");
    start();
    break;
    case '2':
    system("cls");
    cout <<"Type the name of the file you want the decrypter to read: ";
    cin >> filename1;
    cout <<"Type the name of the file you would like to send the decrypted message to: ";
    cin >> filename2;
    cout << "What key is the message encrypted with?" << endl;
    cin >> key;
    if(encrypt(filename1, filename2, key)) cout <<"File successfully decrypted.\n";
    else cout << "Decyprtion failed.\n";
    system("pause");
    system("cls");
    start();
    break;

    case '3':
    system("cls");
    cout <<"Type the name of the file you want the encrypter to read: ";
    cin >> filename1;
    cout <<"Type the name of the file you would like to send the encrypted message to: ";
    cin >> filename2;
    cout << "What key would you like to encrypt this message in?" << endl;
    cin >> key;
    if(encrypt(filename1,filename2, key))cout <<"File successfully encrypted.\n";
    else cout <<"Encryption failed.\n";
    system("pause");
    system("cls");
    start();
    break;

    default:
    system("cls");
    start();
    break;
    }
    }

    void XOR_char_crack(char* str, bool brute)
    {
    fstream file(str, ios::binary | ios::in | ios:ut);
    fstream dump("dump.txt", ios::in | ios:ut | ios::trunc);

    if(!file)
    {
    cout << "ERROR. Cannot open specified file. File must be in same directory as decryptor.\n";
    return;
    }
    if(!dump)
    {
    cout << "ERROR. Cannot open dump.txt file.\n";
    return;
    }

    char ch;
    unsigned char temp[20] = "";
    unsigned char k = 0;
    if(!brute)k=32;
    do
    {
    for(int i=0; str[i]; i++)
    {
    file.get(ch);
    temp[i] = (ch ^ k);
    }
    file.seekg(ios::beg);
    if(filter)
    {
    if(filterStrings(temp, filter))
    {
    dump << "Key of: " << k << " Produces: " << temp << endl << endl;
    cout << "Key of: " << k << " Produces: " << temp << endl << endl;
    }
    }
    k++;
    if(!brute && k> 126) break;
    }while(k != 0);

    return;
    }

    bool encrypt(char *src, char *dest, char k)
    {
    fstream ifile(src, ios::binary | ios::in | ios:ut);
    fstream efile(dest, ios::binary | ios::in | ios:ut | ios::trunc);
    unsigned char key = k;
    char ch;

    if(!ifile)
    {
    cout << "ERROR. Cannot open first file.\n";
    return 0;
    }
    if(!efile)
    {
    cout << "ERROR. Cannot open second file.\n";
    return 0;
    }
    cout << "Contents of file1:\n\n";
    while(ifile)
    {
    ifile.get(ch);
    if(ifile) cout << ch;
    efile.put(ch^key);
    }
    cout << endl << endl;
    cout << "The first file has been encrypted with a key of '" << key <<"' and saved to the second file.\n";
    cout << "Encrypted message: \n\n";
    efile.seekg(ios::beg);
    while(efile)
    {
    efile.get(ch);
    if(efile)cout << ch;
    }
    cout<< endl;
    ifile.close();
    efile.close();
    cout << endl;
    return 1;
    }

    bool filterStrings(unsigned char* str, int l)
    {
    int count = 0;
    if (l == 0) return true;
    else if (l == 1)
    {


    for(int i = 0; str[i]; i++)
    {
    if(str[i] >= 32 && str[i] <= 127)count++;
    else count = 0;
    if(count >= 3)return true;
    }
    }
    else
    {
    for(int i = 0; str[i]; i++)
    {
    if(str[i] >= 65 && str[i] <= 122)count++;
    else count = 0;
    if(count >= 3)return true;
    }
    }
    }

    [/PHP]
    Sorry I didn't comment my code.

    I guess you guys can play around with it if you want... I know you get hours of fun from typing into a console.... =/

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

  2. The Following 2 Users Say Thank You to why06 For This Useful Post:

    LegendaryAbbo (10-24-2009),mormaii2 (09-11-2012)

  3. #2
    bakycar's Avatar
    Join Date
    Aug 2009
    Gender
    female
    Posts
    200
    Reputation
    11
    Thanks
    70
    My Mood
    Angelic
    I'm sorry but what should this do? text Cracker for what? does it encrypt passwords? =P Sry idk what this should do! Teach me xD
    Press *Thanks* If I helped you in any way ^^

    [IMG]https://i587.photobucke*****m/albums/ss319/daniliard/Bakycar-request.jpg[/IMG]


  4. #3
    lalakijilp's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Posts
    310
    Reputation
    9
    Thanks
    53
    My Mood
    Blah
    Quote Originally Posted by bakycar View Post
    I'm sorry but what should this do? text Cracker for what? does it encrypt passwords? =P Sry idk what this should do! Teach me xD
    lol it is clearly in the visible in the code...

    Code:
    void start(){
        char filename1[50] = "";
        char filename2[50] = "";
        char key;
        char choice;
        char ch;
        cout << "Would you like to crack a text file?\n" << endl;
        cout << "q.) Quit\n";
        cout << "1.) XOR ASCII Crack\n";
        cout << "2.) Decrypt XOR ASCII with key\n";
        cout << "3.) XOR Encrypt your own file\n";
        cin >> choice;

  5. #4
    bakycar's Avatar
    Join Date
    Aug 2009
    Gender
    female
    Posts
    200
    Reputation
    11
    Thanks
    70
    My Mood
    Angelic
    Quote Originally Posted by lalakijilp View Post
    lol it is clearly in the visible in the code...

    Code:
    void start(){
        char filename1[50] = "";
        char filename2[50] = "";
        char key;
        char choice;
        char ch;
        cout << "Would you like to crack a text file?\n" << endl;
        cout << "q.) Quit\n";
        cout << "1.) XOR ASCII Crack\n";
        cout << "2.) Decrypt XOR ASCII with key\n";
        cout << "3.) XOR Encrypt your own file\n";
        cin >> choice;
    And what do you need to crack a .txt file for? I dont get it..
    Press *Thanks* If I helped you in any way ^^

    [IMG]https://i587.photobucke*****m/albums/ss319/daniliard/Bakycar-request.jpg[/IMG]


  6. #5
    lalakijilp's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Posts
    310
    Reputation
    9
    Thanks
    53
    My Mood
    Blah
    Quote Originally Posted by bakycar View Post
    And what do you need to crack a .txt file for? I dont get it..
    so that someone else can read except the ones that know ho to decode it in a normal message again.

    Cryptography - Wikipedia, the free encyclopedia

  7. #6
    why06's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    IBM
    Posts
    4,304
    Reputation
    170
    Thanks
    2,203
    My Mood
    Flirty
    Quote Originally Posted by bakycar View Post
    And what do you need to crack a .txt file for? I dont get it..
    Well if a text file was XOR encrypted with a key, this would help you find that key. It can also Encrypt any text file you want with a XOR encryption as well as Decrypt messages that people sent you encrypted with XOR. As for what you would want to do with it that is really up to you. Its really just there to learn by.

    I also added some filters that you can use to narrow down your results and added a common key search that will only try keys located on the keyboard... not that brute force really matters with XOR.... On my next ecryptor, which will use a rotation in conjunction with the XOR I will include a secondary filter that will examine possible matches more closely, maybe try to add a dictionary filter... and so on. Guess this will be like my little pet project, and will become more advanced as time goes on. I'm really just doing it because it keeps up my C++ skill while learning ASM.

    "Every gun that is made, every warship launched, every rocket fired signifies, in the final sense, a theft from those who hunger and are not fed, those who are cold and are not clothed. This world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children. The cost of one modern heavy bomber is this: a modern brick school in more than 30 cities. It is two electric power plants, each serving a town of 60,000 population. It is two fine, fully equipped hospitals. It is some fifty miles of concrete pavement. We pay for a single fighter plane with a half million bushels of wheat. We pay for a single destroyer with new homes that could have housed more than 8,000 people. This is, I repeat, the best way of life to be found on the road the world has been taking. This is not a way of life at all, in any true sense. Under the cloud of threatening war, it is humanity hanging from a cross of iron."
    - Dwight D. Eisenhower

Tags for this Thread