DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet...

23
DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA BENOIT ANCEL & MEHDI TALBI STORMSHIELD

Transcript of DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet...

Page 1: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA

BENOIT ANCEL & MEHDI TALBI STORMSHIELD

Page 2: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

• Motivations

• Haka

• Malware monitoring - Demo – China-Z – Athena

• Conclusions

!2

OUTLINE

Page 3: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

• Long-term malware monitoring – Threat Intelligence – Tracking malware campaign

• Lack of means to monitor, debug and monitor malware network activities

!3

MOTIVATIONS

Page 4: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!4

HAKA

AN OPEN SOURCE SECURITY-ORIENTED LANGUAGE

Page 5: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

1. Malware protocol dissection 2. Advanced API for packet and stream manipulations 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and

inspect their content) 5. Instruction disassembler (disas. packet content at

network level) 6. Dedicated tool to monitor traffic : Hakabana

!5

HAKA MOTIVATIONS

Page 6: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!6

HAKA ARCHITECTURE

Page 7: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

• Protocol Specification : Message format + State machine

• Support of text-based protocols (http) and binary-based protocols (dns)

• Support of packet-based protocols (icmp) and stream-based protocols (http)

• All parsed fields are available in read/write access to security rules

!7

HAKA PROTOCOL DISSECTION

Page 8: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!8

HAKA GRAMMAR BUILDING BLOCKS

basic blocks compound blocks

Page 9: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!9

HAKA PROTOCOL DISSECTION EXAMPLE

Page 10: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

• Inspecting packet content

• Matching a malicious pattern across multiple packets

!10

HAKA SECURITY RULES (1)

Page 11: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!11

HAKA SECURITY RULES (2)

drop packets

inject packets

alter packets

Page 12: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!12

HAKA SECURITY RULE EXAMPLE

Page 13: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!13

MONITORING C2 TRAFFIC

USE CASES

Page 14: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

• Well known Chinese botnet

• 5 known variants: China-Z/{A, B, C, O, S}

• Includes binary and configuration update features

• DDoS campaigns targeting Asia

!14

CHINA-Z OVERVIEW

Page 15: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!15

CHINA-Z C2 COMMUNICATIONS

Request

Response

Page 16: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!16

CHINA-Z - SECURITY RULES BLOCKING DDOS ATTACKS

Page 17: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!17

CHINA-Z DEMO

https://www.youtube.com/watch?v=-XeyMMcZ-TI

Page 18: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

• Several features : click fraud, ddos, bot killer, etc. • Communicates over http • Encoded requests and responses (hex + base64

encodings)

!18

ATHENA OVERVIEW

Page 19: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!19

ATHENA COMMANDS

Page 20: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!20

ATHENA - SECURITY RULES HIJACKING BOTNET COMMANDS

Page 21: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!21

ATHENA DEMO

https://www.youtube.com/watch?v=5hMKN0k_zCQ

Page 22: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

• Haka provides several features to monitor and debug C2 traffic.

• Future works : provide a repository of malware protocol dissectors

!22

CONCLUSIONS

Page 23: DEBUGGING & MONITORING C2 TRAFFIC WITH HAKA · 3. On-the-fly packet modification (hijack botnet commands) 4. Interactive packet filtering mode (break into packets and inspect their

!23

THANK YOU

github.com/haka-security @hakasecurity haka-security.org