# coding=utf-8
#!/usr/bin/env python3

from libs.check_modules import check_modules
from sys import exit
from os import _exit

check_modules()

from os import path

from libs.logo import print_logo
from libs.utils import print_success
from libs.utils import print_error
from libs.utils import ask_question
from libs.utils import print_status
from libs.utils import parse_proxy_file
from libs.proxy_harvester import find_proxies
from libs.attack import report_profile_attack
from libs.attack import report_video_attack

from multiprocessing import Process
from colorama import Fore, Back, Style

def chunks(lst, n):
    """Yield successive n-sized chunks from lst."""
    for i in range(0, len(lst), n):
        yield lst[i:i + n]

def profile_attack_process(username, proxy_list):
    if (len(proxy_list) == 0):
        for _ in range(10):
            report_profile_attack(username, None)
        return

    for proxy in proxy_list:
        report_profile_attack(username, proxy)

def video_attack_process(video_url, proxy_list):
    if (len(proxy_list) == 0):
        for _ in range(10):
            report_video_attack(video_url, None)
        return

    for proxy in proxy_list:
        report_video_attack(video_url, proxy)

def video_attack(proxies):
    video_url = ask_question("Enter the link of the video you want to report")
    print(Style.RESET_ALL)
    if (len(proxies) == 0):
        for k in range(5):
            p = Process(target=video_attack_process, args=(video_url, [],))
            p.start()
            print_status(str(k + 1) + ". Transaction Opened!")
            if (k == 5): print()
        return

    chunk = list(chunks(proxies, 10))

    print("")
    print_status("Video complaint attack is on!\n")

    i = 1
    for proxy_list in chunk:
        p = Process(target=video_attack_process, args=(video_url, proxy_list,))
        p.start()
        print_status(str(i) + ". Transaction Opened!")
        if (k == 5): print()
        i = i + 1

def profile_attack(proxies):
    username = ask_question("Enter the username of the person you want to report")
    print(Style.RESET_ALL)
    if (len(proxies) == 0):
        for k in range(5):
            p = Process(target=profile_attack_process, args=(username, [],))
            p.start()
            print_status(str(k + 1) + ". Transaction Opened!")
        return

    chunk = list(chunks(proxies, 10))

    print("")
    print_status("Profile complaint attack is starting!\n")

    i = 1
    for proxy_list in chunk:
        p = Process(target=profile_attack_process, args=(username, proxy_list,))
        p.start()
        print_status(str(i) + ". Transaction Opened!")
        if (k == 5): print()
        i = i + 1

def main():
    print_success("Modules loaded!\n")

    ret = ask_question("Would you like to use a proxy? [Y / N]")

    proxies = []

    if (ret == "Y" or ret == "y"):
        ret = ask_question("Would you like to collect your proxies from the internet? [Y / N]")

        if (ret == "Y" or ret == "y"):
            print_status("Gathering proxy from the Internet! This may take a while.\n")
            proxies = find_proxies()
        elif (ret == "N" or ret == "n"):
            print_status("Please have a maximum of 50 proxies in a file!")
            file_path = ask_question("Enter the path to your proxy list")
            proxies = parse_proxy_file(file_path)
        else:
            print_error("Answer not understood, exiting!")
            exit()

        print_success(str(len(proxies)) + " Number of proxy found!\n")
    elif (ret == "N" or ret == "n"):
        pass
    else:
        print_error("Answer not understood, exiting!")
        exit()

    

    print("")
    print_status("1 - Report Profile.")
    print_status("2 - Report a video.")
    report_choice = ask_question("Please select the complaint method")
    print("")

    if (report_choice.isdigit() == False):
        print_error("The answer is not understood.")
        exit(0)
    
    if (int(report_choice) > 2 or int(report_choice) == 0):
        print_error("The answer is not understood.")
        exit(0)

    if (int(report_choice) == 1):
        profile_attack(proxies)
    elif (int(report_choice) == 2):
        video_attack(proxies)

