def download(self, filename, local_filename=None): if local_filename is None: local_filename = filename try: self.ftp_client.retrbinary("RETR " + filename, open(local_filename, "wb").write) except error_perm as e: Logger.warning( "Received an error_perm error. The file doesn't exist, or you don't have permissions." )
def failed(self, message="Unknown", plain=False): self.has_failed = True if plain: Logger.warning(message) else: Logger.warning("Failed to run " + self.name + "! (Message: " + str(message) + ")") self._failed(message) self._cleanup()
def login(self, username, password): if username is None and password is None: Logger.debug("Loging into FTP Server with anonymous account") Logger.debug(self.ftp_client.login()) else: Logger.debug("Loging into FTP Server with " + username) Logger.debug(self.ftp_client.login(username, password))
def read(self, convert_to_str=True): Logger.debug("Reading socket from " + self.host + ":" + str(self.port)) buffer_len = 4096 if self.type == socket.SOCK_DGRAM: buffer_len = 65535 buffer = self.socket.recv(buffer_len) if len(buffer) > 0: if convert_to_str: return buffer.decode(self.charset) else: return buffer else: return ""
def _prepare(self): if self.args.target is None: self.failed( "You need to specify a target with --target <target> !") if self.args.port is None: Logger.info("No port specified, using standard port 22") self.port = 22 else: self.port = int(self.args.port) try: self.target = RemoteTarget(self.args.target, self.port) self.target.connect() except Exception as e: self.failed("Failed to connect to the SSH server at " + self.args.target + ":" + str(self.port) + "! (" + str(e) + ")")
def read(self, convert_to_str=True): Logger.debug("Reading socket from " + self.host + ":" + str(self.port)) buffer_len = 4096 if self.type == socket.SOCK_DGRAM: buffer_len = 65535 while True: print("a") connection, address = self.socket.accept() buffer = connection.recv(buffer_len) if len(buffer) > 0: if convert_to_str: return buffer.decode(self.charset) else: return buffer else: return ""
def run(self): if not self.is_prepared: self.prepare() if self.has_failed: return print() Logger.info("Running " + self.name + "...") self.start_time = int(time.time()) try: if not self._run(): self._failed(str("Run returned false")) except Exception as e: tb = traceback.format_exc() Logger.error(tb) self._failed(str(e)) self._after()
def _run(self): subdomains = [] Logger.info("Gathering subdomains for " + str(self.target) + "...") r = requests.get( "https://crt.sh/?q=%.{d}&output=json".format(d=self.target)) if r.status_code != 200: self.failed("Failed to retrieve information from crt.sh (" + req.status_code + ")") return json_data = json.loads('[{}]'.format(r.text.replace('}{', '},{'))) for (key, value) in enumerate(json_data): subdomains.append(value['name_value']) # Delete duplicates subdomains = sorted(set(subdomains)) print() Logger.info("Found " + str(len(subdomains)) + " subdomains for domain " + self.target) for subdomain in subdomains: Logger.info(subdomain)
def _run(self): self.target.send(b'WhoAreYou\r\n') Logger.info(self.args.target + ":" + str(self.port) + " - " + self.target.read())
def connect(self): Logger.debug("Connecting socket to " + self.host + ":" + str(self.port)) self.socket.connect((self.host, self.port)) Logger.debug("Successfully connected to " + self.host + ":" + str(self.port))
def _run(self): Logger.info("Connecting to FTP Server...") self.ftp.connect(None, None) Logger.info("Logged into FTP Server " + self.ftp.host + ":" + str(self.ftp.port)) Logger.info("Testing download...") self.ftp.download("1KB.zip", local_filename="1KB.zip") Logger.info("Done downloading...") if os.path.getsize("1KB.zip") > 0: Logger.info("Download should have worked (Check manually)") Logger.info("Testing cd...") self.ftp.cd("upload") Logger.info("Testing upload...") self.ftp.upload("1KB.zip") Logger.info("Done uploading...") Logger.info("Testing ls...") print(self.ftp.ls())
def listen(self): Logger.debug("Starting to listen on " + self.host + ":" + str(self.port)) self.socket.listen() Logger.debug("Successfully started to listen on " + self.host + ":" + str(self.port))
#!/usr/bin/python3 import argparse import importlib.util import os import sys from treelib.tree import Tree, DuplicatedNodeIdError from core.exploits.ExploitCategory import ExploitCategory from core.logger.Logger import Logger from core.logger import Colors from core.ui.Banner import Banner Banner.print_banner() Logger.info("Initializing LolcatSec Exploits Framework...") categories = {} exploits = {} parser = argparse.ArgumentParser() parser.add_argument("--verbose", "-v", "-d", help="Enabled verbose output", action="store_true") parser.add_argument("--exploit", "-e", help="Skip the exploit list, just run the given exploit", default="") parser.add_argument("--info", "-i", help="Show the about page of an exploit")
def _after(self): Logger.success("Finished running " + self.name + " in " + str(self.time_elapsed) + " seconds!")
def _prepare(self): Logger.info("Preparing " + self.name + "...") self.listener = SocketListener(8383) self.listener.listen()
def after(self): self.time_elapsed = int(time.time()) - self.start_time Logger.success("Finished running " + self.name + " in " + str(self.time_elapsed) + " seconds!") self._after() self._cleanup()