Suspicious traffic in tcpdump: how to test the hypothesis of a botnet

Русский · English · Español · Français · Deutsch

On the router you can see that one device tries several times
connect to an unfamiliar address, queries DNS names and sets
HTTPS connections. This combination is worth checking out. Let’s figure out what
can be determined by short capture and what data is needed to
confirm or exclude infection.

Remove the traffic of one
devices

On Linux, select the interface where the device address before NAT is visible.
Capture traffic only on the network you administer. Here
eth0 is an example of an interface, and 192.0.2.10 — address
for documentation.

ip -br link
sudo tcpdump -i eth0 -nn -tttt -c 200 'host 192.0.2.10'

Key -nn disables substitution of host names and services.
Key -tttt displays date and time. Key -c 200
limits the number of packets, although during low activity the command may
wait longer than expected for them. Record the time zone and capture location. If
PCAP needed, keep file with restricted access: capture may contain
device names, queries, and unencrypted data.

Read
sequence of packets

Below is a synthetic fragment with addresses from ranges for
documentation. It conveys the sequence of events from parsing without
publishing the original dump. Lines are shortened for reading.

12:00:00.100 IP 192.0.2.10.52000 > 198.51.100.20.53113: Flags [S], seq 4000
12:00:01.120 IP 192.0.2.10.52000 > 198.51.100.20.53113: Flags [S], seq 4000
12:00:01.200 IP 192.0.2.10.53001 > 192.0.2.53.53: A? api.example.net.
12:00:01.230 IP 192.0.2.53.53 > 192.0.2.10.53001: A 203.0.113.40
12:00:01.250 IP 192.0.2.10.52001 > 203.0.113.40.443: Flags [S]
12:00:01.280 IP 203.0.113.40.443 > 192.0.2.10.52001: Flags [S.]
12:00:01.281 IP 192.0.2.10.52001 > 203.0.113.40.443: Flags [.]
  • Repeat SYN. Same addresses, ports and number
    sequences indicate resending of the SYN. In capture of the answer
    no. Check packet loss, filtering and asymmetric routing,
    before inferring the state of the remote node.
  • DNS request and response. In the example, the resolver returned
    the address to which the device soon connected. Such
    sequence helps to correlate events, although a common IP CDN or
    a proxy can serve multiple domains. Parallel requests to two
    resolvers are themselves compatible with normal client behavior.
  • Established TCP connection. [S] —
    SYN, [S.] — SYN+ACK, [.] – ACK. These three packages
    indicate the establishment of a TCP connection. Port 443 is often used for
    HTTPS. The application cannot be determined from the port number and flags alone,
    the content of the request or the fact of data transfer to the attacker.

Check the source address and
process

  1. Match device IP with ARP, DHCP and switch logs on
    moment of capture. With NAT, check which internal address matched
    outgoing connection.
  2. On the managed Linux device, run
    sudo ss -ntupwhile the connection is active. Check local
    port, remote address and PID with dump. A short connection may
    disappear before the command runs. Then the endpoint logs are more useful or
    already configured telemetry.
  3. Check the time, address, direction and purpose of the connection with
    DNS, gateway, or proxy logs. If the process is known, check the path to
    executable file, the package it belongs to, and the method
    launch.
  4. Check the reputation of an address taking into account the observation time, source
    information and whether the IP is shared. Match with public
    indicator helps to choose the direction of investigation. For confident
    attribution requires independent confirmation on the device or in
    magazines.

When to isolate a device

If an unknown process with repeated outgoing messages is detected
connections, confirmed malicious file or signs
distribution over the network, limit device access according to the procedure
response. Save the original capture, logs, and timeline. For
critical service, first agree on how to isolate the node and preserve
possibility of investigation. After localization, check other devices
for the same signs.

The result of the analysis should be formulated according to the level of confidence. For example: “In
The capture shows repeated connection attempts and a separate successful session.
The reason for the traffic is still being determined. To check you need information about
process and network gateway logs.”

Sources