예제 #1
0
    def get_partition_from_job(self, job):
        if job.uuid in self.partition_cache:
            return self.partition_cache[job.uuid]

        try:
            client = zerorpc.Client()
            client.connect(job.address)
            obj_str = client.take(job.uuid)
            if obj_str is None:
                raise Exception("get_partition_from_job: Can't be None.")
        except zerorpc.RemoteError as e:
            if e.name == JobTaken.__name__:
                print warn('Remote job is taken. Skip.')
            elif e.name == JobFinished.__name__:
                print warn('Remote job is finished. Skip.')
            else:
                print error('Remote error at getting partition. Skip.')
            return None
        except zerorpc.LostRemote:
            print error('Lost remote at getting partition. Skip.')
            return None
        else:
            logger.info('take job:' + job.address)
            partition = load(obj_str)
            self.partition_cache[job.uuid] = partition
            return partition
예제 #2
0
    def __init__(self, token):
        self.token = token
        self.user_stories = {}

        if self.token is None:
            print colors.error("Token cant be empty")
            exit()
        else:
            self.tp = TargetProcessClient(self.token)
예제 #3
0
    def parse_comments(self):
        self.find_comment()
        comment_dict = {}
        if len(self.found_comments) > 0:
            for comment_code, comment in self.found_comments.items():
                colors.success('Found for {} : {}'.format(
                    comment_code, comment))
                comment_dict[comment_code] = comment
        else:
            colors.error('No comment found')

        return comment_dict
예제 #4
0
파일: stardox.py 프로젝트: Seabreg/Stardox
def format_url(url):

    if url.startswith('http://'):
        url=url.replace('http','https')
    elif url.startswith('www.'):
        url=url.replace('www.','https://')
    elif url.startswith('https://') or url.startswith('https://www.'):
        pass
    else:
        colors.error("Enter the repositories url in given format [ https://github.com/username/repository_name ]")
        sys.exit(1)
    return url
예제 #5
0
def check_ip(ip: str):
    """
    Check whether the input IP is valid or not
    """
    if re.match(
            r'^(?:(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])'
            '(\.(?!$)|$)){4}$', ip):
        return ip
    else:
        colors.error('Please enter a valid IP address')
        LOGGER.error('[-] Please enter a valid IP address')
        sys.exit(1)
예제 #6
0
def process_display(verbose, type, message):
    if args.v is False:
        verbose = 0

    if type == 0 and verbose == 0:
        colors.success(message)
    elif type == 1 and verbose == 0:
        colors.error(message)
    elif type == 2 and verbose == 0:
        colors.process(message)
    elif type == 3 and verbose == 0:
        colors.info(message)
예제 #7
0
    def read_dictionary(self):
        try:
            self.dictionary_path = os.getcwd() +\
                                   '/payloads/10k-most-common-passwords.txt'
            if not os.path.exists(self.dictionary_path):
                raise Exception("Dictionary does not exist")
        except Exception as e:
            colors.error(e)
            sys.exit(1)

        with open(self.dictionary_path) as file:
            for password in file.readlines():
                self.passwords_queue.put(password.strip())
예제 #8
0
def ping_death(args):
    try:
        from lib.attacks.ping_death import ping_death

        ping_deathObj = ping_death.pingDeath(ip=args.ip, url=args.url)
        ping_deathObj.startAttack()
    except ImportError:
        colors.error('Could not import the required module')
        LOGGER.error('[-] Could not import the required module')
    except Exception as e:
        print(e)
        LOGGER.error(e)
        sys.exit(1)
예제 #9
0
def mac_flood(args):
    try:
        from lib.attacks.mac_flood import mac_flood

        mac_floodObj = mac_flood.MACFlood(interface=args.interface)
        mac_floodObj.startAttack()
    except ImportError:
        colors.error('Could not import the required module')
        LOGGER.error('[-] Could not import the required module')
    except Exception as e:
        print(e)
        LOGGER.error(e)
        sys.exit(1)
예제 #10
0
 def pingScan(self, end):
     ping_ip = self.ip + '.' + str(end)
     command = self.checkOS()
     command.append(ping_ip)
     process = subprocess.Popen(command,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.PIPE,
                                shell=False)
     stdout, stderr = process.communicate()
     if self.checkStatus(stdout.decode('utf-8')):
         colors.success('Open : {}'.format(ping_ip))
     else:
         colors.error('Closed : {}'.format(ping_ip))
