Example #1
0
def main():
    lib.print_title("""
    _________________________________________
    [                                       ]
    [                                       ]
    [           Welcome to BinBot           ]
    [            Made by Mili-NT            ]
    [                                       ]
    [_______________________________________]
    """)
    while True:
        configchoice = lib.print_input("Load config file? [y]/[n]")
        if configchoice.lower() not in ['y', 'n', 'yes', 'no']:
            lib.print_error("Invalid Input.")
            continue
        elif configchoice.lower() in ['y', 'yes']:
            vars_dict = load_config()
            break
        elif configchoice.lower() in ['no', 'n']:
            vars_dict = manual_setup()
            break
    try:
        Non_API_Search(vars_dict)
    except KeyboardInterrupt:
        lib.print_status(f"Operation cancelled...")
Example #2
0
def load_config():
    parser = ConfigParser()
    while True:
        configpath = lib.print_input('Enter the full path of the config file')
        if path.isfile(configpath) is True:
            parser.read(configpath, encoding='utf-8-sig')
            workpath = parser.get('initial_vars', 'workpath')
            stop_input = parser.get('initial_vars', 'stop_input')
            if stop_input == str('True'):
                stop_input = True
            else:
                stop_input = int(stop_input)
            limiter = int(parser.get('initial_vars', 'limiter'))
            cooldown = int(parser.get('initial_vars', 'cooldown'))
            yara_scanning = parser.getboolean('initial_vars', 'yara_scanning')
            if yara_scanning is True:
                yara_dir = f"{syspath[0]}/yara_rules"
                search_rules = yara.compile(
                    filepaths={
                        f.replace(".yar", ""): path.join(
                            f'{yara_dir}/general_rules/', f)
                        for f in listdir(f'{yara_dir}/general_rules/') if
                        path.isfile(path.join(f'{yara_dir}/general_rules/', f))
                        and f.endswith(".yar")
                    })
                binary_rules = yara.compile(
                    filepaths={
                        f.replace(".yar", ""): path.join(
                            f'{yara_dir}/binary_rules/', f)
                        for f in listdir(f'{yara_dir}/binary_rules/') if
                        path.isfile(path.join(f'{yara_dir}/binary_rules/', f))
                        and f.endswith(".yar")
                    })
            else:
                search_rules = []
                binary_rules = []
            break
        else:
            lib.print_error("No such file found")
            continue
    vars_dict = {
        'workpath': workpath,
        'stop_input': stop_input,
        'limiter': limiter,
        'cooldown': cooldown,
        'yara_scanning': yara_scanning,
        'search_rules': search_rules,
        'binary_rules': binary_rules,
    }
    try:
        print("\n")
        for x in vars_dict.keys():
            if x != 'search_rules' and x != 'binary_rules':
                print(f"\x1b[94m[{x}]\x1b[0m: " +
                      f"\x1b[1;32;40m{str(vars_dict[x])}\x1b[0m")
                print("\x1b[94m---------------------\x1b[0m")
    finally:
        print("\n")
    return vars_dict
