Ejemplo n.º 1
0
def hunt():
    #Main block
    print(w.ui.jsonFileRadio.isChecked())
    mainname = []
    mainlink = []
    #Get the username
    name = w.ui.usernameIn.text()
    output = ""
    print(colored("Starting the hunt...", "green"))
    #Start grabbing links from the Database
    for field in CurrentCollection.find({}, {
            '_id': 0,
            'name': 1,
            'link': 1,
            'type': 1
    }):
        print(colored("Grabbing one dataset from the database....", "yellow"))
        z = 0
        #If namevariation is wanted
        if w.ui.useNameVar.isChecked():
            #Mutate the name
            print(
                colored("Adding namevariation parameter... LETS MUTATE!",
                        "green"))
            mainname.clear()
            mainname = namevariation(name)
        #If namevariation is not wanted
        else:
            #Skip
            print(colored("No namevariation selected... SKIPPING!", "cyan"))
            mainname.clear()
            mainname.insert(0, name)
        #For every mutated name
        for i in mainname:
            if w.ui.useNameVar.isChecked():
                #Get all links
                print(colored("Starting namevariation...", "yellow"))
                mainlink.insert(z, field["link"].format(mainname[z]))
            else:
                #If no variation only get one link
                mainlink.clear()
                mainlink.insert(0, field["link"].format(mainname[z]))
            json.dumps(field)
            wname = field["name"]
            wtype = field["type"]
            #Is the output NSFW friendly?
            if w.ui.checkNSFWService.isChecked() != True and wtype == 1:
                #If its not friendly, censor all nsfw results
                print(
                    colored(
                        "Censoring one result... Guess you're at work... Or in China...",
                        "red"))
                output = output + "--------------------\n" + "\nCENSORED\n"
                z = z + 1
            #Continue as per usual
            else:
                #If the request uses onion routing
                if w.ui.onTor.isChecked():
                    #Get the html with the Proxy session
                    print(
                        colored("Getting new Tor session... Let's go dark...",
                                "magenta"))
                    session = getTorSession.newTorSession()
                    print(
                        colored(
                            "Getting anonymous request.... Getting statuscode",
                            "yellow"))
                    #Get the current HTTP status code
                    req = session.get(mainlink[z]).status_code
                    print(colored("DONE!", "green"))
                #If it doesnt use onion routing
                else:
                    #Get the request without a proxy
                    print(colored("Grabbing new statuscode...", "yellow"))
                    #Get the current HTTP status code
                    req = requests.get(mainlink[z]).status_code
                    print(colored("DONE!", "green"))
                #Sample the output with the recieved variables
                print(
                    colored("Collecting new sampled output data...", "yellow"))
                output = output + "--------------------\n" + "\n" + wname + "\n" + mainlink[
                    z] + "\n"
                print(colored("Translating statuscode....", "yellow"))
                #Add the current HTTP Status code and translate it to User readable
                if w.ui.jsonFileRadio.isChecked():
                    pathToLog = "./{}.json".format(w.ui.usernameIn.text())
                    loggingMethod = "JSON"
                elif w.ui.textFileRadio.isChecked():
                    pathToLog = "./{}.txt".format(w.ui.usernameIn.text())
                    loggingMethod = "PLAINTEXT"
                else:
                    pathToLog = "NONE"
                    loggingMethod = "NONE"
                output = status.statuscheck(req, output, mainlink, pathToLog,
                                            mainname, loggingMethod)
                w.ui.textEdit.setText(output)
                z = z + 1