예제 #11
0
def hash_scan(args):

    LIST_OF_SCANS = []

    if not args.all:
        if args.md5:
            LIST_OF_SCANS.append('md5')
        if args.sha1:
            LIST_OF_SCANS.append('sha1')
        if args.sha224:
            LIST_OF_SCANS.append('sha224')
        if args.sha256:
            LIST_OF_SCANS.append('sha256')
        if args.sha512:
            LIST_OF_SCANS.append('sha512')
    else:
        LIST_OF_SCANS = ['md5', 'sha1', 'sha224', 'sha256', 'sha512']

    if args.exclude:
        to_ignore = [mode for mode in (args.exclude).split(' ')]
        try:
            for mode in to_ignore:
                LIST_OF_SCANS.remove(mode)
        except Exception as e:
            print(e)

    try:
        from lib.scanner.hash_scanner import hash_scanner

        hashScanObj = hash_scanner.HashScanner(list_scans=LIST_OF_SCANS,
                                               threads=args.threads,
                                               file_path=args.dir)
        resultDict = hashScanObj.startScan()

        if args.output:
            if args.output.endswith('.txt'):
                file = args.output
            else:
                file = args.output + '.txt'

            with open(file, 'wt') as f:
                f.write('[+] Hash Scan Result : \n\n')
                for key, item in resultDict.items():
                    f.write(str(key) + ' : ' + str(item) + os.linesep)

    except ImportError:
        colors.error('Could not import the required module.')
        LOGGER.error('[-] Could not import the required module.')
    except Exception as e:
        print(e)
        LOGGER.error(e)
예제 #12
0
    def read_payloads(self):
        try:
            payloads_path = os.getcwd() + "/payloads/detect_cms/"
            if not os.path.exists(payloads_path):
                raise Exception("Payloads folder does not exists")
        except Exception as e:
            colors.error(e)
            sys.exit(1)

        for file in os.listdir(payloads_path):
            if file.endswith(".json"):
                file = payloads_path + file
                with open(file) as payload_file:
                    self.payloads.append(json.load(payload_file))
예제 #13
0
파일: vault.py 프로젝트: 5l1v3r1/vault-1
def deauth(args):
    try:
        from lib.attacks.deauth import deauth_attack

        deauthObj = deauth_attack.Deauth(interface=args.interface,
                                         target_bssid=args.target_bssid)
        deauthObj.startProcess()
    except ImportError:
        colors.error('Could not import the required module')
        LOGGER.error('[-] Could not import the required module')
    except Exception as e:
        print(e)
        LOGGER.error(e)
        sys.exit(1)
예제 #14
0
def detect_cms(args):
    if not args.url:
        colors.error('Please enter an URL for CMS detecting')
        LOGGER.error('[-] Please enter an URL for CMS detecting')
        sys.exit(1)
    try:
        from lib.others.detect_cms import detect_cms

        detect_cmsObj = detect_cms.DetectCMS(url=args.url)
        detect_cmsObj.start_engine()

    except ImportError:
        colors.error('Could not import the required module.')
        LOGGER.error('[-] Could not import the required module.')
    except Exception as e:
        LOGGER.error(e)
예제 #15
0
    def start_engine(self):
        while not self.fuzz_queue.empty():
            fuzz_text = self.fuzz_queue.get()
            fuzz_url = self.generate_url(fuzz_text)
            self.fuzz_queue.task_done()

            try:
                status = self.send_request(fuzz_url)
                if status == 1:
                    colors.success('Found -> {}'.format(fuzz_url))
                    self.discovered_url.append(fuzz_url)
                elif status == 2:
                    colors.info('Redirection Detected -> {}'.format(fuzz_url))
                    self.redirected_url.append(fuzz_url)
            except Exception as e:
                colors.error(e)
예제 #16
0
def fuzz(args):
    if not args.url:
        colors.error('Please enter an URL for fuzzing')
        LOGGER.error('[-] Please enter an URL for fuzzing')
        sys.exit(1)
    try:
        from lib.others.fuzzer import fuzzer
        colors.info('Performing fuzzing on : {}'.format(args.url))
        fuzzObj = fuzzer.Fuzzer(base_url=args.url, thread_num=args.threads)
        fuzzObj.initiate()

    except ImportError:
        colors.error('Could not import the required module.')
        LOGGER.error('[-] Could not import the required module.')
    except Exception as e:
        LOGGER.error(e)
