Exemple #1
0
def mainService():
    print("[getpass] waiting for ui to connect... ")
    ui_socket_listener = UnixSocketListener(
        ui_socket_path, apps)

    ui_socket = ui_socket_listener.next_client()
    print("[getpass] ui connected ... ")
    print("[getpass] asking master password... ")
    # os.setregid(os.getegid(), os.getegid())
    correct, master_password = ask_master_password(ui_socket)
    # os.setregid(os.getegid(), os.getegid())
    if correct:
        ui_socket.write_line("1 " + master_password)
    else:
        ui_socket.write_line("0")
Exemple #2
0
class APIListener():

    def __init__(self, path_sock, master_password, approver):
        self.listener = UnixSocketListener(path=path_sock, approver=approver)
        API().set_key(master_password)

    def run(self):
        self.listen_loop()

    def listen_loop(self):
        while True:
            sock = self.listener.next_client()
            start_new_thread(self.handle_client, (sock,))

    def handle_client(self, socket):

        while True:
            line = socket.read_line().split()
            if line[0] == "end":
                return
            elif line[0] == "save":
                ret_id = API().save_password(socket.app, line[1], line[2])
                socket.write_line("save %d" % ret_id)
            elif line[0] == "get":
                ret_id, username, password = API().get_password(socket.app, line[1])
                socket.write_line("get %d %s %s" % (ret_id, username, password))
            else:
                print("Invalid Command Recieved")
Exemple #3
0
config.read('passcheck.conf')

sock_path = config.get("connection", "ui_sock")

accessable_from = config.get("access", "exe")
accessable_hash = config.get("access", "sha1")

apps = []
apps.append(SingleApp(accessable_from, accessable_hash))

master_password_hash = config.get("password", "master_password")
secret_code = config.get("password", "secret_code")


print("[checkpass] waiting for connection")
server_listener = UnixSocketListener(sock_path, apps)
server = server_listener.next_client()
print("[checkpass] someone connected successfully")

while True:
    command = server.read_line().split()

    if command[0] == "end":
        break
    if command[0] == "secret_code":
        print("[checkpass] sending secret_code to client")
        server.write_line(secret_code)
    elif command[0] == "check":
        print("[checkpass] checking if client code is correct")
        if SHA512.new(command[1]).hexdigest() == master_password_hash:
            server.write_line("1")
Exemple #4
0
 def __init__(self, path_sock, master_password, approver):
     self.listener = UnixSocketListener(path=path_sock, approver=approver)
     API().set_key(master_password)