Ejemplo n.º 1
0
 def handle_numpad(self, numpad):
     # numpad int or char
     # print("handle numpad", PAGE, numpad)
     if self.MODE == 0:
         # User mode
         if type(numpad) == int:
             key = self.CONFIG["pages"][self.PAGE]["keys"][numpad][2]
             if key != '':
                 # dup code
                 for i, item in enumerate(self.CONFIG["pages"][self.PAGE]["keys"]):
                     r, g, b = hex_to_rgb(item[1])
                     self.KEYPAD.set_led(NUMPAD_TO_TOUCH[i], r, g, b)
                 self.INDEX = numpad
                 if self.CONFIG["pages"][self.PAGE]["type"] == "TOTP":
                     self.OTP = TOTP(key)
                     self.KEYS[15].set_led(0, 100, 0)  # green = enter
                     self.LAST_CODE = ""
                     self.LAST_COUNTER = 0
                     self.DISPLAY.auto_refresh = False
                     # TODO: auto center
                     self.SCREENS["OTP"][2].text = self.CONFIG["pages"][self.PAGE]["keys"][self.INDEX][0]
                     self.SCREENS["OTP"][2].color = int(self.CONFIG["pages"][self.PAGE]["keys"][self.INDEX][1], 16)
                     self.SCREENS["OTP"][1].text = "------"
                     self.DISPLAY.show(self.SCREENS["OTP"][0])
                     self.DISPLAY.auto_refresh = True
                 elif self.CONFIG["pages"][self.PAGE]["type"] == "KEYS":
                     self.KEYS[15].set_led(0, 100, 0)  # green = enter
                     self.DISPLAY.auto_refresh = False
                     # TODO: auto center
                     self.SCREENS["OTP"][2].text = self.CONFIG["pages"][self.PAGE]["keys"][self.INDEX][0]
                     self.SCREENS["OTP"][2].color = int(self.CONFIG["pages"][self.PAGE]["keys"][self.INDEX][1], 16)
                     self.SCREENS["OTP"][1].text = ""
                     self.SCREENS["OTP"][3].progress = 1.0
                     self.DISPLAY.show(self.SCREENS["OTP"][0])
                     self.DISPLAY.auto_refresh = True
             else:
                 self.OTP = None
         elif numpad == "N":
             self.PAGE += 1
             if self.PAGE >= len(self.CONFIG["pages"]):
                 self.PAGE = 0
             self.display_page(self.PAGE)
         elif numpad == "P":
             self.PAGE -= 1
             if self.PAGE < 0:
                 self.PAGE = len(self.CONFIG["pages"]) - 1
             self.display_page(self.PAGE)
         elif numpad == "E":
             if self.OTP and self.CONFIG["pages"][self.PAGE]["type"] == "TOTP":
                 self.LAYOUT.write(self.LAST_CODE)
             if self.CONFIG["pages"][self.PAGE]["type"] == "KEYS":
                 self.LAYOUT.write(self.CONFIG["pages"][self.PAGE]["keys"][self.INDEX][2])
  def __init__(self):
    """Begin the app."""

    web_dir = os.path.join(os.path.dirname(__file__), 'html')
    os.chdir(web_dir)
    print('CWD:', web_dir)

    self.totp = TOTP('supersecretkey32') # Key unique to each user.

    self.fr = FaceRecognition()
    self.fr.set_request_unlock(request_unlock)

    self.server = WebServer(port=8080, ws_port=8081)
    self.server.set_begin_registration(self.begin_registration)
    self.server.set_verify_code(self.verify_code)

    self.requestedUnlock = False

    print('Hello world!')

    self.fr.start_recognition()
Ejemplo n.º 3
0
    try:
        requests.get("https://1.1.1.1/")
        return True
    except:
        return False


while not check_connection():
    time.sleep(1)

hostname = env["HOSTNAME"]
target_ip = env.get("DESTINATION",
                    subprocess.getoutput("ip route | grep default").split()[2])
ngrok = Ngrok("./ngrok." + env["ARCH"], env["NGROK_TOKEN"], env["PROTOCOL"],
              target_ip, int(env["PORT"]), env["REGION"])
totp = TOTP(env["TOTP_SECRET"]) if env.get("TOTP_SECRET") else None

expecting_authentication = False


def on_update(bot, update):
    global expecting_authentication

    message = update["message"]
    if message["from"]["id"] != bot_owner or message["chat"][
            "id"] != bot_owner or message["chat"]["type"] != "private":
        return

    text = message["text"]
    chat = message["chat"]["id"]
    if expecting_authentication: