Updating different scripts related to the issue #21
This commit is contained in:
parent
9fd360d3a5
commit
ea53de887d
@ -28,8 +28,8 @@ class SuricataEngine():
|
|||||||
|
|
||||||
# Generate the rule file an launch suricata.
|
# Generate the rule file an launch suricata.
|
||||||
if self.generate_rule_file():
|
if self.generate_rule_file():
|
||||||
sp.Popen("suricata -S {} -r {} -l /tmp/".format(self.rules_file,
|
sp.Popen(["suricata", "-S", self.rules_file, "-r",
|
||||||
self.pcap_path), shell=True).wait()
|
self.pcap_path, "-l", "/tmp/"]).wait()
|
||||||
|
|
||||||
# Let's parse the log file.
|
# Let's parse the log file.
|
||||||
for line in open("/tmp/fast.log", "r").readlines():
|
for line in open("/tmp/fast.log", "r").readlines():
|
||||||
|
@ -29,8 +29,8 @@ analysis:
|
|||||||
# access to it from remote location.
|
# access to it from remote location.
|
||||||
#
|
#
|
||||||
backend:
|
backend:
|
||||||
login: tinycheck
|
login: userlogin
|
||||||
password: 2de5a04967d6cffd33243bb226db194b97e1d6d1331eea3ad1e8c5e9f6e58315
|
password: userpassword
|
||||||
remote_access: true
|
remote_access: true
|
||||||
|
|
||||||
# FRONTEND -
|
# FRONTEND -
|
||||||
@ -41,7 +41,7 @@ frontend:
|
|||||||
download_links: false
|
download_links: false
|
||||||
hide_mouse: true
|
hide_mouse: true
|
||||||
kiosk_mode: true
|
kiosk_mode: true
|
||||||
remote_access: false
|
remote_access: true
|
||||||
sparklines: true
|
sparklines: true
|
||||||
virtual_keyboard: true
|
virtual_keyboard: true
|
||||||
|
|
||||||
|
@ -40,13 +40,21 @@ class Config(object):
|
|||||||
Write a new value in the configuration
|
Write a new value in the configuration
|
||||||
:return: bool, operation status
|
:return: bool, operation status
|
||||||
"""
|
"""
|
||||||
|
|
||||||
config = yaml.load(
|
config = yaml.load(
|
||||||
open(os.path.join(self.dir, "config.yaml"), "r"), Loader=yaml.SafeLoader)
|
open(os.path.join(self.dir, "config.yaml"), "r"), Loader=yaml.SafeLoader)
|
||||||
config[cat][key] = value if key != "password" else self.make_password(
|
|
||||||
value)
|
|
||||||
|
|
||||||
if cat == "network" and key == "in":
|
if cat == "network" and key in ["in", "out"]:
|
||||||
self.edit_configuration_files(value)
|
if re.match("^wlan[0-9]{1}$", value):
|
||||||
|
if key == "in":
|
||||||
|
self.edit_configuration_files(value)
|
||||||
|
config[cat][key] = value
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
elif cat == "backend" and key == "password":
|
||||||
|
config[cat][key] = self.make_password(value)
|
||||||
|
else:
|
||||||
|
config[cat][key] = value
|
||||||
|
|
||||||
with open(os.path.join(self.dir, "config.yaml"), "w") as yaml_file:
|
with open(os.path.join(self.dir, "config.yaml"), "w") as yaml_file:
|
||||||
yaml_file.write(yaml.dump(config, default_flow_style=False))
|
yaml_file.write(yaml.dump(config, default_flow_style=False))
|
||||||
|
@ -62,7 +62,7 @@ if __name__ == '__main__':
|
|||||||
ssl_key = "{}/{}".format(path[0], 'key.pem')
|
ssl_key = "{}/{}".format(path[0], 'key.pem')
|
||||||
|
|
||||||
if read_config(("backend", "remote_access")):
|
if read_config(("backend", "remote_access")):
|
||||||
app.run(host="0.0.0.0", debug=True, port=443,
|
app.run(host="0.0.0.0", port=443,
|
||||||
ssl_context=(ssl_cert, ssl_key))
|
ssl_context=(ssl_cert, ssl_key))
|
||||||
else:
|
else:
|
||||||
app.run(port=443, debug=True, ssl_context=(ssl_cert, ssl_key))
|
app.run(port=443, ssl_context=(ssl_cert, ssl_key))
|
||||||
|
@ -23,8 +23,8 @@ class Analysis(object):
|
|||||||
|
|
||||||
if self.token is not None:
|
if self.token is not None:
|
||||||
parent = "/".join(sys.path[0].split("/")[:-2])
|
parent = "/".join(sys.path[0].split("/")[:-2])
|
||||||
sp.Popen("{} {}/analysis/analysis.py /tmp/{}".format(sys.executable,
|
sp.Popen(
|
||||||
parent, self.token), shell=True)
|
[sys.executable, "{}/analysis/analysis.py".format(parent), "/tmp/{}".format(self.token)])
|
||||||
return {"status": True,
|
return {"status": True,
|
||||||
"message": "Analysis started",
|
"message": "Analysis started",
|
||||||
"token": self.token}
|
"token": self.token}
|
||||||
|
@ -45,8 +45,8 @@ class Capture(object):
|
|||||||
mkdir(self.working_dir)
|
mkdir(self.working_dir)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sp.Popen(
|
sp.Popen(["tshark", "-i", self.iface, "-w",
|
||||||
"tshark -i {} -w {} -f \"tcp or udp\" ".format(self.iface, self.pcap), shell=True)
|
self.pcap, "-f", "tcp or udp"])
|
||||||
return {"status": True,
|
return {"status": True,
|
||||||
"message": "Capture started",
|
"message": "Capture started",
|
||||||
"capture_token": self.capture_token}
|
"capture_token": self.capture_token}
|
||||||
|
@ -132,17 +132,15 @@ class Network(object):
|
|||||||
|
|
||||||
def wifi_connect(self):
|
def wifi_connect(self):
|
||||||
"""
|
"""
|
||||||
Connect to one of the WiFi networks present in the
|
Connect to one of the WiFi networks present in the wpa_supplicant.conf.
|
||||||
WPA_CONF_PERSIT_FILE.
|
|
||||||
|
|
||||||
:return: dict containing the TinyCheck <-> AP status.
|
:return: dict containing the TinyCheck <-> AP status.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# Kill wpa_supplicant instances, if any.
|
# Kill wpa_supplicant instances, if any.
|
||||||
terminate_process("wpa_supplicant")
|
terminate_process("wpa_supplicant")
|
||||||
# Launch a new instance of wpa_supplicant.
|
# Launch a new instance of wpa_supplicant.
|
||||||
sp.Popen("wpa_supplicant -B -i {} -c {}".format(self.iface_out,
|
sp.Popen(["wpa_supplicant", "-B", "-i", self.iface_out, "-c",
|
||||||
"/etc/wpa_supplicant/wpa_supplicant.conf"), shell=True).wait()
|
"/etc/wpa_supplicant/wpa_supplicant.conf"]).wait()
|
||||||
# Check internet status
|
# Check internet status
|
||||||
for _ in range(1, 40):
|
for _ in range(1, 40):
|
||||||
if self.check_internet():
|
if self.check_internet():
|
||||||
@ -235,9 +233,9 @@ class Network(object):
|
|||||||
# Kill potential zombies of hostapd
|
# Kill potential zombies of hostapd
|
||||||
terminate_process("hostapd")
|
terminate_process("hostapd")
|
||||||
|
|
||||||
sp.Popen("ifconfig {} up".format(self.iface_in), shell=True).wait()
|
sp.Popen(["ifconfig", self.iface_in, "up"]).wait()
|
||||||
sp.Popen(
|
sp.Popen(
|
||||||
"/usr/sbin/hostapd {} > /tmp/hostapd.log".format("/tmp/hostapd.conf"), shell=True)
|
"/usr/sbin/hostapd /tmp/hostapd.conf > /tmp/hostapd.log", shell=True)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
if path.isfile("/tmp/hostapd.log"):
|
if path.isfile("/tmp/hostapd.log"):
|
||||||
@ -293,8 +291,8 @@ class Network(object):
|
|||||||
try:
|
try:
|
||||||
sp.Popen("echo 1 > /proc/sys/net/ipv4/ip_forward",
|
sp.Popen("echo 1 > /proc/sys/net/ipv4/ip_forward",
|
||||||
shell=True).wait()
|
shell=True).wait()
|
||||||
sp.Popen("iptables -A POSTROUTING -t nat -o {} -j MASQUERADE".format(
|
sp.Popen(["iptables", "-A", "POSTROUTING", "-t", "nat", "-o",
|
||||||
self.iface_out), shell=True).wait()
|
self.iface_out, "-j", "MASQUERADE"]).wait()
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
@ -304,8 +302,8 @@ class Network(object):
|
|||||||
This enable interfaces, with a simple check.
|
This enable interfaces, with a simple check.
|
||||||
:return: bool if everything goes well
|
:return: bool if everything goes well
|
||||||
"""
|
"""
|
||||||
sh = sp.Popen("ifconfig {} ".format(iface),
|
sh = sp.Popen(["ifconfig", iface],
|
||||||
stdout=sp.PIPE, stderr=sp.PIPE, shell=True)
|
stdout=sp.PIPE, stderr=sp.PIPE)
|
||||||
sh = sh.communicate()
|
sh = sh.communicate()
|
||||||
|
|
||||||
if b"<UP," in sh[0]:
|
if b"<UP," in sh[0]:
|
||||||
@ -313,7 +311,7 @@ class Network(object):
|
|||||||
elif sh[1]:
|
elif sh[1]:
|
||||||
return False # The interface doesn't exists (most of the cases).
|
return False # The interface doesn't exists (most of the cases).
|
||||||
else:
|
else:
|
||||||
sp.Popen("ifconfig {} up".format(iface), shell=True).wait()
|
sp.Popen(["ifconfig", iface, "up"]).wait()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def check_internet(self):
|
def check_internet(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user