Last active
November 27, 2020 21:26
-
-
Save rchardptrsn/ceeca15dfea3a008a42e8dbdb43317c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import ipinfo | |
| from opencensus.ext.azure.log_exporter import AzureLogHandler | |
| def main(host, port): | |
| print ('Starting honeypot!') | |
| # initialize Azure Monitoring logger object | |
| logger = startLogger() | |
| s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
| s.bind((host, port)) | |
| s.listen(100) | |
| while True: | |
| (insock, address) = s.accept() | |
| # Get information about the hacker | |
| data = ipData(address) | |
| print ('Connection from:{}:{}'.format(address[0], address[1])) | |
| try: | |
| # python 2.7 code commented out: insock.send('{}\n'.format(motd)) | |
| conndata = insock.recv(1024) | |
| insock.close() | |
| except socket.error as e: | |
| writeLog(address) | |
| writeAppInsights(logger, address, data) | |
| else: | |
| writeLog(address, conndata) | |
| writeAppInsights(logger, address, data) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment