Ufe'k wfixvk kf uizeb pfli Fmrckzev.

It's Afternoon, around 12:19 and I just finished a program I was thinking from quite a long time to implement, but didn't get time to do so. This is basically based on an idea I had to get the DeCiphered messages even if I don't know the Secret Key to it. So, that I could make use of the vulnerability in the CC.
I also just used it to get the DeCiphered Text of a blog I had written earlier and I did this without providing any key to it, and it works fine, atleast it did in my sample cases. 
Let's see if you can DeCipher the Title of this blog... if you did, then Kudos to you, now you know what to do 😂.
I would just say that CC is full of Vulnerabilities ;)
Below is the code that I have just written--
#include<bits/stdc++.h>
using namespace std;
/*
Himesh Singh Chauhan
Date: 16:02:2023
*/
void cipher(){
    /* Will take an input and Cipher it using the key
     * provided by the User
     */
    vector<string> vect;
    int key;
    cout<<"Enter the text for Cipher:- ";
    for(int i=0;i<10000;i++){
        string inp;
        cin>>inp;
        if(inp=="xyz"){
            break;
        }
        vect.push_back(inp);
    }
    cout<<"Enter the key that you want to use to Cipher this message: ";
    cin>>key;
    key=key%26;
    cout<<"\nDon't forget this key, you will require this to Decipher your "
    "message in the future :)\n";
    int size=vect.size();
    // Now the Cipher Part
    for(int i=0;i<size;i++){
        string current=vect[i];
        int curr_size=current.size();
        for(int j=0;j<curr_size;j++){
           
            // For Capital Letters
            if(current[j]>='A' && current[j]<='Z'){
                int letter=current[j]-'A';
                vect[i][j]=((letter+key)%26)+'A';
            }
            // For Small Letters
            else if(current[j]>='a' && current[j]<='z'){
                int letter=current[j]-'a';
                vect[i][j]=((letter+key)%26)+'a';
            }
        }
    }
    cout<<"Cipher Complete! Your Ciphered text is:-\n";
    for(string st:vect){
        cout<<st<<" ";
    }
    cout<<endl;
}
void decipher(){
    /* Will take an input and DeCipher it using the key
     * provided by the User
     */
    vector<string> vect;
    int key;
    /* Taking Input */
    cout<<"Enter the text for DeCipher:- ";
    for(int i=0;i<10000;i++){
        string inp;
        cin>>inp;
        if(inp=="xyz"){
            break;
        }
        vect.push_back(inp);
    }
    cout<<"Enter the key that you had used to Cipher this message: ";
    cin>>key;
    key=key%26;
    key=26-key;
    int size=vect.size();
    // Now the Cipher Part
    for(int i=0;i<size;i++){
        string current=vect[i];
        int curr_size=current.size();
        for(int j=0;j<curr_size;j++){
           
            // For Capital Letters
            if(current[j]>='A' && current[j]<='Z'){
                int letter=current[j]-'A';
                vect[i][j]=((letter+key)%26)+'A';
            }
            // For Small Letters
            else if(current[j]>='a' && current[j]<='z'){
                int letter=current[j]-'a';
                vect[i][j]=((letter+key)%26)+'a';
            }
        }
    }
    cout<<"DeCipher Complete! Your DeCiphered text is:-\n";
    for(string st:vect){
        cout<<st<<" ";
    }
    cout<<endl;
}
// Overloaded DeCipher Function which will take an input text and a key as
// arguments to DeCipher the text
void decipher(vector<string> vect,int key){
    /* Will take an input Text and DeCipher it using the key
     * provided by the User
     */
    key=26-key;
    int size=vect.size();
    // Now the Cipher Part
    for(int i=0;i<size;i++){
        string current=vect[i];
        int curr_size=current.size();
        for(int j=0;j<curr_size;j++){
           
            // For Capital Letters
            if(current[j]>='A' && current[j]<='Z'){
                int letter=current[j]-'A';
                vect[i][j]=((letter+key)%26)+'A';
            }
            // For Small Letters
            else if(current[j]>='a' && current[j]<='z'){
                int letter=current[j]-'a';
                vect[i][j]=((letter+key)%26)+'a';
            }
        }
    }
    // cout<<"DeCipher Complete! Your DeCiphered text is:-\n";
    for(string st:vect){
        cout<<st<<" ";
    }
    cout<<endl<<endl;
}
void autoDecipher(){
    /* Will take a string and automatically provide the
       Deciphered message without requiring the Key to it
     */
     /*
    Uses Brute Force Approach to get the Deciphered Text
     */
    vector<string> vect;
    int key;
    /* Taking Input */
    cout<<"Enter the text for DeCipher:- ";
    for(int i=0;i<10000;i++){
        string inp;
        cin>>inp;
        if(inp=="xyz"){
            break;
        }
        vect.push_back(inp);
    }
    // Now will generate all the possible DeCiphered Texts
    for(int i=1;i<26;i++){
        decipher(vect,i);
    }
}
int main() {
    /*
    Sample Text:-
    Text: Qefp fp x Pbzobq Jbppxdb!
    Key: 23
     */
    return 0;
}

Comments

Popular Posts