예제 #17
0
def jquery(args):
    if not args.url:
        colors.error('Please enter an URL for jquery checking')
        LOGGER.error('[-] Please enter an URL for jquery checking')
        sys.exit(1)
    try:
        from lib.others.info_gathering import jquery_check

        jquery_checkObj = jquery_check.JqueryCheck(url=args.url)
        jquery_checkObj.start_engine()

    except ImportError:
        colors.error('Could not import the required module.')
        LOGGER.error('[-] Could not import the required module.')
    except Exception as e:
        LOGGER.error(e)
예제 #18
0
    def get_target_IP(self):
        """
        Fetches target IP to spoof
        """

        if self.target_ip is None:
            print('[-] No target IP selected, please enter an IP address or run network scan (Enter "S") : ')
            value = str(input()).strip()
            if value == 'S' or value == 's':
                self.networkScan()
            elif self.validateIP(value):
                colors.info('Selected target IP is : {}'.format(value))
                self.target_ip = value
            else:
                colors.error('Please enter a valid IP address to continue...')
                self.get_target_IP()
예제 #19
0
def info(args):
    if not args.url:
        colors.error('Please enter an URl for information gathering')
        LOGGER.error('[-] Please enter an URl for information gathering')
        sys.exit(1)
    try:
        from lib.others.info_gathering import header_vuln
        colors.info('Performing information gathering over : {}'.format(
            args.url))

        infoGatherObj = header_vuln.HeaderVuln(args.url)
        header_data = infoGatherObj.gather_header()
        cookie_data = infoGatherObj.insecure_cookies()
        method_data = infoGatherObj.test_http_methods()

        if args.output:
            if args.output.endswith('.txt'):
                file = args.output
            else:
                file = args.output + '.txt'
            i = 1

            with open(file, 'w') as f:
                f.write('---[!] Header Details---\n\n')

                for k, v in header_data.items():
                    f.write(str(k) + ' : ' + str(v) + os.linesep)
                f.write('\n---[!] Testing Insecure Cookies---\n\n')

                for k in cookie_data:
                    f.write(k + os.linesep)
                f.write('\n---[!] Testing HTTP methods---\n\n')

                for k in method_data:
                    if i % 3 != 0:
                        f.write(str(k) + ' ')
                    else:
                        f.write(str(k) + os.linesep)
                    i = i + 1

            colors.success('File has been saved successfully')

    except ImportError:
        colors.error('Could not import the required module.')
        LOGGER.error('[-] Could not import the required module.')
    except Exception as e:
        LOGGER.error(e)
예제 #20
0
    def resetMAC(self):
        """
        Restores the MAC address of the interface
        """

        self.changeMAC(self.origMAC)

        checkMAC = self.interfaceMAC()

        if checkMAC == self.origMAC:
            colors.success('MAC address restored to default : {}'.format(
                self.origMAC))
            colors.info('Exiting...')
            sys.exit(1)
        else:
            colors.error('Failed to restore MAC address, trying again...')
            self.resetMAC()
예제 #21
0
def bruteforce(args):
    if not args.url:
        colors.error('Please enter an URL for bruteforce')
        LOGGER.error('[-] Please enter an URL for bruteforce')
        sys.exit(1)
    try:
        from lib.others.bruteforce_login import bruteforce_login
        colors.info('Performing bruteforce on : {}'.format(args.url))
        bruteforceObj = bruteforce_login.BruteforceLogin(url=args.url,
                                                         threads=args.threads,
                                                         user=args.username)
        bruteforceObj.startAttack()

    except ImportError:
        colors.error('Could not import the required module.')
        LOGGER.error('[-] Could not import the required module.')
    except Exception as e:
        LOGGER.error(e)
예제 #22
0
def scrap(args):
    if args.url is None:
        colors.error('Please provide URL to perform Scraping')
        sys.exit(1)
    else:
        try:
            from lib.crawler import finder
            links, path = crawl(args)
            finder.initiate(links, path)
            print('[X]Scraping completed')

        except ImportError:
            colors.error('Could not import the required module')
            LOGGER.error('[-] Could not import the required module')
        except Exception as e:
            print(e)
            LOGGER.error(e)
            sys.exit(1)
예제 #23
0
def admin_panel(args):
    """Find admin panel of a given domain
    """
    if args.url is None:
        colors.error('Please provide either an URL for finding admin panel')
        sys.exit(1)
    else:
        try:
            from lib.others.admin_panel import admin_panel

            admin_panel.find_admin_panel(args.url)
        except ImportError:
            colors.error('Could not import the required module')
            LOGGER.error('[-] Could not import the required module')
        except Exception as e:
            print(e)
            LOGGER.error(e)
            sys.exit(1)
