Exemple #1
0
    def __init__(self, load_data=False):

        # Amount to reveal.
        self.default_amount_to_reveal = default_amount_to_reveal

        self.width = width
        self.height = height

        # Set the symbols below this line:
        self.goal_symbol = "\033[93m" + "G" + "\033[0m"
        self.treasure_symbol = "\033[36m" + "T" + "\033[0m"

        # Putting player object first
        # Test purpose for putting player.
        if load_data:
            self.load_data()
            self.map_grid = deepcopy(self.original_map_grid)
            self.map_grid[self.player.object_pos[0]][
                self.player.object_pos[1]] = self.player.displayed_character
        else:
            self.player = MazeObject()
            self.level = 1
            self._initialize_map()

        clear()

        # Reveal map grid from the center of the player.

        self._draw_hidden_map()

        self._manipulate_map()
Exemple #2
0
    def sw_case_menu(self, key):
        #row, columns = os.popen('stty size', 'r').read().split()
        bug_logger = BugLogger()
        cipher_r13 = CipherROT13()
        net_scan = NetworkScanner()
        port_scan = PortScanner()
        sub_finder = SubnetFinder()
        data_faker = DataFaker()
        mail_bomb = MailBomber()
        cipher_rsa = CipherRSA()
        shodan_skr = ShodanSeeker()

        rows = 49
        columns = 109
        line_und = ['_'] * (int(columns))
        line_u = ''.join(map(str, line_und))
        line_u = colored(line_u, 'magenta', attrs=['bold'])
        checker = 'false'
        if key == 'clear':
            clear()
        elif key == 'home':
            clear()
            self.main_method()
        elif key == 'menu':
            print(line_u + '\n')
            self.menu_display()
        elif key == 'exit':
            sys.exit(0)
        elif key == 'NS':
            print(line_u + '\n')
            net_scan.network_scan_proc(net_scan.network_scan_input())
            print(line_u + '\n')
        elif key == 'PS':
            print(line_u + '\n')
            port_scan.port_scan_proc(port_scan.port_scan_input())
            print(line_u + '\n')
        elif key == 'SF':
            print(line_u + '\n')
            sub_finder.subnet_finder_proc()
            print(line_u + '\n')
        elif re.search('DF', key):
            print(line_u + '\n')
            data_faker.data_gen_proc(key)
            print(line_u + '\n')
        elif key == 'MB':
            print(line_u + '\n')
            mail_bomb.mail_bomber_proc()
            print(line_u + '\n')
        elif key == 'RO':
            print(line_u + '\n')
            cipher_r13.cipher_gen_rot13_proc()
            print(line_u + '\n')
        elif key == 'RS':
            print(line_u + '\n')
            cipher_rsa.cipher_gen_rsa_proc()
            print(line_u + '\n')
        elif key == 'SS':
            print(line_u + '\n')
            shodan_skr.shodan_seeker_proc()
            print(line_u + '\n')
Exemple #3
0
        def _player_turn_normal_attack():
            # Player turn
            player_base_attack_value = self.player.strength
            player_attack_value = int(
                round(uniform(0.8, 1.0) * player_base_attack_value, 0))
            enemy.current_hp -= player_attack_value

            if enemy.current_hp < 1:
                print("You defeated the creature!")
                print("Player acquire {} exp".format(enemy.exp))
                print("Press any key to return to map...")
                self.player._get_experience(enemy.exp)

                # If it is bigger, then the enemy will drop the
                if uniform(0, 1.0) > 0.8 - (0.8 /
                                            (100 /
                                             (self.player.luckiness**0.70))):
                    print("Enemy dropped item!")
                    print("The content of the item is {}".format(
                        enemy.drop_item))
                    self.player.items.append(enemy.drop_item)

                getch()
                clear()
                return True
            else:
                print("Player delivers {} damage".format(player_attack_value))
                getch()
                return False
Exemple #4
0
def header():
    clear()
    curdate = datetime.datetime.now()
    getdate = curdate.strftime('%A, %d %b %Y')
    gettime = curdate.strftime('%I:%M:%S %p') + ' | v.1.2.1'
    print(
        '_______ _______ _______ ___ ___  ___ _______ __                __       '
    )
    print(
        '|   _   |   _   |   _   |   Y   )|   |   _   |  |--.---.-.-----|__.----.'
    )
    print(
        '|.  1___|.  |   |.  |   |.  1  / |.  |.  1___|  _  |  _  |__ --|  |  __|'
    )
    print(
        '|.  |___|.  |   |.  |   |.  _  \ |.  |.  __)_|_____|___._|_____|__|____|'
    )
    print(
        '|:  1   |:  1   |:  1   |:  |   \|:  |:  1   |                          '
    )
    print('|::.. . |::.. . |::.. . |::.| .  |::.|::.. . |   ' +
          str(getdate).upper())
    print("`-------`-------`-------`--- ---'`---`-------'   " +
          str(gettime).upper())
    print(
        '________________________________________________________________________\n'
    )
def logOut():
    clear()
    now = datetime.now()
    r.mset({
        str(name) + '_lastLoginDate': str(date.today()),
        str(name) + '_lastLoginTime': now.strftime("%H:%M:%S"),
        str(name) + '_lastLogin': time.time()
    })
    time.sleep(1)
    print('* Your session lasted:', round(time.time() - login_Start),
          'Seconds.')
    time.sleep(1)
    print('* Closing Balance:',
          "${:,.2f}".format(float(r.get(str(name) + '_balance'))) + ',',
          '* Savings Balance is:',
          "${:,.2f}".format(float(r.get(str(name) + '_savings'))))
    time.sleep(1)
    print('* Thank You for banking with WAIO Bank *,', str(name).title() + '.')
    time.sleep(1)
    print()
    print("{:*^20}".format('WAIO Bank v1.0'))
    print()
    input("* Press Enter to log out...")
    clear()
    intialise()
def intialise():
    try:
        global r
        r = redis.StrictRedis(host=ghost,
                              port=gport,
                              password=gdb,
                              db=0,
                              decode_responses=True)
        global name
        print("{:*^20}".format('WAIO Bank v1.0'))
        print()
        while True:
            name = input('* Enter Username to Log In: ')
            if name and name.isalpha():
                name = name.lower()
                global login_Start
                login_Start = time.time()
                clear()
                welcome()
            elif name and name.isdigit():
                print('* Please use Alphabet characters only')
            else:
                print('* Only Alphabet Usernames are allowed.')
    except Exception as e:
        print(e)
def header():
    clear()
    curdate = datetime.datetime.now()
    getdate = curdate.strftime('%A, %d %b %Y')
    gettime = curdate.strftime('%I:%M:%S %p') + ' | v.1.2.1'
    print(
        '_______ _______ _______ ___ ___  ___ _______ __                __       '
    )
    print(
        '|   _   |   _   |   _   |   Y   )|   |   _   |  |--.---.-.-----|__.----.'
    )
    print(
        '|.  1___|.  |   |.  |   |.  1  / |.  |.  1___|  _  |  _  |__ --|  |  __|'
    )
    print(
        '|.  |___|.  |   |.  |   |.  _  \ |.  |.  __)_|_____|___._|_____|__|____|'
    )
    print(
        '|:  1   |:  1   |:  1   |:  |   \|:  |:  1   |                          '
    )
    print('|::.. . |::.. . |::.. . |::.| .  |::.|::.. . |   ' +
          str(getdate).upper())
    print("`-------`-------`-------`--- ---'`---`-------'   " +
          str(gettime).upper())
    print(
        '________________________________________________________________________\n'
    )
    print(
        '::::.   NAVIGATE FOLLOWING MENU OPTIONS TO IT CORRESSPOND NUMBER   .::::'
    )
    print(
        '::::::.__________________________________________________________.::::::\n'
    )
Exemple #8
0
def ask_questions_api(api_url,session_flag=True):
    """This module asks the users questions to fetch the options
       they wish to run the api test with and stores their choices"""
    clear()
    while True:

        questionary.print("\nSeleted Options",style="bold fg:green")
        questionary.print("**********",style="bold fg:green")
        print("API URL:",api_url)
        print("Session flag status:",session_flag)
        questionary.print("**********",style="bold fg:green")
        response = get_user_response_api()
        clear()
        if response == "Session flag status":
            session_flag = get_sessionflag_status()

        if response == "API URL":
            api_url = get_api_url()

        if response == "Reset back to default settings":
            api_url = api_example_conf.api_url
            session_flag = True
            questionary.print("Reverted back to default settings",
                               style="bold fg:green")

        if response == "Run":
            break

        if response == "Exit":
            sys.exit("Program interrupted by user, Exiting the program....")

    return api_url,str(session_flag)
Exemple #9
0
def dump_ids():
    clear()
    date = datetime.now().strftime("%H:%M:%S")
    time = datetime.now().strftime("%d/%m/%Y")
    print("     --- Dump All Friends ID's ---")
    print('        --- Author: @Proxy07 ---\n')
    try:
        with open('lib/cache/facebook_token.txt', 'r') as file:
            token = file.read()
    except:
        print(
            style.RED('\n[!]') +
            style.RESET(' You must generate an access token first, exiting...')
        )
        sys.exit(0)

    try:
        print_ids = str(
            input(
                style.GREEN('[+]') +
                style.RESET(' Do you want to print all IDs on screen (y/n): '))
        )
    except KeyboardInterrupt:
        print(style.RED('\n[!]') + style.RESET(' User exit, exiting...'))
        sys.exit(0)

    try:
        i = 0
        while os.path.exists("Logs/IDs - %s.txt" % i):
            i += 1

        req = requests.get(
            f'https://graph.facebook.com/me/friends?access_token={token}')
        json_data = json.loads(req.text)
        with io.open("Logs/IDs - %s.txt" % i, 'w', encoding='UTF-8') as f:
            f.write(
                f'FacebookHunter IDs Scan\nDate : {date}\nTime : {time}\n\n\n\n'
            )
            for x in json_data['data']:
                f.write(f'{x["name"]} : {x["id"]}\n')
                if print_ids.lower() == "y":
                    print(
                        style.YELLOW(' [-]') +
                        style.RESET(f' {x["name"]} : {x["id"]}'))
                else:
                    None

            print(
                style.GREEN('\n[+]') + style.RESET(
                    f" Saved ID's successfuly in Logs/{'Logs/IDs - %s.txt' % i}"
                ))

            print(
                style.RED('\n[!]') +
                style.RESET(' Thank you for using FacebookHunter, exiting...'))
            sys.exit(0)

    except Exception as e:
        raise
Exemple #10
0
def cameraProcess(height, errorHeight, targetHeight):
    # Initial Camera Value
    CV_CAP_PROP_FRAME_WIDTH = 3
    CV_CAP_PROP_FRAME_HEIGHT = 4
    CV_CAP_PROP_FPS = 5
    CV_CAP_PROP_FOURCC = 6

    name = 0
    cap = cv2.VideoCapture(name)                    # Turn on the built-in camera

    cap.set(CV_CAP_PROP_FPS, 1)

    frameWidth = 640
    frameHeight = 480

    cap.set(cv2.CAP_PROP_FRAME_WIDTH, frameWidth)   
    cap.set(cv2.CAP_PROP_FRAME_HEIGHT, frameHeight)

    ratioWindowsHeight = 1                          # Form transformation
    ratioWindowsWidth = 0.6
    windowsWidth = int(frameWidth * ( 0.5 - ratioWindowsWidth / 2 )), int(frameWidth * ( 0.5 + ratioWindowsWidth / 2 ))
    windowsHeight = int(frameHeight * ( 0.5 - ratioWindowsHeight / 2 )), int(frameHeight * ( 0.5 + ratioWindowsHeight / 2 ))

    while True:
        ret,img = cap.read()                        #Read the image in real time
        img = img[ windowsHeight[0] : windowsHeight[1], windowsWidth[0] : windowsWidth[1]]

        imggray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
        ret, thresh = cv2.threshold(imggray,50,255,0)
        _, contours, hierarchy = cv2.findContours(thresh,cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE)
        
        heightTemp = 0
        for cnt in contours:
            if (cv2.contourArea(cnt) > 3000) and (cv2.contourArea(cnt) < 53000):
                # draw a rectangle around the items
                clear()                             #clear 
                print(cv2.contourArea(cnt))
                x,y,w,h = cv2.boundingRect(cnt)
                cv2.rectangle(img, (x,y), (x+w,y+h), (0,255,0),3)
                print("height", h)
                heightTemp = CalculationHigh(h)
        height.value = heightTemp
        errorHeight.value = targetHeight.value - height.value

        print("目标液位",targetHeight.value,"\t目标温度",targetTemperature.value)
        print("当前液位",round(height.value, 2), "\t当前温度",round(temperature.value, 1))
        print("误差液位",round(errorHeight.value, 2),"\t误差温度",round(errorTemperature.value, 1))

        cv2.imshow("Camera", img)
        
        k = cv2.waitKey(1)
        if (k == ord('q')):
            break
        elif(k == ord('s')):                        # Take Photo
            name += 1
            filename = '/home/pi/sheji/' + str(name) + 'test' + '.jpg'
            cv2.imwrite(filename, img)
            break 
    cv2.destroyAllWindows()
Exemple #11
0
    def player_menu(self):
        clear()

        # There is no load function until player moves to exit.
        selection_list = ["Item", "Save", "Status", "Exit"]
        cursor_not_selected = " "
        cursor_selected = ">"
        tmp_cursor = deepcopy(selection_list)
        cursor_selection = 0

        while True:
            for i in range(len(tmp_cursor)):
                if i == cursor_selection:
                    tmp_cursor[i] = cursor_selected + tmp_cursor[i]
                else:
                    tmp_cursor[i] = cursor_not_selected + tmp_cursor[i]
            print("Player Menu")
            print("\n".join(tmp_cursor))

            tmp_cursor = deepcopy(selection_list)
            tmp = getch()

            if tmp == "UP_KEY":
                if cursor_selection > 0:
                    cursor_selection -= 1

            elif tmp == "DOWN_KEY":
                if cursor_selection < len(tmp_cursor) - 1:
                    cursor_selection += 1

            elif tmp == b"\r":

                if cursor_selection == 0:
                    self._display_item()

                if cursor_selection == 1:
                    self.save_data()

                # Displaying player's status, allowing users to
                # improve status using bonus points.
                if cursor_selection == 2:
                    self._display_player_status()

                if cursor_selection == 3:
                    clear()
                    self._draw_hidden_map()
                    break

                clear()

            elif tmp == b"\x1b":
                clear()
                self._draw_hidden_map()
                break

            clear()
