🔎DFIR Cơ Bản Và Thực Tế
Chơi cho vui thì làm thì khác
Book này dành cho CTFer Forensic đến từ Việt Nam

Giới thiệu
Blog này được viết để dễ tiếp cận với những người chơi CTF forensic mới và được thiết kế để phục vụ như một tài liệu tham khảo tương tự như hướng dẫn hacktricks (TRICK LỎ). Hy vọng sẽ hữu ích cho những người không có kinh nghiệm muốn bắt đầu và cho những người có kinh nghiệm cần một tài liệu tham khảo nhanh.
DFIR
Khi hoàn thành các CTF DFIR, việc hiểu câu chuyện mà bằng chứng đang kể là rất quan trọng. Là một nhà phân tích forensic, bạn cần ghép lại ai, cái gì, ở đâu, khi nào và như thế nào của một cuộc tấn công. Một file packet capture (pcap) có thể tiết lộ rất nhiều về một cuộc tấn công, chẳng hạn như một địa chỉ IP đang cố gắng brute force một trang web. Khi kẻ tấn công cuối cùng có được quyền truy cập, đây là một phần quan trọng của câu đố, và nó cũng có thể là nơi có flag. Do đó, việc ghi chú chi tiết để tái tạo timeline của các sự kiện quan trọng là rất cần thiết.
Filtering. Một chủ đề phổ biến ở đây là có quá nhiều dữ liệu. Không khả thi khi xem qua logs hoặc pcap một cách thủ công. Thay vì nghĩ rằng tôi sẽ làm một việc gì đó để tìm flag như tìm kim trong đống cỏ khô, hãy nghĩ "tôi sẽ loại bỏ một loạt những thứ vô dụng".
Cấu trúc của tài liệu này được phân chia theo loại bằng chứng thường được đưa ra.
Những Ý tưởng Cơ bản Sẽ Gặp phải
Mẹo chung. Hầu hết các thử thách ở mức độ trung bình trở lên đều yêu cầu người chơi tạo một script python.
Decoding+Decryption
Cyberchef
Hữu ích cho hầu hết việc decode
https://gchq.github.io/CyberChef/
https://github.com/mattnotmax/cyberchef-recipes#
Dcode
dCode.fr là một bộ sưu tập hơn 900 công cụ để giúp giải các trò chơi, câu đố, mật mã, toán học, puzzle, v.v. https://www.dcode.fr/en
Decoding
Decoding là quá trình chuyển đổi dữ liệu đã được mã hóa thành định dạng có thể đọc được. Encoding là một kỹ thuật được sử dụng để biểu diễn dữ liệu ở một định dạng cụ thể, thường để tiết kiệm không gian hoặc đảm bảo tính toàn vẹn của dữ liệu. Decoding được sử dụng để phân tích dữ liệu nhị phân hoặc trích xuất dữ liệu từ các định dạng file không được hỗ trợ nguyên bản bởi các công cụ forensic.
Base64 decoding: Base64 là một kỹ thuật encoding thường được sử dụng để chuyển đổi dữ liệu nhị phân thành các ký tự ASCII để làm cho nó dễ đọc và dễ vận chuyển hơn. Các nhà phân tích forensic thường gặp dữ liệu được mã hóa Base64 trong tệp đính kèm email hoặc lưu lượng web. Decode Base64 bao gồm việc chuyển đổi dữ liệu đã mã hóa trở lại định dạng nhị phân gốc.
URL decoding: URL thường chứa các ký tự đặc biệt, chẳng hạn như %20 (đại diện cho dấu cách), được mã hóa để làm cho chúng an toàn khi truyền qua internet. Các nhà phân tích forensic có thể gặp URL đã mã hóa trong lịch sử trình duyệt web hoặc lưu lượng mạng. URL decoding bao gồm việc chuyển đổi các ký tự đã mã hóa trở lại dạng gốc.
Unicode decoding: Unicode là một tiêu chuẩn để mã hóa văn bản trong các hệ thống viết khác nhau, chẳng hạn như tiếng Trung, tiếng Ả Rập và tiếng Cyrillic. Các nhà phân tích forensic có thể gặp văn bản được mã hóa Unicode trong email, tài liệu hoặc tin nhắn chat. Decode Unicode bao gồm việc chuyển đổi văn bản đã mã hóa trở lại dạng gốc.
Ví dụ, chuỗi '[email protected]' có thể được encode theo 5 cách sau:
Base64: "aGVsbG9Ad29ybGQuY29t"
URL Encoding: "hello%40world.com"
Hexadecimal Encoding: "68656c6c6f40776f726c642e636f6d"
ASCII Encoding: "104 101 108 108 111 64 119 111 114 108 100 46 99 111 109"
Unicode Encoding: "\u0068\u0065\u006c\u006c\u006f\u0040\u0077\u006f\u0072\u006c\u0064\u002e\u0063\u006f\u006d"
Để decode trong linux

Nhị phân sang thập phân
Hex sang thập phân
Decryption
Encryption là một ý tưởng thấm nhuần tất cả các lĩnh vực của digital forensics và incident response (DFIR), từ phân loại sự cố đến phân tích malware và network forensics. Trong thế giới ngày nay, encryption được sử dụng rộng rãi để bảo vệ thông tin nhạy cảm, và nó thường được gặp trong bằng chứng số. Do đó, hiểu biết về encryption là cần thiết cho bất kỳ người thực hành DFIR nào. Encryption có thể được sử dụng để bảo vệ dữ liệu khi nghỉ, dữ liệu đang truyền, hoặc cả hai, và có thể được triển khai theo nhiều cách khác nhau, từ mã hóa các file riêng lẻ đến mã hóa toàn bộ disk của một hệ thống máy tính. Ngoài ra, encryption có thể được gặp trong nhiều ngữ cảnh khác nhau, chẳng hạn như các giao thức truyền thông, giao tiếp malware, hoặc mã hóa các file được lưu trữ trong cloud.
Encryption có thể đặt ra những thách thức đáng kể cho các cuộc điều tra DFIR, vì nó có thể ngăn cản các nhà điều tra truy cập hoặc hiểu dữ liệu được bảo vệ. Trong một số trường hợp, encryption có thể được sử dụng bởi các tác nhân độc hại để ẩn hoạt động của họ hoặc lấy cắp dữ liệu từ mạng mà không bị phát hiện. Do đó, hiểu biết về encryption là cần thiết để xác định và phân tích dữ liệu đã mã hóa, cũng như để xác định các kỹ thuật phù hợp để phục hồi hoặc vượt qua nó.
Hơn nữa, encryption cũng có thể được gặp trong các artifacts forensic như logs, memory dumps và registry entries. Các artifacts này có thể chứa dữ liệu đã mã hóa có thể cung cấp những hiểu biết có giá trị về một sự cố hoặc cuộc điều tra, và việc giải mã dữ liệu này có thể rất quan trọng để hiểu phạm vi đầy đủ của một sự cố.
Tóm lại, hiểu biết về encryption và các trường hợp sử dụng của nó là cần thiết cho bất kỳ người thực hành DFIR nào. Encryption có thể đặt ra những thách thức đáng kể cho các cuộc điều tra, nhưng nó cũng có thể cung cấp những hiểu biết có giá trị về một sự cố hoặc cuộc điều tra. Do đó, các người thực hành DFIR nên quen thuộc với những kiến thức cơ bản về encryption và các công cụ và kỹ thuật encryption phổ biến được sử dụng trong các cuộc điều tra số.
symmetric vs asymmetric
Symmetric - Sử dụng một key (giống nhau) cho cả encryption và decryption.
ASymmetric - Một key cho encryption, key khác cho decryption.
Các loại phổ biến
AES (Advanced Encryption Standard): Đây là một thuật toán symmetric encryption được sử dụng rộng rãi để mã hóa dữ liệu. Nó sử dụng block ciphers với kích thước key là 128, 192, hoặc 256 bits.
RSA: Đây là một thuật toán asymmetric encryption được sử dụng rộng rãi để bảo mật việc truyền dữ liệu qua internet. Nó sử dụng một cặp key công khai-riêng tư để mã hóa và giải mã dữ liệu.
DES (Data Encryption Standard): Đây là một thuật toán symmetric encryption sử dụng block ciphers với kích thước key là 56 bits. Nó không được coi là an toàn cho các ứng dụng hiện đại.
Triple DES (3DES): Đây là một thuật toán symmetric encryption sử dụng DES với ba key được áp dụng theo trình tự. Nó cung cấp mức độ bảo mật cao hơn DES.
Blowfish: Đây là một thuật toán symmetric encryption sử dụng block ciphers với kích thước key biến đổi lên đến 448 bits. Nó được sử dụng rộng rãi để mã hóa file.
Twofish: Đây là một thuật toán symmetric encryption sử dụng block ciphers với kích thước key là 128, 192, hoặc 256 bits. Nó được thiết kế để nhanh hơn và an toàn hơn AES.
ChaCha20: Đây là một thuật toán symmetric encryption được thiết kế để nhanh và an toàn. Nó sử dụng key 256-bit và có thể được sử dụng để mã hóa dữ liệu, hash mật khẩu và các ứng dụng khác.
XOR
XOR (exclusive OR) là một phép toán cơ bản được sử dụng trong cryptography và làm rối dữ liệu.
Các điểm chính
Binary Operation: XOR hoạt động trên các biểu diễn nhị phân của mã số cho các ký tự.
Reversibility: XOR ciphertext với cùng key sẽ đảo ngược phép toán, tiết lộ plaintext gốc.
Encryption của chữ cái: Quá trình giống nhau cho bất kỳ ký tự nào; điều quan trọng là biểu diễn nhị phân của các ký tự đó và key.
Ví dụ
Giả sử chúng ta muốn mã hóa chữ cái A bằng key K. Trong ASCII:
A được biểu diễn bằng số 65.
K được biểu diễn bằng số 75.
Các biểu diễn nhị phân là:
A = 65 = 01000001 trong nhị phân.
K = 75 = 01001011 trong nhị phân.
Mã hóa A với key (K)
01000001 (A)
⊕ 01001011 (K)
-----------
00001010 (Result)
Giải mã A đã mã hóa với key (K)
00001010 (A đã mã hóa/Kết quả)
⊕ 01001011 (K)
-----------
01000001 (A)
Cyberchef example
AES
Thường thì các tin nhắn AES sẽ có 16 byte đầu tiên của tin nhắn chứa IV.
OpenSSL
OpenSSL là một thư viện phần mềm mã nguồn mở cung cấp các hàm mật mã và công cụ cho nhiều ứng dụng khác nhau. Nó bao gồm một số công cụ command-line có thể được sử dụng cho các tác vụ như tạo cặp key, tạo certificate và mã hóa dữ liệu.
Các lệnh OpenSSL phổ biến
OpenSSL bao gồm nhiều công cụ command-line, một số trong đó thường được sử dụng trong các cuộc điều tra DFIR. Dưới đây là một số lệnh OpenSSL được sử dụng phổ biến nhất và cú pháp của chúng:
openssl genpkey: tạo private key
openssl req: tạo certificate signing request (CSR)
openssl x509: quản lý SSL/TLS certificates
openssl enc: mã hóa và giải mã files
openssl dgst: tính toán message digests (hashes) của files
Các trường hợp sử dụng OpenSSL phổ biến
OpenSSL có thể được sử dụng cho nhiều tác vụ khác nhau, bao gồm tạo SSL/TLS certificates, mã hóa files và dữ liệu, và tạo chữ ký số.
Ví dụ: Giải mã một File
Để giải mã một file được mã hóa bằng AES-256 hoặc DES3 encryption sử dụng OpenSSL, sử dụng các lệnh sau:
Đối với AES-256 encryption:
openssl aes256 -d -salt -in [encrypted file] -out [decrypted file] -k [password]
Ví dụ, để giải mã một file có tên flag.txt.enc sử dụng password unbreakablepassword1234567, bạn sẽ sử dụng lệnh sau:
openssl aes256 -d -salt -in flag.txt.enc -out flag -k unbreakablepassword1234567
Đối với DES3 encryption:
openssl des3 -d -salt -in [encrypted file] -out [decrypted file] -k [password]
Ví dụ, để giải mã một file có tên file.des3 sử dụng password supersecretpassword123, bạn sẽ sử dụng lệnh sau:
openssl des3 -d -salt -in file.des3 -out file.txt -k supersecretpassword123
TrueCrypt
TrueCrypt là một phần mềm mã hóa disk phổ biến có thể mã hóa toàn bộ ổ đĩa, các phân vùng, hoặc tạo một disk ảo được mã hóa trong một file. Đã ngừng phát triển vào năm 2014, VeraCrypt hiện tại là phương án thay thế. Vẫn thỉnh thoảng được thấy như bằng chứng forensic với phần mở rộng .tc.
Volatility 2 có thể lấy password nếu được cache.
Có thể mount
PCAPS (.pcap)
Giới thiệu
Pcaps là viết tắt của packet capture và chúng là các sự kiện (hoặc một log của các sự kiện) về những gì đã xảy ra trên mạng hoặc 'qua dây'. Đối với người mới bắt đầu, chúng có thể được khái niệm hóa tốt nhất như logs tin nhắn văn bản.
Người gửi | Người nhận | Thời gian | Tin nhắn
Bob -> Alice - 5:00pm - Hi
Alice -> Bob - 5:01pm - oh-hey.jpeg
Bob -> Alice - 5:02pm - What you doing tomorrow?
Charles -> Bob - 5:03pm - Dont text my girlfriend!
Pcaps là artifact DFIR được gặp nhiều nhất trong các thử thách. Vấn đề/thách thức với pcaps là chúng có thể chứa hàng trăm nghìn packet. Không thực tế khi xem log từng packet một, do đó quy trình làm việc điển hình sẽ là sử dụng một cái gì đó như zeek để tìm điều gì đó thú vị và điều tra thủ công packet đó sâu hơn trong wireshark.
2 Hương vị của Thử thách
Có 2 hương vị của pcaps và 4-5 loại thử thách khác nhau về kỹ năng.
Hương vị đầu tiên và được thấy nhiều nhất là một network capture điển hình. Đây là những capture lớn với flag được ẩn trong một packet duy nhất có thể chứa html traffic. Điều này thường có thể được nghĩ như việc tìm kim trong đống cỏ khô.
Hương vị thứ hai là khi mọi packet sẽ được cần đến. Điều này có thể được thấy trong một cái gì đó như usb logger và gần như ngay lập tức là một vấn đề encoding hoặc encryption.
Các Khái niệm Mạng Cơ bản
Ports
Trong mạng máy tính, một port là một điểm cuối giao tiếp được sử dụng để xác định một process hoặc service cụ thể đang chạy trên một thiết bị mạng. Ports được xác định bằng một số từ 0 đến 65535, với 1024 đầu tiên được dành riêng cho các services và protocols nổi tiếng.
Khi dữ liệu được truyền qua mạng, nó được gửi đến một số port cụ thể trên một thiết bị, điều này cho phép hệ điều hành xác định process hoặc service nào sẽ nhận dữ liệu. Ví dụ, khi bạn duyệt web, trình duyệt web của bạn gửi yêu cầu đến port 80 (hoặc 443 cho HTTPS) trên server lưu trữ trang web bạn đang truy cập. Server sau đó gửi dữ liệu trang web trở lại trình duyệt của bạn trên một số port khác.
Một số port phổ biến được sử dụng cho các dịch vụ mạng và ứng dụng bao gồm:
Port 80: HTTP web traffic
Port 443: HTTPS encrypted web traffic
Port 25: SMTP email traffic
Port 53: DNS traffic
Port 21: FTP file transfer traffic
Port 22: SSH secure shell traffic
Port 3389: RDP remote desktop traffic
Protocols
Một protocol là một tập hợp các quy tắc chi phối cách dữ liệu được truyền và nhận giữa các thiết bị trên mạng. Protocols rất cần thiết để đảm bảo rằng các thiết bị có thể giao tiếp với nhau một cách hiệu quả và hiệu suất. Các protocols phổ biến thường hoạt động trên một port được chỉ định.
OSI
Mô hình OSI (Open Systems Interconnection) là một mô hình khái niệm định nghĩa cách giao tiếp giữa các hệ thống máy tính khác nhau nên được triển khai. Đây là một cách tiếp cận theo lớp, với mỗi lớp thực hiện các chức năng cụ thể và truyền thông tin lên hoặc xuống lớp tiếp theo trong stack.
Mô hình OSI có bảy lớp, mỗi lớp có một chức năng cụ thể. Các lớp này là:
7
Application Layer
Cung cấp dịch vụ cho applications; protocols như HTTP, FTP, và SMTP.
6
Presentation Layer
Trình bày và định dạng dữ liệu; protocols như SSL và TLS.
5
Session Layer
Quản lý sessions giữa các applications; protocols như NetBIOS.
4
Transport Layer
Truyền dữ liệu đáng tin cậy giữa applications trên các thiết bị khác nhau; protocols như TCP và UDP.
3
Network Layer
Định tuyến data packets giữa các networks; protocols như IP.
2
Data Link Layer
Truyền dữ liệu đáng tin cậy qua physical link; protocols như Ethernet và Wi-Fi.
1
Physical Layer
Truyền raw bit streams qua phương tiện vật lý, như dây hoặc tín hiệu radio.
Ví dụ
Application
DNS, DHCP, SSH, HTTPS, FTP, SNMP, SMTP, POP3
Presentation
Encryption, Encoding, SSL, ASCII, EBCDIC, TIFF, GIF, PICT, JPEG, MPEG, MIDI
Session
NFS, NetBios names, RPC, SQL
Transport
TCP, UDP, RTP, SCTP
Network
IPv4, IPv6, ICMPv4, ICMPv6, IPX
Data Link
Ethernet, PPP, FDDI, ATM, IEEE 802.5/802.2, HDLC, Frame Relay
Physical
Ethernet (IEEE802.3), Wi-Fi (IEEE 802.11), FDDI, B8ZS, V.35, V.24, RJ45
TCP/IP Layers
Application
Transport
Internet
Network Access
Protocols phổ biến
Transmission Control Protocol
TCP
Đây là một protocol đáng tin cậy, hướng kết nối cung cấp kiểm tra lỗi và kiểm soát luồng. Nó được sử dụng cho các applications yêu cầu mức độ tin cậy cao, như duyệt web, email và truyền file.
User Datagram Protocol
UDP
Đây là một protocol không kết nối, không đáng tin cậy thường được sử dụng cho các applications ưu tiên tốc độ hơn độ tin cậy, như streaming video, game online và dịch vụ voice over IP (VoIP).
Internet Protocol
IP
Đây là protocol chính được sử dụng để định tuyến dữ liệu qua internet. IP cung cấp thông tin định địa chỉ và định tuyến cần thiết để đảm bảo dữ liệu được gửi đến đích đúng.
Hypertext Transfer Protocol
HTTP
Đây là protocol được sử dụng bởi trình duyệt web để yêu cầu và nhận trang web và các tài nguyên khác từ web servers.
Domain Name System
DNS
Protocol này được sử dụng để dịch tên miền (như www.example.com) thành địa chỉ IP mà máy tính có thể hiểu.
Simple Mail Transfer Protocol
SMTP
Protocol này được sử dụng để gửi tin nhắn email giữa servers và clients.
File Transfer Protocol
FTP
Protocol này được sử dụng để truyền files giữa các máy tính trên mạng.
DNS
DNS được xem xét kỹ lưỡng để tìm bằng chứng tunneling, một kỹ thuật mà kẻ tấn công sử dụng để vượt qua các biện pháp bảo mật nhằm đánh cắp dữ liệu hoặc thực thi lệnh. Phát hiện các yêu cầu DNS bất thường giúp xác định những vi phạm như vậy.
A
Ánh xạ một domain đến địa chỉ IPv4.
AAAA
Ánh xạ một domain đến địa chỉ IPv6.
CNAME
Ánh xạ một domain đến tên domain khác (aliasing).
MX
Chỉ định mail exchange servers cho domain.
TXT
Cho phép domain admin chèn bất kỳ văn bản nào vào DNS record.
NS
Chỉ định authoritative name servers cho domain.
PTR
Cung cấp tên domain trong reverse-IP lookups.
SOA
Chứa thông tin quản trị về domain, chẳng hạn như primary name server và chi tiết liên hệ cho domain administrator.
SRV
Chỉ định vị trí của các dịch vụ như VOIP, SIP và XMPP.
Wireshark
Wireshark là một công cụ cho phép bạn phân tích network traffic ở mức packet và kiểm tra nội dung của từng packet, bao gồm địa chỉ nguồn và đích, protocols được sử dụng, và bất kỳ dữ liệu nào được truyền. Điều này có thể cực kỳ hữu ích để khắc phục sự cố mạng, xác định các mối đe dọa bảo mật, và phát triển và kiểm tra các protocols mạng.
Hầu hết các Pcaps quá dài để xem qua từng packet một. Vì vậy khi mở wireshark, bạn nên có một kế hoạch và tìm kiếm một số thứ. Tìm kiếm những bất thường.
Để mở wireshark, mở terminal, điều hướng đến pcap
wireshark sus_file.pcp
Statistics
Hữu ích để có được cái nhìn tổng quan nhanh về pcap.
I/O Graph
Có thể hữu ích để xem tần suất của các packet được gửi hoặc kích thước của các packet được gửi theo thời gian.
Conversations
Conversations là luồng traffic hai chiều giữa hai endpoints cụ thể. Một endpoint có thể là sự kết hợp của một địa chỉ IP và một số port. Do đó, đối với TCP/UDP traffic, một conversation được xác định duy nhất bởi cả địa chỉ IP nguồn và đích cũng như số port.
Duration & Activity: Conversations kéo dài trong thời gian dài hoặc ngắn bất thường có thể đáng nghi.
Search for strings in packets
Các truy vấn hữu ích

ip.addr != 192.0.2.1
: Lệnh display filter này loại bỏ các packet có địa chỉ IP là 192.0.2.1. Bạn có thể thay thế "192.0.2.1" bằng bất kỳ địa chỉ IP nào bạn muốn loại bỏ.tcp
: Lệnh display filter này chỉ hiển thị các packet TCP. Bạn có thể thay thế "tcp" bằng "udp" để chỉ hiển thị các packet UDP, hoặc bằng "icmp" để chỉ hiển thị các packet ICMP., hoặc http: Lệnh display filter này chỉ hiển thị các packet HTTP. - (http.request: Lệnh display filter này chỉ hiển thị các packet HTTP request. http.response: Lệnh display filter này chỉ hiển thị các packet HTTP response.)ip.src == 192.0.2.1
: Lệnh display filter này chỉ hiển thị các packet có địa chỉ IP nguồn là 192.0.2.1.ip.dst == 192.0.2.1
: Lệnh display filter này chỉ hiển thị các packet có địa chỉ IP đích là 192.0.2.1.tcp.port == 80
: Lệnh display filter này chỉ hiển thị các packet TCP sử dụng port 80 (HTTP).udp.port == 53
: Lệnh display filter này chỉ hiển thị các packet UDP sử dụng port 53 (DNS).udp.length > 500
: Lệnh display filter này chỉ hiển thị các packet UDP có độ dài lớn hơn 500 bytes.frame.time >= "Feb 13, 2022 12:00:00"
: Lệnh display filter này chỉ hiển thị các packet được capture sau ngày và giờ được chỉ định.
Export Objects
Một trong những việc đầu tiên cần làm là xác định xem có file nào được truyền không. Điều này có thể được thực hiện trong wireshark bằng File -> Export Objects -> (có thể là http, thử tất cả)