예제 #24
0
def template_images(temp_image):

    template_image_dir_path = os.path.join(os.getcwd(),
                                           template_image_dir_name)
    print(template_image_dir_path)
    try:
        if os.path.isdir(template_image_dir_name):
            colors.info('Template image sections folder already exists.')
        else:
            os.mkdir(template_image_dir_path)
            colors.success('Template image sections folder created.')
    except OSError:
        colors.error('Permission denied at {}:\
            Cannot create template image sections folder'.format(
            template_image_dir_path))
        exit(1)

    os.chdir(os.path.join(os.getcwd(), template_image_dir_name))
    colors.success('Directory set to new location ')

    # Loading Template image.
    colors.success('Image read into memory')

    x = y = 0
    width = [160, 320, 480, 640]
    height = [160, 320, 480]
    count = 0
    template_thread_process = []

    for h in height:
        for w in width:
            template_thread_process.append(
                th(target=thread_breaker,
                   args=(x, y, h, w, temp_image, count)))
            x = w
            count += 1
        x = 0
        y = h

    for process in template_thread_process:
        process.start()

    for process in template_thread_process:
        process.join()
예제 #25
0
def mac_changer(args):

    try:
        colors.info('Loading MAC Changer...')

        from lib.utilities.mac_changer import mac_changer

        macObj = mac_changer.MACChanger(mac_addr=args.mac,
                                        interface=args.interface)
        macObj.startProcess()

    except ImportError:
        colors.error('Could not import the required module.')
        LOGGER.error('[-] Could not import the required module.')
        sys.exit(1)

    except Exception as e:
        print(e)
        LOGGER.error(e)
예제 #26
0
def keylogger(args):
    try:
        colors.info('Keylogger starting...')

        from lib.utilities.keylogger import keylogger

        keyloggerObj = keylogger.Keylogger(interval=args.interval,
                                           sender=args.sender,
                                           destination=args.destination,
                                           host=args.host, port=args.port,
                                           username=args.username,
                                           password=args.password)
        keyloggerObj.start_keylogger()

    except ImportError:
        colors.error('Could not import the required module.')
        LOGGER.error('[-] Could not import the required module.')
    except Exception as e:
        LOGGER.error(e)
예제 #27
0
 def __init__(self, base_url=None, thread_num=None):
     self.m = multiprocessing.Manager()
     self.base_url = base_url
     try:
         self.fuzz_file_path = os.getcwd() + '/payloads/fuzz_url.txt'
         if not os.path.exists(self.fuzz_file_path):
             raise Exception('Directory does not exist')
     except Exception as e:
         colors.error(e)
         sys.exit(1)
     if thread_num is None:
         self.thread_num = 1
     else:
         self.thread_num = int(thread_num)
     self.fuzz_queue = self.m.Queue()
     self.discovered_url = []
     self.redirected_url = []
     self.success_codes = [200, 201, 202, 203, 204, 205, 206]
     self.redirection_codes = [300, 301, 302, 303, 304, 305, 306, 307]
예제 #28
0
def ping_sweep(args):
    if not args.ip:
        colors.error('Please enter an IP address for scanning')
        sys.exit(1)
    else:
        try:
            colors.info('Initiating Ping Sweep Scan')

            from lib.ip_scanner import ping_sweep

            pingSweepObj = ping_sweep.IPScanner(ip=args.ip,
                                                start_ip=args.ip_start_range,
                                                end_ip=args.ip_end_range,
                                                threads=args.threads)
            pingSweepObj.threadingScan()
        except ImportError:
            colors.error('Could not import the required module.')
        except Exception as e:
            print(e)
예제 #29
0
def lfi(args):
    if not args.url:
        colors.error('Please enter an URL  for scanning')
        LOGGER.error('[-] Please enter an URL for scanning')
        sys.exit(1)
    try:
        colors.info('Initiating LFI Scan')

        from lib.website_scanner.lfi import lfiEngine
        lfiscanObj = lfiEngine.LFI(url=args.url, payload_path=os.getcwd() +
                                   '/payloads/lfi_payloads.json')
        lfiscanObj.startScanner()

    except ImportError:
        colors.error('Could not import the required module.')
        LOGGER.error('[-] Could not import the required module.')
        sys.exit(1)
    except Exception as e:
        LOGGER.error(e)
