1

I'm currently attempting to clean and secure a server that has pnscan running on it. This instance of pnscan was installed by an outside party most likely to use our server as part of a port scanning botnet. It seems to be able to write it's binaries to /dev/shm and /tmp.

Here's the output of "lsof | grep pnscan":

root@xxx.xxxx.xxx:/home/bitnami# lsof | grep pnscan
pnscan     9588     daemon  cwd       DIR    8,1      4096      647169 /tmp
pnscan     9588     daemon  rtd       DIR    8,1      4096      2      /
pnscan     9588     daemon  txt       REG    8,1      18468     647185 /tmp/pnscan
pnscan     9588     daemon  mem       REG    8,1      42572     418331 /lib/tls/i686/nosegneg/libnss_files-2.11.1.so
pnscan     9588     daemon  mem       REG    8,1    1421892     418349 /lib/tls/i686/nosegneg/libc-2.11.1.so
pnscan     9588     daemon  mem       REG    8,1      79676     418329 /lib/tls/i686/nosegneg/libnsl-2.11.1.so
pnscan     9588     daemon  mem       REG    8,1     117086     418343 /lib/tls/i686/nosegneg/libpthread-2.11.1.so
pnscan     9588     daemon  mem       REG    8,1     113964     402913 /lib/ld-2.11.1.so
pnscan     9588     daemon    0r      CHR    1,3        0t0     705    /dev/null
pnscan     9588     daemon    1w      CHR    1,3        0t0     705    /dev/null
pnscan     9588     daemon    2w     FIFO    0,8        0t0     37499  pipe
pnscan     9588     daemon    3r      REG    8,1        203     516243 /opt/bitnami/apache2/cgi-bin/php-cgi
pnscan     9588     daemon    4u      REG    0,15         0      37558 /dev/shm/.x
pnscan     9588     daemon    5u     IPv4    37559      0t0     TCP  domU-12-31-39-14-41-41.compute-1.internal:52617->lab1.producao.uff.br:www (ESTABLISHED)
pnscan     9588     daemon    6u     IPv4    3688467    0t0     TCP  domU-12-31-39-14-41-41.compute-1.internal:55926->200.25.69.27:www (SYN_SENT)

And here's the output of "ps aux | grep pnscan":

daemon    9588  2.3  0.1 3116204 3272 ?        Sl   21:42   1:55  /tmp/pnscan -rApache -wHEAD / HTTP/1.0\r\n\r\n 200.0.0.0/8 80

Any advice on how we can find the source of this would be greatly appreciated.

Thanks!

2 Answers2

5

Normally, a compromised server is

  1. backed up as an image for further investigation in a closed down lab
  2. reimaged or reinstalled/restored, to keep production going

Leaving a compromised machine, even if you seemingly clean it out, in production, isn't a safe practice

dyasny
  • 19,257
0

it looks like this "pnscan" code is running from UID 9588.

you could set up an iptables directive to match on this UID and DROP any outgoing traffic. or lock down to only outgoing tcp/80 and tcp/22 or something....

nandoP
  • 2,067