Ví dụ như nhấp vào HTTP sẽ hiển thị một màn hình cho thấy các file mà wireshark tìm thấy và tùy chọn để xem trước và tải xuống. Điều quan trọng cần nhớ là nếu bạn tìm thấy credentials và decrypt traffic thì hãy quay lại đây và tìm kiếm các file mới mà wireshark có thể đã tìm thấy.
Streams

Để truy cập streams, nhấp chuột phải vào một packet

Protocols in Wireshark
NetBIOS Name Service (NBNS)
NetBIOS Name Service (NBNS) là một protocol hoạt động qua UDP trên port 137. Nó là một phần của bộ dịch vụ NetBIOS, được sử dụng để phân giải tên trên mạng cục bộ. NBNS cho phép máy tính đăng ký tên của chúng và phân giải tên NetBIOS thành địa chỉ IP trên mạng cục bộ, tương tự như cách DNS phân giải tên miền thành địa chỉ IP trên internet.
Từ góc độ digital forensics, traffic NBNS có thể khá hữu ích trong một số tình huống:
Xác định thiết bị trên mạng:
Device Discovery: Bằng cách phân tích traffic NBNS, bạn có thể khám phá các thiết bị trên mạng, bao gồm tên NetBIOS và địa chỉ IP của chúng. Điều này có thể đặc biệt hữu ích trong việc vẽ sơ đồ topology mạng.
Device Role Identification: Tên NetBIOS thường bao gồm các gợi ý về vai trò của thiết bị (ví dụ: "FORELA-WKSTN001"), có thể giúp xác định các tài sản quan trọng.
Encryption trong Wireshark
Encryption có thể được gặp trong các capture của Wireshark và có thể được xác định bằng việc sử dụng các protocol như SSL/TLS hoặc SSH. Khi encryption được sử dụng, dữ liệu được truyền được bảo vệ và không thể xem ở dạng plain text. Tuy nhiên, có thể xem traffic đã mã hóa trong Wireshark và cố gắng giải mã nó bằng các key hoặc password thích hợp. Để làm điều này, chọn traffic đã mã hóa trong Wireshark và sau đó sử dụng tùy chọn "Follow SSL Stream" hoặc "Follow SSH Stream" để xem dữ liệu đã mã hóa. Nếu có sẵn các key hoặc password thích hợp, chúng có thể được nhập vào cài đặt "Decode As" để giải mã traffic.
Decrpyt TLS
TLS v1.2 + RSA Key Exchange
Tìm kiếm: Server Hello, Certificate → x509 với RSA public key
Cũng hoạt động cho SMTP/POP3/IMAP/FTPS cũ với SSL
✅ Public key của server dễ bị tấn công:
Kích thước key nhỏ (ví dụ: 512-bit, 768-bit)
Các số nguyên tố được tái sử dụng hoặc tính ngẫu nhiên yếu
Lưu output hex là my_certificate
Chuyển đổi thành nhị phân. Lấy Modulus.
Làm sạch nó
Chuyển đổi từ hex sang thập phân
Sử dụng các thừa số để tạo private key
Load key trong Wireshark
Bây giờ chúng ta có thể thấy traffic
Input RSA key
From G, but TLS instead of SSL



Setting this up
# 1 Generate a 2048-bit RSA private key
openssl genrsa -out server_rsa.key 2048
# 2 Create a self-signed certificate
openssl req -new -x509 -key server_rsa.key -out server_rsa.crt -days 365 -subj "/CN=localhost"
Start server
openssl s_server -cert server_rsa.crt -key server_rsa.key -tls1_2 -cipher RSA -accept 4433
Connect
openssl s_client -connect localhost:4433 -tls1_2
Follow adding key như trước trong Wireshark.
Với log file
marshall in the middle sử dụng phương pháp tương tự nhưng thay vì RSA để decrypt TLS thì nó là secrets.log
Tìm thứ gì đó như
Nội dung của sslkey.log có thể trông như thế này
CLIENT_HANDSHAKE_TRAFFIC_SECRET 1883768c955100059c9e4ebcd16d8168e762436f65f66aaf905680f3e8a439a6 35f05c44c0d5cd5b9b80622cc6f7314895a0a0a45a2fa249291a509db8156256
SERVER_HANDSHAKE_TRAFFIC_SECRET 1883768c955100059c9e4ebcd16d8168e762436f65f66aaf905680f3e8a439a6 3a8ec62b1e2b1505ce7a44f1a7977490f302beef16c993b28ac4b1b512a2db76
CLIENT_RANDOM 53172363ba45dbe949f9f5c237c39b4a14f2a9d55cefb751420120a105a07c3e d877c33bdfa568ecc0c2e2304814cc9160209eee8d6b2ffb620f198a451d488010786fd0e7b4bf9c03a462b2af3aa1f8
CLIENT_HANDSHAKE_TRAFFIC_SECRET c42740946ffc0245c919b390949ee549079e8be2e0e4a59e8c0e7487c292822d bb5dd2319fdab57773785e3ec3a6949bc551fad6c090d113a6ed225c9e0a3d3e
Decrypt tương tự như sử dụng key
Preshared key
Thiết lập nó
Thiết lập server với psk của 4d79537570657253656372657450534b
.
openssl s_server -psk 4d79537570657253656372657450534b -nocert -cipher PSK-AES128-CBC-SHA -accept 4433 -tls1_2
Kết nối
openssl s_client -psk 4d79537570657253656372657450534b -cipher PSK-AES128-CBC-SHA -connect localhost:4433 -tls1_2
Đã mã hóa
Nhập PSK để decrypt traffic trong Wireshark
Preferences-TLS-PSK
Đã giải mã
Decrypt SMB2
HTB Rouge cho thấy cách decrypt SMB2 traffic.
Để decrypt SMB2 traffic trong wireshark, bạn cần một session id và một session key. Để lấy session key, chúng ta cần một vài thứ.
Password của user hoặc md5 hash của nó
Username và domain
Ntproofstr
Initial SMB session key
Chúng ta có thể tìm thấy tất cả thông tin cần thiết trong session setup request
Edit > Preferences > Protocols > SMB2
Lấy password user từ SMB
Chúng ta cần tạo một chuỗi gồm 5 phần được tìm thấy trong traffic.
Đối với phần cuối NTLMv2Response, chúng ta phải loại bỏ 16 byte/32 ký tự đầu tiên.
Chúng ta sẽ thấy thứ gì đó như thế này trong pcap.
Chúng ta có thể tìm thấy 4 phần trong
Session Setup Request
SMB2 (Server Message Block Protocol Version 2) -> Session Setup Response (0x1) -> Security Blob -> GSS-API Generic **** ->
Simple Protected Negotiation -> negTokenTarg -> NTLM Secure Service Provider -> -> NTLM Response -> NTLMv2 Response -> NTProofStr.
Phần cuối cùng có thể được tìm thấy trong
Session Setup Response
SMB2 (Server Message Block ProtocolVersion 2) -> Session Setup Response (0x1) -> Security Blob -> GSS-API Generic ->
SimpleProtected Negotiation -> negTokenTarg -> NTLM Secure Service Provider -> NTLM Server Challenge.
Tổng cộng nó sẽ trông như thế này
Có thể thử crack hash trong responder.
hashcat -m 5600 responder_hash /usr/share/wordlists/rockyou.txt
PCAP=Some.pcapng
# 1) CHALLENGE (Type 2): get server challenge per tcp.stream
tshark -r "$PCAP" -Y "ntlmssp.ntlmserverchallenge" -T fields \
-e tcp.stream -e ntlmssp.ntlmserverchallenge \
> /tmp/chal.txt
# 2) AUTH (Type 3): get user, domain, NTLMv2 response per tcp.stream
tshark -r "$PCAP" -Y "ntlmssp.ntlmv2_response && ntlmssp.auth.username" -T fields \
-e tcp.stream -e ntlmssp.auth.username -e ntlmssp.auth.domain -e ntlmssp.ntlmv2_response \
> /tmp/auth.txt
# 3) Join by stream and format for hashcat -m 5600 (NetNTLMv2)
awk 'NR==FNR {chal[$1]=$2; next}
{
stream=$1; user=$2; dom=$3; resp=$4;
ntproof=substr(resp,1,32); blob=substr(resp,33);
printf "%s::%s:%s:%s:%s\n", user, dom, chal[stream], ntproof, blob
}' /tmp/chal.txt /tmp/auth.txt > netntlmv2.txt
echo "[+] Wrote netntlmv2.txt"
Kerberos Analysis and Decryption
AS-REP Hash Extraction
Lấy các thành phần một cách thủ công từ Wireshark.
Xây dựng hash cho john
hashcat cần một format khác, username và realm phải được bao gồm, mặc dù nó không sử dụng.
Decrypt winrm
python3 winrm_decrypt.py capture.pcap -n 8bb1f8635e5708eb95aedf142054fc95 > decrypted
HTB keep the steam going
HID - USB
Một số pcap không phải của mạng, mà là các lệnh bàn phím được capture bởi USB. Có một vài thử thách (logger, deadly arthropod) yêu cầu bạn decode những lệnh này. Thực hiện như vậy thường sẽ cho ra flag. Có một số script python sẽ thực hiện việc decoding, hãy cẩn thận với các trường hợp (A hoặc a). Nhưng về cơ bản chúng ánh xạ
Trong wireshark
Chú ý ở phía dưới cùng có ghi usage và đưa ra 2 ký hiệu, đó là 2 tùy chọn tùy thuộc vào việc shift hoặc caps lock có được sử dụng hay không.
https://github.com/WangYihang/USB-Mouse-Pcap-Visualizer
Bluetooth
https://www.bluetooth.com/wp-content/uploads/Files/Specification/HTML/Core-54/out/en/host/security-manager-specification.html
Key Protocols & Packets
SBC
L2CAP (Logical Link Control and Adaptation Protocol) –
Wireless - Bluetooth Devices
Telephony-RTP-RTP Streams
LTK
https://github.com/dbissell6/DFIR/blob/main/WalkThroughs/Apoorv_CTF_2025.md#dura-lesc-sed-lesc-from-pwnme
Data Exfiltration
ICMP
TTL
tshark -r exfiltration_activity_pctf_challenge.pcapng -Y "ip.src == 192.168.237.132 && icmp" -T fields -e ip.ttl | awk '{for(i=1;i<=NF;i++) printf("%c", $i)}
CheckSum
Cho pcap của ICMP chú ý ngắn và checksum là một trong ba.
Sử dụng tshark để trích xuất checksum.
tshark -r chall.pcap -Y "icmp" -T fields -e icmp.checksum
Sử dụng cyberchef để chuyển đổi sang mã morse.
TCP
Flags
tshark -r abnormal_illegal.pcapng -T fields -e 'tcp.flags.str' 'ip.addr==192.168.237.149'| sort | uniq -c
tshark -r abnormal_illegal.pcapng -Y "tcp.flags.syn==1 and tcp.flags.fin==1" -T fields -e tcp.flags
DNS
Subdomains
Ví dụ tấn công phổ biến: Kẻ tấn công sử dụng tên truy vấn DNS (subdomains) để encode dữ liệu và gửi ra ngoài. Ví dụ, các yêu cầu có thể trông như data1.malicious-domain.com, data2.malicious-domain.com, v.v., trong đó data1, data2, và các phần khác chứa các mảnh của dữ liệu đang được exfiltrate.
Chú ý một loạt DNS traffic kỳ lạ
Sử dụng tshark để trích xuất và làm sạch
tshark -q -r shark2.pcapng -Y "ip.dst == 18.217.1.57 && dns.qry.name" -T fields -e dns.qry.name | cut -d'.' -f1 | uniq | tr -d '\n'
HTTP
Cookies
tshark -r httpcookies.pcapng -Y "http.cookie" -T fields -e http.cookie | sed 's/Session=//g' | tr -d '\n' | base64 -d | tail > flag.txt
Tshark
Đôi khi việc trích xuất dữ liệu từ pcap là hữu ích, điều này có thể được thực hiện với tshark
tshark -r capture.pcapng -T fields -e data -Y "!(_ws.expert) && ip.src == 172.17.0.2 && ip.src!=172.17.0.3" > output
Suricata
Suricata xuất sắc trong việc phân tích toàn diện network traffic, tỉ mỉ tìm kiếm các dấu hiệu tiềm ẩn của hoạt động độc hại trong dữ liệu PCAP. Sức mạnh của nó nằm ở khả năng đánh giá kỹ lưỡng trạng thái mạng của chúng ta và đi sâu vào chi tiết của các giao dịch application-layer riêng lẻ trong PCAP capture. Hiệu quả của Suricata phụ thuộc rất nhiều vào một bộ quy tắc được tinh chỉnh tốt.
Rules
Quy tắc mẫu
alert http any any -> any any (msg:"Investigate suspicious connections, possible Dridex infection"; sid:2200073; rev:2;)
alert http any any -> any any (msg:"Suspicious JavaScript function, possible Dridex infection"; content:""; file_data; sid:10000005;)
https://docs.suricata.io/en/suricata-6.0.0/rules/intro.html
Network Miner
NetworkMiner là một công cụ phân tích forensic mạng nổi tiếng, được thiết kế đặc biệt để phân tích cú pháp và diễn giải network traffic được đóng gói trong file PCAP. Nó xuất sắc trong việc trích xuất file từ network traffic, xác định host, và cung cấp khả năng fingerprinting OS thụ động. Với giao diện thân thiện với người dùng, nó cung cấp cái nhìn tổng thể về các tương tác mạng, khiến nó trở thành công cụ được yêu thích trong số các chuyên gia digital forensics và incident response.
Lấy thông tin cho các file từ việc truyền
Zui
Ứng dụng desktop "Zui", một phần của Brim, cho phép người dùng điều hướng và thao tác hiệu quả các data lake có cấu trúc siêu, thúc đẩy trải nghiệm dữ liệu trực quan và hợp lý hơn.
Zed là một loại data model và format mới kết hợp những điều tốt nhất của logs, Avro, và columnar data. Thay vì nghiêm ngặt dựa trên hàng hoặc cột, Zed cung cấp một format có cấu trúc siêu cho phép người dùng truy vấn và phân tích dữ liệu hiệu quả
Truy vấn theo số alert
Snort
Hoạt động như một packet logger hoặc sniffer tương tự như Suricata, cho phép kiểm tra toàn diện network traffic. Khả năng của Snort trong việc xác định và ghi log tất cả các hoạt động trong PCAP traffic cung cấp cái nhìn sâu sắc về tình hình và logs chi tiết của các giao dịch application layer trong dữ liệu PCAP.
https://docs.snort.org/
Rules
Có thể chỉ định rules trong
/root/snorty/etc/snort/snort.lua
Tương tự như suricata, nhưng không giống nhau. https://docs.suricata.io/en/latest/rules/differences-from-snort.html
sudo snort -c /root/snorty/etc/snort/snort.lua --daq-dir /usr/local/lib/daq -r capture.pcapng
-A cmg
hiển thị thông tin alert cùng với packet header và payload.
-R /home/ViviG/local.rules
Tải các rules không tìm thấy trong .lua
-c configuration file --daq data acquistion
Zeek
Tóm lại, Zeek được tối ưu hóa để diễn giải network traffic và tạo logs dựa trên traffic đó. Nó không được tối ưu hóa cho việc khớp byte, và người dùng tìm kiếm các phương pháp phát hiện signature sẽ được phục vụ tốt hơn bằng cách thử các hệ thống phát hiện xâm nhập như Suricata. Zeek cũng không phải là một protocol analyzer theo nghĩa của Wireshark, tìm cách mô tả mọi thành phần của network traffic ở mức frame, hoặc một hệ thống để lưu trữ traffic dưới dạng packet capture (PCAP). Rather, Zeek sits at the “happy medium” representing compact yet high fidelity network logs, generating better understanding of network traffic and usage.
/usr/local/zeek/bin/zeek -C -r ../pcaps/psexec_pth_download_meterpreter.pcap
Zeek Cut
Lấy các cột
https://docs.zeek.org/en/stable/examples/index.html
Aircrack-ng
Aircrack-ng là một công cụ mạnh mẽ để phân tích WiFi packet capture và có thể được sử dụng để crack nhiều loại encryption key khác nhau được sử dụng để bảo vệ WiFi network traffic. Một số encryption key mà Aircrack-ng có thể crack bao gồm WEP (Wired Equivalent Privacy), WPA (Wi-Fi Protected Access), và WPA2 (Wi-Fi Protected Access II).
Crack mật khẩu wifi

JA3
JA3 là một phương pháp để tạo fingerprint của SSL/TLS client dựa trên các thuộc tính cụ thể của quá trình TLS handshake. Nó tạo ra một MD5 hash của việc nối SSL version, cipher được chấp nhận, danh sách extension, elliptic curve, và elliptic curve point format, tạo ra một định danh duy nhất cho SSL/TLS profile của client. Kỹ thuật fingerprinting này hữu ích để xác định, theo dõi và tương quan các client độc hại hoặc giao tiếp malware qua các kênh đã mã hóa.
https://github.com/salesforce/ja3
Nhập pcap tìm kiếm IP có vấn đề.
Logs + Registry + Artifacts
Giới thiệu
Logs tương tự như pcaps ở chỗ chúng là một danh sách dài các sự kiện.
Trong một số trường hợp, logs có thể chứa các tham chiếu đến files hoặc dữ liệu nhị phân, nhưng dữ liệu thực tế không được lưu trữ trong chính log đó. Ví dụ, một security log có thể chứa một mục cho biết rằng một file đã được tạo hoặc xóa, nhưng file thực tế không được lưu trữ trong log. Ở đây những thứ như powershell commands rất đáng nghi.
Nhiệm vụ
Phân tích log files để xác định nguyên nhân của sự cố hệ thống, phát hiện vi phạm bảo mật, hoặc khôi phục files đã xóa.
Xác định và trích xuất thông tin quan trọng, chẳng hạn như mật khẩu, địa chỉ email, hoặc số thẻ tín dụng.
Kiến thức
Hiểu biết về các định dạng và loại logs, chẳng hạn như system logs, application logs, và security logs.
Nhận thức về các kỹ thuật và mẫu tấn công phổ biến, chẳng hạn như SQL injection, cross-site scripting (XSS), và phishing attacks.
Kiến thức về các chỉ số thỏa hiệp phổ biến (IoCs), chẳng hạn như địa chỉ IP, tên miền, file hashes, và user agent strings.
Khả năng xác định các mục log bất thường, chẳng hạn như nhiều lần đăng nhập thất bại từ cùng một địa chỉ IP, hoặc các mẫu truy cập file bất thường.
Windows Logs
Các loại chính của Event Viewer (EVTX) logs trong Windows là:
System: Log này chứa thông tin về các sự kiện cấp hệ thống, chẳng hạn như khởi động và tắt hệ thống, sự kiện phần cứng, và sự kiện driver.
Application: Log này chứa thông tin về các sự kiện được tạo bởi applications và services, chẳng hạn như application crashes, cài đặt và gỡ bỏ application, và sự kiện bắt đầu và dừng service.
Security: Log này chứa thông tin về các sự kiện liên quan đến bảo mật, chẳng hạn như sự kiện đăng nhập và đăng xuất, sự kiện sử dụng đặc quyền, và sự kiện audit.
Setup: Log này chứa thông tin về các sự kiện setup, chẳng hạn như cài đặt và gỡ bỏ các thành phần Windows và updates.
Forwarded Events: Log này chứa thông tin về các sự kiện đã được chuyển tiếp từ các máy tính khác trong mạng đến máy tính local.
SYSMON: Không phải tất cả hosts đều tạo ra những thứ này theo mặc định, nếu có, đây là nơi tốt để bắt đầu.
Lấy logs từ máy windows
Kiểm tra các logs có sẵn.
Get-WinEvent -ListLog * | Select-Object LogName, RecordCount, IsClassicLog, IsEnabled, LogMode, LogType | Format-Table -AutoSize
Cũng được lưu trữ tại
C:\Windows\System32\winevt\logs
Windows Logs EventId - Description
1102
Audit log đã được xóa
4104
PowerShell script block logging
4624
Đăng nhập tài khoản thành công
4625
Đăng nhập tài khoản thất bại
4648
Đăng nhập sử dụng thông tin xác thực rõ ràng
4634
Một tài khoản đã đăng xuất
4688
Một process mới đã được tạo
4670
Quyền trên một object đã được thay đổi
4697
Một service đã được cài đặt trên hệ thống
4698
Một scheduled task đã được tạo
4699
Một scheduled task đã được xóa
4700
Một scheduled task đã được kích hoạt
4701
Một scheduled task đã được vô hiệu hóa
4702
Một scheduled task đã được cập nhật
4719
System audit policy đã được thay đổi
4720
Một tài khoản người dùng đã được tạo
4722
Một tài khoản người dùng đã được kích hoạt
4723
Một người dùng đã cố gắng thay đổi password của tài khoản
4724
Đã có một nỗ lực đặt lại password của tài khoản
4725
Một tài khoản người dùng đã được vô hiệu hóa
4726
Một tài khoản người dùng đã được xóa
4727
Một security-enabled global group đã được tạo
4728
Một thành viên đã được thêm vào security-enabled global group
4729
Một thành viên đã được loại bỏ khỏi security-enabled global group
4732
Một thành viên đã được thêm vào security-enabled local group
4733
Một thành viên đã được loại bỏ khỏi security-enabled local group
4738
Một tài khoản người dùng đã được thay đổi
4740
Một tài khoản người dùng đã bị khóa
4767
Một tài khoản người dùng đã được mở khóa
4771
Kerberos pre-authentication thất bại
4776
Domain controller đã cố gắng xác thực thông tin đăng nhập cho tài khoản (NTLM authentication)
4798
Thành viên local group của người dùng đã được liệt kê
4799
Thành viên security-enabled local group đã được liệt kê
4826
Boot configuration data đã được tải
4902
Bảng Per-user audit policy đã được tạo
4904
Đã có một nỗ lực đăng ký security event source
4905
Đã có một nỗ lực hủy đăng ký security event source
4912
Per-user audit policy đã được thay đổi
4964
Các nhóm đặc biệt đã được gán cho một lần đăng nhập mới
5024
Windows Firewall Service đã khởi động
5025
Windows Firewall Service đã dừng
5033
Windows Firewall Driver đã khởi động
5037
Windows Firewall Driver đã phát hiện lỗi runtime nghiêm trọng, đang kết thúc
5058
Key file operation
5059
Key migration operation
5061
Cryptographic operation
5062
Một kernel-mode cryptographic self-test đã được thực hiện
5095
Cài đặt Windows Firewall để cho phép hoặc từ chối một ứng dụng đã thay đổi
5124
Một security setting đã được cập nhật trên OCSP Responder Service
5156
Windows Filtering Platform đã cho phép một kết nối
5157
Windows Filtering Platform đã chặn một kết nối
7001
Service start operations
7022
Service bị treo khi khởi động
7045
Một service đã được cài đặt trên hệ thống
Sysmon EventId - Description
Event ID 1: Tạo process
Event ID 2: Một process đã thay đổi thời gian tạo file
Event ID 3: Network connection
Event ID 4: Trạng thái service Sysmon đã thay đổi
Event ID 5: Process đã kết thúc
Event ID 6: Driver đã được tải
Event ID 7: Image đã được tải
Event ID 8: CreateRemoteThread
Event ID 9: RawAccessRead
Event ID 10: ProcessAccess
Event ID 11: FileCreate
Event ID 12: RegistryEvent (Tạo và xóa object)
Event ID 13: RegistryEvent (Value Set)
Event ID 14: RegistryEvent (Key và Value Rename)
Event ID 15: FileCreateStreamHash
Event ID 16: ServiceConfigurationChange
Event ID 17: PipeEvent (Pipe Created)
Event ID 18: PipeEvent (Pipe Connected)
Event ID 19: WmiEvent (Phát hiện hoạt động WmiEventFilter)
Event ID 20: WmiEvent (Phát hiện hoạt động WmiEventConsumer)
Event ID 21: WmiEvent (Phát hiện hoạt động WmiEventConsumerToFilter)
Event ID 22: DNSEvent (DNS query)
Event ID 23: FileDelete (File Delete archived)
Event ID 24: ClipboardChange (Nội dung mới trong clipboard)
Event ID 25: ProcessTampering (Thay đổi process image)
Event ID 26: FileDeleteDetected (File Delete logged)
Event ID 27: FileBlockExecutable
Event ID 28: FileBlockShredding
Event ID 29: FileExecutableDetected
Event ID 255: Error
Sysmon sử dụng các phiên bản viết tắt của tên Registry root key, với các ánh xạ sau:
Key name Abbreviation
HKEY_LOCAL_MACHINE HKLM
HKEY_USERS HKU
HKEY_LOCAL_MACHINE\System\ControlSet00x HKLM\System\CurrentControlSet
HKEY_LOCAL_MACHINE\Classes HKCR
di chuyển Chuyển đổi format thời gian windows
https://www.epochconverter.com/ldap
Phân tích từ Windows
Event Viewer
Windows Event Viewer là một công cụ quản trị tích hợp trong hệ điều hành Microsoft Windows cung cấp cái nhìn tổng hợp về event logs được tạo ra bởi các thành phần hệ thống và applications.
Lọc Current Log.
XML query
<QueryList>
<Query Id="0" Path="file://C:\Users\Blue\htb_interview\Microsoft-Windows-Sysmon%254Operational.evtx">
<Select Path="file://C:\Users\Blue\htb_interview\Microsoft-Windows-Sysmon%254Operational.evtx">
*[System[(EventID=1 or EventID=3)]]
</Select>
</Query>
</QueryList>
Tìm. Tìm kiếm chuỗi
EvtxECmd
Event Log Explorer Command
Log Parser 2.2
Log Parser 2.2 là một công cụ mạnh mẽ, linh hoạt được phát triển bởi Microsoft cho phép người dùng trích xuất thông tin liên quan từ nhiều loại log files khác nhau sử dụng cú pháp giống SQL.
Log Lizard
Log Lizard là một công cụ phân tích logs nâng cao được thiết kế để đơn giản hóa quá trình duyệt, tìm kiếm và phân tích log files. Với giao diện người dùng đồ họa trực quan và backend xử lý mạnh mẽ, Log Lizard giúp người dùng dễ dàng đi sâu vào dữ liệu logs phức tạp. Có thể tạo visualizations.
Truy vấn tương tự cho Log Parser 2.2
Powershell scripts
Tìm kiếm một từ khóa trong thư mục chứa evtxs
# Define the directory containing EVTX files
$evtxDirectory = "C:\Tools\chainsaw\EVTX-ATTACK-SAMPLES\Lateral Movement"
# Define the keyword filter for the network share path
$keywordFilter = "\\*\PRINT"
# Loop through each EVTX file in the directory
Get-ChildItem -Path $evtxDirectory -Filter *.evtx | ForEach-Object {
$evtxFile = $_.FullName
# Search the EVTX file for events matching the keyword filter
$events = Get-WinEvent -Path $evtxFile | Where-Object { $_.Message -like "*$keywordFilter*" }
# If events are found, output the file name and event details
if ($events.Count -gt 0) {
Write-Host "Events found in $($evtxFile):"
$events | ForEach-Object {
Write-Host "File Name: $($evtxFile)"
Write-Host "Time: $($_.TimeCreated)"
Write-Host "Message: $($_.Message)"
Write-Host "---"
}
}
}
Get-WinEvent filter theo ID
DeepBlue
Framework mã nguồn mở để tự động phân tích evtx logs và tìm kiếm các hoạt động độc hại.
Phân tích từ Linux
evtx_dump
Xuất ra một json
https://github.com/omerbenamram/evtx
Sử dụng jq để surf
Công cụ jq cực kỳ linh hoạt để phân tích và thao tác dữ liệu JSON.
Xem record đầu tiên
Lọc các records với eventID 4624
Kiểm tra tổng số lần xuất hiện
Xem số lần xuất hiện của target usernames sau khi lọc
Ví dụ cuối
.EVTX_dump python
Chúng có thể được phân tích bằng evtx_dump.py để xuất ra xml.


Chainsaw
Chainsaw là một công cụ giao diện command-line có thể được sử dụng để phân tích log files được tạo ra bởi nhiều applications và systems khác nhau. Nó cung cấp một cách hiệu quả để điều hướng qua các log files lớn và hỗ trợ khả năng filtering và searching. CLI Chainsaw cũng có thể được sử dụng để phân tích và tương quan các log entries từ các nguồn khác nhau, cho phép phân tích toàn diện hơn về hành vi hệ thống.

Đối với nhiều điều kiện
./chainsaw search -t 'Event.EventData.ProcessId: =4' -t 'Event.System.EventID: =18' ~/Desktop/Tracer/Tracer/C/Windows/System32/winevt/logs/*
To và From với tau
~/Tools/chainsaw/chainsaw search -t 'Event.System.EventID: =4688' C/Windows/System32/winevt/logs/* --timestamp 'Event.System.TimeCreated_attributes.SystemTime' --from '2025-08-24T22:50:57' --to '2025-08-24T23:55:00' --timezone 'UTC' --skip-errors
sigma
Sigma là một tiêu chuẩn mở và chung để định nghĩa các mẫu logs và phát hiện. Nó cung cấp một cách có cấu trúc để mô tả các mẫu logs ở định dạng YAML có thể đọc được. Các mẫu này sau đó có thể được chuyển đổi thành nhiều truy vấn công cụ SIEM (Security Information and Event Management) khác nhau hoặc detection rules để xác định các mối đe dọa bảo mật tiềm tàng hoặc sự cố dựa trên dữ liệu logs.
Sử dụng hunt(+ sigma, rules, mappings)
Thêm một level để giúp filter events
./chainsaw hunt -s sigma -r rules -m mappings/sigma-event-logs-all.yml /home/kali/Desktop/Tracer/Tracer/C/Windows/System32/winevt/logs --skip-errors --level high
Sử dụng from và to (filtering time)
Xuất ra csv
sigmac
Sigmac nhận Sigma rules làm đầu vào và chuyển đổi chúng thành các định dạng truy vấn cho nhiều Tools, giải pháp quản lý logs và hệ thống security information and event management (SIEM) khác nhau.
Tạo một truy vấn cho powershell từ một sigma rule.
python sigmac -t powershell 'C:\Tools\chainsaw\sigma\rules\windows\file\file_access\file_access_win_credential_manager_stealing.yml'
Truy vấn tương tự cho splunk
Registry
Windows registry là một cơ sở dữ liệu phân cấp lưu trữ các cài đặt cấu hình và tùy chọn cho hệ điều hành Windows và các applications đã cài đặt khác. Trong một CTF, registry có thể là một nguồn thông tin có giá trị cho các nhà phân tích forensic, vì nó chứa chi tiết về applications đã cài đặt, tài khoản người dùng, cài đặt hệ thống và nhiều hơn nữa.
Persistence là một kỹ thuật được sử dụng bởi kẻ tấn công để duy trì quyền truy cập vào một hệ thống đã bị xâm phạm, ngay cả sau khi hệ thống đã được khởi động lại hoặc các biện pháp phòng thủ khác đã được thực hiện. Windows registry là một vị trí phổ biến cho kẻ tấn công thiết lập persistence, vì nó cung cấp một vị trí tập trung để lưu trữ các cài đặt cấu hình có thể được thực thi tự động khi khởi động hệ thống hoặc các sự kiện trigger khác.
Kẻ tấn công có thể sử dụng nhiều kỹ thuật khác nhau để thiết lập persistence thông qua registry, bao gồm thêm hoặc sửa đổi registry keys hoặc values, tạo scheduled tasks, hoặc cài đặt malicious services. Bằng cách làm như vậy, họ có thể đảm bảo rằng mã độc hại của họ sẽ thực thi mỗi khi hệ thống khởi động, cho phép họ duy trì quyền truy cập và tiếp tục thực hiện các mục tiêu của họ.
Xác định và phân tích registry keys liên quan đến persistence có thể là một phần quan trọng của thử thách. Điều này có thể bao gồm tìm kiếm các keys hoặc values đáng nghi hoặc bất thường, kiểm tra nội dung của các cơ chế persistence đã biết (chẳng hạn như scheduled tasks), hoặc sử dụng các công cụ và kỹ thuật chuyên biệt để xác định và phân tích các phương pháp persistence ẩn hoặc được làm rối.
Registry Editor
Ứng dụng Windows gốc để xem registry.
Hive
Hive files là một thành phần quan trọng của Windows Registry, chứa thông tin hệ thống quan trọng và thông tin người dùng cụ thể.
SAM hive file chứa thông tin tài khoản người dùng như mật khẩu đã hash, timestamps đăng nhập và thông tin nhóm. SYSTEM hive file cung cấp thông tin về thời gian thực thi file, thiết bị USB đã kết nối và thông tin hệ thống như múi giờ local và thời gian tắt máy cuối cùng. SOFTWARE hive file chứa thông tin về cả user và system software, bao gồm phiên bản và build hệ điều hành, kết nối mạng và thiết bị input/output. SECURITY hive file chứa thông tin về các biện pháp bảo mật và policies được áp dụng cho hệ thống.
Một công cụ thường được sử dụng để trích xuất mật khẩu từ SAM hive file là Mimikatz. Nó cũng có thể được sử dụng để trích xuất thông tin nhạy cảm khác từ hive files, như cached credentials và stored certificates.
Để chạy Mimikatz thành công và trích xuất thông tin nhạy cảm từ hive files, thường cần quyền administrative-level. Điều này là do Mimikatz hoạt động bằng cách inject chính nó vào memory space của các processes đang chạy và truy cập thông tin nhạy cảm thường chỉ có sẵn cho privileged users.
https://github.com/dbissell6/Shadow_Stone/blob/main/RedBook/5-Privilege%20Escalation/Windows.md#hklmsam
User-specific hive files bao gồm Amcache.hve file, chứa thông tin về application executables (Recently ran), như full path, size và SHA-1 hashes của chúng. Ntuser.dat file chứa thông tin về autostart applications, files được truy cập gần đây và thời gian thực thi cuối cùng của applications. UsrClass.dat file chứa thông tin về user-specific shellbags.
Registry Explorer
Registry Explorer là một công cụ được phát triển bởi Eric Zimmerman. Nó cho phép người dùng kiểm tra nội dung của Windows registry files một cách toàn diện.
Sử dụng Tools -> Find
reglookup
regshell
Công cụ CLI cho phép duyệt registry.
RegRipper
RegRipper là một công cụ mã nguồn mở phổ biến được sử dụng để trích xuất và phân tích thông tin từ Windows registry. RegRipper có thể được sử dụng để nhanh chóng và hiệu quả trích xuất các artifacts chính từ registry, bao gồm thông tin user và account, software đã cài đặt, cài đặt mạng và nhiều hơn nữa.
RegRipper hoạt động bằng cách áp dụng một loạt các plugins được định nghĩa trước hoặc "rippers" cho registry, mỗi plugin được thiết kế để trích xuất các loại thông tin cụ thể. Thiết kế modular này cho phép người dùng dễ dàng tùy chỉnh và mở rộng chức năng của RegRipper, điều chỉnh nó theo nhu cầu forensic cụ thể của họ.
RegRipper có thể là một công cụ mạnh mẽ để phân tích hệ thống Windows và xác định các vấn đề bảo mật tiềm tàng. Bằng cách sử dụng RegRipper để trích xuất và phân tích dữ liệu registry, để có những hiểu biết sâu sắc về hoạt động bên trong của hệ thống và xác định các indicators of compromise (IOCs) tiềm tàng hoặc persistence mechanisms.
Để sử dụng tất cả plugins (Một điều khó chịu là đôi khi binary sẽ không hoạt động trừ khi bạn thêm một khoảng trắng hoặc 2 khoảng trắng sau -a)
Cũng có thể đoán loại hive file
-g
Liệt kê tất cả plugins
-l
Các Registry Path quan trọng cho Phân tích Forensic
HKLM\SYSTEM\CurrentControlSet\Control\ComputerName
Computer name
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall
Installed software
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RecentDocs
Recent documents
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\ComDlg32\OpenSaveMRU
Recently opened/saved files
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU
Run history
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
Network configuration
HKCU\Software\Microsoft\Internet Explorer\TypedURLs
Typed URLs in Internet Explorer
HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings
Internet settings
HKLM\SYSTEM\CurrentControlSet\Services\bam\UserSettings
Recently executed programs
HKCU\Software\Microsoft\Office
Microsoft Office usage
HKLM\SYSTEM\CurrentControlSet\Enum\USB
USB device history
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2
Mounted devices
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
Winlogon settings
HKLM\SYSTEM\CurrentControlSet\Control\TimeZoneInformation
Time zone information
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\UserAssist
UserAssist data
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList
User profile paths
HKCU\Control Panel\Desktop
Desktop settings
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders
User-specific folders
HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Group Policy
Group policy settings
HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
Memory management settings
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Windows
Windows folder paths
HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer
User-specific policies
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles
Network profiles
HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts
File extension actions
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Drivers32
System drivers
HKCU\Software\Microsoft\Search Assistant\ACMru
Search Assistant history
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug
Debugger settings
HKCU\Software\Microsoft\Windows\CurrentVersion\Applets\Regedit
Last key viewed in Regedit
HKLM\SYSTEM\CurrentControlSet\Control\SafeBoot
Safe boot options
https://redteamrecipe.com/Registry-Attack-Vectors/
AmcacheParser
Amcache là repository chứa essential data về installed applications và executables. Data này encompass thông tin như file paths, sizes, digital signatures, và timestamps của last execution của applications.
Found at
C:\Windows\AppCompat\Programs\Amcache.hve
Trên windows đảm bảo Amcache.hve và logs đều ở cùng trong same dir/folder
Other Windows artifacts
https://www.sans.org/posters/windows-forensic-analysis/ https://www.sans.org/gated-content?resource=/Shared/Website%20Public%20Content/Posters%20and%20Cheat%20Sheets/SANS_DFPS_FOR500_v4.17_02-23.pdf
https://www.sans.org/blog/running-ez-tools-natively-on-linux-a-step-by-step-guide/
Master File Table (MFT)
NTFS file system bao gồm crucial component được biết đến như Master File Table (MFT), chứa thông tin về every file trên NTFS volume, bao gồm attributes của nó như size, timestamps, permissions, và data content. Files và directories trong NTFS được represented hoặc within MFT hoặc trong areas được described bởi MFT entries. Khi files được added, MFT grows với new entries, và khi files được deleted, MFT entries của chúng được marked như available cho reuse, nhưng allocated disk space cho những entries này remains unchanged. NTFS reserves a specific space, called the MFT zone, to ensure the MFT remains contiguous, and file and directory space is allocated from this zone once all other volume space is used up.
Each MFT record is 1024 bytes in size. Files smaller than 1024 bytes are stored directly in the MFT file itself, known as MFT Resident files. During Windows filesystem investigations, it's crucial to search for any malicious or suspicious files that may be resident in the MFT. This can reveal the contents of malicious files/scripts.
Zone Identifier - to see where a file was downloaded from
https://learn.microsoft.com/en-us/windows/win32/fileio/master-file-table
Chainsaw
MFT utilizing the dump
option and enabling output.
has a --decode-data-streams
option
MFTECmd.exe
Tool to parse MFT +($Boot...)
MTF Explorer
Can load raw MFT. Useful but takes 45 minutes to load
UsnJrnl (Update Sequence Number Journal)
UsnJrnl là feature của NTFS file system logs changes tới files và directories trên volume. Mỗi update hoặc modification tới file hoặc directory tạo entry trong UsnJrnl, bao gồm metadata như timestamps, file attributes, và nature của change (ví dụ: created, modified, deleted).
Forensic investigators thường analyze UsnJrnl để determine file activity, reconstruct timelines, hoặc identify tampering với system files.
Use MFTECmd to parse the USN
usnjrnl_rewind
https://github.com/CyberCX-DFIR/usnjrnl_rewind
Windows prefetch(.pf)
Windows Prefetch files được designed để improve application startup process bằng cách preloading essential components vào memory based trên past usage patterns. Thông tin chúng chứa typically includes:
Name of the Executable: This is the main executable file associated with the application.
Unicode List of DLLs (Dynamic Link Libraries): DLLs are shared libraries containing code and data that multiple programs can use simultaneously. The prefetch file lists the DLLs associated with the executable.
Execution Count: This indicates how many times the executable has been run, helping the system understand the application's frequency of use.
Timestamp: The timestamp indicates the last time the program was run, assisting in determining the most recent usage of the application.
Có thể kiểm tra bằng WindowsPrefetchView
Files được tìm thấy trong C:\Windows\Prefetch
Cũng có thể import một thư mục .pfs Options -> Advanced_Options
Sử dụng exiftool
PECmd.exe
Appdata
Thư mục C:\Users$USER\AppData trong hệ điều hành Windows là một hub trung tâm để lưu trữ dữ liệu application cụ thể của người dùng. This hidden folder is critical for both application functionality and forensic investigations, as it contains data that applications do not want exposed to regular user browsing, which might alter or delete sensitive information unintentionally.
AppData folder được subdivided thành three key subdirectories:
Roaming:
This folder contains data that moves with a user profile from one computer to another in environments where user profiles are managed on a network. Applications store configuration data here, like user settings and profiles that need to be consistent across multiple workstations. Local:
Stores data that is specific to a single computer, used for data that doesn’t need to be with the user’s profile as they move to different machines. This includes cached data and larger files that don’t need to roam. LocalLow:
Used by applications that run with lower security settings than the normal user context, such as Internet Explorer when operating in protected mode.
ActivitiesCache.db
Hiển thị thời gian thực thi của programs và có thể chứa Clipboard payloads.
Clipboard
Có thể tìm clipboard data trong AppData/Local/ConnectedDevicesPlatform/<USER>/ActivitiesCache.db
ở bảng SmartLookup, ClipboardPayload
python3 -c 'import sqlite3,json,base64,sys; print("\n".join(base64.b64decode(i["content"]).decode("utf-8","ignore") for (p,) in sqlite3.connect(sys.argv[1]).execute("select ClipboardPayload from SmartLookup") if p and p!="[]" for i in json.loads(p) if i.get("formatName")=="Text"))' ./ActivitiesCache.db
rdp Bitmap
Được tìm thấy tại
/Users/*/AppData/Local/Microsoft/Terminal Server Client/Cache/Cache0000.bin
tùy chọn -b sẽ ghép tất cả chúng thành một collage không có tổ chức
https://github.com/ANSSI-FR/bmc-tools
Có thể sử dụng để ghép images lại với nhau
https://github.com/BSI-Bund/RdpCacheStitcher
Powershell history
C:\Users\htb-student\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
Browser history
Hầu hết browser artifacts được found ở đây. Có section riêng bên dưới.
Shellbags
Shellbags, viết tắt của "shell folders và bagMRU," là một forensic artifact được tìm thấy trong hệ điều hành Microsoft Windows. Chúng là một phần của tính năng Windows Explorer ghi nhớ cách folders được hiển thị (view settings) và lưu trữ tương tác của user với file hệ thống, bao gồm folder navigation và access times.
Điều quan trọng cần lưu ý là shellbags tập trung vào tương tác của user với GUI, và không phải tất cả file system interactions đều được phản ánh trong data này, do đó shellbags thường có liên quan khi user đang sử dụng Remote Desktop Protocol (RDP).
Found in registry at
• USRCLASS.DAT\Local Settings\Software\Microsoft\Windows\Shell\BagMRU
• USRCLASS.DAT\Local Settings\Software\Microsoft\Windows\Shell\Bags
• NTUSER.DAT\Software\Microsoft\Windows\Shell\BagMRU
• HKEY_CURRENT_USER\Software\Microsoft\Windows\Shell\Bags
Shell Bags Explorer
Xem offline UsrClass.dat
.lnk (Windows Shortcut) Files
.LNK files, còn được gọi là Windows shortcuts, là những files nhỏ chứa một reference đến target file hoặc directory. Khi user click vào .LNK file, nó chuyển hướng họ đến target được chỉ định, cho phép truy cập nhanh vào applications, files, hoặc folders.
Được tìm thấy tại
C:\Users\<Username>\AppData\Local\Microsoft\Windows\Recent\
Trên linux có thể sử dụng file và exiftool để xem contents
Windows Management Instrumentation Repository (WMI)
Được tìm thấy tại
C/Windows/System32/wbem/Repository
WMI repository là một database chứa thông tin về Windows Management Instrumentation (WMI) classes được cài đặt trên computer, và nó có cấu trúc như sau:
OBJECTS.DATA: Objects managed by WMI
INDEX.BTR: Index of files imported into OBJECTS.DATA
MAPPING[1-3].MAP: Correlates data in OBJECTS.DATA and INDEX.BTR
WMI có thể được sử dụng để cài đặt event filters, providers, consumers, và bindings thực thi code khi một event được định nghĩa xảy ra. Ví dụ về events có thể được đăng ký là wall clock time, user logging, hoặc computer's uptime. Adversaries có thể sử dụng khả năng của WMI để đăng ký một event và thực thi arbitrary code khi event đó xảy ra, cung cấp persistence trên system.
WMI data được lưu trữ trong
\Windows\System32\wbem\Repository
Những search terms thú vị .exe .vbs .ps1 .dll .eval ActiveXObject powershell CommandLineTemplate ScriptText
sử dụng wmic cho recon
wmic process get CSName, Description,ExecutablePath,ProcessId
wmic useraccount list full
wmic group list full
wmic netuse list full
JumpLists
Tập hợp các .lnk files.
Jump Lists trong Windows cung cấp truy cập nhanh đến recent files và common tasks cho applications. Từ góc độ cyber, chúng có thể tiết lộ user behavior patterns, recent file access, và priority actions. Phân tích chúng giúp hiểu user activities và potential malicious actions liên quan đến specific applications. Jump Lists rất quan trọng cho việc tạo forensic timeline và xác định accessed files, khiến chúng có giá trị cho security analysis.
Trên Windows 10 được lưu trữ tại
C:\Users\<Username>\AppData\Local\Microsoft\Windows\Recent\AutomaticDestinations
C:\Users\<Username>\AppData\Local\Microsoft\Windows\Recent\CustomDestinations
JLEcmd (Jump List Explorer Command Line)
JLECmd được thiết kế để extracting và interpreting data từ Jump List files, có thể cung cấp thông tin có giá trị về user's activity, bao gồm recently hoặc frequently accessed documents, pictures, và nhiều hơn nữa.
Application Compatibility Cache (Shimcache)
Duy trì log về program execution (trước windows 10) data để hỗ trợ compatibility và performance improvements. Nó capture data như file paths, execution timestamps, và flags biểu thị program execution. Đối với investigators, Shimcache có giá trị trong việc xác định recently run programs và respective files của chúng. Được lưu trữ trong SYSTEM registry hive. Chỉ ghi vào reboot hoặc shutdown (có thể có thể extract current với volatility).
Found at
Registry: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\AppCompatCache
AppCompatCacheParser
AppCompatCacheParser là một forensic tool khác được phát triển bởi Eric Zimmerman, và nó được thiết kế đặc biệt để parse Application Compatibility Cache.
Userassist
Userassist keys là registry artifacts được sử dụng để xem GUI-based programs nào user đã chạy, và khi nào.
Keys được tìm thấy trong và được ROT-13 encoded
NTUSER.DAT
RunMRU Lists
RunMRU (Most Recently Used) lists trong Windows Registry lưu trữ thông tin về recently executed programs từ various locations, như Run và RunOnce keys. Những lists này có thể chỉ ra programs nào đã được chạy, khi chúng được thực thi, và có thể tiết lộ user activity.
Found at
Registry: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\RunMRU
SRUM
SRUM, viết tắt của System Resource Usage Monitor, là một Windows artifact ghi lại detailed system resource usage bởi mỗi application và user. Nó cung cấp thông tin về network connectivity, data usage, và application resource consumption theo thời gian.
C:\Windows\System32\sru\srudb.dat
C:\Windows\System32\config\SOFTWARE
$Logfile
Log file được sử dụng cho transaction logging bởi NTFS file system. Có thể được sử dụng để reconstruct file system operations và recover recent changes.
LogfileParser
https://github.com/jschicht/LogFileParser
Delimters là | có thể thay đổi nhanh với cái này
$inputFile = "path\to\your\inputfile.csv"
$outputFile = "path\to\your\outputfile.csv"
(Get-Content $inputFile) -replace '\|', ',' | Set-Content $outputFile
Chúng ta có thể mở CSV trong timeline explorer.
Trong ví dụ trên chúng ta đang cố gắng tìm thông tin trong shared_key trước khi nó bị xóa với sdelete64.exe Nó nói đi đến debug.log để xem data
Đây là key được sử dụng trong ransomware và bây giờ chúng ta có thể sử dụng nó để decrypt files.
.apmx
File type cho API Monitor, một tool để monitoring và analyzing API calls được thực hiện bởi applications trên Windows systems. Những files này chứa record của API calls, bao gồm details như calling process, APIs invoked, parameters, return values, và bất kỳ errors nào xảy ra.
Trong Monitored Processes
pane, có thể hover over cmd và powershell processes để xem commandline. Trong Summary pane bionoculars để tìm something từ strings và chúng ta có thể lấy nó trong Parameters pane.
Defender
Quarantine
Ghi lại files đã được quarantined sau khi bị flagged as a threat bởi Defender.
Được lưu trữ trong C:\ProgramData\Microsoft\Windows Defender\Quarantine\entries
MP Logs – Key Points:
Windows Defender MP logs store valuable information about files scanned by Defender, such as file paths, hashes, timestamps, and potentially signatures. These logs are located in the hidden directory C:\ProgramData\Microsoft\Windows Defender\Support
. MP logs can record command line arguments, observed files, and results, even if the file wasn’t flagged as suspicious. Common logs include MPDetection (detected threats) and MPLog (scanned files and directories). These logs can be pivotal in incidents where other artifacts or logs are missing, as they consolidate critical data like hashes, file paths, timestamps, and telemetry.
Tasks
In Windows contains XML files that define scheduled tasks for the operating system. These tasks are automated actions that Windows or applications run at specific times or in response to specific triggers, such as system startup or user login. Each XML file typically contains details about the task, including:
Task Name: The name of the scheduled task.
Triggers: Events or conditions that initiate the task (e.g., time-based, event-based).
Actions: The executable command and any arguments or scripts that the task runs.
Conditions: Requirements that must be met for the task to run (e.g., system idle or network availability).
Settings: Additional configurations such as retry intervals, permissions, and whether the task runs with elevated privileges.
C:\Windows\System32\Tasks
exiftool * | grep -E "File Name|File Modification Date/Time|Task Actions Exec Command|Task Actions Exec Arguments" | awk '{print} NR % 4 == 0 {print ""}'
Timeline Explorer
Hầu hết các tools đã được sử dụng để parse windows artifacts đã được tạo bởi Zimmerman và có thể tìm thấy ở đây.
https://ericzimmerman.github.io/#!index.md
Hầu hết những tools này tạo output có thể được ingested vào spreadsheet gui tương tự như excel.
Dark mode
Tools -> Skins -> Ofiice 2019 Black
Easy Filtering
Column Chooser
Kéo columns để remove khỏi table
https://aboutdfir.com/toolsandartifacts/windows/timeline-explorer/
Linux
Logs
Linux logs là một nguồn thông tin thiết yếu để tiến hành phân tích digital forensics và incident response trong cuộc thi CTF. Có một số loại Linux logs có thể được phân tích, bao gồm system logs (ví dụ: syslog), authentication logs (ví dụ: auth.log), và kernel logs (ví dụ: dmesg). Mỗi loại logs này cung cấp những hiểu biết có giá trị về hành vi của hệ thống và có thể giúp xác định dấu hiệu xâm nhập hoặc thỏa hiệp.
Khi phân tích Linux logs trong cuộc thi CTF DFIR, điều quan trọng là tập trung vào các mục cụ thể có thể chỉ ra hoạt động đáng nghi. Những mục này có thể bao gồm các lần đăng nhập thất bại, hành vi hệ thống bất thường và bất kỳ nỗ lực truy cập trái phép nào. Ngoài ra, việc phân tích logs kết hợp với các system artifacts khác (ví dụ: memory dumps, network traffic) có thể cung cấp một bức tranh toàn diện hơn về sự cố và giúp xác định các threat actors tiềm ẩn.
System Logs
/var/log/syslog
& /var/log/messages
General system activity logging.
- System boot-up and shutdown messages.
- Informational, warning, and error messages from system services.
Authentication Logs
/var/log/auth.log
Track user authentication activities.
- Successful and failed login attempts.
- Use of sudo commands.
- SSH logins.
Daemon Logs
/var/log/daemon.log
Logs from background services (daemons).
- Service start/stop messages.
- Service-specific messages.
Kernel Logs
/var/log/kern.log
Logs from the Linux kernel.
- Hardware-related messages.
- Driver issues.
- Kernel panics.
DPKG Logs
/var/log/dpkg.log
Software packages (Debian-based distributions).
- Installed, upgraded, or removed software.
YUM Logs
/var/log/yum.log
Software packages (RedHat-based distributions).
- Installed or removed software.
Cron Logs
/var/log/cron
Logs from the cron daemon.
- Scheduled tasks execution logs.
Mail Logs
/var/log/maillog
or /var/log/mail.log
Mail server logs.
- Sent and received email messages.
- SMTP, POP3, and IMAP messages.
Apache Access and Error Logs
/var/log/apache2/access.log
& /var/log/apache2/error.log
Apache web server logs.
- Client requests.
- Server errors.
Boot Log
/var/log/boot.log
System boot messages.
- Messages during system startup.
Bash history
File .bash_history
là một artifact forensic có giá trị ghi lại các lệnh được người dùng nhập trong Linux shell. Phân tích file này có thể tiết lộ thông tin quan trọng về hoạt động của người dùng, chẳng hạn như các lệnh đã thực thi, truy cập file, kết nối mạng, cài đặt phần mềm và các nỗ lực tiềm ẩn để che giấu dấu vết hoặc thay đổi system files. Được tìm thấy như một file ẩn trong thư mục home của người dùng, các điều tra viên có thể sử dụng .bash_history
để tái tạo hành động của người dùng, xác định hành vi độc hại và thiết lập timeline của các sự kiện, làm cho nó trở thành một công cụ thiết yếu cho incident response và digital forensics.
system.journal
Chứa các system events và messages đã được ghi log.
wtmp
File wtmp trong các hệ điều hành giống Unix là một file nhị phân ghi log tất cả logins, logouts, reboots và shutdowns.
Cũng có thể sử dụng utmpdump
access logs stats
Lấy stats của resources đã truy cập. Giả sử url là entry thứ 7
awk '{print $7}' access.log | sort | uniq -c | sort -rn
Cùng việc đó nhưng cho client IP đang truy cập server
Stats cho resources đã truy cập excluding client IPs
Cùng việc như trên, lần này chỉ tìm kiếm specific IP
Với bytes >= 10000
Useful Greps
New User Creation
sudo grep 'new user' /var/log/auth.log
Failed Login Attempts
sudo grep 'Failed password' /var/log/auth.log
IPs connected SSH
sudo grep 'sshd.*Accepted' /var/log/auth.log | awk '{print $(NF-3)}'
Sus Commands
chmod, whoami, sudo, netstat ... typical enumeration
Persistence
Hầu hết persistence mechanisms được tìm thấy trong /etc
https://github.com/dbissell6/DFIR/blob/main/WalkThroughs/Hold%20On%20Tight%20Walkthrough.pdf
Cronjobs
Trong Linux, cron là một time-based job scheduler chạy commands tại intervals được chỉ định. Một attacker có thể sử dụng cron để duy trì persistence trên compromised system bằng cách tạo cronjob để thực thi malicious script tại regular intervals. Script này có thể được sử dụng để tạo backdoors, steal data, hoặc thực hiện other malicious activities.
Global được tìm thấy trong
/etc/crontab
/var/spool/cron
/var/spool/cron/crontabs
LD_PRELOAD
LD_PRELOAD là một environment variable trong Linux/Unix systems cho phép users chỉ định shared library được loaded trước other libraries. Functionality này thường được exploited bởi attackers để inject malicious code vào legitimate processes.
/etc/ld.so.preload
Internet History artifacts
Zone Identifier
Khi file được downloaded từ internet, Windows gán cho nó một Zone Identifier (ZoneId). Điều này có thể hữu ích để xem file origins hoặc nếu file name đã thay đổi. Có thể được tìm thấy trong /mft/$J(USN).
Using Powershell
using MFT + Timeline
Browser artifacts
Browser artifacts rất quan trọng cho việc profiling user activity trên system. Chúng bao gồm history, cookies, cache, sessions, và configurations. Đáng chú ý, browsers track local file access trong history của chúng, chẳng hạn như khi viewing local PDFs hoặc SVGs. Những accesses này cũng có thể được tìm thấy trong %LocalAppData%\Microsoft\Windows\WebCache\WebCacheV01.dat với entries như file:///X:/path/to/file, trong đó "X" biểu thị drive letter.
Live NirLauncher
NirLauncher -> BrowsingHistoryView
Hầu hết databases sử dụng sqlite. Cũng có thể sử dụng bulkextract
Convert times
https://www.epochconverter.com/webkit
Chrome
appdata/local/google/chrome/User Data/default/History
Recover passwords
MetaMask Vault Location
AppData/Local/Google/Chrome/User Data/Default/Local Extension Settings/nkbihfbeogaeaoehlefnkodbefgpgknn
To Decrypt the Vault
https://metamask.github.io/vault-decryptor/
Firefox
Linux: ~/.mozilla/firefox/<profile_folder>/
Windows: %APPDATA%\Mozilla\Firefox\Profiles/<profile_folder>/logins.json
Places
Lưu trữ browsing history, bookmarks, và downloads.
places.sqlite
View passwords
Encrypted passwords được lưu trữ trong logins.json
Keys để decrypt được lưu trữ trong key4.db
git clone https://github.com/unode/firefox_decrypt
Session history
Open tabs và session data từ last session. Có thể được tìm thấy trong user hoặc sessionstore-backups
Sử dụng https://jsonlint.com/
để prettify json
formhistory
Lưu trữ autocomplete form data được nhập bởi user.
formhistory.sqlite
Downloads
Ghi log details của file downloads, bao gồm source URL, download time, và save location.
downloads.json
Cookies
cookies.sqlite
Edge
appdata\local\Microsoft\Edge\UserData[Default|ProfileX]*
appdata\local\microsoft\windows\webcache\webcacheV01.dat
.git
Không thực sự là internet artifact, Nhưng đặt ở đâu tốt hơn?
.git directory là một goldmine thông tin cho forensic analysts. Nó là hidden folder trong Git repository chứa entire version control history. Điều này bao gồm details về every commit, configuration settings, branches, và objects đại diện cho filesystem của project tại every recorded point in time.
Đọc qua all commits và grep cho specific content trong chúng.
git log --format="%H" | while read commit_hash; do git show "$commit_hash"; done | grep "search_term"
Email
.ost
OST là viết tắt của Offline Storage Table. Những files này được sử dụng bởi Microsoft Outlook để lưu trữ copy của mailbox data (emails, calendar events, contacts, etc.) khi sử dụng Outlook với Microsoft Exchange account. Chúng cho phép bạn work offline và synchronize changes với Exchange server khi bạn reconnect.
Files/Executables
Giới thiệu
Khi nói đến các thử thách CTF, phân tích file là một kỹ năng cần thiết cho bất kỳ thành viên blue team nào. Những thử thách này có thể có độ phức tạp khác nhau từ một file văn bản dài đơn giản cần được tìm kiếm flag đến một executable phức tạp yêu cầu reverse engineering. Là một thành viên blue team, bạn cần được trang bị các công cụ và kỹ thuật phù hợp để phân tích bất kỳ file nào bạn gặp phải trong một CTF.
Một trong những bước đầu tiên trong việc điều tra một file là xác định loại của nó bằng cách sử dụng lệnh file
. Lệnh này có thể tiết lộ thông tin như loại file, kiến trúc và endianness. Một lệnh hữu ích khác là strings
, có thể được sử dụng để trích xuất tất cả các chuỗi có thể in được từ một file. Điều này có thể hữu ích trong việc tìm manh mối hoặc xác định một số chuỗi nhất định có thể chỉ ra hành vi độc hại.
Có hiểu biết vững chắc về phân tích file là rất quan trọng trong việc xác định các mối đe dọa tiềm ẩn và phản ứng với các cuộc tấn công một cách kịp thời và hiệu quả. Vì vậy, cho dù bạn đang xử lý một file văn bản đơn giản hay một executable phức tạp, điều quan trọng là phải có các công cụ và kỹ thuật phù hợp để phân tích và phản ứng hiệu quả với bất kỳ cuộc tấn công dựa trên file nào.
file sus.elf
strings sus.txt
Strings
Lệnh strings trong Linux là một tiện ích hữu ích cho phép người dùng trích xuất các ký tự có thể in được từ các file nhị phân. Lệnh này tìm kiếm và hiển thị tất cả các chuỗi ký tự có thể in được (tức là strings) được tìm thấy trong một file nhị phân, điều này có thể hữu ích trong việc phân tích và debug file.
Một trường hợp sử dụng phổ biến cho lệnh strings là trong việc phân tích các file thực thi và thư viện. Ví dụ, nếu bạn đang cố gắng khắc phục sự cố với một chương trình, bạn có thể sử dụng strings để trích xuất bất kỳ thông tin liên quan nào có thể được lưu trữ trong file nhị phân, chẳng hạn như thông báo lỗi hoặc tùy chọn cấu hình.
Hai trong số các switches phổ biến nhất được sử dụng với strings là:
-a
Switch này yêu cầu strings tìm kiếm strings trong tất cả các phần của file, bao gồm cả những phần thường không được kiểm tra theo mặc định. Điều này có thể hữu ích trong việc xác định các strings được chôn sâu trong file nhị phân.
-n
Switch này chỉ định độ dài tối thiểu của các strings mà strings sẽ hiển thị. Theo mặc định, strings sẽ hiển thị tất cả các strings có ít nhất bốn ký tự, nhưng bạn có thể sử dụng switch -n để điều chỉnh độ dài tối thiểu này theo ý thích của bạn.
strings -el -n 12 winfile.doc
-el: Option này chỉ định encoding của strings để search. Chữ l là viết tắt của "little-endian". Điều này có nghĩa là strings sẽ search cho 16-bit little-endian encoded characters. Điều này đặc biệt hữu ích khi dealing với files từ Windows systems, vì một số files (như những files từ Windows Registry/.doc) có thể store strings trong UTF-16 little-endian encoding.
Strings recursivly
find Users/rumi -type f -size -100M -print0 |
while IFS= read -r -d '' f; do
printf '\n----- %s -----\n' "$f"
strings -a -n 4 "$f"
strings -a -n 4 -e l "$f"
strings -a -n 4 -e b "$f"
done 2>/dev/null
ASCII/UTF-8 (treat all files as text)
rg -n -F -a --hidden --no-ignore \
'toallknownlawsofaviationthereisnowayabeeshouldbeabletofly' Users/rumi
# UTF-16LE and UTF-16BE
rg -n -F -a --encoding utf-16le \
'toallknownlawsofaviationthereisnowayabeeshouldbeabletofly' Users/rumi
rg -n -F -a --encoding utf-16be \
'toallknownlawsofaviationthereisnowayabeeshouldbeabletofly' Users/rumi
Floss
Cũng có thể được sử dụng để get static strings từ binaries
Detect It Easy (DIE)
Detect It Easy, hoặc viết tắt "DIE" là program để determining types của files
Getting hashes
Hữu ích để đảm bảo file hasn't been altered và để submit to virustotal.
MD5 + SHA256
Từ linux
Từ Windows Powershell
Từ Windows cmd
Imphash
Hoạt động bằng cách concat lowercase của import functions.
PE Hashes
pestudio
Sigcheck
Common file types
Dưới đây là một số common files chúng ta có thể gặp phải. Recap ngắn ở đây, more indepth reversing/pwning guide có thể tìm thấy SOMEWHERE ELSE
File Type Key
Files thường được xác định bởi magic bytes hoặc headers của chúng. Nếu bạn có file có wrong extensions, no extensions, hoặc corrupted bạn có thể check magic bytes trong something như hexedit.
ani
52 49 46 46
RIFF
au
2E 73 6E 64
.snd
bmp
42 4D F8 A9
BM..
bmp
42 4D 62 25
BM%
bmp
42 4D 76 03
BMv
cab
4D 53 43 46
MSCF
DOC (.doc)
d0 cf 11 e0 a1 b1 1a e1
...
DOCX (.docx)
PK
dll
4D 5A 90 00
MZ..
Excel
D0 CF 11 E0
...
exe
4D 5A 50 00
MZP.
exe
4D 5A 90 00
MZ..
flv
46 4C 56 01
FLV.
gif
47 49 46 38 39 61
GIF89a
gif
47 49 46 38 37 61
GIF87a
gz
1F 8B 08 08
..
ico
00 00 01 00
....
jpeg
FF D8 FF E1
..
jpeg
FF D8 FF E0
JFIF
jpeg
FF D8 FF FE
JFIF
Linux bin
7F 45 4C 46
.ELF
mp3
49 44 33 2E
ID3.
mp3
49 44 33 03
ID3.
msi
D0 CF 11 E0
...
OFT
4F 46 54 32
OFT2
25 50 44 46
PNG (.png)
89 50 4e 47
.PNG
PPT
D0 CF 11 E0
...
rar
52 61 72 21
Rar!
sfw
43 57 53 06/08
CWS..
tar
1F 8B 08 00
..
tgz
1F 9D 90 70
..p
Word
D0 CF 11 E0
...
wmv
30 26 B2 75
0&.u
XLS (.xls)
d0 cf 11 e0 a1 b1 1a e1
...
XLSX (.xlsx)
PK
zip
50 4B 03 04
PK..
https://www.garykessler.net/library/file_sigs.html
Windows/Macros(.docm, .docx .doc, .bin, .vba, .pptm, .one)
.docm .doc .bin .vba .pptm .one .rtf
Đôi khi sử dụng unzip hoặc 7z trên word files có thể reveal hidden content.
.rtf
Rich Text Format (RTF) là document file format được phát triển bởi Microsoft, chủ yếu được sử dụng cho cross-platform document interchange. Mặc dù RTF files không support macros (common vector cho malware trong .doc hoặc .docx formats), chúng không inherently safe. RTF documents có thể embed OLE (Object Linking and Embedding) objects. Trong context của vulnerability này, maliciously crafted RTF document có thể embed tainted OLE object liên quan đến Equation Editor, từ đó triggering exploit (Cve-2017-11882).
rtfdump.py
Extract và display object tại index 7 trong hex format.
Olevba Tools
Một Python module cho phép analysis của Microsoft Office documents (ví dụ: Word, Excel, PowerPoint) để detect và extract bất kỳ embedded VBA (Visual Basic for Applications) macros nào. Nó có thể được sử dụng cho security assessments, forensics analysis, và malware analysis, vì VBA macros có thể được sử dụng như vector cho malware infection và data exfiltration. Olevba có thể parse VBA code, extract embedded binaries, và detect bất kỳ obfuscation techniques nào được sử dụng trong macro.

