Problem Statement:
Design and implementation of Honeypot
Design and implementation of Honeypot
PROGRAM
#!/usr/bin/env python
#Name: pyp0t.py
#Version: 0.2
#Author: s3my0n
import time
import socket
def getstuff():
banner = raw_input('\nEnter banner information: ')
host = raw_input('Enter IP Address: ')
while True:
try:
port = int(raw_input('Enter Port Number: '))
except TypeError:
print '\n[-] Error: invalid port number\n'
continue
else:
if (port < 1) or (port > 65535):
print '\n[-] Error: invalid port number\n'
continue
else:
return (banner, host, port)
def writelog(client, data=''):
separator = '='*40
fopen = open('\\home\\potlog.txt', 'a')
fopen.write('Time: %s\nIP Address: %s\nPort: %d\n\n%s%s\n\n'%(time.ctime(), client[0], fopen.close()
def main(host, port, banner):
print '\n[*] Listening ...\n'
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((host, port))
s.listen(100)
while True:
(insock, address) = s.accept()
print '[*] Connection from: %s:%d' % (address[0], address[1])
try:
insock.send('%s\n'%(banner))
data = insock.recv(1024)
insock.close()
except socket.error, e:
writelog(address)
else:
writelog(address, data)
if __name__=='__main__':
try:
stuff = getstuff()
main(stuff[1], stuff[2], stuff[0])
except KeyboardInterrupt:
print '\n\n[+] Exiting...'
exit(0)
except BaseException, e:
print '\n[-] Error: %s' % (e)
exit(1)
OUTPUT
No comments:
Post a Comment