Example #3
0
def Non_API_Search(vars_dict):
    arch_runs = 0
    while True:
        if arch_runs > 0:
            lib.print_status(f"Runs: {arch_runs}")
            if arch_runs >= vars_dict['stop_input'] and vars_dict['stop_input'] is False:
                lib.print_success(f"Runs Complete, Operation Finished...")
                exit()
            else:
                lib.print_status(f"Pastes fetched, cooling down for {vars_dict['cooldown']} seconds...")
                sleep(vars_dict['cooldown']/2)
                lib.print_status(f"Halfway through cooldown")
                sleep(vars_dict['cooldown']/2)
                lib.print_status(f"resuming...")
        if arch_runs < vars_dict['stop_input'] or vars_dict['stop_input'] is True:
            arch_page = archive_connect()
            arch_soup = BeautifulSoup(arch_page.text, 'html.parser')
            sleep(2)
            lib.print_status(f"Getting archived pastes...")
            if 'access denied' in arch_page.text:
                lib.print_error(f"IP Temporarily suspending, pausing until the ban is lifted. Estimated time: one hour...")
                sleep(vars_dict['cooldown'])
                lib.print_status(f"Process resumed...")
                continue
            else:
                pass
            lib.print_status(f"Finding params...")
            table = arch_soup.find("table", class_="maintable") # Fetch the table of recent pastes
            while True:
                try:
                    tablehrefs = table.findAll('a', href=True) # Find the <a> tags for every paste
                    break
                except AttributeError:
                    lib.print_error(f"IP Temporarily suspending, pausing until the ban is lifted. Estimated time: one hour...")
                    sleep(vars_dict['cooldown'])
                    lib.print_error(f"Process resumed...")
                    continue
            for h in tablehrefs:
                proch = (h['href']).replace("/", "") # fetch the URL param for each paste
                lib.print_success("params fetched...")
                lib.print_status(f"Acting on param {proch}...")
                full_archpage, full_arch_url = parameter_connect(proch)
                item_soup = BeautifulSoup(full_archpage.text, 'html.parser')
                unprocessed = item_soup.find('textarea') # Fetch the raw text in the paste.
                taglist = [
                    '<textarea class="paste_code" id="paste_code" name="paste_code" onkeydown="return catchTab(this,event)">',
                    '<textarea class="paste_code" id="paste_code" name="paste_code" onkeydown="return catchTab(this,event)">',
                    '<textarea class="paste_textarea" id="paste_code" name="paste_code" onkeydown="return catchTab(this,event)" rows="10">',
                    '</textarea>', '<textarea class="paste_code" id="paste_code" name="paste_code" onkeydown="return catchTab(this,event)">',
                ]
                for tag in taglist:
                    unprocessed = str(unprocessed).replace(tag, "") # process the raw text by removing html tags
                archive_engine(unprocessed, proch, vars_dict)
                arch_runs += 1
                sleep(vars_dict['limiter'])
                continue
        else:
            lib.print_success(f"Operation Finished...")
            break
Example #4
0
 def print_genericerror():
     lib.print_error(f"\nException occurred: {e}")
Example #5
0
 def print_timeouterror():
     lib.print_error(f"\nException occurred: {e}\nPossible causes: Too many requests made to {archive_url}\nPossible fixes: Check firewall settings and check the status of {archive_url}.")
Example #6
0
 def print_connecterror():
     lib.print_error(f"\nException occurred: {e}\nPossible causes: Poor/Non-functioning Internet connection or pastebin is unreachable\nPossible fixes: Troubleshoot internet connection or check status of {archive_url}")
Example #7
0
def manual_setup():
    # Save path
    while True:
        workpath = lib.print_input("Enter the path you wish to save text documents to (enter curdir for current directory)")
        if workpath.lower() == 'curdir':
            if name.lower() == 'nt':
                workpath = getcwd()
            else:
                workpath = syspath[0]
        if path.isdir(workpath):
            lib.print_success("Valid Path...")
            if workpath.endswith('\\') or workpath.endswith('/'):
                pass
            else:
                if name.lower == 'nt':
                    workpath = workpath + str('\\')
                else:
                    workpath = workpath + str('/')
            break
        else:
            lib.print_error("Invalid path, check input...")
            continue
    # Looping
    while True:
        try:
            stopinput_input = lib.print_input("Run in a constant loop? [y]/[n]")
            if stopinput_input.lower() == 'y':
                stop_input = True
            elif stopinput_input.lower() == 'n':
                stop_input = int(lib.print_input("Enter the amount of successful pulls you wish to make (enter 0 for infinite)"))
            # Limiter and Cooldown
            try: limiter = int(lib.print_input("Enter the request limit you wish to use (recommended: 5)"))
            except: limiter = 5
            try: cooldown = int(lib.print_input("Enter the cooldown between IP bans/Archive scrapes (recommended: 1200)"))
            except: cooldown = 1200
            break
        except ValueError:
            lib.print_error("Invalid Input.")
            continue
    while True:
        yara_choice = lib.print_input("Enable scanning documents using YARA rules? [y/n]")
        if yara_choice.lower() not in ['y', 'n', 'yes', 'no']:
            lib.print_error("Invalid Input.")
            continue
        elif yara_choice.lower() in ['y', 'yes']:
            yara_scanning = True
            break
        elif yara_choice.lower() in ['n', 'no']:
            yara_scanning = False
            break
    # Yara Compiling
    if yara_scanning is True:
        yara_dir = f"{getcwd()}/yara_rules"
        search_rules = yara.compile(
            filepaths={f.replace(".yar", ""): path.join(f'{yara_dir}/general_rules/', f) for f in listdir(f'{yara_dir}/general_rules/') if
                       path.isfile(path.join(yara_dir, f)) and f.endswith(".yar")})
        binary_rules = yara.compile(
            filepaths={f.replace(".yar", ""): path.join(f'{yara_dir}/binary_rules/', f) for f in listdir(f'{yara_dir}/binary_rules/') if
                       path.isfile(path.join(yara_dir, f)) and f.endswith(".yar")})
    else:
        search_rules = []
        binary_rules = []
    # Saving
    while True:
        savechoice = lib.print_input('Save configuration to file for repeated use? [y]/[n]')
        if savechoice.lower() == 'n':
            break
        elif savechoice.lower() == 'y':
            configname = lib.print_input("Enter the config name (no extension)")
            try:
                with open(configname + '.ini', 'w+') as cfile:
                    cfile.write(
f"""[initial_vars]
workpath = {workpath}
stop_input = {stop_input}
limiter = {limiter}
cooldown = {cooldown}
yara_scanning = {yara_scanning}""")
                    break
            except Exception as e:
                print(f"{e}")
                break
    vars_dict = {
        'workpath': workpath,
        'stop_input': stop_input,
        'limiter': limiter,
        'cooldown': cooldown,
        'yara_scanning': yara_scanning,
        'search_rules': search_rules,
        'binary_rules': binary_rules,
    }
    try:
        print("\n")
        for x in vars_dict.keys():
            if x != 'search_rules' and x != 'binary_rules':
                if name == 'nt':
                    print(f"{x}]: {str(vars_dict[x])}")
                    print("---------------------")
                else:
                    print(f"\x1b[94m[{x}]\x1b[0m: " + f"\x1b[1;32;40m{str(vars_dict[x])}\x1b[0m")
                    print("\x1b[94m---------------------\x1b[0m")
    finally:
        print("\n")
    return vars_dict
