def glastopf_index(): title = "Glastopf Logs" moi = MoI() if moi.check_conn() is False: return render_template('logs/glastopf_index.html', db_info=False) return render_template('logs/glastopf_index.html', db_info=True)
def cowrie_index(): title = "Cowrie Logs" moi = MoI() if moi.check_conn() is False: return render_template('logs/cowrie_index.html', title=title, db_info=False) return render_template('logs/cowrie_index.html', title=title, db_info=True)
def master_index(): title = "Data Master" moi = MoI() if moi.check_conn() is False: return render_template('logs/master_index.html', title=title, db_info=False) return render_template('logs/master_index.html', title=title, db_info=True)
def dionaea_index(): title = "Dionaea Logs" moi = MoI() if moi.check_conn() is False: return render_template('logs/dionaea_index.html', title=title, db_info=False) return render_template('logs/dionaea_index.html', title=title, db_info=True)
def update(self): if self.condition_id != 1: try: if self.string_id is None: url = "http://{0}:5000/api/v1/sensor/".format(self.ipaddr) req = requests.get(url, {'name_container': 'fipro-agent'}, timeout=5) else: url = "http://{0}:5000/api/v1/sensor/{1}".format(self.ipaddr, self.string_id) req = requests.get(url, timeout=5) resp = req.json() print (resp) if req.status_code == 404: self.condition_id = 5 self.status = "exited" setattr(self, 'attack_count', 0) setattr(self, 'not_found', True) if resp.get('status'): self._set_uptime(resp.get('sensor').get('state').get('StartedAt')) self._set_condition(**resp.get('sensor').get('state')) self.string_id = resp.get('sensor').get('short_id') self.container_id = resp.get('sensor').get('id') self.status = resp.get('sensor').get('status') moi = MoI() count = moi.logs.count(identifier= self.user.identifier, agent_ip= self.ipaddr) setattr(self, 'attack_count', count) self.attack_count = "{:,}".format(self.attack_count).replace(",",".") except Exception as e: print ("Error Found: {}".format(e)) self.condition_id = 5 self.status = "exited" setattr(self, 'attack_count', 0) setattr(self, 'error', True) return self
def update(self): if self.condition_id != 1: try: url = "http://{0}:5000/api/v1/sensor/{1}".format( self.agent.ipaddr, self.string_id) req = requests.get(url, timeout=5) resp = req.json() if req.status_code == 404: self.condition_id = 1 self.status = "dead" setattr(self, 'attack_count', 0) setattr(self, 'not_found', True) if resp.get('status', False): print(resp.get('sensor').get('state').get('StartedAt')) if resp.get('sensor').get('status') == "restarting": self.uptime = 1 else: self._set_uptime( resp.get('sensor').get('state').get('StartedAt')) self._set_condition(**resp.get('sensor').get('state')) self.status = resp.get('sensor').get('status') moi = MoI() count = moi.logs.count(identifier=self.user.identifier, agent_ip=self.agent.ipaddr, sensor=self.type) setattr(self, 'attack_count', count) self.attack_count = "{:,}".format( self.attack_count).replace(",", ".") except Exception as e: print("Error Found: {}".format(e)) self.condition_id = 5 self.status = "exited" setattr(self, 'attack_count', 0) setattr(self, 'error', True) return self
def source_master(): moi = MoI() if moi.check_conn() is False: return make_response(jsonify([]), 500) skip = request.args.get("start", 0) limit = request.args.get("length", 10) options = dict(limit=limit, skip=skip, order_by="-timestamp") identifier = current_user.identifier master_logs = moi.logs.get(options=options, identifier=current_user.identifier) total_data = moi.logs.count(identifier=current_user.identifier) source = [master.to_dict() for master in master_logs] response = dict(draw=request.args.get("draw"), recordsTotal=total_data, recordsFiltered=total_data, data=source) return make_response(jsonify(response), 200)