Logo address

plisten

目次

2013/11/15
2014/07/20

plisten is a protected listen for Plan9 that is designed to protect server from brute force attack.
plisten is available in http://plan9.aichi-u.ac.jp/netlib/plisten/

Brute force attack

2013/11/14

attacks to POP3 server

The IPs in the following list have attempted to steal passwords by brute force attack to my POP3 server.
They are taken from log file starting from 2013/06/03 to 2013/11/14.

108.176.54.138 109.120.137.114 110.172.141.52 112.198.82.252 116.0.102.20 119.161.171.34 120.151.53.128 122.155.5.75 122.192.35.145 122.226.212.222 125.89.78.2 14.23.155.34 142.0.79.188 173.243.112.201 174.122.32.55 176.61.138.108 180.74.130.190 180.74.193.156 184.82.171.202 185.10.201.114 186.225.79.38 187.18.114.175 187.44.14.35 187.75.163.52 189.3.139.114 189.42.52.50 190.210.136.21 193.193.244.11 194.183.71.90 194.186.2.178 196.218.177.100 196.219.180.116 198.52.115.74 199.241.146.221 200.161.81.225 200.175.252.199 200.175.44.222 200.206.180.160 200.54.196.2 200.85.60.138 201.216.163.242 201.47.170.114 202.155.223.103 202.162.24.10 202.203.225.79 203.73.140.202 204.188.195.63 209.48.199.36 210.57.210.2 213.153.176.146 217.156.189.193 218.246.71.33 218.59.209.140 218.59.209.142 220.164.234.202 24.120.131.168 24.123.136.90 27.251.8.26 41.41.142.151 5.12.140.214 61.158.207.22 61.19.97.155 63.131.47.2 64.140.223.11 64.199.111.26 64.31.49.9 64.88.207.58 65.81.88.190 66.214.252.242 69.11.98.246 70.91.229.21 77.240.98.127 78.100.77.98 78.189.74.214 81.17.23.47 81.213.108.41 82.227.169.194 83.0.235.123 83.35.218.45 85.72.35.182 87.126.81.49 89.45.14.73 89.45.14.77 89.45.14.93 90.227.101.224 91.183.99.84 92.63.81.79 95.170.88.226 99.16.218.201

DNS names of some of these IPs are unknown (unregistered).
Others are listed below:

rrcs-108-176-54-138.nyc.biz.rr.com 109.120.137.114.addr.datapoint.ru steelf13.lnk.telstra.net HOST1.ASISHOST.COM ded4u.com gandylab.arvixevps.com 184-82-171-202.static.hostnoc.net next-solutions-38.v4.nextsolutions.net.br r243-pw-passacinco.ibys.com.br 187-44-14-35.mastercabo.com.br 187-75-163-52.dsl.telesp.net.br voip.prima.sm relay.goldenniva.ru host-196.218.177.100-static.tedata.net host-196.219.180.116-static.tedata.net 74-115-52-198-dedicated.multacom.com unknown-client.static.huge-dns.com 200-161-81-225.dsl.telesp.net.br 200.175.252.199.static.gvt.net.br 200.175.44.222.static.gvt.net.br 200-206-180-160.dsl.telesp.net.br 200-54-196-2.static.tie.cl 242.163.216.201.static.intelnet.net.gt dbdistribuidora114.static.gvt.net.br h202-203-73-140.topvision.com.tw sah1.sah.com.tr wsip-24-120-131-168.lv.lv.cox.net rrcs-24-123-136-90.central.biz.rr.com abs-static-26.8.251.27.aircel.co.in host-41.41.142.151.tedata.net 5-12-140-214.residential.rdsnet.ro 22.207.158.61.ha.cnc static-63-131-47-2.gra.onecommunications.net web01.nessit.net 64-199-111-26.ip.mcleodusa.net 9-49-31-64.static.reverse.lstn.net adsl-065-081-088-190.sip.cha.bellsouth.net 66-214-252-242.static.gldl.ca.charter.com 69-11-98-246.sktn.hsdb.sasknet.sk.ca mail.ederm.com gw.pilecky.cz 78.189.74.214.static.ttnet.com.tr 81.213.108.41.dynamic.ttnet.com.tr tru75-4-82-227-169-194.fbx.proxad.net ood123.internetdsl.tpnet.pl 45.Red-83-35-218.dynamicIP.rima-tde.net ginestra.static.otenet.gr 87-126-81-49.btc-net.bg ptr.73.startdedicated.pw ptr.77.startdedicated.pw ptr.93.startdedicated.pw 90-227-101-224-no21.business.telia.com 84.99-183-91.adsl-static.isp.belgacom.be ip81-79.mwtv.lv 95-170-88-226.colo.transip.net adsl-99-16-218-201.dsl.sndg02.sbcglobal.net

Some of them are web servers that does "software download service"!

attacks to ssh server

Of cource, we observe much more attacks to tcp22 (ssh port).
My log shows 2535 unique IPs that tried this port during the period from 2013/03/14 to the present(2013/11/23).
So many IPs to list up!

get list of these IPs

The observation shows that some of them tried a hundred password and then went away without looking "Reject" message from my server.

Protected Listner

2014/07/20

We have plisten (protected listen) and plisten1 (protected listen1).
Both listen and listen1 are listeners for Plan9.

How To Protect

Both plisten and plisten1 check the IP of requester.
The steps are as follows:
(1) if it is burst access then reject
(2) if (it is not in accept_database) and (it is in reject_database) then reject
(3) start a subprocess for the connection
That is, step (1) and (2) are added in Plan9 official listen and listen1.

The definition of burst access:
trials more than maxconnect in a given time (10 seconds).
the maxconnect is given in command option.

For simplicity, directories /sys/log/accept and /sys/log/reject are used in place of accept_database and reject_database.

File names in these directories are the IPs to accept or reject.
Therefore you can register 202.250.160.40 to accept_database by

	touch /sys/log/accept/202.250.160.40

pop3 before connection

Pop3 is the only way for a remote (non Plan9) user to register himself to accept_database.
Many authentication failures will let him to be registered in reject_database.

The code below is tcp110:

#!/bin/rc

ifs='!
' r=`{cat $3/remote} l=`{cat $3/local} {ip_local=$l(1) ip=$r(1) p=$l(2)}

if(test -e /sys/log/reject/$ip){
	/usr/local/bin/386/logit -l pop3 Rejected $ip
	echo '-ERR Rejected'
	exit
}

if(test -e /sys/log/accept/$ip){
	/$cputype/bin/upas/pop3
	exit
}

w=`{tail -10 /sys/log/pop3 | grep 'Fail '$ip | wc}

if(test $w(1) -gt 5){
	touch /sys/log/reject/$ip
	/usr/local/bin/386/logit -l pop3 List $ip
	echo '-ERR Rejected'
	exit
}

/$cputype/bin/alarm 60 /$cputype/bin/upas/pop3

# /sys/log/pop3 is something like:
# old pop3 message:
# ar Apr  8 14:56:50 user arisawa logged in
# new pop3 message:
# ar Apr  8 14:56:50 user arisawa OK 202.250.160.166
a=`{tail -1 /sys/log/pop3}
if(~ $a(7) OK && ~ $a(8) $ip){
	touch /sys/log/accept/$ip
	exit
}

/usr/local/bin/386/logit -l pop3 Fail $ip

/rc/bin/service/tcp110

Other services are rejected unless the requesting IP is in accept_database.

#!/bin/rc

ifs='!
' r=`{cat $3/remote} l=`{cat $3/local} {ip=$r(1) p=$l(2)}

if(test -e /sys/log/accept/$ip){
	exec /bin/aux/sshserve -A 'tis password' `{cat $3/remote} >>[2]/sys/log/ssh
}

echo Rejected

/usr/local/bin/386/logit -l honeypot $p $ip

/rc/bin/service/tcp22

You need to change pop3.c so that the script tcp110 can work.

	if(newns(user, 0) < 0){
		senderr("newns failed: %r; server exiting");
		exits(nil);
	}
-	syslog(0, "pop3", "user %s logged in", user);
+	syslog(0, "pop3", "user %s OK %s", user, peeraddr);
	enableaddr();

/sys/src/cmd/upas/pop3/pop3.c