Nowadays Internet is full of crawlers, bots and skids. If their purpose is evil, this could be a significant threat for unprepared users. To reduce risk for ordinary users, there are a few reputation services, providing rating of IP, domain or even URI. Some of them are: AbuseIPDB, SANS DShield, VirusTotal and CSIRTG. Mostly, they are filled by volunteers maintaining own honeypots.
How those websites can be used?
All of them are collecting huge amounts of computer abuse reports from volunteers around the world, then calculating reported IP-address’ suspicity and providing huge lists of bad addresses to avoid, or even nullroute. Thus harm from low-effort and non-targeted attack, involving huge subnets, can be minimized.
How to maintain own honeypot?
You just need some time to configure software, computer, server or Raspberry Pi, etc (I suggest to use any Linux distribution on such host) and static IPv4 (to open 22/tcp port).
If you are ready, let’s start. I will show example for CentOS 7 (should be valid for CentOS 8 Stream too), but in case of any errors at distro of your choice don’t forget to search information on the net.
1) Install Cowrie
Firstly, we need to create new user - it will be used to run our SSH honeypot:
useradd -mU cowrie &&cd /home/cowrie
Install required packages:
sudo yum -y install git python3-virtualenv vim
Then, we need to download latest sources. Let’s login to cowrie user:
Now let’s edit /home/cowrie/cowrie/etc/cowrie.cfg:
sudo -u cowrie vim /home/cowrie/cowrie/etc/cowrie.cfg
Paste following config:
[ssh]enabled=trueforwarding=falsesftp_enabled=falselisten_endpoints=tcp:2222:interface=0.0.0.0[telnet]enabled=truelisten_endpoints=tcp:2323:interface=0.0.0.0[output_jsonlog]enabled=false# Send login attemp information to SANS DShield# See https://isc.sans.edu/ssh.html# You must signup for an api key.# Once registered, find your details at:# https://isc.sans.edu/myaccount.html# Enable DShield later[output_dshield]enabled=falseuserid=YOUR_USERIDauth_key=YOUR_AUTH_KEYbatch_size=1# VirusTotal output module# You must signup for an api key.# Enable VT output later[output_virustotal]enabled=falseapi_key=YOUR_API_KEYupload=Truedebug=Falsescan_file=Truescan_url=True# https://www.abuseipdb.com# You have to set api_key to# enable abuseipdb reporting[output_abuseipdb]enabled=falseapi_key=YOUR_API_KEY_HERErereport_after=24tolerance_window=0tolerance_attempts=1
Don’t forget to carefully read comments in the config and add needed credentials or api keys to upload reports.
Before starting cowrie, we need to move our SSH to different port. We need to edit /etc/ssh/sshd_config. Change this:
#Port 22
To this:
Port YOUR_RANDOM_PORT
You have to change YOUR_RANDOM_PORT to any port of your choice. I suggest to use ephermal port like 32976. And open this port in our firewall:
For security reasons, cowrie listens on ports >1024. So, we need to forward requests from 22 and 23 to 2222 and 2323 respectively. To do this we can simply use firewalld (I assume you have properly configurated it):