Exemplo n.º 1
0
def response(kctgs, auth):
    idc = auth['idc']
    adc = auth['adc']
    ts4, lt4 = functions.timeterms()

    string_v = uuid.uuid4().hex[:6].lower()
    # print(string_v)
    kcv = functions.generatePassword(string_v)
    ticket = {
        "kcv": kcv,
        "idc": idc,
        "adc": adc,
        "idv": idv,
        "ts4": str(ts4),
        "lt4": str(lt4)
    }

    kv = functions.generatePassword("Vsecret")
    keyv = AES.generateKey(kv)

    encrypted_ticket = functions.dict_encryption(ticket, keyv)

    final_pkg = {
        "kcv": kcv,
        "idv": idv,
        "ts4": str(ts4),
        "ticketv": encrypted_ticket.decode()
    }
    return final_pkg
Exemplo n.º 2
0
def response(package, address):
    ts2, lt2 = functions.timeterms()
    idc = package["idc"]
    adc = address[0]
    stringtgs = uuid.uuid4().hex[:6].lower()
    # print(stringtgs)
    kctgs = functions.generatePassword(stringtgs)
    ticket = {
        "kctgs": kctgs,
        "idc": idc,
        "adc": adc,
        "idtgs": idtgs,
        "ts2": str(ts2),
        "lt2": str(lt2)
    }

    ktgs = functions.generatePassword("TGSsecret")
    keytgs = AES.generateKey(ktgs)

    encrypted_ticket = functions.dict_encryption(ticket, keytgs)

    final_pkg = {
        "kctgs": kctgs,
        "idtgs": idtgs,
        "ticket_tgs": encrypted_ticket.decode(),
        "ts2": str(ts2),
        "lt2": str(lt2)
    }
    return final_pkg
Exemplo n.º 3
0
while True:
    try:
        package = recvmsg(clientsocket)
        print("Message received from client")
        # print(package,"\n")
        ticket_tgs_bytes = AES.decrypt(package['ticket_tgs'], keytgs)
        ticket_tgs = json.loads(ticket_tgs_bytes.decode())
        kctgs = ticket_tgs['kctgs']
        keyctgs = AES.generateKey(kctgs)

        authc = functions.getauth(kctgs, package['authenticatorC'])
        if (not functions.checkTimestamp(authc['ts'])):
            if (functions.verify(authc, ticket_tgs)):
                idv = package['idv']
                resp = response(kctgs, authc)
                # print("Message before encryption\n",resp,"\n")
                resp_to_send = functions.dict_encryption(resp, keyctgs)
                sendmsg(resp_to_send)
                print("Encrypted message sent back to the client")
                # print(resp_to_send)

            else:
                print("Breach detected!!")

        else:
            print("Taking too long to respond")

    except:
        print("TGS has closed down")
        break
Exemplo n.º 4
0
def authenticator(keyS, idc, adc):
    ts = str(datetime.now())
    key = AES.generateKey(keyS)
    authc = {"idc": idc, "adc": adc, "ts": ts}
    encrypted_auth = functions.dict_encryption(authc, key)
    return encrypted_auth
Exemplo n.º 5
0
        password = str(val[1])

    keyc = AES.generateKey(password)
    return keyc


s = socket.socket()
host = socket.gethostname()
port = 8001
s.bind((host, port))
s.listen(5)

clientsocket, address = s.accept()
print(f"Connection from {address} has been established")
idtgs = 1101

while True:
    try:
        package = recvmsg(clientsocket)
        print("Packet received from client\n")
        resp = response(package, address)

        resp_to_send = functions.dict_encryption(resp,
                                                 clientKey(package["idc"]))
        sendmsg(resp_to_send)
        print("Message sent to the client")

    except:
        print("AS has closed down")
        break