Advertisement
ponyboy837

testobfuscation

Apr 14th, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.07 KB | None | 0 0
  1. #include <iostream>
  2. #include <iterator>
  3. #include <string.h>
  4.  
  5. /*
  6. ---------------------------------------------------------------------
  7. Base Creator: ???? (If you find who did make the base I improved upon
  8.                     let me know!)
  9. ---------------------------------------------------------------------
  10. Creator: TheClashingFritz
  11. ---------------------------------------------------------------------
  12.  
  13. This is my test obfuscation program.
  14. Ideally i'd also include some AES in here but
  15. this is meant to be executable on http://ideone.com.
  16. Check it out if you want. It's a pretty cool site.
  17. */
  18.  
  19.  
  20. using namespace std;
  21.  
  22. void gen_random(char *s, const int len) {
  23.      for (int i = 0; i < len; ++i) {
  24.          int randomChar = rand()%(26+26+10);
  25.          if (randomChar < 26) {
  26.              s[i] = 'a' + randomChar;
  27.          } else if (randomChar < 26+26) {
  28.              s[i] = 'A' + randomChar - 26;
  29.          } else {
  30.              s[i] = '0' + randomChar - 26 - 26;
  31.          }
  32.      }
  33.      s[len] = 0;
  34.  }
  35.  
  36. int main() {
  37.     // The first 2 real key chunks with the other fake 2 attached to the end.
  38.     string keyChunks[4] = {"EKdhtXMmr18n2", "8eMlGn7CPKsht", "1zjuSa7tcY8PB", "NdmKxIvFGNG6L"};
  39.    
  40.     //Create our first part from the real chunks.
  41.     string keyPart1 = *new string(keyChunks[0]) + *new string(keyChunks[1]);
  42.    
  43.     //The last 2 key chunks with the fakes attached before them.
  44.     keyChunks[0] = "5HDUmxiXiknwz";
  45.     keyChunks[1] = "fncXGg4NB8fOJ";
  46.     keyChunks[2] = "aKbhtZn718n2h";
  47.     keyChunks[3] = "ZMnMlGn7C18nL";
  48.    
  49.     //Create our second part from the real chunks.
  50.     string keyPart2 = *new string(keyChunks[2]) + *new string(keyChunks[3]);
  51.    
  52.     //Create our actual key!.
  53.     string originalKey = *new string(keyPart1) + *new string(keyPart2);
  54.    
  55.     //Clean the key parts.
  56.     keyPart1 = "TENFl8Zqu6k7QVrZALs7zJ9CNMYdN01t8xAOjGcdnrUQIryv";
  57.     keyPart2 = "vhaMT0RPqShJy9q12nWXCz1QPFuHDaElmpAsM82jCT7Bx0ZV";
  58.    
  59.     char *keyArray = new char[originalKey.length()];
  60.     memcpy(keyArray, originalKey.c_str(), originalKey.length());
  61.     int size = *new int(originalKey.length());
  62.    
  63.     //Clean the original key.
  64.     originalKey = "UfZNKqWi16jze4pFYEPqykkL9LTYeWaSYwUZWoPNMEkZpJiK";
  65.  
  66.     //Time to do some cleanup!
  67.     string FillerText = "NULL";
  68.     keyChunks[0] = *new string(FillerText);
  69.     keyChunks[1] = *new string(FillerText);
  70.     keyChunks[2] = *new string(FillerText);
  71.     keyChunks[3] = *new string(FillerText);
  72.  
  73.     //Back to obfuscating then solving the key we go!
  74.     char *key1 = new char[size];
  75.     char *key2 = new char[size];
  76.     char *resultKey = new char[size];
  77.  
  78.     gen_random(key1, size);
  79.  
  80.     for (int temp = 0; temp < size; temp++){
  81.         key2[temp] = keyArray[temp] ^ key1[temp];
  82.     }
  83.  
  84.     for (int temp = 0; temp < size; temp++){
  85.         resultKey[temp] = key1[temp] ^ key2[temp];
  86.     }
  87.    
  88.     //This overwrites the Key Array then we free the overwritten memory with delete[]. (Because it's an array!)
  89.     for (int temp = 0; temp < size; temp++){
  90.         keyArray[temp] = 'n';
  91.     }
  92.     delete[] keyArray;
  93.    
  94.     //Output our results!
  95.     cout<<"Key1 Values\n";
  96.     for (int temp = 0; temp < size; temp++){
  97.         cout << key1[temp];
  98.     }
  99.     cout<<"\n\nKey2 Values\n";
  100.     for (int temp = 0; temp < size; temp++){
  101.         cout <<  key2[temp];
  102.     }
  103.     cout<<"\n\nResult Values\n";
  104.     for (int temp = 0; temp < size; temp++){
  105.         cout << resultKey[temp];
  106.     }
  107.  
  108.     // Now let's cleanup our result arrays!
  109.    
  110.     //Techinally key1 and key2 could be ANY size however we'll clean
  111.     //the key size just in case.
  112.     for (int temp = 0; temp < size; temp++){
  113.         key1[temp] = 'n';
  114.     }
  115.     delete[] key1;
  116.    
  117.     for (int temp = 0; temp < size; temp++){
  118.         key2[temp] = 'n';
  119.     }
  120.     delete[] key2;
  121.    
  122.     //This is the one that matters most when cleaning. It's the actual result!
  123.     for (int temp = 0; temp < size; temp++){
  124.         resultKey[temp] = 'n';
  125.     }
  126.     delete[] resultKey;
  127.    
  128.     //Set the size just so people won't know the size from memory if viewed from when after we're finished.
  129.     size = 0;
  130.    
  131.     return 0;
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement