Esempio n. 1
0
 def __check_programming_language(self, url):
     """
     Description:
     ============
     This method will try its level best to get the name of the programming
     language used to build the website.
     Notes:
     ======
     This method will heavily used URL class from url package
     :return:
     """
     self.__thread_semaphore.acquire()
     print("[+] ANALYSING PROGRAMMING LANGUAGE")
     # These are the popular programming languages used for designing websites
     language_names = {
         ".php": "PHP",
         ".jsp": "JSP",
         ".asp": "ASP",
         ".aspx": "ASPX",
         ".py": "PYTHON",
         ".pl": "PERL"
     }
     user_agent = UserAgent.get_user_agent()
     r = URL().get_request(url=url, user_agent=user_agent)
     if r is not None:
         soup = BeautifulSoup(r.content, "html.parser")
         for i in soup.find_all("a"):
             try:
                 partial_url = i.get("href")
                 if "http" not in partial_url:
                     new_url = URL.join_urls(url, partial_url)
                 else:
                     new_url = partial_url if URL.is_same_domain(
                         url, new_url) else ""
                 file_name = URL.get_file_name(new_url)
                 for i in language_names:
                     if i in file_name:
                         self.__programming_language_used = language_names[
                             i]
                         # Now we will update the programming language used into the database
                         InfoGatheringPhaseOneDatabase.update_programming_language(
                             self.__database_semaphore, self.__connection,
                             self.__project_id,
                             self.__programming_language_used)
                         break
                     if i in file_name:
                         break
             except Exception:
                 pass
     self.__thread_semaphore.release()
Esempio n. 2
0
 def test_firewall(self):
     self.assertEqual(
         InfoGatheringPhaseOneDatabase.update_firewall(
             database_semaphore=self.semaphore,
             connection=self.connection,
             project_id=800,
             firewall_name="Hower\""), None)
Esempio n. 3
0
 def __load_phase_one_info(self):
     """
     Description:
     ============
     This method is used to load the information from the phase one
     to the respective attributes
     :return:
     """
     result = InfoGatheringPhaseOneDatabase.get_info_gathering_phase_one(
         project_id=self.__project_id, connection=self.__connection)
     if result is not None:
         result = result[
             0]  # result will deliver tuple of tuples so we need only the first one since we used limit 1
         # e.g (project_id, status, ip, webserver_name, server_os, programming_language, firewall)
         self.__ip = result[2]
         self.__webserver_name = result[3]
         self.__server_os = result[4]
         self.__programming_language_used = result[5]
         self.__firewall_name = result[6]
     else:
         print("[-] CANNOT ADD THE INFORMATION. PLEASE CHECK YOUR DATABASE")
Esempio n. 4
0
 def get_info_gathering_details(self, project_id):
     result = InfoGatheringPhaseOneDatabase.get_info_gathering_phase_one(
         project_id=project_id, connection=self.__connection)
     return result
Esempio n. 5
0
def check_for_vulnerabilities(connection, project_id, url):
    """First phase of Information gathering"""
    thread_semaphore = threading.Semaphore(100)
    database_semaphore = threading.Semaphore(100)

    # ======================== PROOF OF CONCEPT FOR EXISTENCE OF VULNERABILITY ========
    poc = POCMaker()
    poc_thread = threading.Thread(target=poc.create_object)
    poc_thread.daemon = True
    poc_thread.start()

    # =========================== INFORMATION GATHERING PHASE - 1 =====================
    print("[*] Gathering PHASE-1 INFORMATION")
    information_gathering = web_server_informtaion.WebServerInformation(
        project_id=project_id,
        connection=connection,
        thread_semaphore=thread_semaphore,
        database_semaphore=database_semaphore,
        url=url)
    information_gathering.gather_information()
    SivaDB.update_result(connection=connection,
                         project_id=project_id,
                         phase_id="IG-PHASE-1")

    # =====================  INFORMATION ANALYSIS PHASE - 1 =============================
    PhaseOneAnalysis(project_id=project_id,
                     url=url,
                     thread_semaphore=thread_semaphore,
                     database_semaphore=database_semaphore,
                     connection=connection)
    SivaDB.update_result(connection=connection,
                         project_id=project_id,
                         phase_id="IA-PHASE-1")

    # =========================  IG PHASE - 2 HOST - DISCOVERY =================
    print("[+] INFORMATION GATHERING PHASE-2 HAS BEEN STARTED")
    result = InfoGatheringPhaseOneDatabase.get_info_gathering_phase_one(
        project_id=project_id, connection=connection)
    if result is not None:
        result = result[0]
        ip = result[2]
        firewall_name = result[6]
    if firewall_name == "None":
        port_scan = PortScan(project_id=project_id,
                             ip=ip,
                             connection=connection,
                             thread_semaphore=thread_semaphore,
                             database_semaphore=database_semaphore)
        port_scan.scan()
    SivaDB.update_result(connection=connection,
                         project_id=project_id,
                         phase_id="IG-PHASE-2")

    # =========================== INFORMATION GATHERING PHASE - 3 ============================
    print("[+] INFORMATION GATHERING PHASE-3 HAS BEEN STARTED")
    InfoGatheringPhasethree(project_id=project_id,
                            url=url,
                            thread_semaphore=thread_semaphore)
    SivaDB.update_result(connection=connection,
                         project_id=project_id,
                         phase_id="IG-PHASE-3")

    # ============================ INFORMATION ANALYSIS PHASE - 2 ===========================
    print("[+] INFORMATION ANALYSIS PHASE - 2 HAS BEEN STARTED")
    PhaseTwoAnalysis(project_id=project_id,
                     url=url,
                     thread_semaphore=thread_semaphore,
                     database_semaphore=database_semaphore,
                     connection=connection)
    SivaDB.update_result(connection=connection,
                         project_id=project_id,
                         phase_id="IA-PHASE-2")

    # ============================ INFORMATION ANALYSIS PHASE - 3 ==========================
    print("[+] INFORMATION ANALYSIS PHASE - 3 HAS BEEN STARTED")
    info_result = InfoGatheringPhaseOneDatabase.get_info_gathering_phase_one(
        project_id=project_id, connection=connection)
    webserver_name = None  # At this stage we should have the name of the webserver
    programming_language = None  # and also the name of the programming language
    info_result = info_result[0]
    if info_result is not None:
        webserver_name = info_result[3]
        programming_language = info_result[5]
    PhaseThreeAnalysis(project_id=project_id,
                       webserver_name=webserver_name,
                       programming_language=programming_language,
                       thread_semaphore=thread_semaphore,
                       database_semaphore=database_semaphore)

    # ============================= INFORMATION GATHERING PHASE - 4 =========================
    print("[+] INFORMATION GATHERING PHASE - 4 HAS BEEN STARTED")
    InfoGatheringPhaseFour(project_id=project_id,
                           url=url,
                           thread_semaphore=thread_semaphore,
                           database_semaphore=database_semaphore,
                           connection=connection)
    SivaDB.update_result(connection=connection,
                         project_id=project_id,
                         phase_id="IG-PHASE-4")

    # ========================== PERFORM A SIMPLE SCAN =======================================
    print("[*] SIMPLE SCANNER STARTED")
    SimpleCrawler(project_id=project_id,
                  base_url=url,
                  thread_semaphore=thread_semaphore,
                  database_semaphore=database_semaphore,
                  connection=connection,
                  poc_oject=poc)