oledump.py
Để get single stream
python3 oledump.py ~/Desktop/MalDoc101/sample.bin -s 16
xlsx
Sử dụng exiftool để get info
Extract text từ cells của xlsx bằng cách converting to csv
Windows Executables (.exe, .dll, .so, .ps1)
Những files này có thể chứa mã độc mà kẻ tấn công có thể sử dụng để xâm phạm hệ thống. Phân tích những files này có thể tiết lộ thông tin về cách cuộc tấn công đã được thực hiện. Thường những files này sẽ bị obfuscated, đó là một nghệ thuật riêng biệt để làm sáng tỏ.
.psm1 - File extension _.psm1 đại diện cho PowerShell module file. Nó định nghĩa module là gì và những gì được chứa trong đó. .psd1 - _.psd1 là PowerShell data file chi tiết nội dung của PowerShell module trong bảng các cặp key/value. .dll - Một Windows file chứa code có thể được sử dụng bởi chương trình khác (.exe) .NET - .NET files về cơ bản là assemblies, chủ yếu bao gồm DLLs (Dynamic Link Libraries) và EXEs (Executable Files). Những assemblies này được xây dựng từ source code sử dụng .NET languages như C#, VB.NET, và F#.
Important DLLs
User32.dll
Tất cả các chức năng giao diện người dùng và tương tác.
Kernel32.dll
Các chức năng cơ bản cho hệ điều hành.
WSock32.dll
Các chức năng mạng cơ bản.
Gdi32.dll
Các chức năng chịu trách nhiệm quản lý đồ họa.
Advapi32.dll
Chức năng người dùng nâng cao.
Ws2_32.dll
Các chức năng chịu trách nhiệm quản lý network sockets.
Ntdll32.dll
Các chức năng quan trọng cho hoạt động kernel thích hợp.
Msvcrt.dll
Standard “lib C” library functions.
Linux Executables (.sh, .bin, .elf)
Trong Linux, executable files không nhất thiết phải có file extension cụ thể như trong Windows
.sh (shell script) .bin (binary file) .elf (executable and linkable format) .run (installer script) .out (object file)
Python (.py, .pyc)
py Files: .py files là Python source code files. Những files này chứa code có thể đọc được bởi con người được viết trong ngôn ngữ lập trình Python. Chúng có thể bao gồm scripts, modules, hoặc ứng dụng hoàn chính.
Compiled Python Files: .pyc files là kết quả của việc biên dịch Python source code (.py files) thành bytecode. Bytecode này là đại diện ở mức thấp, độc lập với nền tảng của source code mà Python interpreter có thể thực thi.
https://github.com/extremecoders-re/pyinstxtractor
# Clone the repository
git clone https://github.com/zrax/pycdc.git
# Change directory to the cloned repository
cd pycdc
# Build the tool
mkdir build
cd build
cmake ..
make
pylingual là online decompiler. PyLingual sử dụng một cách mới lạ các transformer models để học các đặc tả bytecode Python mới khi chúng được phát hành.
https://pylingual.io/
Image files (.jpg, .png, .bmp)
Những files này có thể chứa tin nhắn ẩn hoặc steganography, nơi dữ liệu được ẩn trong image.
bmp
File .bmp là định dạng file bitmap image chứa dữ liệu image không nén. File bắt đầu với header 14-byte chứa thông tin về định dạng file, như kích thước file, offset đến pixel data, và số bits trên mỗi pixel. Sau header, có một bảng màu tùy chọn ánh xạ các giá trị màu đến pixel cụ thể. Pixel data theo sau bảng màu (nếu có) và được lưu trữ theo từng hàng, với mỗi hàng được đệm đến bội số của 4 bytes. Mỗi pixel được biểu diễn bởi một chuỗi bits cho biết màu sắc và vị trí của nó trong image. Kích thước của pixel data có thể được tính toán dựa trên kích thước file và các giá trị offset trong header. Điều quan trọng cần lưu ý là .bmp files không chứa bất kỳ compression hoặc encryption nào.
png
File .png được tạo thành từ các chunks dữ liệu, trong đó mỗi chunk chứa thông tin về image. Mỗi chunk bắt đầu với trường length 4-byte, chỉ định số bytes trong chunk (không bao gồm chính trường length). Tiếp theo là trường type 4-byte, xác định loại dữ liệu trong chunk. Sau trường type là chunk data, có thể có độ dài khác nhau tùy thuộc vào loại chunk. Cuối cùng, chunk kết thúc với trường CRC (Cyclic Redundancy Check) 4-byte, được sử dụng để xác minh tính toàn vẹn của chunk data.
Chunk đầu tiên trong file PNG luôn là chunk IHDR (Image Header), chứa thông tin cơ bản về image như kích thước, độ sâu màu và phương pháp compression.
Tóm lại, mỗi chunk trong file PNG chứa 4 trường theo thứ tự sau:
Length (4 bytes): chỉ định số bytes trong chunk (không bao gồm chính trường length).
Type (4 bytes): xác định loại dữ liệu trong chunk.
Chunk data (độ dài biến đổi): dữ liệu thực tế chứa trong chunk.
CRC (4 bytes): checksum được sử dụng để xác minh tính toàn vẹn của chunk data.
jpeg/jpg
Chú ý discrepancy trong size
Email (.eml)
PDF (.pdf)
Database files
SQLite (.sqlite, .db, .sqlite3)
sqlite3
sqliteBrowser
Browse data
MySQL Database (.sql)
keepass (.kdbx)
Keepass là password manager cho phép người dùng lưu trữ an toàn passwords của họ trong một database duy nhất, được khóa bằng một master key hoặc key file. Thường cần password để đọc nó, có thể được crack bằng keepass2john + john.
Mở với
Bitcode Formats (.o,)
llvm
Audio files (e.g., MP3, WAV)
Thông tin có thể được ẩn trong frequency spectrum của audio signal, trong không gian không sử dụng trong file, hoặc bằng cách chỉnh sửa phase của audio waveform.
Video files (e.g., MP4, AVI)
Thông tin có thể được ẩn trong các khung hình riêng lẻ của video, trong không gian không sử dụng trong file, hoặc bằng cách chỉnh sửa motion vectors của video stream.
Compressed Files (.zip, .rar, .tar.gz, .7z, .bz2, .cab, ...)
Compressed files là cách phổ biến để đóng gói và phân phối nhiều files hoặc thư mục như một archive duy nhất. Trong CTF, compressed files có thể chứa manh mối hoặc thông tin quan trọng có thể hỗ trợ trong việc giải quyết thử thách. Đây là một số loại phổ biến của compressed files:
.zip: Đây là định dạng compression phổ biến được sử dụng rộng rãi trong cả môi trường Windows và Linux. Nó hỗ trợ cả lossless compression và encryption của nội dung archive. Để giải nén nội dung của .zip file, có thể sử dụng lệnh 'unzip' trong Linux hoặc phần mềm file archiver trong Windows.
.rar: Đây là một định dạng compression phổ biến khác được biết đến với tỷ lệ compression cao. Nó hỗ trợ cả lossless compression và encryption của nội dung archive. Để giải nén nội dung của .rar file, có thể sử dụng lệnh 'unrar' trong Linux hoặc phần mềm file archiver trong Windows.
.tar.gz: Đây là định dạng compression phổ biến được sử dụng trong môi trường Linux. Nó kết hợp nhiều files hoặc thư mục thành một archive duy nhất và nén archive bằng gzip algorithm. Để giải nén nội dung của .tar.gz file, có thể sử dụng lệnh 'tar' và 'gzip' trong Linux.
.7z: Đây là định dạng compression cung cấp tỷ lệ compression cao và hỗ trợ cả lossless và lossy compression. Nó thường được sử dụng để nén các files lớn. Để giải nén nội dung của .7z file, có thể sử dụng lệnh '7za' trong Linux hoặc phần mềm file archiver trong Windows.
.tar: Đây là định dạng file được sử dụng để lưu trữ files và thư mục trong hệ thống Unix-based. Nó không nén archive nhưng kết hợp nhiều files hoặc thư mục thành một archive duy nhất. Để giải nén nội dung của .tar file, có thể sử dụng lệnh 'tar' trong Linux.
.tar.bz2: Đây là định dạng compression kết hợp tar archive và bzip2 compression algorithm. Nó thường được sử dụng trong môi trường Linux. Để giải nén nội dung của .tar.bz2 file, có thể sử dụng lệnh 'tar' và 'bzip2' trong Linux.
.tgz: Đây là định dạng compression kết hợp tar archive và gzip compression algorithm. Nó thường được sử dụng trong môi trường Linux. Để giải nén nội dung của .tgz file, có thể sử dụng lệnh 'tar' và 'gzip' trong Linux.
.tar.xz: Đây là định dạng compression kết hợp tar archive và xz compression algorithm. Nó thường được sử dụng trong môi trường Linux. Để giải nén nội dung của .tar.xz file, có thể sử dụng lệnh 'tar' và 'xz' trong Linux.
.zipx: Đây là một phần mở rộng của định dạng .zip hỗ trợ các phương pháp compression nâng cao như LZMA, PPMD, và WavPack. Nó thường được sử dụng trong môi trường Windows. Để giải nén nội dung của .zipx file, có thể sử dụng phần mềm file archiver trong Windows.
.cab: Đây là định dạng file được sử dụng để phân phối các thành phần phần mềm trong môi trường Windows. Nó thường được sử dụng cho device drivers và system files. Để giải nén nội dung của .cab file, có thể sử dụng lệnh 'cabextract' trong Linux hoặc phần mềm file archiver trong Windows.
.iso: Đây là định dạng file được sử dụng để tạo disc images của CDs hoặc DVDs. Nó thường được sử dụng để phân phối media cài đặt hệ điều hành. Để giải nén nội dung của .iso file, có thể mount image như một virtual drive hoặc sử dụng phần mềm file archiver trong Windows.
Decompressing
Files có thể được nén theo rất nhiều cách để tránh phát hiện. Một số công cụ và lệnh giải nén phổ biến nhất.
unzip file.zip
gzip -d file.gz
bzip2 -d file.bz2
tar -xf file.tar
7z x file.7z
unrar x file.rar
xz -d file.xz
cabextract file.cab
lzip -d -k flag
lz4 -d flag.out flag2.out
lzma -d -k flag2.lzma
lzop -d -k flag2.lzop -o flag3
lzip -d -k flag3
Unzipping ZipCrypto
ZipCrypto là một trong những phương pháp encryption được sử dụng trong định dạng ZIP file. Nó đã tồn tại một thời gian và được coi là yếu vì nó sử dụng stream cipher không đủ mạnh về mặt mã hóa theo tiêu chuẩn hiện đại. Các lỗ hổng thiết kế của algorithm, như cách encryption keys được tạo ra và tính dễ bị tấn công của cipher trước known-plaintext attacks, khiến nó dễ bị tổn thương.
Known Plaintext: Kẻ tấn công phải có một phần của plaintext của một trong những files trong encrypted ZIP archive. Điều này có thể là standard file header, bất kỳ nội dung có thể dự đoán nào, hoặc các files không mã hóa đã được giải nén trước đó từ archive.
Để exploit
Reconstruct file (svg).
Run bkcrack để get keys
Recreate zip với password of your choice
Open
Another store example
Thêm plaintext vào file và zip nó với -0
có thể run pointing at index
Another Example, không phải 16 continuous bytes https://github.com/dbissell6/DFIR/blob/3eeb5a757fbe5b3bbabe088b65b4a23dc8b36726/WalkThroughs/TexSaw_CTF_2025.md#hidden-beneath-the-wavs
Reconstructing
Đôi khi bạn có thể gặp phải something (như Hex output trong wireshark) cần được reconstructed back thành binary hoặc zip. Đôi khi bạn gặp file với corrupted header cần được fixed.
Intro
Trước khi diving vào tools như hexedit, điều essential là grasp những gì bạn đang seeing trong hex editor. Every file trên computer của bạn, từ image đến executable, về cơ bản là collection của bytes. Những bytes này được stored trong binary format – sequences của ones và zeros – không easily readable bởi humans. Hexadecimal representation cung cấp more human-readable format cho những sequences này.
Offset: Trên leftmost column, bạn sẽ thường see "offset." Điều này represents location của byte trong file. Nó helps bạn identify where you are, đặc biệt trong extensive files.
Hexadecimal Values: Next broad section shows file's content trong hexadecimal format (Base 16, 0-255 int). Mỗi two-character hex value corresponds với byte trong file. Đây là nơi modifications thường được made khi correcting corrupted files hoặc altering binary data.
ASCII Representation: Trên right side, nhiều hex editors cung cấp ASCII representation của file's bytes. Mặc dù không phải all bytes translate thành visible characters (một số có thể show như dots hoặc other symbols), view này có thể help bạn spot strings hoặc familiar patterns trong file.
Example/Reminder một value được represented 4 ways
Decimal: 90
Binary: 01011010
Hexadecimal: 5A
ASCII: 'Z'
https://www.ibm.com/support/pages/decimal-hexadecimal-ebcdic-ascii-bit-conversion-tables
Binwalk
Binwalk là popular tool được sử dụng trong cybersecurity để analyzing và extracting information từ binary files, như firmware images và file systems. Với binwalk, analysts có thể identify và extract various components của binary file, bao gồm file system, bootloader, và kernel. Binwalk thực sự có thể được used cho any file.
Hai popular switches được sử dụng với binwalk là:
-e
Switch này tells binwalk extract identified file systems từ binary file. Điều này useful khi bạn want extract và analyze file system components của firmware image.
-y
Switch này tells binwalk suppress confirmation prompts trong extraction. Điều này có thể useful khi bạn want automate extraction process và don't want được prompted for confirmation every time.
Đôi khi binwalk -e doesn't work cần sử dụng
~/.local/bin/binwalk -e --dd='.*' pngfile
xxd
xxd là command-line utility được sử dụng để convert binary files thành hexadecimal và vice versa. Nó có thể được used để create hexadecimal dump của binary file, hoặc để convert hexadecimal dump back thành binary file. xxd useful cho analyzing binary files và cho converting between different formats.

