예제 #1
0
    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."
            )
예제 #2
0
    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()
예제 #3
0
 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))
예제 #4
0
    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) + ")")
예제 #6
0
    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 ""
예제 #7
0
    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()
예제 #8
0
    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())
예제 #10
0
 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))
예제 #11
0
    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())
예제 #12
0
 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))
예제 #13
0
#!/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")
예제 #14
0
 def _after(self):
     Logger.success("Finished running " + self.name + " in " +
                    str(self.time_elapsed) + " seconds!")
예제 #15
0
    def _prepare(self):
        Logger.info("Preparing " + self.name + "...")

        self.listener = SocketListener(8383)
        self.listener.listen()
예제 #16
0
 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()