Пример #1
0
def authenticate(request, client_info):
    try:
        request_dis = util.disassemble(request)
        client_info_dis = util.disassemble(client_info)
    except Exception, e:
        print '[!!!]ERROR: ', e
        error_log('authenticate', e)
        return (0, 'Invalid')
Пример #2
0
    def authenticate(self, KDC_key_encrypt, KDC_encrypt_client_info, client_encrypt_client_info):
        session_key = self.KDC_decrypt(KDC_key_encrypt)
        session_k = des(session_key, CBC, '\0\0\0\0\0\0\0\0', pad=None, padmode=PAD_PKCS5)

        KDC_client_info = self.KDC_decrypt(KDC_encrypt_client_info)
        client_client_info = session_k.decrypt(client_encrypt_client_info)

        try:
            KDC_client = util.disassemble(KDC_client_info)
            client_client = util.disassemble(client_client_info)
        except Exception, e:
            print '[!!!]FATAL: ', e
            self.error_log('AS authenticate disassemble', e)
            return
Пример #3
0
    def addTo(self, client):
        try:
            assemble_key = util.assemble(str(public_key.n), str(public_key.e))
            client.send(assemble_key)
            client_public_key = client.recv(self.BUFSIZ)

            client_info_encrypt = client.recv(self.BUFSIZ)
            client_info_signature = client.recv(self.BUFSIZ)

            n, e = util.disassemble(client_public_key)
            client_key = rsa.PublicKey(int(n), int(e))

            rsa.verify(client_info_encrypt, client_info_signature, client_key)
            client_info = rsa.decrypt(client_info_encrypt, private_key)
            client_ID, KDCID, timestamp, reverse, client_decrypt = util.disassemble(client_info)
        except Exception, e:
            print '[!!!]ERROR :', e
            self.error_log('KC addTo decrypt', e)
            client.close()
            return
Пример #4
0
    def generate_session_ticket(self, encrypt_client_info):
        client_info = self.KDC_decrypt(encrypt_client_info)
        client_id, server_id, KDCID, timestamp = util.disassemble(client_info)

        try:
            session_key = self.get_session_key()
            client_key = self.get_master_key(int(client_id))
            client_k = des(client_key, CBC, '\0\0\0\0\0\0\0\0', pad=None, padmode=PAD_PKCS5)
            server_key = self.get_master_key(int(server_id))
            server_k = des(server_key, CBC, '\0\0\0\0\0\0\0\0', pad=None, padmode=PAD_PKCS5)
        except Exception, e:
            print '[!!!]FATAL: ', e
            self.error_log('AS generate_session_ticket', e)
            return
Пример #5
0
import time
from pyDes import *

_KDCAddr = "172.18.187.103"
_KCPORT = 3210
BUFSIZ = 1024

(pub, pri) = rsa.newkeys(1024)

ADDR = (_KDCAddr, _KCPORT)
sock = socket(AF_INET, SOCK_STREAM)
sock.connect(ADDR)

sock.send("000")
assemble_key = sock.recv(BUFSIZ)
n, e = util.disassemble(str(assemble_key))
public_key = rsa.PublicKey(int(n), int(e))

assemble_key = util.assemble(str(pub.n), str(pub.e))
sock.send(assemble_key)

message = "abcdefgh"
timestamp = str(int(time.time()))
info = util.assemble("2222", "10385011", timestamp, 1, message)
crypto = rsa.encrypt(info, public_key)
sock.send(crypto)
time.sleep(0.1)
si = rsa.sign(crypto, pri, "SHA-1")
sock.send(si)

des_key = des(message, CBC, "\0\0\0\0\0\0\0\0", pad=None, padmode=PAD_PKCS5)