예제 #30
0
def arp_scan(args):
    if not args.ip:
        colors.error('Please enter an IP address for scanning')
        sys.exit(1)
    else:
        try:
            colors.info('Initiating ARP Scan')

            from lib.scanner.ip_scanner import arp_scanner

            arpScanObj = arp_scanner.ARPScan(ip=args.ip,
                                             start_ip=args.ip_start_range,
                                             end_ip=args.ip_end_range,
                                             threads=args.threads)
            arpScanObj.threadingScan()
        except ImportError:
            colors.error('Could not import the required module.')
        except Exception as e:
            print(e)
예제 #31
0
def open_redirect(args):
    if not args.url:
        colors.error('Please enter an URL  for scanning')
        LOGGER.error('[-] Please enter an URL for scanning')
        sys.exit(1)
    else:
        try:
            colors.info("Testing for open redirection Vulnerability")

            from lib.others.open_redirection import redirection
            redirection.ORVT(args.url)

        except ImportError:
            colors.error('Could not import the required module')
            LOGGER.error('[-] Could not import the required module')
        except Exception as e:
            print(e)
            LOGGER.error(e)
            sys.exit(1)
예제 #32
0
def check_ip_range(ip_start_range: int, ip_end_range: int):
    """
    Check whether the input IP range is valid or not
    """
    try:
        ip_start_range = int(ip_start_range)
        ip_end_range = int(ip_end_range)
    except ValueError:
        colors.error('Please enter a valid number for the IP range')
        LOGGER.error('[-] Please enter a valid number for the IP range')
        sys.exit(1)
    else:
        if ip_start_range > 0 and ip_end_range < 255 and\
           ip_start_range < ip_end_range:
            return ip_start_range, ip_end_range
        else:
            colors.error('Please enter a valid IP range')
            LOGGER.error('[-] Please enter a valid IP range')
            sys.exit(1)
예제 #33
0
파일: parse.py 프로젝트: pollow/CoreSML
def p_error(p):
    if p:
        print(colors.error("Syntax error near '%s' at line %d, %d" % (p.value, p.lineno, p.lexpos)))
    else:
        print(colors.error("Syntax error at EOF"))
    if error_handle == 1:
        print("Trying to discard the token '%s'" % p.value)
        yacc.errok()
    elif error_handle == 2:
        print("Trying to discard the whole sentence which includes '%s'" % p.value)
        while 1:
            tok = yacc.token()  # Get the next token
            if not tok or tok.type == ';':
                break
        yacc.restart()
    elif error_handle == 3:
        print(colors.error("It won't be fixed in p_error"))
        pass
    else:
        print(colors.error("Nothing would take place to fix the error"))
    errflag[0] = True
예제 #34
0
    def add_tag(self, tag):
        self.check_user_stories()
        succeed = []
        failed = []

        for user_story in self.user_stories['Items']:
            response = self.tp.post('UserStories', {
                'Id': user_story['Id'],
                'Tags': user_story['Tags'] + ', ' + tag
            })

            if response.status_code == 200:
                succeed.append(colors.success("User story %d add tag '%s' success" % (user_story['Id'], tag)))
            else:
                failed.append(colors.error("User story %d add tag '%s' failed" % (user_story['Id'], tag)))

        return succeed, failed
예제 #35
0
    def set_user_stories_ids(self, user_stories_ids):
        if not isinstance(user_stories_ids, list):
            print colors.error("User stories should be list instance")
            exit()

        response = self.tp.get('UserStories', {'id': user_stories_ids})

        if response.status_code != 200:
            print colors.error("Cant get user stories")
            exit()

        self.user_stories = json.loads(response.text)

        if 'Items' not in self.user_stories:
            print colors.error('Bad response')
            exit()
예제 #36
0
    def move_user_stories(self, to_state):
        self.check_user_stories()
        succeed = []
        failed = []
        for user_story in self.user_stories['Items']:
            response = self.tp.post('UserStories', {
                'Id': user_story['Id'],
                'EntityState': {'Id': self.tp.getStateCode(to_state)}
            })

            if response.status_code == 200:
                succeed.append(colors.success("User story {} \"{}\" -> \"{}\" success".format(
                    user_story['Id'],
                    user_story['EntityState']['Name'],
                    to_state
                )))
            else:
                failed.append(colors.error("User story {} \"{}\" -> \"{}\" failed".format(
                    user_story['Id'],
                    user_story['EntityState']['Name'],
                    to_state
                )))

        return succeed, failed
예제 #37
0
__all__ = ["colors"]
if __name__ == "__main__":
    import colors as console
    console.warning("Warning example")
    console.error("Error example")
    console.log("Log example")
    console.success("Success example")
    console.header("Header example")
    console.title("Title example")