Rework imports to improve dependency management
parent
707dc93fa2
commit
5ab47c5a76
14
AutoLoads.py
14
AutoLoads.py
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from DB import *
|
||||
from Config import *
|
||||
from DB import update_mods, new_task, select_mods
|
||||
from Config import ModulesDirectory
|
||||
import os, base64
|
||||
|
||||
def check_module_loaded( module_name, randomuri, user, force=False ):
|
||||
|
@ -11,25 +11,17 @@ def check_module_loaded( module_name, randomuri, user, force=False ):
|
|||
for modname in os.listdir(ModulesDirectory):
|
||||
if modname.lower() in module_name.lower():
|
||||
module_name = modname
|
||||
file = open(("%s%s" % (ModulesDirectory,module_name)), "r")
|
||||
module = file.read()
|
||||
new_task(("loadmodule %s" % module_name), user, randomuri)
|
||||
if modules_loaded:
|
||||
new_modules_loaded = "%s %s" % (modules_loaded, module_name)
|
||||
if module_name in modules_loaded:
|
||||
loaded = "YES"
|
||||
else:
|
||||
if module_name not in modules_loaded:
|
||||
for modname in os.listdir(ModulesDirectory):
|
||||
if modname.lower() in module_name.lower():
|
||||
module_name = modname
|
||||
file = open(("%s%s" % (ModulesDirectory,module_name)), "r")
|
||||
module = file.read()
|
||||
new_task(("loadmodule %s" % module_name), user, randomuri)
|
||||
update_mods(new_modules_loaded, randomuri)
|
||||
else:
|
||||
new_modules_loaded = "%s" % (module_name)
|
||||
file = open(("%s%s" % (ModulesDirectory,module_name)), "r")
|
||||
module = file.read()
|
||||
new_task(("loadmodule %s" % module_name), user, randomuri)
|
||||
update_mods(new_modules_loaded, randomuri)
|
||||
except Exception as e:
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from DB import *
|
||||
from Colours import *
|
||||
from Core import *
|
||||
from Colours import Colours
|
||||
from Core import decrypt
|
||||
from DB import get_keys
|
||||
import os, sys, re
|
||||
|
||||
file = open(sys.argv[1], "r")
|
||||
|
|
4
Core.py
4
Core.py
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import zlib, argparse, os, re, datetime, time, base64, string, random, codecs
|
||||
from Config import *
|
||||
from Utils import *
|
||||
from Config import HTTPResponses, POSHDIR
|
||||
from Utils import randomuri
|
||||
|
||||
def default_response():
|
||||
return (random.choice(HTTPResponses)).replace("#RANDOMDATA#",randomuri())
|
||||
|
|
6
Help.py
6
Help.py
|
@ -1,12 +1,14 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
logopic = """ __________ .__. _________ ________
|
||||
logopic = r"""
|
||||
__________ .__. _________ ________
|
||||
\_______ \____ _____| |__ \_ ___ \ \_____ \\
|
||||
| ___/ _ \/ ___/ | \ / \ \/ / ____/
|
||||
| | ( <_> )___ \| Y \ \ \____/ \\
|
||||
|____| \____/____ >___| / \______ /\_______ \\
|
||||
\/ \/ \/ \/
|
||||
=============== v4.8 www.PoshC2.co.uk ============="""
|
||||
=============== v4.8 www.PoshC2.co.uk =============
|
||||
"""
|
||||
|
||||
|
||||
py_help1 = """
|
||||
|
|
22
Implant.py
22
Implant.py
|
@ -1,11 +1,12 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from DB import *
|
||||
from Colours import *
|
||||
from Core import *
|
||||
from AutoLoads import *
|
||||
from ImplantHandler import *
|
||||
import urllib2
|
||||
from Colours import Colours
|
||||
from Utils import randomuri, gen_key
|
||||
from Config import PayloadsDirectory, FilesDirectory
|
||||
from DB import select_item, get_defaultbeacon, get_killdate, get_dfheader, get_otherbeaconurls, get_defaultuseragent, new_implant, new_task, update_mods, get_autoruns
|
||||
from Core import get_images
|
||||
|
||||
import urllib2, base64, datetime
|
||||
|
||||
class Implant(object):
|
||||
|
||||
|
@ -30,7 +31,7 @@ class Implant(object):
|
|||
self.ImplantID = ""
|
||||
self.Pivot = pivot
|
||||
self.KillDate = get_killdate()
|
||||
self.ServerURL = new_serverurl = select_item("HostnameIP", "C2Server")
|
||||
self.ServerURL = select_item("HostnameIP", "C2Server")
|
||||
self.AllBeaconURLs = get_otherbeaconurls()
|
||||
self.AllBeaconImages = get_images()
|
||||
self.SharpCore = """
|
||||
|
@ -63,13 +64,12 @@ IMGS19459394%s49395491SGMI""" % (self.RandomURI, self.AllBeaconURLs, self.KillDa
|
|||
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:
|
||||
EspeakError = "espeak error"
|
||||
pass
|
||||
|
||||
try:
|
||||
apikey = select_item("APIKEY","C2Server")
|
||||
|
@ -92,9 +92,9 @@ IMGS19459394%s49395491SGMI""" % (self.RandomURI, self.AllBeaconURLs, self.KillDa
|
|||
if enotifications == "Yes" and apikey and mobile:
|
||||
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 = "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)
|
||||
urllib2.urlopen(url)
|
||||
except Exception as e:
|
||||
print "SMS send error: %s" % e
|
||||
|
||||
|
|
|
@ -1,8 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import os, time, readline, base64, re, traceback, glob, sys, argparse, shlex, signal, subprocess, argparse
|
||||
import datetime
|
||||
from datetime import datetime, timedelta
|
||||
import os, time, readline, base64, re, traceback, glob, sys, argparse, shlex, signal, subprocess, argparse, datetime
|
||||
from sqlite3 import Error
|
||||
from Help import *
|
||||
from AutoLoads import *
|
||||
|
@ -15,6 +13,7 @@ from Payloads import *
|
|||
from Core import *
|
||||
from Alias import *
|
||||
from Opsec import *
|
||||
from Utils import validate_sleep_time
|
||||
|
||||
def catch_exit(signum, frame):
|
||||
sys.exit(0)
|
||||
|
@ -22,14 +21,11 @@ def catch_exit(signum, frame):
|
|||
def process_mimikatz(lines):
|
||||
# code source https://github.com/stufus/parse-mimikatz-log/blob/master/pml.py
|
||||
main_count = 0
|
||||
num_lines = len(lines)
|
||||
current = {}
|
||||
all = []
|
||||
for line in lines.split('\n'):
|
||||
main_count += 1
|
||||
percentage_count = "{0:.0f}%".format(float(main_count)/num_lines * 100)
|
||||
|
||||
val = re.match('^\s*\*\s+Username\s+:\s+(.+)\s*$', line.strip())
|
||||
val = re.match(r'^\s*\*\s+Username\s+:\s+(.+)\s*$', line.strip())
|
||||
if val != None:
|
||||
x = process_mimikatzout(current)
|
||||
if x not in all:
|
||||
|
@ -39,7 +35,7 @@ def process_mimikatz(lines):
|
|||
current['Username'] = val.group(1).strip()
|
||||
continue
|
||||
|
||||
val = re.match('^\s*\*\s+(Domain|NTLM|SHA1|Password)\s+:\s+(.+)\s*$', line.strip())
|
||||
val = re.match(r'^\s*\*\s+(Domain|NTLM|SHA1|Password)\s+:\s+(.+)\s*$', line.strip())
|
||||
if val != None:
|
||||
if val.group(2).count(" ") < 10:
|
||||
current[val.group(1).strip()] = val.group(2)
|
||||
|
@ -141,7 +137,7 @@ def argp(cmd):
|
|||
parser.add_argument('-NotHidden', '-nothidden', action='store', dest='nothidden', required=False)
|
||||
args, unknown = parser.parse_known_args(shlex.split(cmd))
|
||||
except:
|
||||
error = "error"
|
||||
pass
|
||||
return args
|
||||
|
||||
def filecomplete(text, state):
|
||||
|
@ -298,8 +294,8 @@ def startup(user, printhelp = ""):
|
|||
else:
|
||||
new_commandhistory(implant_id)
|
||||
except Exception as e:
|
||||
ExError = e
|
||||
|
||||
pass
|
||||
|
||||
if (implant_id == "") or (implant_id.lower() == "back") or (implant_id.lower() == "clear"):
|
||||
startup(user)
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from Config import *
|
||||
from Colours import *
|
||||
from Utils import *
|
||||
from Config import PayloadsDirectory, QuickCommand, FilesDirectory
|
||||
from Colours import Colours
|
||||
from Utils import gen_key, randomuri
|
||||
import StringIO, gzip, io, base64, subprocess, os, hashlib, re
|
||||
|
||||
class Payloads(object):
|
||||
|
@ -32,7 +32,7 @@ class Payloads(object):
|
|||
with open("%saes.py" % PayloadsDirectory, 'rb') as f:
|
||||
content = f.read()
|
||||
import re
|
||||
m = re.search('#KEY(.+?)#KEY', content);
|
||||
m = re.search('#KEY(.+?)#KEY', content)
|
||||
if m: keyfound = m.group(1)
|
||||
self.PythonHash = hashlib.sha512(content).hexdigest()
|
||||
self.PythonKey = keyfound
|
||||
|
|
|
@ -1,9 +1,6 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import readline
|
||||
import glob
|
||||
import os, sys, readline, glob
|
||||
|
||||
class tabCompleter(object):
|
||||
"""
|
||||
|
@ -19,8 +16,6 @@ class tabCompleter(object):
|
|||
This is the tab completer for systems paths.
|
||||
Only tested on *nix systems
|
||||
"""
|
||||
line = readline.get_line_buffer().split()
|
||||
|
||||
return [x for x in glob.glob(text+'*')][state]
|
||||
|
||||
|
||||
|
|
4
Tasks.py
4
Tasks.py
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
from Colours import *
|
||||
from Core import *
|
||||
from Colours import Colours
|
||||
from Core import load_module, load_module_sharp, encrypt, default_response
|
||||
import DB, datetime, hashlib
|
||||
|
||||
def newTask(path):
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
#!/usr/bin/env python
|
||||
import re
|
||||
import random
|
||||
import urlparse
|
||||
import os.path
|
||||
import re, random, urlparse, os.path
|
||||
|
||||
class UrlConfig:
|
||||
#urlConfig class represents the necessary URL information for PoshC2.
|
||||
|
|
Loading…
Reference in New Issue