CsdecryptBeacon

Last updated on 2 years ago

CS beacon资源解密

原文 https://xz.aliyun.com/t/9224

解压 CS 核心文件 cobaltstrike.jar 提内容:

1
2
3
4
mkdir -p CSDecrypt/src
unzip CobaltStrike4.1/cobaltstrike.jar -d CSDecrypt/src
cd CSDecrypt/src
touch Csdecrypt.java

解密脚本 Csdecrypt.java 代码:

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
// Chang Author: kali
import common.SleevedResource;

import java.io.*;

public class Csdecrypt {
public static void saveFile(String filename, byte[] data) throws Exception {
if (data != null) {
String filepath = filename;
File file = new File(filepath);
if (file.exists()) {
file.delete();
}
FileOutputStream fos = new FileOutputStream(file);
fos.write(data, 0, data.length);
fos.flush();
fos.close();
}
}

public static byte[] toByteArray(File f) throws IOException {
ByteArrayOutputStream bos = new ByteArrayOutputStream((int) f.length());
BufferedInputStream in = null;
try {
in = new BufferedInputStream(new FileInputStream(f));
int buf_size = 1024;
byte[] buffer = new byte[buf_size];
int len = 0;
while (-1 != (len = in.read(buffer, 0, buf_size))) {
bos.write(buffer, 0, len);
}
return bos.toByteArray();
} catch (IOException e) {
e.printStackTrace();
throw e;
} finally {
try {
in.close();
} catch (IOException e) {
e.printStackTrace();
}
bos.close();
}
}

public static void main(String[] var0) throws Exception {
byte[] csdecrypt = new byte[]{1, -55, -61, 127, 102, 0, 0, 0, 100, 1, 0, 27, -27, -66, 82, -58, 37, 92, 51, 85, -114, -118, 28, -74, 103, -53, 6};

SleevedResource.Setup(csdecrypt);
byte[] var7 = null;
File file = new File("/home/kali/Desktop/CSDecrypt/src/sleeve");
File[] fs = file.listFiles();

for (File ff : fs) {
if (!ff.isDirectory())
var7 = SleevedResource.readResource(ff.getPath());
saveFile("/home/kali/Desktop/CSDecrypt/src/sleevedecrypt/" + ff.getName(), var7);
System.out.println("解密成功: " + ff.getName());
}
}
}

Javac 编译然后执行 .class 文件开始解密资源:

1
2
javac Csdecrypt.java
java Csdecrypt

(o゜▽゜)o☆[BINGO!]


CsdecryptBeacon
https://guosec.online/posts/a53b1765.html
Posted on
March 27, 2021
Updated on
February 24, 2022
Licensed under
本博客所有文章除特别声明外,均采用  协议,转载请注明出处!