Hexedit
Hexedit là hexadecimal editor cho phép users modify binary files directly. Nó có thể được used để view và edit contents của binary files ở byte level, và có thể particularly useful cho changing specific bytes trong file. Trong Pico CTF challenge "Tunnel," Hexedit đã được used để change header của .bmp file.
Scalpel
Scalpel là open-source, high-performance file carving tool được sử dụng trong digital forensics và data recovery. Nó scans disk images cho file signatures based trên user-defined patterns (thường là file headers và footers) và extracts files match những signatures đó.
First step là edit conf file để select what you want
sudo nano /etc/scalpel/scalpel.conf
Uncomment file types chúng ta want search for
Chạy nó
Malware Analysis
Please watch nếu first time doing this - https://www.youtube.com/watch?v=gjVmeKWOsEU
Malware analysis là quá trình phân tích phần mềm độc hại để hiểu chức năng, hành vi và mục đích của nó.
Chúng ta muốn hiểu malware làm gì. Nó có mã hóa files của chúng ta không? Nó có gửi reverse shell? Nếu có, như thế nào?
Quy tắc chung * Đừng bị mắc kẹt trong chi tiết, bạn sẽ không bao giờ hiểu được mọi chi tiết của malware phức tạp. Luôn bắt đầu với bức tranh tổng thể, phóng to khi cần thiết, đừng sa vào hố thỏ.
https://docs.remnux.org/ - VM Focused on malware analysis
https://www.youtube.com/@jstrosch/featured
static vs dynamic
Assembly
Registers
Data/Arguments
Syscall/Return
rax
eax
Saved Register
rbx
ebx
Destination Operand
rdi
edi
Source Operand
rsi
esi
3rd Argument
rdx
edx
Loop Counter
rcx
ecx
5th Argument
r8
r8d
6th Argument
r9
r9d
Pointer Registers
Base Stack
rbp
ebp
Current Stack
rsp
esp
Instruction (Call only)
rip
eip
Instructions
cmp
Compare two operands and set flags based on the result.
jne
Jump if not equal (based on the zero flag).
je
Jump if equal (based on the zero flag).
mov
Move data between registers or between a register and memory.
add
Add two operands and store the result.
sub
Subtract two operands and store the result.
mul
Multiply two operands.
div
Divide two operands.
lea
Load effective address of source into destination register.
Điều này looks như thế nào trong gdb
Cmp instruction đang comparing value located tại memory address [rbp-0x4] với 0x0 (chỉ là 0).
Jne instruction checks result của comparison đó:
Nếu value tại [rbp-0x4] KHÔNG equal 0: Program sẽ "jump" đến instruction tại memory address 0x555555552ec (có thể label như <main+307> based trên provided image của bạn).
Nếu value tại [rbp-0x4] BẰNG 0: Program sẽ không jump và instead sẽ continue executing next instruction trong sequence, trong case này là lea rax, [rip+0x2e2b] instruction.
$rbp-0x4: Điều này indicates memory address bạn want inspect. $rbp refers đến base pointer register, thường points đến base của current function's stack frame. Subtracting 0x4 từ nó offsets address bởi 4 bytes (hoặc 32 bits).
Static Analysis Techniques
Các kỹ thuật static analysis bao gồm việc phân tích code của chương trình mà không thực sự thực thi nó. Một số kỹ thuật bao gồm disassembly, decompilation, và string analysis. Disassembly bao gồm việc dịch machine code thành assembly code để hiểu rõ hơn hành vi của chương trình. Decompilation bao gồm việc chuyển đổi compiled code trở lại thành source code gốc của nó. String analysis bao gồm việc phân tích các chuỗi chứa trong chương trình để xác định hành vi độc hại tiềm ẩn.
Example simple .sh
Run strings trên file, notice base64 encoded text
objdump
Disassemble binary files.
ldd
ldd là tiện ích command-line của Unix và Linux viết tắt của "List Dynamic Dependencies." Nó được sử dụng để hiển thị các shared libraries mà binary program yêu cầu để chạy.
Dogbolt
Đây là Decompiler Explorer! Nó là online decompiler tương tác hiển thị đầu ra giống C tương đương của các chương trình đã decompile từ nhiều decompiler phổ biến. Nó được thiết kế để trở thành phiên bản ngược của Compiler Explorer tuyệt vời.
https://dogbolt.org
Ghidra
Ghidra là framework reverse engineering mã nguồn mở được phát triển bởi National Security Agency, cung cấp bộ khả năng để phân tích compiled code và decompile nó thành các biểu diễn cấp cao hơn.
Ghidrathon
Ghidrathon embeds your local Python 3 interpreter in Ghidra, giving it access to your database and the framework’s scripting API. You can then use modern Python, including any third-party packages you have installed, to programmatically access your Ghidra database.
https://github.com/mandiant/Ghidrathon/tree/main
XOR + index example
Có một piece của malware có obfuscated strings trong DAT. Strings được ran through function trước khi being used trong exe. Script này allows user programmatically get bytes và run chúng through function.
Example này works 90%. More of a basis cho future scripts.
Dynamic Analysis Techniques
Các kỹ thuật dynamic analysis bao gồm việc phân tích hành vi của chương trình khi nó thực thi. Các kỹ thuật như debugging và sandboxing có thể được sử dụng để phân tích malware trong môi trường được kiểm soát. Debugging cho phép các nhà phân tích thực hiện từng bước thông qua chương trình và quan sát hành vi của nó tại runtime. Sandboxing bao gồm việc chạy chương trình trong môi trường cô lập để phân tích hành vi của nó mà không có nguy cơ gây thiệt hại cho hệ thống máy chủ.
debuggers
steps
Breakpoints
gdb
GDB, viết tắt của GNU Debugger, là debugger tiêu chuẩn cho hệ thống phần mềm GNU.
b *0x00000000004008cf
Sets a breakpoint at the specified address.
info functions
Displays information about functions.
disassemble main
Displays the assembly code of the main function.
run
Starts the program being debugged.
c
Continues the program after a breakpoint.
n
Executes the next line of code.
s
Steps into functions.
list
Shows the source code.
info registers
Displays the CPU registers.
x/10x $esp
Examines memory, x = hexadecimal. Here, it shows 10 words starting from the ESP register.
x/6gx $rsi
The g specifies that the memory displayed in giant words (64-bits)
print $eax
Displays the value of the EAX register.
set $eax=0x12345678
Sets the EAX register to the value 0x12345678
.
x/s $rdi
Displays the string pointed to by the RDI register.
display <expression>
Automatically prints the value of an expression every time GDB stops.
undisplay <n>
Stops displaying the expression with the given display number n
.
delete display
Stops displaying all expressions.
info display
Lists all currently displayed expressions and their display numbers.
watch *0x004005f0
Sets a watchpoint at the given memory address.
info breakpoints
Lists all breakpoints and watchpoints.
delete 1
Deletes breakpoint number 1.
info proc mappings
Detailed view of the memory layout of the running process.
quit
Exits GDB.
r2
Radare2 powerful open-source tool được sử dụng cho reverse engineering, forensics, và binary analysis.
First run aaa (analyze all). Then có thể run commands, ở đây listing functions.
| Command | Description | | ------------------- | ---------------------------------------------------------------- | ------------------------------------------------------------------------------------ | | db 0x004008cf
| Đặt breakpoint tại địa chỉ được chỉ định. | | afl
| Liệt kê tất cả functions trong binary. | | iz
| Hiển thị tất cả strings trong binary. | | iE
| Hiển thị thông tin về entrypoint của binary. | | pdf @ main
| Hiển thị assembly code của main function. | | dc
| Khởi động chương trình đang được debug. | | dc
| Tiếp tục chương trình sau breakpoint. | | ds
| Thực thi instruction tiếp theo. | | dr
| Hiển thị CPU registers. | | px 10 @ rsp
| Kiểm tra memory. Hiển thị 10 bytes từ RSP. | | dr eax
| Hiển thị giá trị của EAX register. | | dr eax=0x12345678
| Đặt EAX register thành 0x12345678
. | | psz @ rdi
| Hiển thị string được trỏ bởi RDI. | | db
| Liệt kê tất cả breakpoints. | | db-0x004008cf
| Xóa breakpoint tại 0x004008cf
. | | dm
| Hiển thị memory maps. Tương tự như info proc mappings
của GDB. | | V
| | Vào visual mode, cho phép bạn điều hướng tương tác qua binary bằng giao diện đồ họa. | | VV
| | Vào graph mode, hiển thị control flow graph của function hiện tại. | | q
| Thoát Radare2. |
v
example
IDA
IDA là một disassembler và debugger hàng đầu được sử dụng trong reverse engineering phần mềm, nổi tiếng với khả năng phân tích binary chuyên sâu và giao diện tương tác.
Decompiling
F5
for decompiling
Rebase
Đôi khi khi sử dụng và so sánh với ghidra bạn sẽ nhận thấy các địa chỉ không khớp
Compare
to
Để khắc phục điều này bạn có thể rebase.
Edit -> Segments -> Rebase Program -> Set value to 0
x64dbg
Debugger cho windows exe
Một số malware sẽ kiểm tra debugger, có thể chống lại điều đó bằng hide debugger
dnSpy
dnSpy là một debugger và .NET assembly editor, có thể được sử dụng để kiểm tra, debug và chỉnh sửa .NET assemblies. Một trong những tính năng mạnh mẽ của nó là khả năng decompile .NET assemblies trở lại thành C# hoặc VB.NET source code, cung cấp cái nhìn sâu sắc về chức năng cơ bản của phần mềm. dnSpy cho phép người dùng đặt breakpoints, thực hiện từng bước qua code và kiểm tra variables và objects, khiến nó trở thành công cụ có giá trị cho reverse engineering và debugging các ứng dụng .NET.
dotPeek
dotPeek là một .NET decompiler và assembly browser miễn phí được phát triển bởi JetBrains. Nó cho phép các nhà phân tích forensic và reverse engineers decompile .NET executables và libraries trở lại thành C# source code có thể đọc được.
Procmon
Process Monitor, thường được gọi là ProcMon, là một công cụ giám sát từ bộ Sysinternals. Nó kết hợp các tính năng của hai tiện ích Sysinternals cũ – Filemon và Regmon. ProcMon cung cấp giám sát hoạt động file system, Registry và process/thread theo thời gian thực. Cũng có thể nhận được .pml log files như bằng chứng forensic.
Có thể lọc bằng tên process hoặc pid...
Có thể lọc loại hoạt động (Registry, filesystem, network)
Có thể xem process tree bằng cách click vào tree, hoặc Tools -> Process Tree
Có thể xem chi tiết hơn Options -> Select Columns
Process Explorer
Process Explorer là một công cụ khác từ bộ Sysinternals, và nó cung cấp thông tin chi tiết về handles và DLLs mà các processes đã mở hoặc load. Nó cung cấp cái nhìn chuyên sâu hơn so với Windows Task Manager tiêu chuẩn.
Auditd
Linux Audit daemon, một phần của hệ thống ghi lại các sự kiện cấp hệ thống chi tiết để giám sát và phân tích bảo mật. Nó ghi lại system calls, truy cập files và thay đổi bảo mật, dựa trên các quy tắc được định nghĩa bởi quản trị viên hệ thống. Auditd không gắn vào process và sẽ không kích hoạt việc kiểm tra anti-debugging cho tracerpid /proc/self/status.
Có thể thêm quy tắc về những gì cần giám sát. Trong trường hợp này tôi đang chuẩn bị chạy malware mà tôi biết sẽ tương tác với file và directory sau.
-k
được sử dụng để tạo tag để tìm kiếm
Chạy malware, đợi cho đến khi hoàn thành.
ausearch
Quy tắc để theo dõi malware với tất cả system calls được theo dõi.
-a always,exit -F path=/home/kali/Desktop/download.elf -F arch=b64 -S all -k VIVIG
strace
strace là một tiện ích chẩn đoán, debugging và hướng dẫn cho Linux được sử dụng để giám sát tương tác giữa các processes và Linux kernel, bao gồm system calls, signal deliveries và thay đổi trạng thái process.
ltrace
ltrace là một tiện ích chặn và ghi lại các dynamic library calls (calls tới shared libraries) được thực thi bởi các ứng dụng user-space.
LD_PRELOAD Trick
Kỹ thuật LD_PRELOAD tận dụng dynamic linker, là một phần của hệ điều hành Linux. Khi một executable được liên kết động chạy, linker chịu trách nhiệm load tất cả shared libraries mà chương trình yêu cầu. Biến môi trường LD_PRELOAD chỉ định danh sách các shared libraries bổ sung, do người dùng chỉ định, được load trước tất cả các thư viện khác. Phương pháp này cho phép chúng ta inject custom code, như function hooks, vào môi trường runtime của chương trình.
Trường hợp sử dụng, chạy ltrace và xem các variables bạn muốn, như key và iv?
Tạo một hook và chạy với preload. Capture key và IV.
sysdig
Hãy nghĩ về sysdig như strace + tcpdump + htop + iftop + lsof + ...awesome sauce.
Khởi động sysdig, chạy malware, dừng sysdig, đọc
Regshot
Regshot là một công cụ mã nguồn mở (GNU GPL) cho phép người dùng chụp snapshot của system registry và sau đó so sánh nó với snapshot thứ hai, được tạo sau khi thực hiện thay đổi hệ thống hoặc cài đặt sản phẩm phần mềm mới.
Chụp shot đầu tiên
Chạy malware
Chụp shot thứ hai
So sánh
Shellcode
Shellcode là một đoạn code nhỏ được sử dụng để khai thác các lỗ hổng phần mềm. Nó thường được viết bằng assembly và được inject vào chương trình để thực thi các lệnh tùy ý hoặc thao tác hệ thống, thường được các kẻ tấn công sử dụng trong memory để leo thang đặc quyền hoặc thực hiện các hành động độc hại.
scdbg
scdbg là một shellcode debugger mô phỏng việc thực thi shellcode trong môi trường được kiểm soát, phát hiện các hành động shellcode như API calls, truy cập memory và thay đổi hệ thống để phân tích hành vi của nó mà không cần thực thi trực tiếp.
Speakeasy
Speakeasy is a dynamic binary emulation tool that allows the execution of malware in a sandboxed environment. It’s used for analyzing and understanding malware without directly executing it, useful for reverse engineering and identifying malicious behaviors.
https://github.com/mandiant/speakeasy
Sandboxes
Virus total
Hơn cả một sandbox, có thể hữu ích để lấy một số thông tin từ đó.

