示例#1
0
def Check_Installtion_G3nius(Verbos=True):
    if (isdir('/usr/share/G3nius-Tools') and isfile('/bin/g3nius-tools')):
        if (Verbos):
            Handler(Error_Levels.Alert, "G3nius-Tools already Installed.")
        return True
    else:
        if (Verbos):
            Handler(Error_Levels.Failed_Job, "G3nius-Tools not installed.")
        return False
示例#2
0
def gpl_read_from_file(File_Name,
                       read_bytes=False,
                       encoding='UTF-8',
                       show_error=True,
                       on_access_failed_text="Can't read file.",
                       on_access_failed_description_text=None,
                       on_access_failed_return_value=None,
                       on_access_failed_exit_code=None,
                       on_CTRL_C_return_value=None,
                       on_CTRL_C_exit_code=None):
    try:
        if read_bytes:
            file = open(File_Name, 'rb', encoding=encoding)
        else:
            file = open(File_Name, 'r', encoding=encoding)
        Content = file.read()
        file.close()
    except KeyboardInterrupt:
        if on_CTRL_C_exit_code:
            Exit_Request(Exit_Codes.CTRL_C)
        return on_CTRL_C_return_value
    except:
        if show_error:
            Handler(Error_Levels.High, on_access_failed_text,
                    on_access_failed_description_text)
        if on_access_failed_exit_code:
            Exit_Request(on_access_failed_exit_code)
        return on_access_failed_return_value
    return Content
示例#3
0
def Clean_Temp_Dir(Exit_If_Error=True):
    Location = G3nius_Location()
    try:
        if isdir(Location + '/tmp'):
            rmtree(Location + '/tmp')
        elif isfile(Location + '/tmp'):
            remove(Location + '/tmp')
        mkdir(Location + '/tmp')
    except:
        # import here to block loop
        from lib.core.Error_Handler import Handler
        if Exit_If_Error:
            Handler(Critical,
                    "'tmp' folder can't be delete or create! Manage access.")
        else:
            Handler(High,
                    "'tmp' folder can't be delete or create! Manage access.")
示例#4
0
def gpl_while_input(title: str,
                    list_of_chooses=[],
                    text_color='magenta',
                    number_color='green',
                    title_color='white',
                    input_text='Number of choose : ',
                    input_color='blue',
                    on_invalid_sleep_time=1,
                    on_invalid_text='Invalid number!',
                    on_exit_request_text='Exit with user request.',
                    on_exit_request_forground_text_color='yellow',
                    exit_option=True,
                    exit_option_text='Exit (or "q").'):
    if exit_option:
        list_of_chooses.append(exit_option_text)
    while True:
        gpl_clear_and_banner()
        print(colored(title, title_color))
        i = 0
        for option in list_of_chooses:
            i += 1
            print("\t" + colored(str(i), number_color) + ' ' +
                  colored(option, text_color))
        choose = gpl_input("\n" + input_text,
                           input_color,
                           clear_and_banner_before=False)
        try:
            choose = int(choose)
        except:
            Handler(Error_Levels.High, on_invalid_text)
            gpl_sleep(on_invalid_sleep_time)
            continue
        else:
            if choose <= 0 or choose > len(list_of_chooses):
                Handler(Error_Levels.High, on_invalid_text)
                gpl_sleep(on_invalid_sleep_time)
                continue
        if exit_option and choose == len(list_of_chooses):
            print(
                colored(on_exit_request_text,
                        on_exit_request_forground_text_color))
            Exit_Request(Exit_Codes.Normal)
        else:
            list_of_chooses.pop()
            return choose
def Uninstall_G3nius(Verbos=True):
    if Check_Installtion_G3nius(False):
        if Verbos:
            Handler(Error_Levels.Alert, "Uninstalling G3nius-Tools...")
        try:
            rmtree(Location, '/usr/share/G3nius-Tools')
            unlink('/bin/g3nius-tools')
        except:
            if Verbos:
                Handler(Error_Levels.Failed_Job, "Can't delete from '/usr/share/' or '/bin/'.", "Manage your access and make sure run as root or administrator.")
            return False
        else:
            if Verbos:
                Handler(Error_Levels.Alert, "G3nius-Tools uninstalled successfully.")
            return True
    else:
        if Verbos:
            Handler(Error_Levels.Alert, "G3nius-Tools already not installed.")
        return False
示例#6
0
def Plugin_Launcher(Plugin):
    # check open source
    if Plugin['Import_G3nius']:
        # run source with g3nius-tools libs
        try:
            Crash_Details = Run_File('plugins.' + Plugin['Name'] + '.main',
                                     subprocess_call=False)
        except EndScript_Class:
            return
        except (KeyboardInterrupt, EOFError):
            Handler(Error_Levels.Failed_Job, 'Plugin ended with user request.')
        except Exception as EX:
            Handler(Error_Levels.Failed_Job,
                    "Plugin crashed! Can't find & say line number to you :(",
                    str(EX))
        else:
            if Crash_Details != None:
                if Crash_Details[1] == 0:
                    Handler(
                        Error_Levels.Failed_Job, "Failed to import " +
                        G3nius_Location() + '/' + Crash_Details[0])
                else:
                    Handler(
                        Error_Levels.Failed_Job,
                        "Plugin crashed at: '" + G3nius_Location() + '/' +
                        Crash_Details[0] + "' Line: " + str(Crash_Details[1]))

    else:
        # close source
        try:
            Run_File(Plugin['File_Address'])
        except PermissionError:
            try:
                chmod(Plugin['File_Address'], 0o771)
            except:
                Handler(
                    Error_Levels.Failed_Job, 'File address "' +
                    Plugin['File_Address'] + '" not have execute access!')
            else:
                Plugin_Launcher(Plugin)
        except Exception as EX:
            if str(EX)[0:28] == '[Errno 8] Exec format error:':
                Handler(
                    Error_Levels.Failed_Job,
                    "This plugin isn't for your CPU (ARM or AMD) or not have SheBang.",
                    "SheBang is first line at file, should thats like: #!/bin/python3"
                )
            else:
                Handler(Error_Levels.Failed_Job, "Plugin crashed!",
                        "Exception:\t" + str(EX))
        except:
            Handler(Error_Levels.Failed_Job, "Plugin crashed!")
def Install_G3nius(Verbos=True):
    if not Check_Installtion_G3nius(False):
        if Verbos:
            Handler(Error_Levels.Alert, "Installing G3nius-Tools...")
        try:
            move(Location, '/usr/share/G3nius-Tools')
            symlink('/usr/share/G3nius-Tools/launcher.py', '/bin/g3nius-tools')
        except:
            if Verbos:
                Handler(Error_Levels.Failed_Job, "Can't write on G3nius folder or '/usr/share/' or '/bin/'.", "Manage your access and make sure run as root or administrator.")
            return False
        else:
            if Verbos:
                Handler(Error_Levels.Alert, "G3nius-Tools installed successfully.", "Command is 'g3nius-tools'")
                Handler(Error_Levels.Alert, "Current directory is moved to '/usr/share/G3nius-Tools/',\nUse 'cd ..' before.")
            return True
    else:
        if Verbos:
            Handler(Error_Levels.Alert, "G3nius-Tools already installed.")
        return None
示例#8
0
def gpl_check_root_needed_with_error(text='Access denie! Run again as Root.',
                                     description=None,
                                     end_plugin=False,
                                     exit_code=None,
                                     before_exit_text=None):
    if not gpl_check_is_root():
        Handler(Error_Levels.High, text, description)
        if end_plugin:
            End_Plugin()
        elif exit_code != None:
            Exit_Request(exit_code, text_after_clear=before_exit_text)
示例#9
0
def gpl_write_to_file(File_Name: str,
                      Data,
                      Mode='w',
                      on_access_error_text="Can't write to file!",
                      on_accesss_error_text_description=None):
    try:
        File = open(File_Name, Mode)
        File.write(Data)
        File.close()
    except (KeyboardInterrupt, EOFError):
        return None
    except:
        if on_access_error_text:
            Handler(Error_Levels.High, on_access_error_text,
                    on_accesss_error_text_description)
        return False
    else:
        return True
示例#10
0
def gpl_arp_spoof(target_IP, gateway_IP, ignore_IP_exists_check=False, print_log=False):
    global ARP_SPOOF_RUN
    try:
        gpl_set_ipv4_forward_state(True)
        Target_State = gpl_ipv4_icmp_exists_check(target_IP)
        Gateway_State = gpl_ipv4_icmp_exists_check(gateway_IP)
        if (Target_State == True and Gateway_State == True) or ignore_IP_exists_check:
            Target_MAC = gpl_ip_to_mac(target_IP)
            Gateway_MAC = gpl_ip_to_mac(gateway_IP)
            while ARP_SPOOF_RUN:
                if print_log:
                    Handler(Error_Levels.Alert, 'Send ArpSpoof between "' + target_IP + '" (' + Target_MAC + ') and "' + gateway_IP + '" (' + Gateway_MAC + ')')
                # target -> hacker -> gateway
                gpl_arp_spoof_fake_once(target_IP, Target_MAC, gateway_IP)
                # gatewat -> hacker -> target
                gpl_arp_spoof_fake_once(gateway_IP, Gateway_MAC, target_IP)
                gpl_sleep(ARP_Spoof_Resend_Sleep, manage_ctrl_C_and_exit=False)
            ARP_SPOOF_RUN = True
        else:
            return None
    except (KeyboardInterrupt, EOFError):
        gpl_set_ipv4_forward_state(False)
        raise KeyboardInterrupt
示例#11
0
def gpl_input(text: str,
              dont_style=False,
              forground_color='white',
              clear_and_banner_before=True,
              on_invalid_after_clear_text=None,
              clear_before=False,
              on_exit_request_text='\nExit with user request.',
              on_exit_request_forground_color='yellow',
              q_to_exit=True,
              clear_and_banner_when_exit=True,
              clear_when_exit=False,
              get_int=False,
              get_float=False,
              get_ip=False,
              on_invalid_number_text='Invalid number!',
              on_invalid_sleep_by_sec=1,
              on_invalid_clear_and_banner=True,
              on_invalid_ip_text="Invalid IP!"):
    if clear_and_banner_before and (not clear_before):
        gpl_clear_and_banner()
    elif clear_before:
        gpl_clear()
    try:
        while True:
            if dont_style:
                choose = input(text)
            else:
                choose = input(colored(text, forground_color))
            if q_to_exit and (str.lower(choose) == 'q'
                              or str.lower(choose) == 'exit'):
                if clear_when_exit:
                    gpl_clear()
                elif clear_and_banner_when_exit:
                    gpl_clear_and_banner()
                print(
                    colored(on_exit_request_text,
                            on_exit_request_forground_color))
                Exit_Request(Exit_Codes.Normal)
            else:
                if get_float:
                    try:
                        choose = float(choose)
                    except:
                        Handler(Error_Levels.High, on_invalid_number_text)
                        gpl_sleep(on_invalid_sleep_by_sec)
                        if on_invalid_clear_and_banner:
                            gpl_clear_and_banner()
                        if on_invalid_after_clear_text:
                            print(on_invalid_after_clear_text)
                    else:
                        return choose
                elif get_int:
                    try:
                        choose = int(choose)
                    except:
                        Handler(Error_Levels.High, on_invalid_number_text)
                        gpl_sleep(on_invalid_sleep_by_sec)
                        if on_invalid_clear_and_banner:
                            gpl_clear_and_banner()
                        if on_invalid_after_clear_text:
                            print(on_invalid_after_clear_text)
                    else:
                        return choose
                elif get_ip:
                    try:
                        ip_address(choose)
                    except:
                        Handler(Error_Levels.High, on_invalid_ip_text)
                        gpl_sleep(on_invalid_sleep_by_sec)
                        if on_invalid_clear_and_banner:
                            gpl_clear_and_banner()
                        if on_invalid_after_clear_text:
                            print(on_invalid_after_clear_text)
                    else:
                        return choose
                else:
                    return choose
    except (KeyboardInterrupt, EOFError):
        print(
            colored("\n" + on_exit_request_text,
                    on_exit_request_forground_color))
        Exit_Request(Exit_Codes.CTRL_C,
                     text_after_clear=colored('Exit with user request.',
                                              'yellow'))
示例#12
0
# core
from lib.core.End_Plugin import End_Plugin
from lib.core.Error_Handler import Handler
from lib.core.G3nius_Location import G3nius_Location
from lib.core.main.Restart_G3nius import Restart_G3nius
from lib.core.Check_Supported_OS import Check_Supported
# GPL
from lib.GPL.HTTP_Managers import gpl_http_get
from lib.GPL.IO import gpl_input, gpl_sleep, gpl_confirm
from lib.GPL.Page_Managers import gpl_clear_and_banner, gpl_set_banner_verion
from lib.GPL.File_Workers import gpl_write_to_file
from lib.GPL.String_Workers import gpl_fix_string_to_uri
"""		check supporting OS		"""
if not Check_Supported(Linux=True):
    Handler(Error_Levels.Failed_Job,
            "Only Linux users can use online Updater plugin!",
            "Download and reinstall new version of G3nius-Tools.")
"""		local varibles		"""
URL = 'https://api.BugZone.ir/G3nius/'
Plugin_Version = '2.0.6'
Location = G3nius_Location()

# collect data from server
gpl_set_banner_verion(Plugin_Version)
del Plugin_Version
gpl_clear_and_banner()
Handler(Error_Levels.Info, "Checking update...")

Busy_Server_Text = 'Update server is very busy. auto retry.. (If take many times, Use CTRL+C and retry later)'
Last_version = gpl_http_get(URL + 'Version.Version',
                            ok_http_codes=[200],
示例#13
0
# import G3nius-Tools
#!/bin/python3
# coding: utf-8
"""     libs      """
from lib.GPL.attackers.network.IP_To_MAC import gpl_ip_to_mac
from lib.GPL.IO import gpl_input
from lib.GPL.Page_Managers import gpl_clear_and_banner, gpl_set_banner_verion
from lib.core.Error_Handler import Handler
import lib.config.Error_Levels as Error_Levels
"""     configs     """
Version = '2.0.1'
"""     proccess      """
# clear page
gpl_set_banner_verion(Version)
gpl_clear_and_banner()

# find mac
IP = gpl_input('Enter IP address: ', get_ip=True)
MAC = gpl_ip_to_mac(IP)
gpl_clear_and_banner()
if MAC:
    Handler(Error_Levels.Alert, 'Found:\t' + MAC)
else:
    Handler(Error_Levels.Failed_Job, 'MAC not found!',
            'May be ARP (as broadcast) filtered by firewall.')
示例#14
0
# GPL
from lib.GPL.IO import gpl_input, gpl_while_input, gpl_sleep
from lib.GPL.File_Workers import gpl_write_to_file, gpl_read_from_file
from lib.GPL.Page_Managers import gpl_set_banner_verion, gpl_clear_and_banner
# Core
from lib.core.Check_Supported_OS import Check_Supported
from lib.core.End_Plugin import End_Plugin
from lib.core.Error_Handler import Handler
# config
import lib.config.Error_Levels as Error_Levels

# EOF and Keyboard Interupt
try:
    # check OS
    if not Check_Supported(Linux=True):
        Handler(Error_Levels.High, "This plugin is only for Linux users.")
        End_Plugin()
    """     config      """
    Plugin_Version = '2.0.0'
    Status_Codes = {1: "0", 2: "1", 3: "255"}
    """     setup      """
    gpl_set_banner_verion(Plugin_Version)
    gpl_clear_and_banner()
    """     get LEDs"""
    LEDs = listdir('/sys/class/leds/')
    LEDs.sort()

    while True:
        # ask from user
        Choose = gpl_while_input("Select once LED on your system:", LEDs)
        Value = gpl_while_input(
示例#15
0
                    'cyan'))
            print(
                colored("	3. ", 'magenta') + colored(
                    "You don't should use cracked versions or try to reverse engineering.\n\tAlso, we may be use some APIs, You don't should do any attacks on us.",
                    'cyan'))
            print(
                colored("	4. ", 'magenta') + colored(
                    "We're collecting some data from your system\n\t(like: run times count. G3nius-Tools errors etc…) to improve G3nius.\n\tThis is optional,\n\tYou can set to 'False' value in 'lib/config/Main_Configs.py' file.",
                    'cyan'))
            choose = gpl_input("Type 'yes' to agree terms & rules: ",
                               clear_and_banner_before=False)
            if choose.lower() == 'yes':
                try:
                    open(Location + '/lib/agree', 'w').close()
                except:
                    Handler(Error_Levels.Critical,
                            "Can't create file! check access of folder.")
                break
            else:
                Handler(Error_Levels.Failed_Job, 'Type "yes" to agree.')
                gpl_sleep(1)

    # checking if give parameters
    if len(argv) > 1:
        Delete_TMP_Folder = True
        if '-h' in argv or '--help' in argv:
            print(colored('HELP PAGE:', 'white'))
            print(colored('\n	Parameters:', 'white'))
            print(
                colored('\n		-h ', 'green') + colored(',', 'magenta') +
                colored(' --help', 'green') +
                colored('\n		Get help page.', 'blue'))