lib.start(args.name, args.url)
calendarId = args.calendarId
if not calendarId:
    url = args.url
    
    html = lib.get_url_content(url)

    if html == "":
        lib.finish(args.name, args.url)
    
    google_calendar_pattern = re.compile(r'https://www.google.com/calendar.*?src=(?P<cID>[0-9a-zA-Z].*?((%40)|@).*?\.com)')
    
    
    try: calendarId = google_calendar_pattern.search(html).groupdict()['cID'].replace("%40", "@")
    except Exception, e: 
        lib.print_error("fail to get calendar ID")
        print e
        lib.finish(args.name, args.url)


print "~~~~~~~calendarID:%s ~~~~~~~~~~" %calendarId
    

FLOW = OAuth2WebServerFlow(
    client_id='154781234816-h5nmu0iuq3do0tsga33km22g2t0al0ru.apps.googleusercontent.com',
    client_secret='JRwb4_2ZXMe8iTf6t6GazJbD',
    scope='https://www.googleapis.com/auth/calendar.readonly',
    user_agent='test/0.1')

storage = Storage('../calendar.dat')
credentials = storage.get()
Example #9
0
def config(configpath):
    """
    :param configpath: path to config file, if it is blank or non-existent, it runs manual setup
    :return: vars_dict, a dictionary containing all the variables needed to run the main functions
    """
    # Manual Setup:
    if path.isfile(configpath) is False:
        # Saving options (workpath and saveall):
        while True:
            workpath = lib.print_input(
                "Enter the path you wish to save text documents to (enter curdir for current directory)"
            )
            workpath = syspath[0] if workpath.lower() == 'curdir' else workpath
            if path.isdir(workpath):
                lib.print_success("Valid Path...")
                workpath = workpath if any(
                    [workpath.endswith('\\'),
                     workpath.endswith('/')]) else f'{workpath}/'
            else:
                lib.print_error("Invalid path, check input...")
                continue
            savechoice = input(
                "Save all documents (Enter N to only save matched documents)? [y/n]: "
            )
            saveall = True if savechoice.lower() in ['y', 'yes'] else False
            break
        # Services to Enable (services):
        while True:
            for x in collectors.service_names.keys():
                lib.print_status(f"[{x}]: {collectors.service_names[x]}")
            service_choice = lib.print_input(
                "Enter the number(s) of the services you wish to scrape, "
                "separated by a comma").replace(" ", '').split(',')
            services = [
                collectors.service_names[int(x)] for x in service_choice
                if int(x) in collectors.service_names.keys()
            ]
            services = list(collectors.service_names.values()
                            ) if services == [] else services
            break
        # Looping, Limiter, and Cooldown Input (stop_input, limiter, cooldown):
        while True:
            loop_input = lib.print_input("Run in a constant loop? [y]/[n]")
            if loop_input.lower() == 'y':
                stop_input = True
            else:
                stop_input = int(
                    lib.print_input(
                        "Enter the amount of times you want to fetch the archives: "
                    ))
                # If they enter 0 or below pastes to fetch, run in an infinite loop:
                stop_input = True if stop_input <= 0 else stop_input
            # Limiter and Cooldown
            limiter = int(
                lib.print_input(
                    "Enter the request limit you wish to use (recommended: 5)")
            )
            cooldown = int(
                lib.print_input(
                    "Enter the cooldown between IP bans/Archive scrapes (recommended: 600)"
                ))
            # If no values are entered, select the recommended
            limiter = 5 if any(
                [limiter <= 0, isinstance(limiter, int) is False]) else limiter
            cooldown = 600 if any(
                [cooldown <= 0,
                 isinstance(cooldown, int) is False]) else cooldown
            break
        # YARA (yara_scanning)
        while True:
            yara_choice = lib.print_input(
                "Enable scanning documents using YARA rules? [y/n]")
            if yara_choice.lower() not in ['y', 'n', 'yes', 'no']:
                lib.print_error("Invalid Input.")
                continue
            elif yara_choice.lower() in ['y', 'yes']:
                yara_scanning = True
            elif yara_choice.lower() in ['n', 'no']:
                yara_scanning = False
            break
        # Building Settings Dict:
        vars_dict = {
            'workpath': workpath,
            'stop_input': stop_input,
            'limiter': limiter,
            'cooldown': cooldown,
            'yara_scanning': yara_scanning,
            'services': services,
            'saveall': saveall,
        }
        # Saving
        savechoice = lib.print_input(
            'Save configuration to file for repeated use? [y]/[n]')
        if savechoice.lower() == 'y':
            configname = lib.print_input(
                "Enter the config name (no extension)")
            configname = configname.split(
                ".")[0] if '.json' in configname else configname
            json.dump(vars_dict, open(f"{configname}.json", 'w'))
    # Loading Config:
    else:
        vars_dict = json.load(open(configpath))
    # YARA Compilation:
    # YARA rules aren't written to files because they cant be serialized
    if vars_dict['yara_scanning']:
        vars_dict['search_rules'] = yara.compile(
            filepaths={
                f.split('.')[0]: path.join(
                    f'{syspath[0]}/yara_rules/general_rules/', f)
                for f in listdir(f'{syspath[0]}/yara_rules/general_rules/')
                if path.isfile(
                    path.join(f'{syspath[0]}/yara_rules/general_rules/', f))
                and f.endswith(".yar") or f.endswith(".yara")
            })
        vars_dict['binary_rules'] = yara.compile(
            filepaths={
                f.split('.')[0]: path.join(
                    f'{syspath[0]}/yara_rules/binary_rules/', f)
                for f in listdir(f'{syspath[0]}/yara_rules/binary_rules/')
                if path.isfile(
                    path.join(f'{syspath[0]}/yara_rules/binary_rules/', f))
                and f.endswith(".yar") or f.endswith(".yara")
            })
    # Display and Return:
    try:
        print("\n")
        for x in vars_dict.keys():
            if x != 'search_rules' and x != 'binary_rules':
                print(f"\x1b[94m[{x}]\x1b[0m: " +
                      f"\x1b[1;32;40m{str(vars_dict[x])}\x1b[0m")
                print("\x1b[94m---------------------\x1b[0m")
    finally:
        print("\n")
        return vars_dict
Example #10
0
    url = args.url

    html = lib.get_url_content(url)

    if html == "":
        lib.finish(args.name, args.url)

    google_calendar_pattern = re.compile(
        r'https://www.google.com/calendar.*?src=(?P<cID>[0-9a-zA-Z].*?((%40)|@).*?\.com)'
    )

    try:
        calendarId = google_calendar_pattern.search(
            html).groupdict()['cID'].replace("%40", "@")
    except Exception, e:
        lib.print_error("fail to get calendar ID")
        print e
        lib.finish(args.name, args.url)

print "~~~~~~~calendarID:%s ~~~~~~~~~~" % calendarId

FLOW = OAuth2WebServerFlow(
    client_id=
    '154781234816-h5nmu0iuq3do0tsga33km22g2t0al0ru.apps.googleusercontent.com',
    client_secret='JRwb4_2ZXMe8iTf6t6GazJbD',
    scope='https://www.googleapis.com/auth/calendar.readonly',
    user_agent='test/0.1')

storage = Storage('../calendar.dat')
credentials = storage.get()
if credentials is None or credentials.invalid == True: