# 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)
[((134, 149), 'libs.check_modules.check_modules', 'check_modules', ([], {}), '()\n', (147, 149), False, 'from libs.check_modules import check_modules\n'), ((1323, 1385), 'libs.utils.ask_question', 'ask_question', (['"""Enter the link of the video you want to report"""'], {}), "('Enter the link of the video you want to report')\n", (1335, 1385), False, 'from libs.utils import ask_question\n'), ((1748, 1795), 'libs.utils.print_status', 'print_status', (['"""Video complaint attack is on!\n"""'], {}), "('Video complaint attack is on!\\n')\n", (1760, 1795), False, 'from libs.utils import print_status\n'), ((2092, 2159), 'libs.utils.ask_question', 'ask_question', (['"""Enter the username of the person you want to report"""'], {}), "('Enter the username of the person you want to report')\n", (2104, 2159), False, 'from libs.utils import ask_question\n'), ((2489, 2544), 'libs.utils.print_status', 'print_status', (['"""Profile complaint attack is starting!\n"""'], {}), "('Profile complaint attack is starting!\\n')\n", (2501, 2544), False, 'from libs.utils import print_status\n'), ((2814, 2848), 'libs.utils.print_success', 'print_success', (['"""Modules loaded!\n"""'], {}), "('Modules loaded!\\n')\n", (2827, 2848), False, 'from libs.utils import print_success\n'), ((2862, 2916), 'libs.utils.ask_question', 'ask_question', (['"""Would you like to use a proxy? [Y / N]"""'], {}), "('Would you like to use a proxy? [Y / N]')\n", (2874, 2916), False, 'from libs.utils import ask_question\n'), ((3819, 3854), 'libs.utils.print_status', 'print_status', (['"""1 - Report Profile."""'], {}), "('1 - Report Profile.')\n", (3831, 3854), False, 'from libs.utils import print_status\n'), ((3860, 3895), 'libs.utils.print_status', 'print_status', (['"""2 - Report a video."""'], {}), "('2 - Report a video.')\n", (3872, 3895), False, 'from libs.utils import print_status\n'), ((3917, 3967), 'libs.utils.ask_question', 'ask_question', (['"""Please select the complaint method"""'], {}), "('Please select the complaint method')\n", (3929, 3967), False, 'from libs.utils import ask_question\n'), ((4411, 4423), 'libs.logo.print_logo', 'print_logo', ([], {}), '()\n', (4421, 4423), False, 'from libs.logo import print_logo\n'), ((979, 1017), 'libs.attack.report_profile_attack', 'report_profile_attack', (['username', 'proxy'], {}), '(username, proxy)\n', (1000, 1017), False, 'from libs.attack import report_profile_attack\n'), ((1238, 1275), 'libs.attack.report_video_attack', 'report_video_attack', (['video_url', 'proxy'], {}), '(video_url, proxy)\n', (1257, 1275), False, 'from libs.attack import report_video_attack\n'), ((1852, 1918), 'multiprocessing.Process', 'Process', ([], {'target': 'video_attack_process', 'args': '(video_url, proxy_list)'}), '(target=video_attack_process, args=(video_url, proxy_list))\n', (1859, 1918), False, 'from multiprocessing import Process\n'), ((2601, 2668), 'multiprocessing.Process', 'Process', ([], {'target': 'profile_attack_process', 'args': '(username, proxy_list)'}), '(target=profile_attack_process, args=(username, proxy_list))\n', (2608, 2668), False, 'from multiprocessing import Process\n'), ((2990, 3076), 'libs.utils.ask_question', 'ask_question', (['"""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]')\n", (3002, 3076), False, 'from libs.utils import ask_question\n'), ((4038, 4082), 'libs.utils.print_error', 'print_error', (['"""The answer is not understood."""'], {}), "('The answer is not understood.')\n", (4049, 4082), False, 'from libs.utils import print_error\n'), ((4092, 4099), 'sys.exit', 'exit', (['(0)'], {}), '(0)\n', (4096, 4099), False, 'from sys import exit\n'), ((4176, 4220), 'libs.utils.print_error', 'print_error', (['"""The answer is not understood."""'], {}), "('The answer is not understood.')\n", (4187, 4220), False, 'from libs.utils import print_error\n'), ((4230, 4237), 'sys.exit', 'exit', (['(0)'], {}), '(0)\n', (4234, 4237), False, 'from sys import exit\n'), ((884, 921), 'libs.attack.report_profile_attack', 'report_profile_attack', (['username', 'None'], {}), '(username, None)\n', (905, 921), False, 'from libs.attack import report_profile_attack\n'), ((1144, 1180), 'libs.attack.report_video_attack', 'report_video_attack', (['video_url', 'None'], {}), '(video_url, None)\n', (1163, 1180), False, 'from libs.attack import report_video_attack\n'), ((1488, 1546), 'multiprocessing.Process', 'Process', ([], {'target': 'video_attack_process', 'args': '(video_url, [])'}), '(target=video_attack_process, args=(video_url, []))\n', (1495, 1546), False, 'from multiprocessing import Process\n'), ((2262, 2321), 'multiprocessing.Process', 'Process', ([], {'target': 'profile_attack_process', 'args': '(username, [])'}), '(target=profile_attack_process, args=(username, []))\n', (2269, 2321), False, 'from multiprocessing import Process\n'), ((3127, 3202), 'libs.utils.print_status', 'print_status', (['"""Gathering proxy from the Internet! This may take a while.\n"""'], {}), "('Gathering proxy from the Internet! This may take a while.\\n')\n", (3139, 3202), False, 'from libs.utils import print_status\n'), ((3226, 3240), 'libs.proxy_harvester.find_proxies', 'find_proxies', ([], {}), '()\n', (3238, 3240), False, 'from libs.proxy_harvester import find_proxies\n'), ((3726, 3772), 'libs.utils.print_error', 'print_error', (['"""Answer not understood, exiting!"""'], {}), "('Answer not understood, exiting!')\n", (3737, 3772), False, 'from libs.utils import print_error\n'), ((3782, 3788), 'sys.exit', 'exit', ([], {}), '()\n', (3786, 3788), False, 'from sys import exit\n'), ((4616, 4624), 'os._exit', '_exit', (['(0)'], {}), '(0)\n', (4621, 4624), False, 'from os import _exit\n'), ((3296, 3358), 'libs.utils.print_status', 'print_status', (['"""Please have a maximum of 50 proxies in a file!"""'], {}), "('Please have a maximum of 50 proxies in a file!')\n", (3308, 3358), False, 'from libs.utils import print_status\n'), ((3384, 3433), 'libs.utils.ask_question', 'ask_question', (['"""Enter the path to your proxy list"""'], {}), "('Enter the path to your proxy list')\n", (3396, 3433), False, 'from libs.utils import ask_question\n'), ((3457, 3484), 'libs.utils.parse_proxy_file', 'parse_proxy_file', (['file_path'], {}), '(file_path)\n', (3473, 3484), False, 'from libs.utils import parse_proxy_file\n'), ((3513, 3559), 'libs.utils.print_error', 'print_error', (['"""Answer not understood, exiting!"""'], {}), "('Answer not understood, exiting!')\n", (3524, 3559), False, 'from libs.utils import print_error\n'), ((3573, 3579), 'sys.exit', 'exit', ([], {}), '()\n', (3577, 3579), False, 'from sys import exit\n')]