Exemple #1
0
    def upgrade(self) -> None:
        """ Updates Heimdall to the most current version available. """
        # Checks for the .git directory
        if not os.path.exists(os.path.realpath(".git")):
            Color.println("{!} Not a git repository.")
            Color.println(
                "{+} It is recommended to clone the 'ygorsimoes/Heimdall' repository from GitHub ("
                "'git clone %sHeimdall')" % self.get_github)
            sys.exit()

        # Try to update Heimdall
        output = ""
        try:
            Color.println("{+} Updating...")
            process = subprocess.Popen(
                f"git checkout . && git pull {self.get_github}Heimdall",
                shell=True,
                stdout=subprocess.PIPE,
                stderr=subprocess.STDOUT)
            output = process.communicate()
            Color.println("{+} Heimdall was successfully updated.")
            Color.println(
                "{+} Check the new release notes at: {"
                "G}https://github.com/ygorsimoes/Heimdall/commits/master{W}")
        except Exception as e:
            Color.exception("Could not update.", e)
Exemple #2
0
    def run(self):
        try:
            for j in range(self.threads):
                th = Thread(target=self.find)
                th.start()

        except (KeyboardInterrupt, SystemExit) as ex:
            Color.println("\n{!} CTRL + C has pressed. %s" % ex)
Exemple #3
0
    def banner_description(self):
        """Print design and author specifications."""

        print(f"""\n                      Version: {self.get_version}
    Author: {self.get_author} (Security Researcher)
        GitHub: {self.get_github}""")
        Color.println(
            "{O}________________________________________________________________{W}\n"
        )
Exemple #4
0
 def dashboard(self):
     """
     Heimdall, find!
     """
     Color.println("{+} User-Agent: %s" % self._user_agent['User-Agent'])
     """
     Format the target URL as simple.
     Select the output directory.
     """
     url_simple = Config.target_simple(self._url)
     path_out = os.path.realpath(f"output/{url_simple}/{date_now}/")
     """
     Create the output directory.
     """
     os.makedirs(path_out)
     Color.println("{+} Output: '%s'" % path_out)
     """
     Creates the "info.txt" file to 
     write the attack specifications.
     """
     output_info = open(os.path.realpath(f"{path_out}/info.txt"), 'w')
     output_info.writelines(f"[+] URL (Target): {self._url}\n"
                            f"[+] Proxy: {self._proxy}\n"
                            f"[+] User-Agent: {self._user_agent}\n"
                            f"[+] Output: {path_out}\n\n"
                            f"[+] Wordlist: {self._wordlist}")
     output_info.close()
     """
     Starts the request loop to the target.
     """
     Color.println("\n{+} {G}Heimdall, find the dashboard!{W}\n")
     for link in self._wordlist:
         target = self._url + link.rstrip("\n")
         request = get(target,
                       proxies=self._proxy,
                       headers=self._user_agent)
         if request.status_code == 200:
             """
             Create the file "sites-found.txt" to
             write the possible directories found.
             """
             output_sites_found = open(
                 os.path.realpath(f"{path_out}/sites-found.txt"), 'a')
             output_sites_found.writelines("\n" + target)
             output_sites_found.close()
             Color.println("{+} {G}%s{W}" % target)
         else:
             """
             Creates the file "sites-not-found.txt" to
             write the directories not found.
             """
             output_sites_not_found = open(
                 os.path.realpath(f"{path_out}/sites-not-found.txt"), 'a')
             output_sites_not_found.write("\n" + target)
             output_sites_not_found.close()
             Color.println("{-} %s" % target)
Exemple #5
0
    def banner():
        """Print the pure colored Heimdall banner."""

        Color.println(
            r"""{O}________________________________________________________________
                    _               _       _ _ 
          /\  /\___(_)_ __ ___   __| | __ _| | |
         / /_/ / _ \ | '_ ` _ \ / _` |/ _` | | |
        / __  /  __/ | | | | | | (_| | (_| | | |
        \/ /_/ \___|_|_| |_| |_|\__,_|\__,_|_|_|{W}""")
Exemple #6
0
    def run(self) -> list:
        """Opens the text files containing the wordlist."""

        if self._wordlist == "1":
            wordlist_text = open(os.path.realpath("extra/wordlists/small.txt"),
                                 'r')
            Color.println("{+} Wordlist Small: 'extra/wordlists/small.txt'")

        elif self._wordlist == "2":
            wordlist_text = open(
                os.path.realpath("extra/wordlists/medium.txt"), 'r')
            Color.println("{+} Wordlist Medium: 'extra/wordlists/medium.txt'")

        elif self._wordlist == "3":
            wordlist_text = open(os.path.realpath("extra/wordlists/big.txt"),
                                 'r')
            Color.println("{+} Wordlist Big: 'extra/wordlists/big.txt'")

        else:
            Color.println("{+} Wordlist Alternative: %s" % self.run())
            wordlist_text = open(self._wordlist, 'r')

        wordlist = wordlist_text.readlines()
        wordlist_text.close()

        # Returns the selected wordlist.
        return wordlist
Exemple #7
0
    def verify(self, arg_update: bool) -> bool:
        """ Checks for updates to update versions. """
        # Make a request for the repository version.
        req_repository = self.request.get(self.get_repository).json()
        repository_version = req_repository["specifications"]["version"]

        # Checks whether the repository version is different from the current version.
        if repository_version != self.get_version:
            Color.println("\n{+} New version available: {G}%s{W}" %
                          repository_version)
            return True
        else:
            if arg_update:
                Color.println(
                    "\n{+} Congratulations, you are already using the latest version available."
                )
                sys.exit()
