Repository navigation
Expand file tree
/
Copy pathsetup.py
More file actions
120 lines (98 loc) · 4.49 KB
/
Copy pathsetup.py
File metadata and controls
120 lines (98 loc) · 4.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
"""This is the main file for icarus"""
import os
import curses
import sys
from multiprocessing import Process
import aiosmtpd.smtp
# Below are my functions.
from app.editor import editor
from app.udp import runudp
from app.tcp import runtcp
from app.abuseipdb import largfeed, httppost
import app.cfg
# pylint: disable=R0801
from app.config import config
aiosmtpd.smtp.__ident__ = "Microsoft ESMTP MAIL Service"
# pylint: disable=R0915, W0613
def start_background_processes():
"""Starts all the background processes."""
processes = []
# Largfeed Queue processor
if config.largfeedon != "no" and config.httpposton == 'no':
process3 = Process(name='largfeed', target=largfeed, daemon=True)
process3.start()
processes.append(process3)
if config.largfeedon == "no" and config.httpposton != 'no':
process3 = Process(name='httppost', target=httppost, daemon=True)
process3.start()
processes.append(process3)
# Dynamic low interaction port services.
for tcpport in config.tcpports.replace(" ", "").split(','):
dyntcpprocess = Process(name='DynamicTCP ' + str(tcpport), target=runtcp, daemon=True, args=(int(tcpport),))
dyntcpprocess.start()
processes.append(dyntcpprocess)
for udpport in config.udpports.replace(" ", "").split(','):
dynudpprocess = Process(name='DynamicUDP ' + str(udpport), target=runudp, daemon=True, args=(int(udpport),))
dynudpprocess.start()
processes.append(dynudpprocess)
return processes
def handle_ui(window, processes):
"""Handles the user interface."""
while True:
scurses = curses.initscr()
curses.curs_set(0)
curses.noecho()
curses.napms(500)
# Pretty standard configs. I have the curses refresh set to 3 seconds.
# https://docs.python.org/3.5/library/curses.html#module-curses
curses.start_color()
curses.init_pair(1, curses.COLOR_RED, curses.COLOR_BLACK)
curses.init_pair(2, curses.COLOR_CYAN, curses.COLOR_BLACK)
curses.init_pair(3, curses.COLOR_GREEN, curses.COLOR_BLACK)
sheight, swidth = scurses.getmaxyx()
cursewinder = curses.newwin(sheight, swidth, 0, 0)
cursewinder.nodelay(True)
# No delay fixes a problem of the screen not updating properly.
# the above 5 are just standard curses commands.
# First number is vertical, 51 is horizontal
cursewinder.addstr(0, 51, "Icarus.config")
cursewinder.addstr(1, 51, "Virustotal:")
cursewinder.addstr(2, 51, "Enabled: " + config.virustotal)
cursewinder.addstr(3, 51, "APIKEY: " + config.vtapikey)
cursewinder.addstr(5, 51, "AbuseIPDB:")
cursewinder.addstr(6, 51, "Enabled: " + config.abuseip)
cursewinder.addstr(7, 51, "APIKEY: " + config.abuseapikey)
cursewinder.addstr(9, 51, "Syslog:")
cursewinder.addstr(10, 51, "Enabled: " + config.syslogenable)
cursewinder.addstr(11, 51, "Syslog Server: " + config.syslogip + ":" + config.syslogport)
cursewinder.addstr(13, 51, "LARGfeed:")
cursewinder.addstr(14, 51, "Enabled: " + config.largfeedon)
cursewinder.addstr(15, 51, "LARGfeed Server: " + config.largfeedserver + ":" + config.largfeedport)
cursewinder.addstr(17, 51, "Press P to change values.", curses.color_pair(2))
cursewinder.addstr(18, 51, "Press R to restart.", curses.color_pair(3))
cursewinder.addstr(19, 51, "Press Q to quit.", curses.color_pair(1))
cursewinder.addstr(0, 0, "ICARUS HONEYPOT", curses.color_pair(1))
cursewinder.addstr(12, 0, "Attacks: " + str(app.cfg.numattacks['num']))
cursewinder.addstr(13, 0, "Last 5 Attackers: ", curses.color_pair(3))
if app.cfg.attackers:
for num, address in enumerate(app.cfg.attackers, start=1):
cursewinder.addstr((num + 13), 0, str(address))
cursewinder.refresh()
key = cursewinder.getch()
if key == ord('q'):
break
if key == ord('r'):
for p in processes:
p.terminate()
os.execv(sys.executable, ['python3'] + sys.argv)
# Nice little thing that restarts a python script.
elif key == ord('p'):
editor() # from editor.py, opens your system editor.
cursewinder.erase()
cursewinder.refresh()
def main(window):
"""MAIN!"""
processes = start_background_processes()
handle_ui(window, processes)
if __name__ == '__main__':
curses.wrapper(main)