Issue
Server generates outgoing requests to other sites. It is necessary to find the user on the server on whose name such requests are generated.
Environment
- iptables
- Any OS
- Any control panel
Solution
The example below describes an attempt to log outgoing requests to port 80, containing "testtest047".
1. Create a custom rule for logging all outgoing requests to 80 port with the string "testtest047":
# iptables -I OUTPUT -p tcp -m tcp -m string --string "testtest047" --algo kmp --dport 80 -j LOG --log-prefix "Outgoing attack: " --log-level 4 --log-uid
2. Try to generate a request from any user (to test the rule):
$ wget --quiet http://google.com/?string=tko44047
3. Request will be logged in the system log:
# tail -n2 /var/log/messages
Feb 8 16:49:16 1354153 kernel: Outgoing attack: IN= OUT=eth0 SRC=10.51.48.14 DST=216.58.215.110 LEN=176 TOS=0x00 PREC=0x00 TTL=64 ID=56169 DF PROTO=TCP SPT=48296 DPT=80 WINDOW=229 RES=0x00 ACK PSH URGP=0 UID=1288 GID=1288
Feb 8 16:49:16 1354153 kernel: Outgoing attack: IN= OUT=eth0 SRC=10.51.48.14 DST=172.217.20.164 LEN=180 TOS=0x00 PREC=0x00 TTL=64 ID=14083 DF PROTO=TCP SPT=53282 DPT=80 WINDOW=229 RES=0x00 ACK PSH URGP=0 UID=1288 GID=1288
In this example, requests were made from user with id 1288 on the server.
After that, files and databases on account with detected UID can be checked with Malware Scanner. It is also worth checking the processes running on behalf of this user and his cron tasks - it is possible that suspicious requests are generated by the cron scheduler or in-memory malware.
If nothing is detected, it is worth checking the site access.log, perhaps suspicious requests that are made to the scripts will be logged and thus understand through which script attack is generated.
If you want to catch only packets to some subnet and port, please, use:
iptables -I OUTPUT -p tcp -m tcp -d “192.168.0.0/16” --dport 80 -j LOG --log-prefix “Outgoing attack: ” --log-level 4 --log-uid
Useful links
Comments
0 comments
Please sign in to leave a comment.