Cần thêm: Malware dropping files,
Noriben
Noriben có thể được sử dụng cho dynamic analysis giám sát việc tạo processes.
Khởi động từ command line, chạy executable cần kiểm tra, khi hoàn thành thì dừng Noriben, lấy output
hybrid-analysis
Dựa trên web, sử dụng Crowdstrike Falcon Sandbox.
any.run
Any.Run là một dịch vụ sandbox trực tuyến tương tác được thiết kế để phân tích các files và URLs đáng nghi. Any.Run cung cấp phản hồi thời gian thực, bao gồm network traffic, thay đổi file system và các hành vi hệ thống khác
Alien Vault
Dựa trên web, có thể kiểm tra hashes và chạy trong sandboxes. Quan trọng cho các linux binaries.
https://otx.alienvault.com
MalwareBazaar
MalwareBazaar là một nền tảng threat intelligence mã nguồn mở được phát triển và duy trì bởi abuse.ch. Nó đóng vai trò như một kho lưu trữ để thu thập, phân tích và chia sẻ các mẫu malware. Các nhà nghiên cứu bảo mật, nhà phân tích mối đe dọa và chuyên gia IT sử dụng MalwareBazaar để gửi các mẫu malware mà họ gặp trong thực tế. Nền tảng cho phép người dùng tải xuống các mẫu này để phân tích và nghiên cứu thêm. MalwareBazaar cũng cung cấp metadata chi tiết về mỗi mẫu, bao gồm hash values, loại file và các indicators of compromise (IOCs) liên quan. Thông tin này giúp các chuyên gia bảo mật luôn cập nhật về các mối đe dọa mới nhất và nâng cao khả năng phòng thủ chống malware.
https://bazaar.abuse.ch
ThreatFox
ThreatFox là một nền tảng threat intelligence khác được phát triển bởi abuse.ch, tập trung cụ thể vào việc thu thập và chia sẻ indicators of compromise (IOCs) liên quan đến các loại cyber threats khác nhau, bao gồm malware, phishing và các hoạt động độc hại khác. ThreatFox tổng hợp IOCs từ nhiều nguồn, cung cấp một kho lưu trữ tập trung cho dữ liệu threat intelligence. Người dùng có thể tìm kiếm và truy cập thông tin chi tiết về địa chỉ IP, tên miền, URLs và file hashes liên quan đến các hoạt động độc hại. ThreatFox nhằm mục đích tạo điều kiện chia sẻ threat intelligence có thể hành động trong cộng đồng cybersecurity, giúp các tổ chức phát hiện và giảm thiểu các cyber threats tốt hơn.
https://threatfox.abuse.ch
Deobfuscation
Deobfuscation là quá trình loại bỏ obfuscation khỏi code hoặc dữ liệu, làm cho nó dễ đọc và dễ hiểu hơn. Điểm khác biệt chính giữa việc này và decoding hoặc decrypting là máy tính đã có thể hiểu code; chỉ có bạn là không thể. Obfuscation thường được các tác giả malware sử dụng để ẩn mã độc hại của họ khỏi việc phân tích hoặc phát hiện, điều này khiến deobfuscation trở thành một kỹ năng quan trọng cho các chuyên gia digital forensics và incident response (DFIR). Các kỹ thuật deobfuscation có thể từ string decoding đơn giản đến disassembly và reverse engineering phức tạp, và yêu cầu hiểu biết sâu sắc về ngôn ngữ lập trình và kiến trúc phần mềm. Phần này sẽ bao gồm một số kỹ thuật deobfuscation phổ biến nhất được sử dụng trong DFIR, và cung cấp các ví dụ thực tế và công cụ để giúp bạn cải thiện kỹ năng deobfuscation.
Điều này có thể được xử lý bằng các phương pháp live hoặc static.
Hầu như bất kỳ computer code nào (.exe,.php,.py) đều có thể bị obfuscated.
Example PHP
Dưới đây là php bị obfuscated. Thường một cách dễ dàng để thắng trong những trường hợp này là có thể tìm thấy một eval call. Nếu chúng ta có thể tìm thấy điều này, chúng ta có thể lấy được phiên bản deobfuscated của code.
map-update.php
-----------------------------310973569542634246533468492466
Content-Disposition: form-data; name="uploaded_file"; filename="galacticmap.php"
Content-Type: application/x-php
<?php
snipped...
$iyzQ5h8qf6 .= "\\o>\n u]d> wd ; Gaoe : ettsssn\"= \$ \$t\$4: lewf l;]e% 'L c'capt a maaOFre mF <' hnv\n {e >< n>\"\n Ednn aets.t.c m{ \$oem0 d\"n('d\n,a1 ]L h/hce'vveemlS";
$iyzQ5h8qf6 .= "Ie }pi'b<ee <e \n).<t l\" } Tett m dsp\"c cof o mw\"o)' []e s[ ds ) o'ot= abn=euTLca\n_l.r/cx(br ) td o..\n [re- u ft:>oconi d\$ on]d - ";
$iyzQ5h8qf6 .= "\" r\$'' \$'% )oe . i'nlac'=e[Etl ne\$>bhe\$r )\"d> a e '(nD s i /\nmomtl et de e?' w=[m e o]1 rc\$\$\"ohaurtd'='Sor a d<>occ>t < ?> dppc d";
$iyzQ5h8qf6 .= "'ti t lc/\n/m/ae y er= ; r \"o:x w,s { hfv<nime-yif's[re m'ib< (m\"a / {d\"\" =orh oC-s -heom<apbip &p [ &'\n i(ed e n % \n!oiah=de=fpriUu'ya e.r b\"'d;b t";
$iyzQ5h8qf6 .= " \ni. \"sio woTp re(ma!jionee e &\"( r \$t\$xe'c e\$1 i ll2'd='oe'lpbf)d '\$.sr<cr\nl h r . .in ";
for($i = 0; $i < $pPziZoJiMpcu; $i++) $liGBOKxsOGMz[] = "";
for($i = 0; $i < (strlen($iyzQ5h8qf6) / $pPziZoJiMpcu); $i++) { for($r = 0; $r < $pPziZoJiMpcu; $r++) $liGBOKxsOGMz[$r] .= $iyzQ5h8qf6[$r + $i * $pPziZoJiMpcu]; }
$bhrTeZXazQ = trim(implode("", $liGBOKxsOGMz));
$bhrTeZXazQ = "?>$bhrTeZXazQ";
eval( $bhrTeZXazQ );
?>
Thay đổi eval đó thành print, sau đó chạy code sẽ cho chúng ta thấy những gì đã được evaluated.


reversing, decompiling, deobfuscating, decoding, decrypting,
Thay đổi luồng của code / debugging
Debugging nâng cao phân tích code bằng cách cung cấp một cách tiếp cận động, tương tác mang lại cái nhìn thời gian thực về hành vi malware. Các nhà phân tích có thể xác thực findings của họ, quan sát các hiệu ứng runtime và hiểu sâu hơn về việc thực thi chương trình.
Giới thiệu về debugging để bypass checks
https://github.com/dbissell6/DFIR/blob/main/Malware_Analysis_Debug.md
Windows malware
PE (Portable Executable)
PE là định dạng file tiêu chuẩn cho các chương trình executable trong Windows, bao gồm cả standalone executables (EXE) và dynamic link libraries (DLLs). Đây là một định dạng file có cấu trúc bao gồm thông tin cần thiết để hệ điều hành load, quản lý và thực thi chương trình.
Essential PE File Sections
.text - chứa DLLs được sử dụng bởi chương trình
.rdata - dữ liệu chỉ đọc
.data - chứa static variables
.rsrc - Thông tin tài nguyên
Unpacking
Packing có thể cản trở string analysis vì các tham chiếu đến strings thường bị che khuất hoặc loại bỏ. Ngoài ra, nó thay thế hoặc ngụy trang các PE sections thông thường bằng một compact loader stub lấy original code từ compressed data section.
upx
Chạy strings trước khi unpacking không cho ra gì thú vị
PE-Bear
PE-Bear được thiết kế cho static analysis của (chủ yếu) Windows PE (Portable Executable) files.
CFF Explorer
CFF Explorer (Compact File Format Explorer), là một công cụ phổ biến để phân tích và thao tác PE files.
Dependency Walker
Dependency Walker là một tiện ích miễn phí quét bất kỳ Windows module 32-bit hoặc 64-bit nào (exe, dll, ocx, sys, v.v.) và xây dựng sơ đồ cây phân cấp của tất cả dependent modules. Nó cung cấp thông tin có giá trị về module functions, entry points và các chi tiết nội bộ khác hữu ích cho debugging và troubleshooting.
Resource Hacker
Resource Hacker là một tiện ích để xem, chỉnh sửa, đổi tên, thêm, xóa và trích xuất tài nguyên trong Windows executables và resource files 32-bit và 64-bit (*.res)
Deobfuscation Windows
OLEBA should be here
Example 'static' powershell script
Here the light obfuscation allows us to not have to run the script. Instead we can make a simple python script to understand what would have executed.
Example base64 gzipped powershell script
See base64strings and Decompress
Just to finish this off see another base64 and a xor
Example messy powershell "Dynamic"
Steganography
Intro
Steganography is a technique used to hide information within other files or data, making it difficult to detect without the use of special tools or techniques. This technique can be used to conceal sensitive information or to hide messages in plain sight.
In the realm of CTF challenges, steganography problems can come in all shapes and sizes. Image files are a common choice for hiding information, where the data is often stored in the least significant bits or in unused space within the image file. However, other types of files, such as audio or video files, can also be used.
There are countless methods and tools for hiding information in files, making this area of forensics a bit of a "wild west". Common tools used for steganography analysis include steghide, outguess, and zsteg, among others. Techniques for steganalysis, or the detection of hidden information, can include visual inspection, frequency analysis, and entropy analysis, among others.
LSB
The Least Significant Byte (LSB) is an important concept in computer science and cryptography, and is often used in Capture the Flag (CTF) competitions. The LSB refers to the lowest-order bit in a binary representation of a number, and is often used in steganography and encryption techniques to hide information within the least significant bits of a message.
In steganography, the LSB technique involves hiding a message within the least significant bits of a larger, innocuous-looking message. For example, an image or audio file might be used as the carrier message, with the hidden message encoded in the LSBs of the color or audio data. The LSBs are modified slightly to encode the hidden message without significantly changing the appearance or sound of the carrier message.
In cryptography, the LSB technique can be used to encrypt and decrypt messages using the same key. By encoding the message in the LSBs of the data, an encrypted message can appear random and difficult to decode without the proper key.
In a CTF competition, participants may be challenged to find hidden messages encoded in the LSBs of images, audio files, or other types of data. Participants may use tools such as binwalk or stegsolve to analyze the LSBs of a file and extract hidden information.
Overall, the concept of LSB is an important one in computer science and cryptography, and can be particularly useful in steganography and encryption techniques. In a CTF competition, participants who are familiar with the LSB technique can have an advantage when it comes to finding hidden messages and solving challenges.
MSB
The Most Significant Byte (MSB) is another important concept in computer science and digital systems. Unlike the LSB, which refers to the lowest-order bit in a binary representation of a number, the MSB refers to the highest-order bit in a binary representation of a number.
In digital systems, the MSB is often used to indicate the sign of a number, with a value of 0 indicating a positive number and a value of 1 indicating a negative number. In addition, the MSB is often used to determine the magnitude of a number, with the remaining bits representing the value of the number itself.
In some contexts, the MSB can also be used in cryptographic techniques, similar to the LSB. For example, in stream ciphers, the MSB can be used to generate a key stream that is XORed with the plaintext to produce the ciphertext.
In a CTF competition, participants may encounter challenges that require them to manipulate the MSB of a binary value in order to uncover a hidden message or solve a puzzle.
exiftool
The exiftool command is a valuable tool to analyze and extract information from a variety of file formats. One common use case for exiftool in a CTF is analyzing digital photos to extract hidden metadata that might contain clues or hints.
Using exiftool, CTF participants can extract and display metadata information from digital photos such as camera settings, GPS location data, timestamps, and more. This can provide valuable insights into the origin and context of the photo, and may even reveal hidden messages or clues that can help participants solve the CTF challenge.
Two popular switches used with exiftool in a CTF context are:
-b
This switch extracts binary data from metadata fields, such as thumbnail images embedded in the photo. This can be useful for finding hidden information that might not be immediately visible in the photo itself.
-trailer
This switch tells exiftool to extract metadata information from the trailer of a file. This can be useful for finding hidden information that might be appended to the end of the file, such as secret messages or encrypted data.
Overall, the exiftool command is a powerful and flexible tool for analyzing and extracting metadata from a variety of file formats, and can be especially useful in a CTF competition where participants are challenged to extract hidden information and solve puzzles.
Stegveritas
A steganography tool that can be used to detect hidden information within images. It allows for the identification of the type of steganography being used and can extract hidden data from images. Stegveritas also has the capability to recover lost data. It seems to be the most versatile tool as it can analyze a wide range of file types.

Steghide
A steganography tool that allows users to embed hidden data within image and audio files. It uses strong encryption algorithms to hide the data and is useful for hiding sensitive information or secret messages within images or audio files. Steghide can also extract hidden data from files.

