Advertisement
Sweetening

hidefilesinkeys.c

Jan 7th, 2025
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.83 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <windows.h>
  5.  
  6. #define MAX_PATH_LEN 260
  7. #define HIDDEN_FILE_PATH "C:\\Windows\\System32\\hidden_file.txt"
  8. #define KEYWAREZ_FILE "C:\\Windows\\System32\\keywarez.txt"
  9.  
  10. // Function to hide the file
  11. void hideFile(const char *filePath) {
  12.     if (MoveFileA(filePath, HIDDEN_FILE_PATH) == 0) {
  13.         printf("Error hiding file: %d\n", GetLastError());
  14.     } else {
  15.         printf("File %s is now hidden.\n", filePath);
  16.     }
  17. }
  18.  
  19. // Function to reveal the file
  20. void revealFile(const char *filePath) {
  21.     if (MoveFileA(HIDDEN_FILE_PATH, filePath) == 0) {
  22.         printf("Error revealing file: %d\n", GetLastError());
  23.     } else {
  24.         printf("File %s is now visible.\n", filePath);
  25.     }
  26. }
  27.  
  28. // Function to save the key mapping
  29. void saveKeyMapping(char key, const char *filePath) {
  30.     FILE *keyFile = fopen(KEYWAREZ_FILE, "a");
  31.     if (keyFile != NULL) {
  32.         fprintf(keyFile, "Key: %c, File: %s\n", key, filePath);
  33.         fclose(keyFile);
  34.         printf("Key mapping saved to %s.\n", KEYWAREZ_FILE);
  35.     } else {
  36.         printf("Error opening key mapping file for writing.\n");
  37.     }
  38. }
  39.  
  40. int main() {
  41.     char filePath[MAX_PATH_LEN];
  42.     char key;
  43.     int keyChoice;
  44.  
  45.     // Display the attribution for the script
  46.     printf("Made by Taylor Christian Newsome\n\n");
  47.  
  48.     // Get file path from user
  49.     printf("Enter the full path of the file you want to hide: ");
  50.     fgets(filePath, sizeof(filePath), stdin);
  51.     filePath[strcspn(filePath, "\n")] = 0; // Remove newline
  52.  
  53.     // Ask for key to hide the file
  54.     printf("Enter the key number (1-9) you want to use to hide/unhide the file: ");
  55.     scanf("%d", &keyChoice);
  56.     getchar();  // Consume the newline left by scanf
  57.  
  58.     // Map key choice to a character
  59.     switch (keyChoice) {
  60.         case 1: key = '1'; break;
  61.         case 2: key = '2'; break;
  62.         case 3: key = '3'; break;
  63.         case 4: key = '4'; break;
  64.         case 5: key = '5'; break;
  65.         case 6: key = '6'; break;
  66.         case 7: key = '7'; break;
  67.         case 8: key = '8'; break;
  68.         case 9: key = '9'; break;
  69.         default:
  70.             printf("Invalid choice. Using default key 'F1'.\n");
  71.             key = 'F1';  // Default key
  72.             break;
  73.     }
  74.  
  75.     // Hide the file
  76.     hideFile(filePath);
  77.  
  78.     // Save the key mapping
  79.     saveKeyMapping(key, filePath);
  80.  
  81.     // Listen for key press to reveal the file
  82.     printf("Press the assigned key '%c' to reveal the file...\n", key);
  83.     while (1) {
  84.         if (GetAsyncKeyState(key) & 0x8000) {  // Check if the key is pressed
  85.             printf("\nYou pressed the key '%c'. Revealing the file...\n", key);
  86.             revealFile(filePath);
  87.             break;
  88.         }
  89.         Sleep(100);  // Delay to prevent high CPU usage
  90.     }
  91.  
  92.     return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement