#!/usr/bin/env python3 # -*- coding: utf-8 -*-" """ This file is part of the UFONet project, https://ufonet.03c8.net Copyright (c) 2013/2020 | psy You should have received a copy of the GNU General Public License along with UFONet; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA """ import socket, threading, re, os, time, base64, traceback import webbrowser, subprocess, json, sys, shlex import urllib.request, urllib.error from urllib.parse import urlparse as urlparse from .main import UFONet try: import pygeoip except: print("\n[Error] [AI] Cannot import lib: pygeoip. \n\n To install it try:\n\n $ 'sudo apt-get install python3-geoip libgeoip-dev libgeoip1'\n") sys.exit(2) class AjaxMap(object): def __init__(self): self.geo_db_mirror1 = 'https://turina.space/bordercheck/maps.tar.gz' # Turina Server self._geoip=None self._geoasn=None self._geoipstatus='nomap' self._err='' ufonet = UFONet() ufonet.create_options() try: self.zombies = ufonet.extract_zombies() aliens_army = ufonet.extract_aliens() droids_army = ufonet.extract_droids() ucavs_army = ufonet.extract_ucavs() rpcs_army = ufonet.extract_rpcs() self.zombies.extend(aliens_army) self.zombies.extend(droids_army) self.zombies.extend(ucavs_army) self.zombies.extend(rpcs_army) except: return def get_err(self): return self._err # check for geoip data status # basic lock file mechanism to avoid multiple downloads def get_status(self): if os.path.exists('maps.downloading'): if not os.path.exists('maps.downloadmsg'): f=open("maps.downloadmsg","wb") f.write("".encode('utf-8')) f.close() print("[Info] [AI] [Control] GeoIP data download started! -> [OK!]\n") self._geoipstatus='downloading' elif os.path.isdir('maps'): if self._geoip == None : self._geoip = pygeoip.GeoIP('maps/GeoLiteCity.dat') if self._geoasn == None : self._geoasn = pygeoip.GeoIP('maps/GeoIPASNum.dat') if os.path.exists("maps.downloadmsg") : os.remove("maps.downloadmsg") self._geoipstatus='ok' return self._geoipstatus def retrieve(self,url,name): try: handle = urllib.request.urlopen(url) CHUNK = 16384 with open(name,'wb') as fp: while True: chunk = handle.read(CHUNK) if not chunk: break fp.write(chunk) except: traceback.print_exc() def download_maps(self): # generate geolocation values on a map if self.get_status() != 'nomap': return self._geoipstatus == 'ok' if os.path.exists("maps.downloadmsg"): os.remove("maps.downloadmsg") f=open("maps.downloading",'w') f.write("download started' if os.path.exists('/tmp/ufonet.html'): for x in open(r'/tmp/ufonet.html').readlines(): stat = stat + x else: stat="[Info] [AI] [Control] Generating statistics... -> [Waiting!]" return stat+"" if self.get_status() != "ok": dljs="" if self.get_status() == "nomap": dljs+="$('#ufomsg').load('/js/ajax.js?fetchgeoip=')\n" if 'doll' in list(pGet.keys()): dljs+="$('#ufomsg').load('/js/ajax.js?fetchdoll="+pGet['doll']+"')\n" dljs+="doll=new Doll('"+pGet["doll"]+"')\n" return "[Info] [AI] GeoIP data download in progress...
See console for errors+" if 'zombie' in list(pGet.keys()): zn=base64.b64decode(pGet['zombie']).decode('utf-8') nzn=self.get_next_zombie(zn) if nzn is not None: zombie=self.get_js(nzn) return """ """ else: return "\n" if 'fetchdoll' in list(pGet.keys()): tn=pGet['fetchdoll'] target = self.geo_ip(tn) if target is None: return "doll waiting for geoip data !" return """ doll up !""" if 'doll' in list(pGet.keys()): tn=pGet['doll'] return """""" return "\n"