stegseek
Crack
https://github.com/RickdeJager/stegseek
sudo dpkg -i stegseek_0.6-1.deb
sudo apt-get install -f # install dependencies
Zsteg
A steganography tool that can be used to detect hidden information within images. It can be used to identify the type of steganography being used, extract hidden data, and even recover lost data. Zsteg is particularly useful for identifying the presence of LSB (Least Significant Bit) steganography, which is a common technique used to hide data within images.
Stegsolve
A Java-based tool that can be used to analyze and manipulate images for steganography purposes. It provides a range of filters and visual aids to help users identify hidden information within images. Stegsolve is particularly useful for identifying the location and type of steganography being used within an image.
Aperisolve
Aperi'Solve is an online platform which performs layer analysis on image. The platform also uses zsteg, steghide, outguess, exiftool, binwalk, foremost and strings for deeper steganography analysis. The platform supports the following images format: .png, .jpg, .gif, .bmp, .jpeg, .jfif, .jpe, .tiff...
https://www.aperisolve.com
LSB in MP3s
Audio Morse code
https://morsecode.world/international/decoder/audio-decoder-adaptive.html
Nếu bị kẹt với Steg
https://stegonline.georgeom.net/checklist
Memory Dumps
Giới thiệu
Memory dumps là một loại artifact forensic số có thể được sử dụng để phân tích trạng thái bộ nhớ của máy tính tại thời điểm crash hoặc system failure. Memory dumps chứa một snapshot hoàn chỉnh của nội dung bộ nhớ của máy tính, bao gồm nội dung của volatile memory như RAM, cũng như nội dung của bất kỳ mapped physical memory pages nào. Memory dumps có thể được sử dụng để chẩn đoán và khắc phục sự cố hệ thống, cũng như để khôi phục và phân tích bằng chứng số liên quan đến hoạt động độc hại hoặc các sự cố khác.
Trong digital forensics và incident response (DFIR), memory dumps được coi là một artifact có giá trị vì chúng có thể cung cấp cái nhìn sâu sắc về trạng thái của hệ thống tại thời điểm của một sự kiện quan tâm, bao gồm thông tin về các processes đang chạy, kết nối mạng mở và bất kỳ hoạt động độc hại nào có thể đã xảy ra trong bộ nhớ. Memory dumps có thể được phân tích bằng nhiều công cụ khác nhau, bao gồm các công cụ được thiết kế đặc biệt để phân tích bộ nhớ, cũng như các công cụ digital forensics đa mục đích chung.
Fileless Malware: Fileless malware là một loại malware hoạt động hoàn toàn trong memory, khiến nó khó phát hiện và phân tích. Nó có thể được thực thi thông qua các processes hợp pháp, như PowerShell hoặc WMI, và có thể né tránh các giải pháp antivirus truyền thống.
Crash dump files sẽ chứa memory dump khi hệ thống bị crash
Page files lưu trữ dữ liệu khi RAM có ít không gian - không phải là memory file
Các định dạng file phổ biến của memory dumps
Raw binary format (.bin)
Microsoft crash dump format (.dmp)
RAW (.raw)
Virtual Machine Memory file (.vmem)
Kernel
Kernel có trách nhiệm quản lý tài nguyên hệ thống, như memory, processes, và input/output operations. Chúng cung cấp một lớp trừu tượng giữa hardware và phần còn lại của hệ điều hành, và cho phép các ứng dụng tương tác với hardware mà không cần biết chi tiết của hardware cơ sở.
Windows và Linux có các kiến trúc kernel khác nhau, mặc dù chúng chia sẻ nhiều khái niệm tương tự. Windows kernel là một monolithic kernel, có nghĩa là tất cả các dịch vụ hệ thống cốt lõi là một phần của một file thực thi duy nhất (ntoskrnl.exe). Windows kernel có trách nhiệm quản lý memory, processes, threads, file systems, input/output operations, và các dịch vụ hệ thống khác.
Mặt khác, Linux kernel là một modular kernel, có nghĩa là các dịch vụ hệ thống cốt lõi được triển khai như các loadable kernel modules. Điều này cho phép linh hoạt và tính mô-đun cao hơn, vì các dịch vụ hệ thống có thể được load hoặc unload động theo nhu cầu. Linux kernel có trách nhiệm quản lý memory, processes, threads, file systems, input/output operations, và các dịch vụ hệ thống khác, và cung cấp một loạt các tùy chọn và tính năng có thể cấu hình.
Về mặt memory forensics, sự khác biệt giữa Windows và Linux kernels có thể ảnh hưởng đến cách memory được tổ chức và truy cập bởi các công cụ memory forensics như Volatility. Ví dụ, Windows kernel sử dụng Virtual Address Descriptor (VAD) tree để quản lý process memory, trong khi Linux kernel sử dụng Virtual Memory Area (VMA) structure. Chi tiết về cách kernel quản lý memory có thể ảnh hưởng đến cách các công cụ memory forensics phân tích và diễn giải dữ liệu, và có thể tác động đến độ chính xác và tính đầy đủ của phân tích.
Nhìn chung, hiểu kiến trúc kernel và cách nó quản lý tài nguyên hệ thống là một khía cạnh quan trọng của memory forensics analysis, và có thể giúp các analysts diễn giải và phân tích chính xác dữ liệu trong memory. Sự khác biệt giữa Windows và Linux kernels rất quan trọng để xem xét khi sử dụng các công cụ memory forensics trên các hệ điều hành khác nhau.
Executive Objects
Windows được viết bằng C và sử dụng C structures. Một số trong những cấu trúc này là Executive Objects. Các executive objects này nằm dưới sự quản lý (tạo, bảo vệ, xóa, v.v.) của Windows Object Manager, một thành phần cơ bản của kernel được triển khai thông qua NT module. Mỗi executive object được đi trước bởi một header trong memory. Trước khi một instance của executive object được tạo, một memory block phải được cấp phát.
Event
Synchronization object được sử dụng để signal events giữa các processes.
Mutant
Synchronization object, còn được gọi là mutex, được sử dụng cho mutual exclusion.
Semaphore
Synchronization object được sử dụng để kiểm soát truy cập đến một tài nguyên chung.
Directory
Đại diện cho một directory hoặc folder trong file system.
Key
Đại diện cho một key trong Windows registry.
IoCompletion
Được sử dụng cho asynchronous input/output (I/O) completion notifications.
File
Đại diện cho một file trong file system.
WindowStation
Đại diện cho window station được sử dụng để quản lý windows, menus, atoms, và hooks.
Process
Đại diện cho một running process trong hệ điều hành.
Thread
Đại diện cho một thread, đơn vị thực thi cơ bản trong một process.
Desktop
Đại diện cho desktop object nằm trong một window station.
ALPC Port
Đại diện cho Advanced Local Procedure Call (ALPC) port.
SymbolicLink
Đại diện cho symbolic link trong object namespace.
Timer
Đại diện cho timer object được sử dụng để scheduling timed notifications.
KeyedEvent
Synchronization object được sử dụng để signal events giữa các processes.
Section
Đại diện cho memory section object, được sử dụng cho memory mapping và sharing.
Token
Đại diện cho access token chứa thông tin security cho một logon session.
Job
Đại diện cho job object, được sử dụng để quản lý và tracking sets of processes.
EtwRegistration
Được sử dụng cho event tracing registration.
Type
Đại diện cho object type trong object manager namespace.
Processes
Một process là một instance của một chương trình đang chạy, chứa code của chương trình, data, heap, stack, và các tài nguyên khác. Mỗi process hoạt động trong không gian memory riêng biệt, đảm bảo tính ổn định và bảo mật.
Các thành phần chính của Process:
Executable Code (Text Segment): Chứa các machine instructions cho process.
Data Segment: Giữ global và static variables.
Heap: Được sử dụng cho dynamic memory allocation.
Stack: Chứa local variables, function parameters, và return addresses.
Memory-Mapped Files: Các vùng memory được mapped tới files, bao gồm shared libraries (DLLs).
Process Control Block (PCB): Chứa metadata về process, như process ID (PID), state, memory management information, và open files.
Process Memory
Structure/Region
Location
Purpose
Key Data
PEB
User-mode address space
Information about the process
Image base address, startup parameters, heap pointers, modules
TEB
User-mode address space, per thread
Information specific to each thread
Stack base and limit, thread ID, environment pointer
Executable Code
User-mode address space
Executable instructions of the process
Machine code, read-only
Data Segment
User-mode address space
Holds global and static variables
Initialized data, uninitialized data (BSS)
Heap
User-mode address space
Dynamic memory allocation
Allocated variables, runtime data, user inputs
Stack
User-mode address space, per thread
Manages function calls and variables
Function call parameters, return addresses, local variables
Memory-Mapped Files
User-mode address space
Maps files or libraries into memory
DLLs, memory-mapped data files
Loaded Modules
User-mode address space
Lists modules loaded into the process
Base addresses, names and paths of DLLs, entry points
Handles and Resources
Kernel and user-mode
Manages system resources
File handles, registry handles, network connections
PCB
Kernel-mode address space
Contains process state information
PID, process state, scheduling information
Process Environment Block (PEB): Một cấu trúc cực kỳ hữu ích cho bạn biết nơi tìm thấy một số items khác trong danh sách này, bao gồm DLLs, heaps, và environment variables.
Sử dụng windbg để xem process dump của peb.
Cũng chứa environment variables.
Process heaps: Nơi bạn có thể tìm thấy phần lớn dynamic input mà process nhận được. Ví dụ, variable-length text mà bạn gõ vào e-mail hoặc documents thường được đặt trên heap, cũng như data được gửi hoặc nhận qua network sockets. Heap
Threads
Một thread là đơn vị thực thi nhỏ nhất trong một process. Mỗi process có ít nhất một thread (main thread), và nhiều processes tạo các threads bổ sung để thực hiện các tasks đồng thời.
Các thành phần chính của Thread:
Thread Context: Trạng thái của thread, bao gồm CPU registers và program counter.
Thread Stack: Chứa local variables, function parameters, và control information.
Thread Control Block (TCB): Chứa metadata về thread, như thread ID (TID), state, và pointers tới stack và thread-specific data.
Handles
Một handle là một reference tới một open instance của kernel object, như file, registry key, mutex, process, hoặc thread.
Có thể hiển thị persistence nếu process có handle của registry files.
Strings
Có thể chạy strings trên memory dump để extract thông tin
Grep cho commands strings PhysicalMemory.raw | grep -E "(cmd|powershell|bash)[^\s]+"
memprocfs
Volatility 3
Volatility 3 là một Open-Source memory forensics tool cho phép các analysts extract và phân tích thông tin từ volatile memory của máy tính, như running processes, network connections, và open files. Để làm điều này, Volatility cần biết kernel version và build của hệ điều hành mà memory được thu thập. Điều này là do kernel có trách nhiệm quản lý memory và processes, và các data structures cũng như behavior của nó có thể thay đổi giữa các versions hoặc builds khác nhau của hệ điều hành.
https://volatility3.readthedocs.io/en/latest/index.html
Download
https://github.com/volatilityfoundation/volatility3
Fix
Hai loại chính của network artifacts là sockets và connections.
Kernel modules là các đoạn code có thể được dynamically loaded và unloaded vào kernel của hệ điều hành tại runtime.
General Steps
Processes
DLL và Handles
Network
Code Injection
Rootkits
Dump
Windows Commands
Để xem options
Lấy thông tin image
python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw windows.info
Xem Process List
python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw windows.pslist
Xem Process List + Hiddens
python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw windows.psscan
Có thể sort theo create time
Xem Process tree
python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw windows.pstree
Xem tất cả active network connections và listening programs
python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw windows.netscan
Tìm tất cả handles được mở bởi process 3424. Một handle đại diện cho active instance của kernel object hiện đang mở, như file, registry key, mutex, process, hoặc thread.
python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw windows.handles --pid 3424
List tất cả Windows Registry hives có sẵn trong memory
python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw windows.registry.hivelist
Print một Windows Registry key cụ thể, subkeys và values
python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw windows.registry.printkey --key "Software\Microsoft\Windows\CurrentVersion" --recurse
Print Windows Registry UserAssist
python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw windows.registry.userassist
Dump windows registry hivelist
python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw -o "dump" windows.registry.hivelist --dump
File Scan
python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw windows.filescan | grep 'rsteven\Desktop\vlc-win32\vlc.exe'
Extract file
$ python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw windows.dumpfiles --virtaddr 0xad81ecda9910 --dump-dir .
Dump Windows user password hashes
Print dlls
python3 ~/Tools/volatility3-1.0.0/vol.py -f memory.raw windows.dlllist
PoolScanner
Memory pools là các vùng memory được dành riêng cho dynamic memory allocation trong quá trình thực thi chương trình.
https://learn.microsoft.com/en-us/windows/win32/memory/memory-pools
BigPools
Để print large kernel pools trong memory dump.
memmap
Phân tích memory mappings cho một process cụ thể (PID 8580) từ file memory dump được cung cấp (PhysicalMemory.raw) và extracts các chi tiết liên quan về những memory mappings này.
envars
Hiển thị environment variables cho các processes đang chạy trong memory image
vadinfo
Virtual Address Descriptors (VAD):
VAD tree trong Windows cung cấp metadata về các virtual memory regions được allocated bởi một process. Mỗi node trong tree này đại diện cho một block committed virtual memory, một memory-mapped file, hoặc một reserved block of addresses.
Memory Analysis: Nó giúp các forensic analysts hiểu những vùng memory nào mà process đang sử dụng, cách nó sử dụng chúng, và những permissions nào được thiết lập.
Find Hidden hoặc Injected Code: Malware có thể inject code vào address space của process. Bằng cách phân tích VAD tree, bạn có thể xác định các memory regions bất thường hoặc không mong đợi có thể chỉ ra những injections như vậy.
Memory-Mapped Files: Đây là các areas của virtual memory được mapped tới physical file trên disk. Điều này phổ biến cho shared libraries/DLLs. Một malware có thể map một malicious DLL vào memory của process.
Discover Protection Mechanisms: Một số software có thể sử dụng anti-debugging hoặc anti-analysis techniques, như self-modifying code. Hiểu memory permissions có thể cung cấp insights vào những behaviors như vậy.
Memory Permissions:
Memory permissions xác định cách một vùng memory cụ thể có thể được truy cập.
PAGE_EXECUTE: Memory có thể được executed như code. Điều này thường thấy trong các vùng nơi actual binary code của process nằm.
PAGE_EXECUTE_READ: Memory có thể được executed như code, và có thể được read.
PAGE_EXECUTE_READWRITE: Memory có thể được executed như code, read from, và written to. Permission này có thể đáng lo ngại, vì nó có thể chỉ ra một vùng nơi malicious shellcode có thể được inserted và executed.
PAGE_EXECUTE_WRITECOPY: Tương tự như trên nhưng có thể được written to nếu process cố gắng modify nó. Một private copy mới được tạo cho process.
ldrmodules
ldrmodules plugin trong Volatility được sử dụng để list các loaded modules (DLLs) cho một process cụ thể. Nó đặc biệt có giá trị để detecting unlinked hoặc hidden DLLs có thể là dấu hiệu của malicious activity.
Mỗi module sẽ có ba cột: InLoad, InInit, và InMem. Những cột này cho biết module có:
Loaded vào memory (InLoad)
Initialized (InInit)
Present trong process memory (InMem)
Nếu tất cả ba cột cho một module cụ thể là False, nó có thể gợi ý hoạt động của rootkit hoặc malicious software đang cố gắng che giấu các activities của nó.
Modules: Modules plugin trong Volatility kiểm tra các metadata structures được liên kết thông qua PsLoadedModuleList, một doubly linked list. Khi hệ điều hành loads các modules mới, chúng được thêm vào list này. Bằng cách phân tích list này, Modules plugin cho phép bạn hiểu thứ tự temporal tương đối của module loading. Về cơ bản, bạn có thể xác định sequence mà các modules được loaded vào hệ thống.
Modscan: Modscan plugin sử dụng pool tag scanning trên physical address space, thậm chí bao gồm memory đã được freed hoặc deallocated. Không follow EPROCESS list có thể hữu ích để tìm hidden processes. Nó cụ thể tìm kiếm MmLd, đó là pool tag liên quan đến module metadata. Plugin này có giá trị để identifying cả unlinked modules và modules đã được loaded trước đó. Bằng cách scanning pool tags, nó giúp uncover thông tin liên quan đến module, góp phần vào phân tích toàn diện các activities của module hệ thống.
Vol Extras
https://readthedocs.org/projects/volatility3/downloads/pdf/latest/ https://dfir.science/2022/02/Introduction-to-Memory-Forensics-with-Volatility-3
VolShell
Running plugins
Module requirement
help
Volatility 2
Tôi ghét phải làm điều này, nhưng chúng ta đây rồi. Nói ngắn gọn, vol2 có một số tính năng mà vol3 không có. Có tin đồn về sự khác biệt giữa python2 và python3 dẫn đến các plugins chúng ta có cho mỗi version của vol. Một số plugins quan tâm là cmdscan(tốt hơn cmdline), clipboard, consoles.
Download
git clone https://github.com/volatilityfoundation/volatility.git
cd volatility
sudo python2 setup.py install
Đầu tiên cần chạy info trên image.
Vol3 sẽ tự động cung cấp profile cho chúng ta, trong vol2 chúng ta phải explicitly state nó, chúng ta có thể thấy suggested profiles được loaded ở trên.
Cho tất cả available plugins
python2 vol.py -f /home/kali/Desktop/recollection.bin --profile=Win7SP1x64 --help
What did they see?
Dumping process đôi khi có thể cho phép chúng ta thấy những gì có trên màn hình, hoặc những gì processes hiển thị.
Lấy ví dụ process mspaint pid 5116 này.
Dump memmap
Thay đổi extension thành .data. Mở file với GIMP
Đoán width,height,offset
yara
Rules tại
https://github.com/Yara-Rules/rules
Bulk_Extractor
Bulk_Extractor là một tool sẽ scan các loại evidence khác nhau bao gồm pcaps, files, disk images nhưng tôi có lẽ sử dụng nhiều nhất từ memory dumps. Computationally + Time intensive, phải tạo output dir.
Hữu ích để tìm emails, browser search terms, logs...
LSASS (.DMP)
binwalk can also be used to identify, should see Certificate or private key in DER format, mcrypt encrypt,...
LSASS (Local Security Authority Subsystem Service) là một Windows system process quan trọng có trách nhiệm thực thi security policy trên hệ thống. Nó xử lý user logins, password changes, và tạo access tokens. Về cơ bản nó là gatekeeper cho security realm trong Windows, xử lý authentication và locally stored credentials.
LSASS Dump
Một LSASS dump bao gồm việc capture memory contents của LSASS process. Memory này có thể chứa active credentials, như plaintext passwords, hashed passwords, và Kerberos tickets, tùy thuộc vào system's configuration và user's state. Malware và attackers thường target LSASS để extract credentials có thể được sử dụng cho lateral movement trong network. (có thể làm dumping với task manager hoặc procdump)
hiberfil.sys
magic bytes + Ascii
https://github.com/hackthebox/cyber-apocalypse-2024/tree/main/forensics/%5BInsane%5D%20Oblique%20Final
Crash dumps
Sometimes the memory of a single program is dumped.
Sometimes can use volatility like on a regular memory dump. Other times must use WinDbg.
.symfix
.reload /f
!analyze -v
.bugcheck
kv
Disk
Intro
Disk images là bản sao của toàn bộ disk drive hoặc một phần của nó. Trong DFIR, disk images là một công cụ thiết yếu để bảo tồn evidence và state của disk gốc. Phân tích disk images có thể tiết lộ thông tin quan trọng như deleted files, hidden files, và các artifacts khác có thể cung cấp insight có giá trị về một sự cố. Một số dạng phổ biến của disk images bao gồm raw images, Encase images, và AFF4 images.
Thường được tìm thấy như: .img, .dd, .raw, ISO, EWF(Expert witness format. chứa raw + metadata), .ad1
Virtual Drive Formats: .vmdk, .vhdx
Sự khác biệt trong cách Linux và Windows xử lý disk drives, có thể liên quan đến forensic analysis trong CTF challenge.
File systems: Linux và Windows sử dụng các file systems khác nhau để tổ chức và lưu trữ data trên disk drives. Windows chủ yếu sử dụng NTFS (New Technology File System) file system, trong khi Linux thường sử dụng ext4 (Fourth Extended File System) file system. Cũng có các file systems khác được sử dụng bởi cả hai hệ điều hành, như FAT32, exFAT, và ReFS (Resilient File System). Các file systems khác nhau có structures và metadata khác nhau, có thể ảnh hưởng đến cách files được stored, accessed, và recovered.
Permissions và ownership: Linux và Windows sử dụng các approaches khác nhau để quản lý permissions và ownership của files và directories. Linux sử dụng permission model dựa trên users, groups, và permissions bits (ví dụ: read, write, execute), trong khi Windows sử dụng permission model phức tạp hơn bao gồm access control lists (ACLs) và security identifiers (SIDs). Điều này có thể ảnh hưởng đến cách files và directories được accessed và modified, cũng như khả năng recover deleted files hoặc data.
Disk partitioning: Linux và Windows sử dụng các methods khác nhau để partitioning disk drives. Windows sử dụng Master Boot Record (MBR) hoặc GUID Partition Table (GPT) mới hơn cho partitioning, trong khi Linux thường sử dụng GPT partitioning scheme. Các partitioning schemes khác nhau có thể ảnh hưởng đến cách data được organized và accessed trên disk, cũng như khả năng recover deleted files hoặc data.
Forensic tools và techniques: Các forensic tools và techniques khác nhau có thể cần thiết để phân tích disk drives trên Linux versus Windows. Ví dụ, một số tools có thể hiệu quả hơn trong việc recovering data từ một file system hoặc partitioning scheme cụ thể, trong khi những tools khác có thể phù hợp hơn để phân tích permissions và ownership. Điều quan trọng là hiểu sự khác biệt giữa Linux và Windows disk drives khi selecting và sử dụng forensic tools và techniques cho CTF challenge.
File Carving: File carving là một technique được sử dụng để extract data từ file hoặc disk image mà không sử dụng file system. Technique này có thể được sử dụng để recover lost hoặc deleted files hoặc để phân tích malware có thể đang ẩn trong file. Một số file carving tools thường được sử dụng bao gồm Scalpel, Foremost, và PhotoRec. Nó đòi hỏi hiểu biết sâu về file structure và data recovery techniques.
Hard drive type
Khả năng recover deleted files bị ảnh hưởng bởi loại hard drive được sử dụng. Trong trường hợp mechanical hard drives, khuyến khích không xóa data trực tiếp từ disk, vì đánh dấu nó là deleted sẽ khiến hard drive overwrite area đó với fresh data. Do đó, việc xóa data trở nên không cần thiết. Mặt khác, Solid-State Drives (SSD) gặp hạn chế trong việc writing new data vào các areas đã được occupied. Writing data vào marked-as-deleted area trên SSD bao gồm hai operations: đầu tiên, erasing old data, và sau đó writing new data. SSDs thường implement các techniques để periodically remove data được đánh dấu để deletion, tăng cường speed của chúng. Do đó, sự hiện diện của deleted files thường thấp hơn trên SSD so với mechanical disk.
FTK Imager để extract .ad1
File -> Add Evidence Item -> Image -> source path -> Finish
Evidence Tree -> right click on root -> Export Files
Example fdisk+Mount Linux
Mounting file system trong Linux tương tự như gaining access tới victim system trên các platforms như Hack The Box (HTB). Tuy nhiên, có một số key differences. Không giống như live computer, mounted system chỉ là file system, và bạn không thể chạy commands như netstat để xem current connections. Bạn không on the system, chỉ file system như plugging in external hardrive. Mặc dù vậy, quá trình enumeration từ pentesting perspective tương tự. Lợi thế của mounting file system là bạn có thể sử dụng sudo, cấp cho bạn root access tới mounted system, cho phép phân tích và investigation toàn diện hơn. Điều này hữu ích khi tìm kiếm sensitive information hoặc interesting executable... Những lúc khác bạn có thể chỉ cần extract logs.
Để mount filesystem, bạn thường cần đầu tiên xác định offset hoặc starting point của filesystem trong disk image hoặc device file. Khi bạn đã xác định offset, bạn có thể sử dụng "mount" command với "-o loop" option để mount filesystem tại specified location.
Để tìm offset để mount.
fdisk -l disk.img


mkdir test
sudo mount -o loop,offset=210763776 disk.flag.img test/

automate search
Giống như pentesting, chúng ta có thể sử dụng linpeas trong mount. Điều này đã giúp tôi tìm thấy important files trong CTFs.
sudo /usr/share/peass/linpeas/linpeas.sh -f ~/PICO/Forensics/Orchid/test
Noob tip nếu bạn mount system và bạn cố truy cập something như root và nó báo permission denied, sử dụng sudo
sudo ls -la root
EWF on Linux
Expert Witness Format (EWF), thường được đại diện bởi .E01 files, là một forensic disk image format được sử dụng để lưu trữ digital evidence. Nó được phát triển bởi Guidance Software cho EnCase và được sử dụng rộng rãi trong digital forensics. EWF hỗ trợ compression, encryption, và metadata storage, như case details và hash values cho verification.
Cũng có thể mount với
WIM
WIM (Windows Imaging Format)
A WIM file is a disk image format created by Microsoft to store multiple disk images in a single file. It’s commonly used for Windows installation files or backups. The .wim file typically contains the contents of an entire disk or a partition and is used in Windows deployment scenarios.
wimlib-imagex info budget.wim
Để extract
wimlib-imagex extract budget.wim 1 --dest-dir=./extracted
Để mount
wimlib-imagex mount budget.wim 1 wim_mount
Cũng có thể sử dụng 7z để extract everything
Hữu ích vì sẽ extract và hiển thị nếu files có alternate data streams.
Example fdisk+Mount Windows vhdx