def sw_case_menu(key):
    checker = 'false'
    if key == 'clear':
        clear()
    elif key == 'home':
        clear()
        main_method()
    elif key == 'menu':
        print(
            '________________________________________________________________________\n'
        )
        menu_display()
    elif key == 'exit':
        sys.exit(0)
    elif key == '1':
        print(
            '________________________________________________________________________\n'
        )
        network_scan_proc(network_scan_input())
        print(
            '________________________________________________________________________\n'
        )
    elif key == '2':
        print(
            '________________________________________________________________________\n'
        )
        port_scan_proc(port_scan_input())
        print(
            '________________________________________________________________________\n'
        )
    elif key == '3':
        print(
            '________________________________________________________________________\n'
        )
        subnet_finder_proc()
        print(
            '________________________________________________________________________\n'
        )
    elif re.search('4', key):
        print(
            '________________________________________________________________________\n'
        )
        data_gen_proc(key)
        print(
            '________________________________________________________________________\n'
        )
    elif key == '5':
        print(
            '________________________________________________________________________\n'
        )
        mail_bomber_proc()
        print(
            '________________________________________________________________________\n'
        )
def test_header():
    clear()
    #row, columns = os.popen('stty size', 'r').read().split()
    columns = 109
    rows = 49
    line_und = ['_'] * (int(columns))
    line_u = ''.join(map(str, line_und))
    line_u = colored(line_u, 'magenta', attrs=['bold'])
    line_hint = ['_'] * (int(columns) - 14)
    line_h = ''.join(map(str, line_hint))

    #print(row+' x '+columns)

    curdate = datetime.datetime.now()
    getdate = curdate.strftime('%A, %d %B %Y')
    gettime = curdate.strftime('%I:%M:%S %p')
    print(
        colored(' _______ _______ _______ ___ ___  ___ _______',
                'cyan',
                attrs=['bold']),
        colored('__                __       ', 'yellow', attrs=['bold']))
    print(
        colored('|   _   |   _   |   _   |   Y   )|   |   _  ',
                'cyan',
                attrs=['bold']),
        colored('|  |--.---.-.-----|__.----.', 'yellow', attrs=['bold']))
    print(
        colored('|.  1___|.  |   |.  |   |.  1  / |.  |. ____',
                'cyan',
                attrs=['bold']),
        colored('|  _  |  _  |__ --|  |  __|', 'yellow', attrs=['bold']))
    print(
        colored('|.  |___|.  |   |.  |   |.  _  \ |.  |. ____',
                'cyan',
                attrs=['bold']),
        colored('|_____|___._|_____|__|____|', 'yellow', attrs=['bold']))
    print(
        colored('|:  1   |:  1   |:  1   |:  |   \|:  |:  1   |',
                'cyan',
                attrs=['bold']))
    print(
        colored('|::.. . |::.. . |::.. . |::.| .  |::.|::.. . |  ',
                'cyan',
                attrs=['bold']) +
        colored(str(getdate).upper(), 'cyan', attrs=['bold']))
    print(
        colored("`-------`-------`-------`--- ---'`---`-------'  ",
                'cyan',
                attrs=['bold']) +
        colored(str(gettime).upper(), 'yellow', attrs=['bold']))
    print(line_u)
    #print(hint)
    print(line_u + '\n')
Exemple #14
0
    def _treasure_selection(self, next_player_pos):
        # Allows the users to select whether they will proceed to the next floor...

        selection_list = ["Yes", "No"]
        cursor_not_selected = " "
        cursor_selected = ">"
        tmp_cursor = deepcopy(selection_list)
        cursor_selection = 1

        while True:

            self._draw_hidden_map()
            for i in range(len(tmp_cursor)):
                if i == cursor_selection:
                    tmp_cursor[i] = cursor_selected + tmp_cursor[i]
                else:
                    tmp_cursor[i] = cursor_not_selected + tmp_cursor[i]

            print("Will you pick up the item?")
            print("".join(tmp_cursor))

            tmp_cursor = deepcopy(selection_list)
            tmp = getch()
            if tmp == "LEFT_KEY":
                if cursor_selection > 0:
                    cursor_selection -= 1

            elif tmp == "RIGHT_KEY":
                if cursor_selection < len(tmp_cursor) - 1:
                    cursor_selection += 1

            elif tmp == b"\r":

                # Yes case --> Initialise map.
                if cursor_selection == 0:
                    obtained_item = random_item_selection()
                    self.player.items.append(obtained_item)

                    # Remove the treasure from map.
                    self.original_map_grid[next_player_pos[0]][
                        next_player_pos[1]] = " "
                    self.map_grid = deepcopy(self.original_map_grid)
                    self.map_grid[next_player_pos[0]][
                        next_player_pos[1]] = self.player.displayed_character
                    print("Player obtained {}".format(obtained_item))
                    getch()
                    break

                # No case --> Do nothing.
                if cursor_selection == 1:
                    break
            clear()
        clear()
Exemple #15
0
    def imprimir_mesa(self):
        clear()
        print("{}: ".format(self.jugadores[0].nombre), end=' ')
        for carta in self.jugadores[0].mano.get_mano():
            print("{}{}".format(carta.valor, carta.palo), end=' ')

        print("\n")

        for j in range(len(self.jugadores) - 1, 0, -1):
            print("{}: ".format(self.jugadores[j].nombre), end=' ')
            for carta in self.jugadores[j].mano.get_mano():
                print("{}{}".format(carta.valor, carta.palo), end=' ')
            print("\n")
Exemple #16
0
 def pedir_numero_jugadores(self):
     while True:
         try:
             clear()
             cantidad = int(input("¿Cuantos jugadores (1 - 7): ?"))
             if cantidad not in [1, 2, 3, 4, 5, 6, 7]:
                 raise
             break
         except:
             print(
                 "      Numero invalido... Digite un numero entre 1 y 7\n")
             input()
             continue
     return cantidad
Exemple #17
0
def dump_emails():
    while True:
        clear()
        date = datetime.now().strftime("%H:%M:%S")
        time = datetime.now().strftime("%d/%m/%Y")
        print("     --- Dump All Friends Emails ---")
        print('         --- Author: @Proxy07 ---\n')
        try:
            with open('lib/cache/facebook_token.txt', 'r') as file:
                token = file.read()
        except:
            print(style.RED('\n[!]') + style.RESET(' Error: You must generate an access token first.'))
            sys.exit(0)
        try:
            print_emails = str(input(style.GREEN('[+]') + style.RESET(' Do you want to print all emails on screen (y/n): ')))
        except KeyboardInterrupt:
            print(style.RED('\n[!]') + style.RESET(' Error: User exited.'))
            sys.exit(0)
        try:
            i = 0
            while os.path.exists("Logs/emails - %s.txt" % i):
                i += 1
            req1 = requests.get(f'https://graph.facebook.com/me/friends?access_token={token}')
            data1 = json.loads(req1.text)
            with io.open("Logs/emails - %s.txt" % i, 'w', encoding = 'UTF-8') as f:
                for i in data1['data']:
                    req2 = requests.get(f'https://graph.facebook.com/{i["id"]}?access_token={token}')
                    data2 = json.loads(req2.text)

                    try:
                        f.write(f'{data2["name"]} : {data2["email"]}\n')
                        if print_emails == "y":
                            print(style.YELLOW(' [-]') + style.RESET(f'{data2["name"]} : {data2["email"]}'))
                        else:
                            None
                    except KeyError:
                        pass
                    except KeyboardInterrupt:
                        print(style.RED('\n[!]') + style.RESET(' Error: User exited.'))
                        sys.exit(0)
                print(style.GREEN('\n[+]') + style.RESET(f" Saved ID's successfuly in Logs/{'Logs/IDs - %s.txt' % i}"))
    
        except KeyboardInterrupt:
            print(style.RED('\n[!]') + style.RESET(' Error: User exited.'))
            sys.exit(0)
        except (requests.exceptions.ConnectionError, requests.exceptions.ChunkedEncodingError):
            print(style.RED('\n[!]') + style.RESET(' Error: Failed to get emails due to connection error.'))
            sys.exit(0)
        input(style.CYAN('[*]') + style.RESET(' Press any key to go back to the main menu.'))
        break
Exemple #18
0
def sw_case_menu(key):
    checker = 'false'
    if key == 'C':
        clear()
        main_method()
    elif key == 'E':
        sys.exit(0)
    elif key == '2':
        print(
            '________________________________________________________________________\n'
        )
        port_scan_proc(port_scan_input())
        print(
            '________________________________________________________________________\n'
        )
Exemple #19
0
def intialise():
    try:
        global r
        r = redis.StrictRedis(host=os.environ['redis_host'],
                              port=os.environ['redis_port'],
                              password=os.environ['redis_password'],
                              db=os.environ['redis_db'],
                              decode_responses=True)
        global name
        print("{:*^20}".format('WAIO Bank v1.0'))
        name = input('* Enter Username to Log In: ')
        global login_Start
        login_Start = time.time()
        clear()
        welcome()
    except Exception as e:
        print(e)
def main_function():
    while True:
        if os.path.isdir('Logs') == False:
            os.mkdir('Logs')
        else:
            None
        if os.path.isdir('lib/cache') == False:
            os.mkdir('lib/cache')
        else:
            None
        clear()
        print('     --- Welcome to FacebookHunter ---')
        print('        --- Author: @Proxy07 ---')

        # Menu options
        print(style.GREEN('\n[1]') + style.RESET(' Generate access token.'))
        print(style.GREEN('[2]') + style.RESET(" Dump all IDs."))
        print(style.GREEN('[3]') + style.RESET(" Dump all phone numbers."))
        print(style.GREEN('[4]') + style.RESET(' Dump all email addresses.'))
        print(
            style.GREEN('[5]') +
            style.RESET(' Full information search by ID/Username.'))
        print(style.GREEN('[6]') + style.RED(' Exit FacebookHunter.'))
        try:
            mode_option = int(
                input(
                    style.YELLOW('\n[+]') +
                    style.RESET(" Enter your option number: ")))
        except:
            print(style.RED('\n[!]') + style.RESET(' Error: User exited.'))
            sys.exit(0)

        if mode_option == 1:
            get_credentials()
        elif mode_option == 2:
            dump_ids()
        elif mode_option == 3:
            dump_phones()
        elif mode_option == 4:
            dump_emails()
        elif mode_option == 5:
            dump_info()
        elif mode_option == 6:
            print(style.RED('[!]') + style.RESET(' User exit, exiting...'))
            sys.exit(0)
def run_Delete():
    print('* Alert * Reset in progress, please wait... ')
    mobile = r.get(str(name) + '_mobile')
    email = r.get(str(name) + '_email')
    if r.exists(email):
        r.delete(str(email))
    if r.exists(mobile):
        r.delete(str(mobile))
    for key in r.scan_iter(match=f"*{str(name)}*"):
        time.sleep(0.2)
        r.delete(key)
    print('* Account, reset, please click "Run" and sign up!')
    print('* Your session lasted:', round(time.time() - login_Start),
          'Seconds.')
    time.sleep(1)
    input("* Press Enter to log out...")
    clear()
    intialise()
def display_menu():
    clear()
    print(gcolor, "Provide Stock Dividend Yield or Price-per-Share\n",
          resetcolor)
    u_choice = input(
        'Input "d" in order to Compute Dividend Yield OR "p" for the Price-Per-Share: '
    )
    u_choice = u_choice.lower()

    if u_choice == "d":
        compute_div()
    elif u_choice == 'p':
        compute_pps()
    else:
        print(
            '\nPlease insert a valid character.  Input only accepts "d" or "p"'
        )
        exit(1)
Exemple #23
0
        def _enemy_turn_normal_attack():
            # Enemy turn
            enemy_base_attack_value = enemy.strength
            enemy_attack_value = int(
                round(uniform(0.8, 1.0) * enemy_base_attack_value, 0))
            self.player.current_hp -= enemy_attack_value

            if self.player.current_hp < 1:
                print("You are defeated...")
                print("Game Over...")
                getch()
                clear()
                return True

            else:
                print("Enemy delivers {} damage".format(enemy_attack_value))
                getch()
                return False
Exemple #24
0
    def _map_proceed_selection(self):
        clear()

        selection_list = ["Yes", "No"]
        cursor_not_selected = " "
        cursor_selected = ">"
        tmp_cursor = deepcopy(selection_list)
        cursor_selection = 1

        while True:

            self._draw_hidden_map()
            for i in range(len(tmp_cursor)):
                if i == cursor_selection:
                    tmp_cursor[i] = cursor_selected + tmp_cursor[i]
                else:
                    tmp_cursor[i] = cursor_not_selected + tmp_cursor[i]

            print("Will you proceed to the next level?")
            print("".join(tmp_cursor))

            tmp_cursor = deepcopy(selection_list)
            tmp = getch()
            if tmp == "LEFT_KEY":
                if cursor_selection > 0:
                    cursor_selection -= 1

            elif tmp == "RIGHT_KEY":
                if cursor_selection < len(tmp_cursor) - 1:
                    cursor_selection += 1

            elif tmp == b"\r":
                # Yes case --> Initialise map.
                if cursor_selection == 0:

                    self._initialize_map()
                    self.level += 1
                    break

                # No case --> Do nothing.
                if cursor_selection == 1:
                    break
            clear()
def sw_case_menu(key):
    #row, columns = os.popen('stty size', 'r').read().split()
    line_und = ['_'] * (int(columns))
    line_u = ''.join(map(str, line_und))
    line_u = colored(line_u, 'magenta', attrs=['bold'])
    checker = 'false'
    if key == 'clear':
        clear()
    elif key == 'home':
        clear()
        main_method()
    elif key == 'menu':
        print(line_u + '\n')
        menu_display()
    elif key == 'exit':
        sys.exit(0)
    elif key == 'NS':
        print(line_u + '\n')
        net_scan.network_scan_proc(net_scan.network_scan_input())
        print(line_u + '\n')
    elif key == '2':
        print(line_u + '\n')
        port_scan_proc(port_scan_input())
        print(line_u + '\n')
    elif key == '3':
        print(line_u + '\n')
        subnet_finder_proc()
        print(line_u + '\n')
    elif re.search('4', key):
        print(line_u + '\n')
        data_gen_proc(key)
        print(line_u + '\n')
    elif key == '5':
        print(line_u + '\n')
        mail_bomber_proc()
        print(line_u + '\n')
    elif key == 'RO':
        print(line_u + '\n')
        cipher_r13.cipher_gen_rot13_proc()
        print(line_u + '\n')
