Hunting Beacons: Bartosz Jerzman
Hunting Beacons: Bartosz Jerzman
Hunting Beacons: Bartosz Jerzman
Bartosz Jerzman
agenda
PAYLOAD
Mozilla/
5.0 Trackr=e
10.18.7.3 50474 39.88.160[.]18 80 POST test.com /test.php (Window 0 303 DMzZm
s NT 6.1; Nvbg==
WOW64)
Hipothesis #1: analysis of connections intervals
WHY?
Beaconing malware often has configuration options for setting:
- sleep time
- jitter (variations from central value)
Hipothesis #1: analysis of connections intervals
Hipothesis #1: analysis of connections intervals
https://www.investopedia.com
Hipothesis #1: analysis of connections intervals
Variation
Beacon #1 #2 #3 #4 #5 #6 AVG STDDEV
Coefficient
A 48s 51s 62s 69s 55s 60s 57,5s +/- 7,75 s 13,4 %
Variation
Beacon #1 #2 #3 #4 #5 #6 AVG STDDEV
Coefficient
A 48s 51s 62s 69s 55s 60s 57,5s +/- 7,75 s 13,4 %
Aggregate connections
By srcIP,dstIP,User-Agent
C2 server 78.187.72[.]190
AvgBeaconTime 7s
StdDev +/- 3
= very interactive session
Hipothesis #1: analysis of connections intervals
C2 server 222.186.31[.]162
BeaconTime: 28min
+/- 7 min
Longterm operation for
maintaining access
Hipothesis #2: same URI for different Host names
Hipothesis is based on the assumption that:
Adversary is using backdoor that has several C2 backup
domains included in the configuration.
https://www.cobaltstrike.com/help-http-beacon
Hipothesis #2: same URI for different Host names
Hipothesis #2: same URI for different Host names
Detection threshold: 3
different hosts
Hipothesis #2: same URI for different Host names
5 unique C2 domains
discovered for 2 similar
yet different URI
requests
Hipothesis #3: Same or none Referrer to many URIs
Hipothesis #3: Same or none Referrer to many URIs
Counting Referrers on
single destination
Threshold >3 AND < 10
Another C2 domain
discovered with
3 different URIs of same
length
Jack Crook (still waiting for you, Jack, at x33fcon) has a
great set for hipothesis inspirations:
https://twitter.com/jackcr/status/1029457184164335617
PART II
Beaconing over HTTPS
{ FakeTLS example from LAZARUS APT }
FakeTLS – how does it work?
C2 COMMS
192.168.56.19
114.215.107[.]218
The Funny Part of
FakeTLS – how does it work? mimicking TLS to
popular sites e.g.
wetransfer.com
C2 COMMS
192.168.56.19
114.215.107[.]218
C2 sends back real
FakeTLS – how does it work? (often expired)
certificate
C2 COMMS
192.168.56.19
114.215.107[.]218
FakeTLS – how does it work?
C2 COMMS
192.168.56.19
114.215.107[.]218
Non-TLS encryption with
symmetric, shared RC4
key
FakeTLS – does it beacon?
C2 COMMS
FakeTLS – interesting part shortly after handshake
The beginning of
REAL comms has
fixed size
messages
C2 COMMS
FakeTLS – is it really hardcoded?
24 B
24 B
8B
8B
4B
backdoor FakeTLS C2
24 B
8B
8B
4B
backdoor FakeTLS C2
In TLS algorithms every message is hashed (e.g. md5) for integrity check
length(md5(msg)) = 16B
8B < 16B ;)
FakeTLS – where to hunt unknown C2
infrastructure?
Reactive: Proactive:
- own network traffic - pcaps from sandboxes e.g.
detection Hybrid-Analysis
- Can your network traffic
analyser process TLS data
after the handshake?
PART III
Let’s hunt them early – C2 scanning
NBA in 1990s – „Offense starts with defense”
http://b-rise.com
Quick intro to wide topic
https://attack.mitre.org/
Finding defaults: #1 Cobalt Strike console port