guestmount windows vhdx
Encrypted drive
.vhdx encrypted với bitlocker.
bit-locker2john
crack hash với hashcat
.\hashcat.exe -m 22100 -a 0 C:\Users\Daniel\Desktop\bitlocker.hash C:\Users\Daniel\Desktop\SecLists-2024.3\SecLists-2024.3\Passwords\Leaked-Databases\rockyou-75.txt
Mở trên windows
Autopsy on Linux
GUI để xem disk.
New Case -> Add Host -> Add Image -> Analyze -> File Analysis
Trong file analysis có thể browse directories và xem All Deleted Files.
Autopsy on Windows
Open Case -> Next -> Finish
Start analysis, điều này sẽ mất một lúc.
Autopsy Timeline
Mount Windows on Windows
Mount-DiskImage -Access ReadOnly -ImagePath 'C:\Users\Blue\Desktop\Artifact Of Dangerous Sighting\HostEvidence_PANDORA\2023-03-09T132449_PANDORA.vhdx'
Alternate data streams
Alternate Data Streams là một tính năng của NTFS file system cho phép multiple data streams được liên kết với một file duy nhất. Trong khi primary data stream chứa actual content của file, những additional streams này có thể lưu trữ metadata hoặc thậm chí các files khác một cách kín đáo, thường không được chú ý bởi standard file browsing tools, khiến chúng trở thành avenue tiềm năng để concealing data hoặc malicious activity.
Trên linux cũng có thể sử dụng 7z x
để extract /parse streams
Android Forensics
https://github.com/RealityNet/Android-Forensics-References
ALEAPP
Android Logs Events And Protobuf Parser.
https://github.com/abrignoni/ALEAPP
PowerForensics
PowerForensics là một tool mạnh mẽ và linh hoạt cho digital forensic investigations trên Windows systems. Có thể sử dụng trên mounted systems hoặc live systems. PowerForensics cung cấp một suite các cmdlets có thể extract nhiều forensic artifacts, như Master File Table (MFT), Volume Boot Record (VBR), Event Logs, và nhiều hơn nữa.
Docs - https://powerforensics.readthedocs.io/en/latest/#cmdlets
Get-ForensicFileRecord -VolumeName E:
Get-ForensicAlternateDataStream -VolumeName E:
Alternate Data Stream
Example HTB Artifact Of Dangerous Sighting
SluethKit
SleuthKit là một popular open-source digital forensic platform khác cung cấp một set command-line tools để phân tích disk images. Nó hỗ trợ một wide range các file systems, bao gồm FAT, NTFS, và EXT, và có thể được sử dụng để recover deleted files, xem file metadata, và thực hiện keyword searches.
mmls: Command 'mmls' được sử dụng để hiển thị partition layout của disk image. Nó xác định start và end sectors của mỗi partition và hiển thị thông tin khác như partition type, size, và offset. Thông tin này quan trọng để xác định partition chứa file system bạn quan tâm.
fsstat: Command 'fsstat' được sử dụng để hiển thị thông tin về file system, như size, block size, và số lượng allocated và unallocated blocks. Nó cũng có thể hiển thị thông tin về metadata của file system, như location của Master File Table (MFT) trong NTFS file systems.
fls: Command 'fls' được sử dụng để list contents của file system. Nó hiển thị files và directories trong file system cùng với attributes và inode numbers của chúng. Command 'fls' cũng có thể hiển thị deleted files và directories, có thể quan trọng để recovering data đã được deleted bởi attacker hoặc lost do system crash.
sudo mmls dds1-alpine.flag.img
sudo fsstat -o 2048 dds1-alpine.flag.img
Thay thế '2048' với start sector của partition bạn quan tâm.
Sử dụng 'fls' command để list contents của file system:
sudo fls -o 2048 -f ext3 dds1-alpine.flag.img
Search folder recursively bằng cách chỉ định inode
sudo fls -r -o 2048 dds1-alpine.flag.img 20324
Photorec
Photorec là một phần của TestDisk suite và được thiết kế để recover lost files, bao gồm documents, archives, và multimedia files, từ hard disks, CD-ROMs, và lost pictures (do đó có tên) từ digital camera memory.
Trên linux - Select disk -> file system type -> nơi để save
foremost
Foremost là một tool được sử dụng cho file recovery và reconstruction. Nó có thể được sử dụng để recover deleted files, carve out files từ disk images, và extract files từ các file formats khác nhau. Foremost đặc biệt hữu ích để recovering files từ damaged hoặc corrupted disks, hoặc để recovering files đã được deleted hoặc lost.
Foremost sử dụng technique gọi là file carving để recover files từ disk images hoặc sources khác. Nó scans qua input data tìm kiếm specific file headers và footers, và sau đó extracts data giữa chúng. Foremost hỗ trợ wide range các file types, bao gồm images, audio files, videos, documents, và archives.
Foremost có thể được sử dụng trong nhiều scenarios khác nhau, như khi cố gắng recover deleted files, investigating cybercrime incident, hoặc recovering data từ damaged disk. Nó là một powerful tool cho file recovery và reconstruction và có thể giúp trong việc restoring valuable data có thể đã bị lost hoặc deleted.
RAID Disk recovery
RAID Intro
RAID, hoặc Redundant Array of Independent Disks, là một technology cho phép multiple hard drives được sử dụng như một single logical unit để storing data. Trong khi RAID có thể cung cấp increased performance và redundancy, nó cũng có thể làm cho data recovery challenging hơn trong trường hợp disk failure.
RAID 5 là một popular type của RAID configuration cung cấp cả data redundancy và increased performance. Tuy nhiên, trong CTF competitions, RAID 5 arrays thường được deliberately subjected to các types failures khác nhau để test khả năng recover data của contestants.
Một số common types của RAID 5 failures có thể gặp trong CTFs bao gồm:
Single Drive Failure: Nếu single drive trong RAID 5 array fails, array vẫn có thể function. Tuy nhiên, array trở nên vulnerable hơn với additional drive failures, và performance có thể bị degraded.
Multiple Drive Failures: Nếu multiple drives fail trong RAID 5 array, data loss có thể xảy ra. Số lượng drive failures có thể tolerated phụ thuộc vào số lượng drives trong array và stripe size. Trong CTFs, multiple drive failures có thể được simulated bằng cách removing multiple drives từ array.
Rebuild Failure: Khi failed drive được replaced trong RAID 5 array, data được rebuilt onto new drive từ parity data. Tuy nhiên, nếu parity data incorrect hoặc missing, rebuild có thể fail, và data loss có thể xảy ra. Trong CTFs, contestants có thể được given partially rebuilt RAID 5 array và được yêu cầu recover missing data.
RAID Controller Failure: Nếu RAID controller fails trong RAID 5 array, array có thể trở nên inaccessible. Trong CTFs, contestants có thể được given faulty RAID controller và được yêu cầu recover data without controller.
Để successfully recover data từ failed RAID 5 array trong CTF, contestants phải có deep understanding về RAID 5 configurations, data recovery techniques, và tools. Bằng cách practicing và gaining experience với những challenges này, contestants có thể trở nên skilled hơn trong việc recovering data từ RAID 5 arrays và gain competitive advantage trong CTF competitions.
XOR
Trong RAID 5 array với n drives, data được striped across n-1 drives, và parity block được stored trên remaining drive. Parity block được generated sử dụng XOR operation trên corresponding blocks của data trên other drives. Điều này có nghĩa là nếu one of the drives fails, missing data có thể được reconstructed sử dụng data trên remaining drives và parity block.
Đây là example để illustrate cách XOR có thể được sử dụng để recover missing data trong RAID 5 array:
Giả sử chúng ta có RAID 5 array với 3 drives, A, B, và C, và block size là 512 bytes. Chúng ta write file có size 1KB, được striped across drives như sau:
Block 1 được written to drive A
Block 2 được written to drive B
Block 3 được written to drive C
Parity block được calculated như XOR của blocks 1, 2, và 3 và written to drive A (parity block có thể được written to any drive)
Nếu drive B fails, chúng ta có thể recover missing data như sau:
Read blocks 1 và 3 từ drives A và C, respectively
Calculate missing block 2 như XOR của blocks 1, 3, và parity block trên drive A: Block 2 = Block 1 XOR Block 3 XOR Parity
Write recovered data to new drive để rebuild RAID array
Bằng cách sử dụng XOR để calculate missing block, chúng ta có thể recover data bị lost do failure của one of the drives trong RAID 5 array. Tuy nhiên, nếu more than one drive fails, recovery process trở nên complex hơn và có thể require specialized tools và techniques.
Python pseudocode sau đây đầu tiên simulates file có size 1KB và striped across RAID 5 array với three drives. Sau đó nó simulates single drive failure bằng cách removing drive B từ array. Cuối cùng, nó sử dụng XOR để recover missing data từ remaining drives và parity block.
# Define the RAID 5 array configuration
drives = ['A', 'B', 'C'] # Drive labels
block_size = 512 # Block size in bytes
# Simulate a file that is 1KB in size striped across the drives
data = b'0123456789' * 100 # 1KB file data
n_blocks = len(data) // block_size
stripe = [[] for _ in range(len(drives))]
parity = [0] * block_size
for i in range(n_blocks):
block = data[i*block_size:(i+1)*block_size]
parity = [p ^ b for p, b in zip(parity, block)]
for j in range(len(drives)):
if j != i % len(drives):
stripe[j].append(block)
stripe.append(parity)
# Simulate a single drive failure (drive B)
failed_drive = 1
# Recover the missing data using XOR
recovered_data = b''
for i in range(n_blocks):
if failed_drive == i % len(drives):
block1 = stripe[(i+1)%len(drives)][i//len(drives)]
block2 = stripe[(i+2)%len(drives)][i//len(drives)]
recovered_block = bytes([b1 ^ b2 ^ p for b1, b2, p in zip(block1, block2, parity)])
recovered_data += recovered_block
else:
block = stripe[i%len(drives)][i//len(drives)]
recovered_data += block
print(recovered_data)
https://blog.bi0s.in/2020/02/09/Forensics/RR-HackTM/
mdadm
mdadm là Linux utility được sử dụng để managing và monitoring software RAID devices. Nó cho phép users create, manage, và monitor RAID devices, cũng như assemble và disassemble RAID arrays. Trong CTFs, mdadm có thể được sử dụng để reconstruct RAID 5 array sử dụng thông tin về disks tạo nên array. Điều này có thể helpful khi trying to recover data hoặc find hidden clues trong CTF challenge involve RAID 5 array.
losetup
losetup là Linux command được sử dụng để set up và control loop devices, là virtual block devices cho phép file được accessed như thể nó là block device. Trong context của RAID 5 reconstruction trong CTF, losetup có thể được sử dụng để map individual disks hoặc partitions tạo nên RAID 5 array to loop device. Khi disks được mapped to loop devices, tools như mdadm có thể được sử dụng để assemble array và recover data.
Scenario:
You are participating in a CTF and have been given an image of a RAID 5 array. The image consists of four disks, with one of them having failed. Your task is to reconstruct the array and recover the data. The image file is named raid5.img.
Steps:
Determine the block size of the RAID array by inspecting the image file. You can use the fdisk command to view the partition table of the image file and note the block size. Let's assume that the block size is 512 bytes.
bash
fdisk -l raid5.img
Create loop devices for the image file and each disk image. You can use the losetup command to associate the image files with loop devices. Let's assume that the disk images are named disk1.img, disk2.img, and disk3.img.
bash
losetup -fP raid5.img
losetup -fP disk1.img
losetup -fP disk2.img
losetup -fP disk3.img
Use mdadm to create the RAID 5 array using the loop devices. The -C option creates a new array, -l5 specifies RAID level 5, -n4 specifies the number of disks in the array, and missing indicates that one disk is missing.
bash
mdadm -C /dev/md0 -l5 -n4 missing /dev/loop0 /dev/loop1 /dev/loop2
Verify that the array is created successfully and check the status. The /proc/mdstat file shows the current status of the array.
bash
cat /proc/mdstat
Use mdadm to add the failed disk to the array. The -a option adds a new device to the array.
bash
mdadm /dev/md0 -a /dev/loop3
Once the array is reconstructed, mount it and recover the data as necessary.
bash
mount /dev/md0 /mnt/raid
Infected host
Intro
2 điều để lấy từ đây
Extracting artifacts
Performing analysis từ (copy) của infected host machine
Extracting
Điều này có thể không xuất hiện thường xuyên trong CTF, trong CTFs bạn hầu như luôn được cung cấp artifacts để analyze. Tuy nhiên nó có thể xảy ra và có khả năng hơn nếu bạn ở đây bạn sẽ muốn có job trong domain này và bạn thực sự không muốn vào job interview và biết complex things như malware analysis và miss những gì họ coi là fundamental questions như process of making copy of disk. Crede experto
Một câu hỏi trong domain này là nếu bạn đang làm việc tại site và ai đó nghĩ computer của họ bị compromised thì bạn nên làm gì. KHÔNG TẮT NÓ, điều này sẽ eliminate volatile memory. HÃY Disconnect nó khỏi network. Tạo copies của artifacts bạn cần.
Dump Windows Disk
FTK Imager
File -> Create Disk Image - Physical Drive -> Add -> E01 -> fill info -> finish -> start
Expert Witness Format (.e01) chứa không chỉ raw disk image (tương tự .dd file) mà còn additional metadata và thông tin liên quan đến forensic image.
Điều này có thể mất một lúc
Caine
Nhấn F12 khi booting select Caine
KAPE (Kroll Artifact Parser and Extractor)
KAPE extracts artifacts từ system.
Đi kèm với Targets và Modules.
./kape.exe --tsource C: --target !SANS_Triage,ProgrameData --tdest D:\KAPEOUT
Velociraptor + KAPE
Velociraptor là robust EDR tool cho phép remote artifact collection và analysis at scale. Leveraging Velociraptor Query Language (VQL) và Hunt capabilities của nó, analysts có thể efficiently gather host-based information và artifacts, streamlining evidence collection và enabling rapid triage.
Choose a host -> New Hunt -> Configure Hunt -> Select Artifacts -> Configure Parameters -> Launch -> Download results -> Available Downloads
Chọn Windows.Kape
Typical output/
|-- Windows/
| |-- $Boot
| |-- $Extend
| |-- $LogFile
| |-- $MFT
| |-- $Recycle.Bin
| |-- ProgramData
| |-- Program Files
| |-- Users
| |-- System32
| |-- config
| |-- LogFiles
| |-- SleepStudy
| |-- sru
| |-- Tasks
| |-- wbem
| |-- WDI
| |-- winevt
| |-- Logs
Dump Linux Disk
dd
Catscale (Dump linux artifacts)
Linux CatScale là bash script sử dụng live off the land tools để collect extensive data từ Linux based hosts. Data này nhằm giúp DFIR professionals triage và scope incidents. Elk Stack instance cũng được configured để consume output và assist analysis process. Lưu ý rằng script có khả năng alter artefacts trên endpoints. Cần cẩn thận khi sử dụng script. Điều này không có nghĩa là tạo forensically sound disk images của remote endpoints.
Nó collect gì? https://labs.f-secure.com/tools/cat-scale-linux-incident-response-collection/
source code https://github.com/WithSecureLabs/LinuxCatScale/tree/master
Misc
Sử dụng exec-perm-files.txt
để cross reference hashes trên VT.
full-timeline.csv
Có thể rất hữu ích.
Dump Windows Memory
FTK Imager
Capture memory ->
output .mem
Velociraptor + memdump
output will be our .raw
Dump Linux Memory
Network (.pcap)
Không giống như logs, pcaps không được saved và kept by default. Chúng ta sẽ cần chạy something. Điều này có thể hữu ích kết hợp khi checking malware để xem nó có reaching out không.
Capture pcaps trên Linux
wireshark
Wireshark -> pick interface -> let run -> Stop -> Save
tcpdump
Capture pcaps on Windows
Live analysis Windows
Phân tích live system hoặc direct copy của virtual machine (VM) thay vì static artifacts như disk images mang lại nhiều advantages. Những lợi ích này bao gồm real-time data analysis, dynamic state assessment, behavioral analysis, memory forensics, immediate triage, interaction với running services, malware detection và analysis, contextual understanding, reduced imaging time, và improved resource availability. Trong khi live analysis cung cấp những benefits này, điều cần thiết là tuân thủ proper forensic procedures để minimize impact trên live system. Combined approach bao gồm cả live và artifact analysis đảm bảo comprehensive understanding của incident và enhances investigative process.
Một cách để làm điều này là mount Caine trong vm.
On Virtual Box Devices -> Optical Drives -> Caine.iso
In the VM This PC -> CD Drive CAINE
Một số manual enumeration
Lấy system info
lấy powershell history
type (Get-PSReadlineOption).HistorySavePath
Check loaded modules
filtering trên properties
sorting
Get-Service | Sort-Object -Property Status
Finding/filtering với where
Get registry
Powershell commands
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.management/?view=powershell-7.4&viewFallbackFrom=powershell-7
or
Get-Command
NirLauncher
NirLauncher là tool package được tạo bởi NirSoft cung cấp collection của small utilities cho various purposes, bao gồm system analysis, network monitoring, password recovery, và nhiều hơn nữa.
Windows File Analyzer
Windows File Analyzer là forensic tool được thiết kế để examine various Windows artifacts, như registry hives, event logs, hibernation files và nhiều hơn nữa.
Autoruns
Được sử dụng trên live device để inspect registry và schd tasks và show processes sẽ run on startup.
DNS
Có thể cung cấp clues về sites đã visited.
ipconfig /displaydns
Live analysis Linux
Có thể nc vào host để extract info đảm bảo không có gì được put on disk.
lsof có thể tốt hơn ps
LinuxRescueCD
Cloud
AWS (Amazon Web Services)
Amazon Web Services (AWS) là comprehensive và widely adopted cloud platform cung cấp hơn 200 fully featured services từ data centers globally. AWS cung cấp services bao gồm computing power, storage options, networking, và databases, delivered như scalable cloud computing.
Forensic Investigation Tips trên AWS
AWS CloudTrail: Logs tất cả API calls, crucial cho trail của user và resource activity.
CloudTrail-Digest: Automatically created để giúp bạn ensure integrity của CloudTrail logs.
AWS Config: Cung cấp inventory và configuration changes của AWS resources.
Access và Analyze Logs: Sử dụng services như Amazon S3 và AWS Lambda cho log storage và analysis.
Artifacts of Interest
EC2 Artifacts: Instances, snapshots, AMIs, security groups.
S3 Buckets: Data, access logs, bucket policies.
IAM Logs: User, group, role, và policy details.
VPC Flow Logs: IP traffic information.
RDS Snapshots: Database backups.
Useful Commands & Tools
AWS CLI: Command line tool cho AWS services. Example: Listing S3 buckets với
aws s3 ls
.EC2 Snapshots: Create snapshots với
aws ec2 create-snapshot
.DB Snapshots: Create snapshots với
CreateDBSnapshot
.CloudTrail Logs: Access với AWS Console hoặc
aws cloudtrail lookup-events
.S3 Data Access: Download files sử dụng
aws s3 cp s3://bucket-name/path/to/object localpath
.whoami: Returns details về IAM user
GetCallerIdentity
.Describe: Returns metadata về running EC2 instances
DescribeInstances
.
Using AWS CLI
Useful search queries cho json logs
Select tất cả logs với username
find . -name "*.json" -exec jq -r '.Records[] | select(.userIdentity.userName == "forela-ec2-automation")' {} +
Select event names từ user forela-ec2-automation
sorted by time
Getting Cloudtrails on splunk
https://help.splunk.com/en/splunk-enterprise/get-started/install-and-upgrade/9.2/install-splunk-enterprise-in-virtual-and-containerized-environments/deploy-and-run-splunk-enterprise-inside-a-docker-container
https://www.youtube.com/watch?v=TG6zBnSgf5M
Copy data into docker container
HOẶC ... consolidate thành một .json file
find . -type f -name '*.json' -exec cat {} + | jq -c '.Records[]' > combined_cloudtrail_logs.json
#Get files trong docker
sudo docker cp combined_cloudtrail_logs.json splunk:/tmp/combined_cloudtrail_logs.json
Download aws add-on
Apps -> Find More Apps ->
Upload data -> upload -> Set source type aws:cloudtrail
Azure
Azure is Microsoft’s cloud computing platform offering services for computing, analytics, storage, and networking. Users can develop new applications or run existing ones in the public cloud.
Forensic Investigation Tips trên Azure
Azure Activity Log: Cung cấp data về operations được performed trên resources.
Azure Monitor: Collects và analyzes performance metrics và operational data.
Azure AD Investigation: Logs sign-in activity và user account changes.
Azure Blob Storage: Securely stores forensic data trong cloud.
Network Security Group Flow Logs: Cung cấp IP traffic data cho network forensic investigations.
Disk Snapshots: Analyze state của VMs tại specific points in time.
Azure Backup: Protects data từ accidental deletion hoặc corruption.
Artifacts of Interest
VM Artifacts: Disks, snapshots, networking info.
Azure AD Logs: Sign-in, audit logs, user/group info.
Storage Account Logs: Blob, Queue, Table, File storage logs.
NSG Flow Logs: Network traffic logs.
SQL Database Auditing: Database auditing logs.
Useful Commands & Tools
Azure CLI: Azure's command line interface. Example:
az vm list
để listing VMs.Disk Snapshots: Create VM disk snapshots với
az snapshot create
.NSG Flow Logs: Manage với
az network watcher flow-log
.Blob Storage Access: Download blobs với
az storage blob download
.
Azure Data Explorer
Azure Data Explorer (ADX) sử dụng query language được gọi là Kusto Query Language (KQL). Không thực sự là SIEM, nhưng là resource để filter data.
show tables
Show columns cho tables.
Getting sample của data
https://learn.microsoft.com/en-us/azure/data-explorer/kusto/query/kql-quick-reference
summarize
SIEMS
SIEM, viết tắt của Security Information và Event Management, là comprehensive solution được thiết kế để cung cấp real-time analysis của security alerts và events được generated bởi various hardware và software entities trong IT infrastructure. Sử dụng SIEM giống như mix của viewing logs và see
Splunk
Splunk là powerful platform để searching, monitoring, và analyzing machine-generated data, có thể đến từ web applications, sensors, devices, hoặc bất kỳ data nào mà organization's IT infrastructure generates.
Tìm available data sources
| metadata type=sourcetypes index=* | table sourcetype
| metadata type=sources index=* | table source
Xem Fields từ source
sourcetype="WinEventLog:Security" | fieldsummary
Có thể sử dụng sigmac để create queries
Search và sort theo client ID
index=* | stats count by clientip | sort - count
Complex Examples
index=* Sysmon source="WinEventLog:Microsoft-Windows-Sysmon/Operational" EventCode=3 |
bin _time span=1h |
stats count as NetworkConnections by _time, Image |
streamstats time_window=24h avg(NetworkConnections) as avg stdev(NetworkConnections) as stdev by Image |
eval isOutlier=if(NetworkConnections > (avg + (0.5*stdev)), 1, 0) | search isOutlier=1
Chúng ta target network connection events với EventCode=3 và group chúng hourly. Với mỗi distinct process (Image), chúng ta tally network connection events trong mỗi time slot.
Rolling 24-hour average và standard deviation của connection counts cho mỗi process được calculated sử dụng streamstats.
Với eval command, chúng ta tag events như outliers nếu connection counts của chúng exceed 0.5 standard deviations từ average, indicating potential anomalies.
Results sau đó được refined để display chỉ những outliers này.
Download install splunk docker
https://docs.splunk.com/Documentation/Splunk/9.2.1/Installation/DeployandrunSplunkEnterpriseinsideDockercontainers
Nếu docker chưa được Downloaded
sudo apt install docker.io
ELK
ELK Stack, bao gồm Elasticsearch, Logstash, và Kibana, là robust suite của tools collectively enable organizations để efficiently search, analyze, và visualize vast volumes của data trong real-time.
Discover
controlling columns
Ở left side có thể search cho feature và add nó như column bằng cách clicking blue + .
Useful queries examples
OSINT
Open Source Intelligence (OSINT) bao gồm gathering evidence từ sources như websites, social media, domain records, và other internet-based platforms.
https://dfir.blog/unfurl/
https://osintframework.com/
Google
Google là bạn của bạn.
email unique identifier
Discord
This needs to be moved
Geoguesser
https://docs.google.com/spreadsheets/d/1UNvkoY-LaktF75nU_cP7-wVRAEvH3fSqVZet20HqxXA/edit?gid=0#gid=0
Reading Japanese Utility pole plates
https://docs.google.com/document/d/17WL3aQeSvfnqymGKtV-DbSJDd7KTYCqEbWgtEsJNKFs/edit
geohints
https://geohints.com/
Reverse image
https://www.google.com/?authuser=0
Search bằng image
move
graph TD;
A-->B;
A-->C;
B-->D;
C-->D;
Last updated