Exemple #8
0
    def find(self):
        """Heimdall, Find! """

        # Starts the request loop to the target.
        for link in self._wordlist:

            target = self._url + link.rstrip("\n")

            if target not in self.scanned:

                self.scanned.append(target)

                request = get(target,
                              proxies=self._proxy,
                              headers=self._user_agent)
                if self._no_redirects is False:
                    request = get(target,
                                  proxies=self._proxy,
                                  headers=self._user_agent,
                                  allow_redirects=self._no_redirects)

                if request.status_code == 200:
                    # Create the file "sites-found.txt" to write the possible directories found.
                    output_sites_found = open(
                        os.path.realpath(f"{self.path_out}/sites-found.txt"),
                        'a')
                    output_sites_found.writelines("\n" + target)
                    output_sites_found.close()
                    Color.println("{+} {G}%s{W}" % target)

                else:
                    # Creates the file "sites-not-found.txt" to write the directories not found.
                    output_sites_not_found = open(
                        os.path.realpath(
                            f"{self.path_out}/sites-not-found.txt"), 'a')
                    output_sites_not_found.write("\n" + target)
                    output_sites_not_found.close()
                    Color.println("{-} %s" % target)
Exemple #9
0
 def proxy(self):
     """
     Formats the selected proxy accordingly.
     """
     if self._proxy is not None:
         if self._proxy[:7] == "http://":
             self._proxy = {'http://': self._proxy}
             Color.println("{+} Proxy: %s" % self._proxy['http://'])
         elif self._proxy[:8] == "https://":
             self._proxy = {'https://': self._proxy}
             Color.println("{+} Proxy: %s" % self._proxy['https://'])
         elif self._proxy[:3] == "ftp":
             self._proxy = {'ftp': self._proxy}
             Color.println("{+} Proxy: %s" % self._proxy['ftp'])
         else:
             self._proxy = ""
         return self._proxy
Exemple #10
0
    def format_proxy(self) -> dict:
        """ Formats the selected proxy accordingly. """

        if self._proxy[:7] == "http://":
            self._proxy = {'http://': self._proxy}
            Color.println("{+} Proxy: %s" % self._proxy['http://'])

        elif self._proxy[:8] == "https://":
            self._proxy = {'https://': self._proxy}
            Color.println("{+} Proxy: %s" % self._proxy['https://'])

        elif self._proxy[:3] == "ftp":
            self._proxy = {'ftp': self._proxy}
            Color.println("{+} Proxy: %s" % self._proxy['ftp'])

        else:
            self._proxy = {'': ''}

        return self._proxy
Exemple #11
0
    def dashboard(self) -> None:
        """Heimdall, Dashboard!"""

        Color.println("{+} Follow redirects: %s" % self._no_redirects)
        Color.println("{+} User-Agent: %s" % self._user_agent['User-Agent'])

        # Format the target URL as simple and select the output directory.
        url_simple = Config.target_simple(self._url)
        self.path_out = os.path.realpath(f"output/{url_simple}/{date_now}/")

        # Create the output directory.
        os.makedirs(self.path_out)
        Color.println("{+} Output: '%s'" % self.path_out)

        # Creates the "info.txt" file to write the attack specifications.
        output_info = open(os.path.realpath(f"{self.path_out}/info.txt"), 'w')
        output_info.writelines(f"[+] URL (Target): {self._url}\n"
                               f"[+] Proxy: {self._proxy}\n"
                               f"[+] User-Agent: {self._user_agent}\n"
                               f"[+] Allow-Redirects: {self._no_redirects}\n"
                               f"[+] Output: {self.path_out}\n\n"
                               f"[+] Wordlist: {self._wordlist}")
        output_info.close()
Exemple #12
0
from src.core.color import Color
from src.core.banner import Strings
from src.core.update import Update

from src.request.user_agent import UserAgent
from src.request.proxy import Proxy
from src.request.request import Request

from src.finder import Finder
from src.utils.wordlist import Wordlist

# Try to import libraries.
try:
    from requests import get
except ModuleNotFoundError as ex:
    Color.println("{!} %s Please install requirements: {R}pip3 install -r requirements.txt{W}" % ex)

parser = argparse.ArgumentParser(add_help=False)

parser.add_argument("-h", "--help",
                    action="store_true",
                    help="Show this help message and exit")

parser.add_argument("-u", "--url",
                    action="store",
                    type=str,
                    default=False,
                    help="Target URL (https://www.site_target.com/)")

parser.add_argument("-t", "--threads",
                    action="store",
Exemple #13
0
from src.core.config import Config
from src.core.color import Color
from src.core.strings import Strings
from src.core.update import Update

from src.finder import Finder
from src.utils.check import Check
from src.utils.setter import Setter
"""
Try to import libraries.
"""
try:
    from requests import get
except ModuleNotFoundError as ex:
    Color.println(
        "{!} %s Please install requirements: {R}pip3 install -r requirements.txt{W}"
        % ex)
"""
Capture all passed 
command line arguments.
"""
parser = argparse.ArgumentParser(add_help=False)

parser.add_argument("-h",
                    "--help",
                    action="store_true",
                    help="Show this help message and exit")

parser.add_argument("-u",
                    "--url",
                    action="store",