示例#1
0
def key_packet(context, data):
    if verbose:
        print("[KeyPacket] Decrypting RC4 key packet!")
    rsa_blob = data[0x8:0x88]
    decrypted = rsaDecrypter.decrypt(rsa_blob)
    if decrypted is None:
        print(
            "[KeyPacket] Could not decrypt RSA for client %s, Perhaps their client's key is unmodified? Hanging up."
            % context.transport.getPeer().host)
        brokenlist.append(context.transport.getPeer().host)
        context.transport.loseConnection()
        return None
    if verbose:
        print("[KeyPacket] Client %s RC4 key %s" % (
            context.transport.getPeer().host,
            ''.join("%02x " % b for b in bytearray(decrypted[0x10:0x20])),
        ))
    context.c4crypto = PSO2RC4(decrypted[0x10:0x20])
    context.peer.c4crypto = PSO2RC4(decrypted[0x10:0x20])
    # Re-RSA packet
    blob = io.BytesIO()
    blob.write(data[:0x8])
    blob.write(rsaEncryptor.encrypt(decrypted))
    blob.write(data[0x88:len(data)])
    blob.flush()
    return blob.getvalue()
示例#2
0
def key_packet(context, data):
    if verbose:
        print("[KeyPacket] Decrypting RC4 key packet!")
    rsa_blob = data[0x8:0x88]
    decrypted = rsaDecrypter.decrypt(rsa_blob)
    if decrypted is None:
        print(
            "[KeyPacket] Could not decrypt RSA for client {}, Perhaps their client's key is unmodified? Hanging up.".format(
                context.transport.getPeer().host
            )
        )
        brokenlist.append(context.transport.getPeer().host)
        context.transport.loseConnection()
        return None
    if verbose:
        print("[KeyPacket] Client %s RC4 key %s" % (
            context.transport.getPeer().host, ''.join("%02x " % b for b in bytearray(decrypted[0x10:0x20])),))
    context.c4crypto = PSO2RC4(decrypted[0x10:0x20])
    context.peer.c4crypto = PSO2RC4(decrypted[0x10:0x20])
    # Re-RSA packet
    blob = io.BytesIO()
    blob.write(data[:0x8])
    blob.write(rsaEncryptor.encrypt(decrypted))
    blob.write(data[0x88:len(data)])
    blob.flush()
    return blob.getvalue()