tls-attacker / TLS-Attacker

TLS-Attacker is a Java-based framework for analyzing TLS libraries. It can be used to manually test TLS clients and servers or as as a software library for more advanced tools.
Apache License 2.0
778 stars 135 forks source link

how can i resend a same app message packet in one session. #120

Open dennisokko opened 2 years ago

dennisokko commented 2 years ago

this is my code, i try to use the firse message's message and records to replay the second one, but before execution, it is null.

dennisokko commented 2 years ago
    Config config = Config.createConfig();
    config.setDefaultRunningMode(RunningModeType.CLIENT);
    OutboundConnection outboundConnection = config.getDefaultClientConnection();
    outboundConnection.setPort(Integer.parseInt(args[0]));
    config.setDefaultClientConnection(outboundConnection);
    config.setDefaultSelectedCipherSuite(CipherSuite.TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256);
    config.setAddSessionTicketTLSExtension(true);

    WorkflowTrace trace = new WorkflowTrace();
    trace.addTlsAction(MessageActionFactory.createAction(
            config, outboundConnection, ConnectionEndType.CLIENT, new ClientHelloMessage(config)));
    trace.addTlsAction(
            MessageActionFactory.createAction(
                    config,
                    outboundConnection,
                    ConnectionEndType.SERVER,
                    new ServerHelloMessage(config),
                    new CertificateMessage(config),
                    new ECDHEServerKeyExchangeMessage(config),
                    new ServerHelloDoneMessage(config)));
    trace.addTlsAction(
            MessageActionFactory.createAction(
                    config,
                    outboundConnection,
                    ConnectionEndType.CLIENT,
                    new ECDHClientKeyExchangeMessage(config),
                    new ChangeCipherSpecMessage(config),
                    new FinishedMessage(config)));
    trace.addTlsAction(
            MessageActionFactory.createAction(
                    config,
                    outboundConnection,
                    ConnectionEndType.SERVER,
                    new ChangeCipherSpecMessage(config),
                    new FinishedMessage(config)));
    config.setUseFreshRandom(false);
    config.setUseAllProvidedRecords(true);
    ApplicationMessage app1 = new ApplicationMessage(config);
    MessageAction messageAction = MessageActionFactory.createAction(
            config,
            outboundConnection,
            ConnectionEndType.CLIENT,
            app1);
    trace.addTlsAction(messageAction);
    MessageAction messageAction2 = MessageActionFactory.createAction(
            config,
            outboundConnection,
            ConnectionEndType.CLIENT,
            app1);
    messageAction2.setMessages(messageAction.getMessages());
    messageAction2.setRecords(messageAction.getRecords());
    System.out.println(messageAction.getReadableString());
    trace.addTlsAction(messageAction2);
    State state = new State(config, trace);
    WorkflowExecutor workflowExecutor =
            WorkflowExecutorFactory.createWorkflowExecutor(config.getWorkflowExecutorType(), state);
    workflowExecutor.executeWorkflow();