I would like to ask for some directions to trace back to the original (malicious) script on my system (Ubuntu Server). I would try to be more specific if needed. If the question does not fit this stackexchange, then I will modify it.
In netstat's output, the PID/Program name only showed "-" and the one next to it 1441/-bash. While i can locate the PID of the latter, I have no idea to do that with the first one. These two processes would respawn after reboot.
To give more context, the two suspicious connections are from 198.251.80.207 and 157.230.4.227. It seems like they are trying to mine XMR. I have got rid of their keys in authorized_keys but could not find a way to stop the established connection to port 50866 from foreign port 443 (UFW already blocked that IP in and out but somehow it can still establish a connection). I was able to block connection from my server to 157.230.4.227, hence it only showed SYN_SENT.
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 my_server_ip:50866 198.251.80.207:443 ESTABLISHED -
tcp 0 1 my_server_ip:36730 157.230.4.227:8443 SYN_SENT 1441/-bash
UFW info
To Action From
-- ------ ----
[ 1] Anywhere DENY IN 159.75.245.82
[ 2] Anywhere DENY IN 45.137.21.134
[ 3] 194.163.163.20 DENY IN Anywhere
[ 4] Anywhere DENY IN 194.163.163.20
[ 5] 155.94.171.66 DENY IN Anywhere
[ 6] Anywhere DENY IN 155.94.171.66
[ 7] 198.251.89.111 DENY IN Anywhere
[ 8] Anywhere DENY IN 198.251.89.111
[ 9] Anywhere DENY IN 88.99.242.92
[10] Anywhere DENY IN 198.251.80.207
[11] Anywhere DENY IN 157.230.4.227
[12] 157.230.4.227 DENY IN Anywhere
[13] 198.251.80.207 DENY IN Anywhere
[14] 88.99.242.92 DENY IN Anywhere
ls -l /proc/1441's output, the -bash script got deleted right after reboot.
<snipped>
-r--r--r-- 1 root root 0 1월 28 16:17 cpuset
lrwxrwxrwx 1 root root 0 1월 28 16:06 cwd -> //
-r-------- 1 root root 0 1월 28 16:17 environ
lrwxrwxrwx 1 root root 0 1월 28 16:06 exe -> /bin/-bash (deleted)
dr-x------ 2 root root 0 1월 28 16:05 fd/
dr-x------ 2 root root 0 1월 28 16:17 fdinfo/
<snipped>
How to I find what script/process that triggered exe binary file above?