if __name__ == "__main__":
    print_logo()
    try:
        main()
        print(Style.RESET_ALL)
    except KeyboardInterrupt:
        print("\n\n" + Fore.RED + "[*] Program is closing!")
        print(Style.RESET_ALL)
        _exit(0)
[((8, 0, 8, 15), 'libs.check_modules.check_modules', 'check_modules', ({}, {}), '()', False, 'from libs.check_modules import check_modules\n'), ((49, 16, 49, 78), 'libs.utils.ask_question', 'ask_question', ({(49, 29, 49, 77): '"""Enter the link of the video you want to report"""'}, {}), "('Enter the link of the video you want to report')", False, 'from libs.utils import ask_question\n'), ((62, 4, 62, 51), 'libs.utils.print_status', 'print_status', ({(62, 17, 62, 50): '"""Video complaint attack is on!\n"""'}, {}), "('Video complaint attack is on!\\n')", False, 'from libs.utils import print_status\n'), ((73, 15, 73, 82), 'libs.utils.ask_question', 'ask_question', ({(73, 28, 73, 81): '"""Enter the username of the person you want to report"""'}, {}), "('Enter the username of the person you want to report')", False, 'from libs.utils import ask_question\n'), ((85, 4, 85, 59), 'libs.utils.print_status', 'print_status', ({(85, 17, 85, 58): '"""Profile complaint attack is starting!\n"""'}, {}), "('Profile complaint attack is starting!\\n')", False, 'from libs.utils import print_status\n'), ((96, 4, 96, 38), 'libs.utils.print_success', 'print_success', ({(96, 18, 96, 37): '"""Modules loaded!\n"""'}, {}), "('Modules loaded!\\n')", False, 'from libs.utils import print_success\n'), ((98, 10, 98, 64), 'libs.utils.ask_question', 'ask_question', ({(98, 23, 98, 63): '"""Would you like to use a proxy? [Y / N]"""'}, {}), "('Would you like to use a proxy? [Y / N]')", False, 'from libs.utils import ask_question\n'), ((126, 4, 126, 39), 'libs.utils.print_status', 'print_status', ({(126, 17, 126, 38): '"""1 - Report Profile."""'}, {}), "('1 - Report Profile.')", False, 'from libs.utils import print_status\n'), ((127, 4, 127, 39), 'libs.utils.print_status', 'print_status', ({(127, 17, 127, 38): '"""2 - Report a video."""'}, {}), "('2 - Report a video.')", False, 'from libs.utils import print_status\n'), ((128, 20, 128, 70), 'libs.utils.ask_question', 'ask_question', ({(128, 33, 128, 69): '"""Please select the complaint method"""'}, {}), "('Please select the complaint method')", False, 'from libs.utils import ask_question\n'), ((145, 4, 145, 16), 'libs.logo.print_logo', 'print_logo', ({}, {}), '()', False, 'from libs.logo import print_logo\n'), ((37, 8, 37, 46), 'libs.attack.report_profile_attack', 'report_profile_attack', ({(37, 30, 37, 38): 'username', (37, 40, 37, 45): 'proxy'}, {}), '(username, proxy)', False, 'from libs.attack import report_profile_attack\n'), ((46, 8, 46, 45), 'libs.attack.report_video_attack', 'report_video_attack', ({(46, 28, 46, 37): 'video_url', (46, 39, 46, 44): 'proxy'}, {}), '(video_url, proxy)', False, 'from libs.attack import report_video_attack\n'), ((66, 12, 66, 79), 'multiprocessing.Process', 'Process', (), '', False, 'from multiprocessing import Process\n'), ((89, 12, 89, 80), 'multiprocessing.Process', 'Process', (), '', False, 'from multiprocessing import Process\n'), ((103, 14, 103, 95), 'libs.utils.ask_question', 'ask_question', ({(103, 27, 103, 94): '"""Would you like to collect your proxies from the internet? [Y / N]"""'}, {}), "(\n    'Would you like to collect your proxies from the internet? [Y / N]')", False, 'from libs.utils import ask_question\n'), ((132, 8, 132, 52), 'libs.utils.print_error', 'print_error', ({(132, 20, 132, 51): '"""The answer is not understood."""'}, {}), "('The answer is not understood.')", False, 'from libs.utils import print_error\n'), ((133, 8, 133, 15), 'sys.exit', 'exit', ({(133, 13, 133, 14): '(0)'}, {}), '(0)', False, 'from sys import exit\n'), ((136, 8, 136, 52), 'libs.utils.print_error', 'print_error', ({(136, 20, 136, 51): '"""The answer is not understood."""'}, {}), "('The answer is not understood.')", False, 'from libs.utils import print_error\n'), ((137, 8, 137, 15), 'sys.exit', 'exit', ({(137, 13, 137, 14): '(0)'}, {}), '(0)', False, 'from sys import exit\n'), ((33, 12, 33, 49), 'libs.attack.report_profile_attack', 'report_profile_attack', ({(33, 34, 33, 42): 'username', (33, 44, 33, 48): 'None'}, {}), '(username, None)', False, 'from libs.attack import report_profile_attack\n'), ((42, 12, 42, 48), 'libs.attack.report_video_attack', 'report_video_attack', ({(42, 32, 42, 41): 'video_url', (42, 43, 42, 47): 'None'}, {}), '(video_url, None)', False, 'from libs.attack import report_video_attack\n'), ((53, 16, 53, 75), 'multiprocessing.Process', 'Process', (), '', False, 'from multiprocessing import Process\n'), ((77, 16, 77, 76), 'multiprocessing.Process', 'Process', (), '', False, 'from multiprocessing import Process\n'), ((106, 12, 106, 87), 'libs.utils.print_status', 'print_status', ({(106, 25, 106, 86): '"""Gathering proxy from the Internet! This may take a while.\n"""'}, {}), "('Gathering proxy from the Internet! This may take a while.\\n')", False, 'from libs.utils import print_status\n'), ((107, 22, 107, 36), 'libs.proxy_harvester.find_proxies', 'find_proxies', ({}, {}), '()', False, 'from libs.proxy_harvester import find_proxies\n'), ((120, 8, 120, 54), 'libs.utils.print_error', 'print_error', ({(120, 20, 120, 53): '"""Answer not understood, exiting!"""'}, {}), "('Answer not understood, exiting!')", False, 'from libs.utils import print_error\n'), ((121, 8, 121, 14), 'sys.exit', 'exit', ({}, {}), '()', False, 'from sys import exit\n'), ((152, 8, 152, 16), 'os._exit', '_exit', ({(152, 14, 152, 15): '(0)'}, {}), '(0)', False, 'from os import _exit\n'), ((109, 12, 109, 74), 'libs.utils.print_status', 'print_status', ({(109, 25, 109, 73): '"""Please have a maximum of 50 proxies in a file!"""'}, {}), "('Please have a maximum of 50 proxies in a file!')", False, 'from libs.utils import print_status\n'), ((110, 24, 110, 73), 'libs.utils.ask_question', 'ask_question', ({(110, 37, 110, 72): '"""Enter the path to your proxy list"""'}, {}), "('Enter the path to your proxy list')", False, 'from libs.utils import ask_question\n'), ((111, 22, 111, 49), 'libs.utils.parse_proxy_file', 'parse_proxy_file', ({(111, 39, 111, 48): 'file_path'}, {}), '(file_path)', False, 'from libs.utils import parse_proxy_file\n'), ((113, 12, 113, 58), 'libs.utils.print_error', 'print_error', ({(113, 24, 113, 57): '"""Answer not understood, exiting!"""'}, {}), "('Answer not understood, exiting!')", False, 'from libs.utils import print_error\n'), ((114, 12, 114, 18), 'sys.exit', 'exit', ({}, {}), '()', False, 'from sys import exit\n')]