Exemple #26
0
def CrearJugadores():

  maxPlayerNameLenght = 0

  cantJug = input("Cantidad jugadores: ")

  if not cantJug.isnumeric():
    cprint("Caracter Inválido", "yellow")
    CrearJugadores()

  i = 0
  while i < int(cantJug):
    name = input("Nombre: ")    

    if len(name) > maxPlayerNameLenght:
        maxPlayerNameLenght = len(name)

    jugadores.append(Jugador(name))
    i += 1
    
  clear()
  return maxPlayerNameLenght
Exemple #27
0
def get_credentials():
    clear()
    print('     --- Generate Facebook Access Token ---')
    print('           --- Author: @Proxy07 ---\n')
    try:
        username = str(
            input(style.GREEN('[+]') + style.RESET(' Facebook email: ')))
    except KeyboardInterrupt:
        print(style.RED('\n[!]') + style.RESET(' Error: User exited.'))
        sys.exit(0)
    try:
        password = str(
            getpass.getpass(
                style.GREEN('[+]') + style.RESET(' Facebook password: '******'\n[!]') + style.RESET(' Error: User exited.'))
        sys.exit(0)
    API_SECRET = '62f8ce9f74b12f84c123cc23437a4a32'
    API_KEY = '882a8490361da98702bf97a021ddc14d'
    data = {
        "api_key": API_KEY,
        "credentials_type": "password",
        "email": username,
        "format": "JSON",
        "generate_machine_id": "1",
        "generate_session_cookies": "1",
        "locale": "en_US",
        "method": "auth.login",
        "password": password,
        "return_ssl_resources": "0",
        "v": "1.0"
    }
    sig = 'api_key=' + API_KEY + 'credentials_type=passwordemail=' + username + 'format=JSONgenerate_machine_id=1generate_session_cookies=1locale=en_USmethod=auth.loginpassword='******'return_ssl_resources=0v=1.0' + API_SECRET

    hash = hashlib.new('md5')
    hash.update(sig.encode('utf-8'))
    data.update({'sig': hash.hexdigest()})
    generate_token(data)
Exemple #28
0
    def _exit_game(self):
        clear()

        selection_list = ["Yes", "No"]
        cursor_not_selected = " "
        cursor_selected = ">"
        tmp_cursor = deepcopy(selection_list)
        cursor_selection = 1

        while True:

            self._draw_hidden_map()
            for i in range(len(tmp_cursor)):
                if i == cursor_selection:
                    tmp_cursor[i] = cursor_selected + tmp_cursor[i]
                else:
                    tmp_cursor[i] = cursor_not_selected + tmp_cursor[i]

            print("Will you exit the game?")
            print("".join(tmp_cursor))
            tmp_cursor = deepcopy(selection_list)
            tmp = getch()
            if tmp == "LEFT_KEY":
                if cursor_selection > 0:
                    cursor_selection -= 1

            elif tmp == "RIGHT_KEY":
                if cursor_selection < len(tmp_cursor) - 1:
                    cursor_selection += 1

            elif tmp == b"\r":
                # Yes case --> Initialise map.
                if cursor_selection == 0:
                    return True

                # No case --> Do nothing.
                if cursor_selection == 1:
                    return False
            clear()
        clear()
Exemple #29
0
    def learn(self):
        try:
            while True:
                self.__print_last_attempt()
                print("The password is: {}".format(
                    colored(self.contents, "green")))
                print("Your last attempt was: {}".format(
                    colored(self.last_attempt, "red")))
                try:
                    countdown(1)
                except KeyboardInterrupt:
                    pass
                clear()

                prompt = "Give in another try: " if self.correct == self.__size else "Polish it: "
                self.last_attempt = str(input(prompt))
                clear()
        except KeyboardInterrupt:
            clear()
            print(
                colored("Saving this password to renew in the next session...",
                        "yellow"))
            self.save()
Exemple #30
0
def ShowContours(img):
    # ret , thresh1 = cv2.threshold(img,90,255,cv2.THRESH_BINARY)
    # ret , thresh2 = cv2.threshold(img,127,255,cv2.THRESH_BINARY_INV)
    # ret , thresh3 = cv2.threshold(img,127,255,cv2.THRESH_TRUNC)
    # ret , thresh4 = cv2.threshold(img,127,255,cv2.THRESH_TOZERO)
    # ret , thresh5 = cv2.threshold(img,127,255,cv2.THRESH_TOZERO_INV)

    # titles = ['original image','Binary','binary-inv','trunc','tozero','tozero-inv']
    # images = [img,thresh1,thresh2,thresh3,thresh4,thresh5]
    # cv2.imshow(titles[1], images[1])
    # cv2.imshow(titles[2], images[2])
    # cv2.imshow(titles[3], images[3])
    # cv2.imshow(titles[4], images[4])
    # cv2.imshow(titles[5], images[5])

    #show contours
    imggray = cv2.cvtColor(
        img, cv2.COLOR_BGR2GRAY)  # cv2.cvtColor(src, code[, dst[, dstCn]])
    # src:它是要更改其色彩空间的图像
    # code:它是色彩空间转换代码。
    # dst:它是与src图像大小和深度相同的输出图像。它是一个可选参数。
    # dstCn:它是目标图像中的频道数。如果参数为0,则通道数自动从src和代码得出。它是一个可选参数。
    # 返回值:它返回一个图像。

    ret, thresh = cv2.threshold(imggray, 50, 255, 0)  #简单阈值 黑色识别
    # ret,thresh=cv2.threshold(imggray,127,255,0)
    #第一个原图像,第二个进行分类的阈值,第三个是高于(低于)阈值时赋予的新值,第四个是一个方法选择参数,常用的有
    #cv2.THRESH_BINARY(黑白二值)
    # cv2.THRESH_BINARY_INV(黑白二值反转)
    # cv2.THRESH_TRUNC (得到的图像为多像素值)
    # cv2.THRESH_TOZERO
    # cv2.THRESH_TOZERO_INV

    imgimg, contours, hierarchy = cv2.findContours(
        thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)  #用来绘制轮廓
    #cv2.findContours(image, mode, method[, contours[, hierarchy[, offset ]]])
    #第一个参数是原始图像,第二个参数是轮廓,一个python列表,第三个参数是轮廓的索引
    #输出:第一个是图像,第二个是我们的轮廓,第三个输出名字是hierarchy
    # opencv2返回两个值:contours:hierarchy。注:opencv3会返回三个值,分别是img, countours, hierarchy
    # 需要直线时,找到两个端点即可。cv2.CHAIN_APPROX_SIMPLE可以实现。它会将轮廓上的冗余点去掉,压缩轮廓,从而节省内存开支。

    # img1 = cv2.drawContours(img,contours,-1,(0,255,0),5)  # img为三通道才能显示轮廓 RGB

    # img2 = cv2.drawContours(img,contours,0,(0,0,0),5)  # img为三通道才能显示轮廓
    # img3 = cv2.drawContours(img,contours,1,(0,255,0),5)  # img为三通道才能显示轮廓
    # img4 = cv2.drawContours(img,contours,2,(205,85,85),5)  # img为三通道才能显示轮廓
    # 第一个参数是指明在哪幅图像上绘制轮廓,第二个参数是轮廓本身,在Python中是一个list。
    #第三个参数指定绘制轮廓list中的哪条轮廓,如果是-1,则绘制其中的所有轮廓
    #第四个参数,轮廓颜色
    # 第五个参数thickness为轮廓的线宽,如果为负值或CV_FILLED表示填充轮廓内部
    # 第六个参数lineType为线型
    # 第七个参数为轮廓结构信息

    # cnt0=contours[0]
    # cnt1=contours[1]

    # print("the contours[0]")#
    # Calculation(cnt0)
    # print("the contours[1]")#
    # Calculation(cnt1)
    clear()  #清屏

    # print("contours",len(contours))
    for cnt in contours:
        # print(cv2.contourArea(cnt))
        if (cv2.contourArea(cnt) > 3000) and (cv2.contourArea(cnt) < 50000):
            # draw a rectangle around the items
            x, y, w, h = cv2.boundingRect(cnt)
            cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 3)
            print("左上角坐标x:", x)
            print("左上角坐标y:", y)
            print("矩形宽 w:", w)
            print("矩形高 h:", h)
            print("液体高度:", '%.4f' % CalculationHigh(h), "cm")
            # return CalculationHigh(h)

    cv2.imshow("-1", img)
#!/usr/local/bin/python3
""" Divides 10 by an integer and provides basic exception handling """

import clear_screen
user_input_text = "Please input an integer: "
error_response = {'ValueError':('Invalid type of input','a valid'), 'ZeroDivisionError':('Cannot divide by zero','a non-zero')}

def validate_user_input(x):
    """ Check if user input is a non-zero integer. """

    try:
        return 10/int(x)
    except Exception as error_code:
        print(error_response[error_code.__class__.__name__][0])
        raise
        
user_input = input(user_input_text)        
while True:
    clear_screen.clear()
    if user_input:
        try:
            print(validate_user_input(user_input))
            user_input = input(user_input_text)
        except Exception as error_code:
            user_input = input("Please input {0} integer: ".format(error_response[error_code.__class__.__name__][1]))
    else:
        break