def init_display_info(self, screen, info): """ Initialization of the ApDisplyInfo object :param self: A TuiApSel object :type self: TuiApSel :param screen: A curses window object :type screen: _curses.curses.window :param info: A namedtuple of information from pywifiphisher :type info: namedtuple :return ApDisplayInfo object :rtype: ApDisplayInfo """ position = 1 page_number = 1 # get window height, length and create a box inside max_window_height, max_window_length = screen.getmaxyx() if max_window_height < 14 or max_window_length < 9: box = curses.newwin(max_window_height, max_window_length, 0, 0) self.renew_box = True else: box = curses.newwin(max_window_height-9, max_window_length-5, 4, 3) box.box() # calculate the box's maximum number of row's box_height = box.getmaxyx()[0] # subtracting 2 from the height for the border max_row = box_height - 2 key = 0 box_info = [max_window_height, max_window_length, max_row, key] ap_info = ApDisplayInfo(position, page_number, box, box_info) self.mac_matcher = info.mac_matcher # start finding access points self.access_point_finder = recon.AccessPointFinder( info.interface, info.network_manager) if info.args.lure10_capture: self.access_point_finder.capture_aps() self.access_point_finder.find_all_access_points() return ap_info
def select_access_point(screen, interface, mac_matcher, network_manager): """ Return the access point the user has selected :param screen: A curses window object :param interface: An interface to be used for finding access points :param network_manager: A NetworkManager object :type screen: _curses.curses.window :type interface: NetworkAdapter :type interface: NetworkAdapter :return: Choosen access point :rtype: accesspoint.AccessPoint """ # make cursor invisible curses.curs_set(0) # don't wait for user input screen.nodelay(True) # start finding access points access_point_finder = recon.AccessPointFinder(interface, network_manager) if args.lure10_capture: access_point_finder.capture_aps() access_point_finder.find_all_access_points() position = 1 page_number = 1 # get window height, length and create a box inside max_window_height, max_window_length = screen.getmaxyx() box = curses.newwin(max_window_height - 9, max_window_length - 5, 4, 3) box.box() # calculate the box's maximum number of row's box_height = box.getmaxyx()[0] # subtracting 2 from the height for the border max_row = box_height - 2 # information regarding access points access_points = list() total_ap_number = 0 # added so it would go through the first iteration of the loop key = 0 # show information until user presses Esc key while key != 27: # resize the window if it's dimensions have been changed if screen.getmaxyx() != (max_window_height, max_window_length): max_window_height, max_window_length = screen.getmaxyx() box.resize(max_window_height - 9, max_window_length - 5) # calculate the box's maximum number of row's box_height = box.getmaxyx()[0] # subtracting 2 from the height for the border max_row = box_height - 2 # reset the page and position to avoid problems position = 1 page_number = 1 # check if any new access points have been discovered if len(access_point_finder.get_all_access_points()) != total_ap_number: access_points = access_point_finder.get_sorted_access_points() total_ap_number = len(access_points) # display the information to the user display_access_points((screen, box, access_points, total_ap_number, page_number, position), mac_matcher) # check for key movement and store result key_movement_result = key_movement( (key, position, page_number, max_row, access_points)) key = key_movement_result[0] position = key_movement_result[1] page_number = key_movement_result[2] # ask for a key input (doesn't block) key = screen.getch() # in case ENTER key has been pressed on a valid access point if key == ord("\n") and total_ap_number != 0: # show message and exit screen.addstr( max_window_height - 2, 3, "YOU HAVE SELECTED " + access_points[position - 1].get_name()) screen.refresh() time.sleep(1) # turn off access point discovery and return the result access_point_finder.stop_finding_access_points() return access_points[position - 1] # turn off access point discovery access_point_finder.stop_finding_access_points()