[HC Official] HoneyPy - A port scanner honeypot 07-17-2014, 12:39 AM
#1
HoneyPy is a tool (Written in the span of an hour) designed to place a passive port on your server that, when scanned for open ports/finger printed, will block the IP of a possible attacker. This requires IPTables, Python, and Linux.
I know it is hypocritical of me to not use github for this, but I don't want to link h3r0/hc to my real life work.
Let me know if you find any bugs/feature requests.
UPDATE: I have updated HoneyPy to work A LOT smoother. I found a bug where generic scans (nmap 192.168.1.*) would not trigger a connection due to SYN methods. Also using sudo nmap would completely bypass the honeypot, this has also been fixed in the newest version.
![[Image: 2xHDX0o.jpg]](http://i.imgur.com/2xHDX0o.jpg)
Notes:
Iptables will restart if your computer restarts
To flush ip table settings runTo unblock an ip run
I know it is hypocritical of me to not use github for this, but I don't want to link h3r0/hc to my real life work.
Let me know if you find any bugs/feature requests.
UPDATE: I have updated HoneyPy to work A LOT smoother. I found a bug where generic scans (nmap 192.168.1.*) would not trigger a connection due to SYN methods. Also using sudo nmap would completely bypass the honeypot, this has also been fixed in the newest version.
Code:
#!/usr/bin/env python
import socket, os, sys, getopt
from struct import *
print "\033[95m /\\ /\\/ __\\"
print " / /_/ / / Honeypy - A HoneyPot for port scans"
print "/ __ / /___ Made for http://HackCommunity.com by H3R0"
print "\\/ /_/\\____/ \033[0m"
print "Usage: ./honeypy -p 1337\n"
if not os.geteuid() == 0:
sys.exit('\033[91mScript must be run as root\033[0m')
ops, args = getopt.getopt(sys.argv[1:],"p:h:l:")
h,p,noblock = '', 5000, False
for o, a in ops:
if o == '-h':
h = a
if o == '-p':
p = int(a)
if o == '-l':
noblock = True
ls, s = socket.socket(socket.AF_INET, socket.SOCK_STREAM), socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_TCP)
ls.bind((h, p))
print '\033[92mStarted on listening on port \033[0m' + str(p)
ls.listen(5)
while 1:
packet = s.recvfrom(500)
packet = packet[0]
iph = packet[0:20]
iph = unpack('!BBHHHBBH4s4s' , iph)
version = iph[0] >> 4
ihl = iph[0] & 0xF
iph_length = ihl * 4
s_addr,d_addr = socket.inet_ntoa(iph[8]), socket.inet_ntoa(iph[9]);
tcp_header = packet[iph_length:iph_length+20]
tcph = unpack('!HHLLBBHHH' , tcp_header)
dest_port,length = tcph[1], tcph[4] >> 4
if (str(dest_port) == str(p)):
print '\033[93mINDAVER DETECTED:\033[0m ', str(s_addr)
if (noblock == False):
print 'Blocking IP...'
os.system("iptables -A INPUT -s " + str(s_addr) + " -j DROP")![[Image: 2xHDX0o.jpg]](http://i.imgur.com/2xHDX0o.jpg)
Notes:
Iptables will restart if your computer restarts
To flush ip table settings run
Code:
sudo iptables -FCode:
sudo iptables -D INPUT -s 127.0.0.1 -j DROP
(This post was last modified: 07-30-2014, 11:11 PM by zimba.)
![[Image: iQ3pcQu.png]](http://i.imgur.com/iQ3pcQu.png)
BTC Address: 1DCKgDaWcmc9dxBkhe9qrTQtrQpoFUzXdn
![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)

![[Image: wvBFmA5.png]](http://i.imgur.com/wvBFmA5.png)
A honeypot would be much more complex, it's a system which is quite easy to get into, which is used to keep the attacker away from DMZ or internal network (depending on security policy and configuration). Also a honeypot would possibly be used to gather information on the attacker so it does the opposite: easily let the attacker in to keep him there!


![[Image: 5R6Js8r.gif]](http://i.imgur.com/5R6Js8r.gif)