Ejemplo n.º 2
0
def statuscheck(req, output, mainlink, pathToLog, mainname, loggingMethod):
    y = 0
    #Translate the statuscode
    for i in mainlink:
        print(colored(mainlink[y], "cyan"))
        print(colored("Testing....", "yellow"))
        if req == 200:
            output = output + "200 OK!\n"
        elif req == 503:
            output = output + "503 ERROR!\n"
        elif req == 403:
            output = output + "403 DENIED!\n"
        elif req == 404:
            output = output + "404 MISSING!\n"
        elif req == 301:
            output = output + "301 MOVED!\n"
        else:
            output = output + "TIMEOUT OR DOWN!\n"
        print(colored("DONE!", "green"))
        if w.ui.onTor.isChecked():
            print(colored("Getting new Tor session... Let's go dark... (again)", "magenta"))
            session = getTorSession.newTorSession()
            print(colored("Getting HTML document anonymously....", "yellow"))
            page = session.get(mainlink[y])
            print(colored("DONE!", "green"))
        else:
            print(colored("Getting HTML document...", "yellow"))
            page = requests.get(mainlink[y])
            print(colored("DONE!", "green"))
        #Look for Data suspicious of a missing profile in the html document
        print(colored("Parsing HTML...", "yellow"))
        soup = BeautifulSoup(page.text, 'html.parser')
        print(colored("Looking for title...", "yellow"))
        try:
            status = soup.find('title').extract()
            print(colored("Lowering title...", "yellow"))
            #Get the current html title to a parsable format
            status = status.text.lower()
        except AttributeError:
            print("Non-Valid title found... Skipping...")

        if w.ui.saveHTML.isChecked():
            print(colored("Saving to HTML document...", "yellow"))
            #Save data from custom html tag given from UI if the option is checked
            htmlFile = open("./{}.html".format(w.ui.usernameIn.text()), "a")
            #Get the html text
            soup2 = BeautifulSoup(page.text, 'html.parser')
            deeptext = w.ui.htmlTags.text()
            htmltext = soup2.find(deeptext).extract()
            htmlFile.write(str(htmltext))
            print(colored("DONE!", "green"))
            htmlFile.close()

        if status is not None:
            print(colored("Found active HTML Document...", "yellow"))
            #If the website gave back a HTTP Status code, check for words suspicious of a missing page
            if status in errorListString:
                print(colored("Guessing that page may not exist...", "yellow"))
                output = output + "FAILED TO FIND!\n"
                hit = "bad"
            else:
                print(colored("Guessing that page probably exists...", "yellow"))
                output = output + "PROBABLY EXISTS!\n"
                hit = "good"
        else:
            print(colored("FATAL ERROR! Server might be down...", "red"))
            output = output + "EMPTY TITLE CODE MAYBE DOWN OR BAD HTML?\n"
            hit = "error"
        y = y + 1
        #Give output to the main Log field
        print(colored("Outputting data....", "yellow"))
        #Write to a textfile if wanted
        if loggingMethod == "PLAINTEXT":
            print(colored("Writing to textfile in root directory...", "yellow"))
            outFileText = open(pathToLog, "w")
            outFileText.write(output)
            outFileText.close()
            print(colored("DONE!", "green"))
        #Output to json if wanted
        elif loggingMethod == "JSON":
            print(colored("Writing to JSON file in root directory...", "yellow"))
            toJSON = {
                "username": mainname,
                "link": mainlink,
                "site_status": req,
                "hit": hit
            }
            textJSON = json.dumps(toJSON)
            textJSON = textJSON + "\n"
            textJSON = re.sub(", ", ", \n", textJSON)
            textJSON = re.sub("{", "{\n", textJSON)
            textJSON = re.sub("}", "\n}", textJSON)
            jfile = open(pathToLog, "a")
            jfile.write(textJSON)
            jfile.close()
            print(colored("DONE!", "green"))
        return output
Ejemplo n.º 3
0
import re
from termcolor import colored
import requests
import pymongo
from PyQt5.QtWidgets import QApplication, QMainWindow, QDialog
from PyQt5 import QtGui
import qdarkstyle
from submodules.ui import Ui_QMainWindow
from submodules.databaseInsertion import Ui_databaseInsertion
import submodules.testForErrors as testForErrors
import submodules.getTorSession as getTorSession
import submodules.status as status
import submodules.showCredits as showCredits

errorListString = testForErrors.testAll()
newProxy = getTorSession.newTorSession()


#Make a local class for the main Window
class AppWindow(QMainWindow):
    def __init__(self):
        super().__init__()
        self.ui = Ui_QMainWindow()
        self.ui.setupUi(self)
        self.show()


#Make a local class for the Database insertion window
class DBInsertion(QDialog):
    def __init__(self):
        super().__init__()