Score:1

Find process that makes outbound HTTP calls, trying auditd with syslog-ng

in flag

Some of application (it's unknown) makes sporadic nonregular rare short outbound HTTP(S) requests to a known host/port/url (this is a WAF honeypot, host/url/port is known) using HTTPS protocol. Requests may occur once per 3-5 days. It's literally one short request per 3-5 days. The goal is to define what application (path to binary, PID etc) makes these requests. Server has plenty of software installed including nginx, php, mariadb, redis, docker etc.

For simplicity, honeypot IP will have 7.7.7.7 here.

What I've tried sofar:

  1. tcpdump
$ sudo tcpdump -i any dst host 7.7.7.7 and "tcp[tcpflags] & (tcp-syn) != 0" and "tcp[tcpflags] & (tcp-ack) == 0" &> /tmp/out_7.7.7.7_$(date "+%Y.%m.%d-%H.%M.%S").log &

It seems tcpdump doesn't allow to detect process id or executable which makes outbound http requests.

  1. auditctl/auditd
sudo auditctl -a exit,always -F arch=b64 -S connect -k connectLog

auditctl/auditd seems can output the path and pid, but it lacks filtering feature. If I start audit rule for a 3-5 days, my disk will be full of auditlog. Or, if audit logs are rotating, I could miss required log data in log file alreayd rotated and wiped out. If auditctl would have filtering feature on write (not on parse logs) by target IP, it probably would be the best candidate. Maybe I'm missing something and it has filtering feature?

Another option that I figured out is to make some bash script, which:

  • started the auditing of connect
  • started the monitoring process like this: ( tail -f -n0 /var/log/audit/audit.log & ) | grep -q "7.7.7.7"
  • once monitor detects this, stop auditing auditctl -d...

The problem is, this event may occur after 3-5 days, when all disks will be full.

  1. netstat
$ sudo netstat -tupnc | grep 7.7.7.7

It seems that netstat with -c option (continuos) repeats reading each 1 second. Since requests are very short, it could miss this request.

  1. ss

ss seems doesn't display the process originated the outbound connection.

  1. lsof
lsof -i TCP:80,443 -r 1

The outbound connection is very short and quick, it may be not logged by running lsof each 1 second

  1. wireshark Wireshark has good filtering features (by IP), but it seems that it doesn't display the connection originator process name or pid.

  2. Currently I'm stuck with the solution: combine syslog-ng (wich has filtering capabilities when receiving logs via TCP/network) as a receiver and auditd as a log events sender. I succeeded starting syslog-ng on port 2222, receiveing data from network and filtering it by some string (tested with curl). But I cannot manage auditd send logs to network.

What I've done:

7.1) Installed audisp-remote-plugin:

$ sudo apt install audispd-plugins

7.2) Enabled audisp-remote plugin:

in file /etc/audit/plugins.d/au-remote.conf: set active = yes

7.3) Configured audisp-remote plugin:

in file /etc/audit/auditsp-remote.conf:

remote_server = 127.0.0.1
port = 2222

7.4) Disabled writing to a local log_file

in file /etc/audit/auditd.conf:

write_logs = no

and restarted auditd:

$ sudo systemctl restart auditd

7.5) Added audit rule to catch connections (connect syscalls):

$ sudo auditctl -a exit,always -F arch=b64 -F saddr_fam=2 -S connect -k sckt

7.6) Rotated logs to clean previous data in auditd logs

$ service auditd rotate

7.7) Made test HTTP call:

$ curl -v https://7.7.7.7/api/v1/t

7.8) Checked syslog-ng log, but it doesn't have expected records.

If any knows the appropriatest, easiest and simple the best approach to do this, any help will be appreciated!

Score:0
ke flag

You could probably ingest the audit log using a file source into syslog-ng, then use a relatively short retention time for audit logs.

With that you can apply filtering on the syslog-ng side and output the interesting records into a separate log file.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.