Skip to content

Commit f872038

Browse files
authored
Safer workflow loading (#903)
* Removed automatic workflow loading/saving from TLS-Attacker "Core" * TLS-Attacker now issues warnings when workflow traces are loaded via the "secure" function if originalValues are still present in the workflowtrace to avoid confusion
1 parent b22b13f commit f872038

File tree

26 files changed

+372
-500
lines changed

26 files changed

+372
-500
lines changed

TLS-Client/src/main/java/de/rub/nds/tlsattacker/client/config/ClientCommandConfig.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
package de.rub.nds.tlsattacker.client.config;
1111

12+
import com.beust.jcommander.Parameter;
1213
import com.beust.jcommander.ParametersDelegate;
1314
import de.rub.nds.tlsattacker.core.config.Config;
1415
import de.rub.nds.tlsattacker.core.config.TLSDelegateConfig;
1516
import de.rub.nds.tlsattacker.core.config.delegate.CertificateDelegate;
1617
import de.rub.nds.tlsattacker.core.config.delegate.CipherSuiteDelegate;
1718
import de.rub.nds.tlsattacker.core.config.delegate.ClientDelegate;
1819
import de.rub.nds.tlsattacker.core.config.delegate.CompressionDelegate;
19-
import de.rub.nds.tlsattacker.core.config.delegate.ConfigOutputDelegate;
2020
import de.rub.nds.tlsattacker.core.config.delegate.FilterDelegate;
2121
import de.rub.nds.tlsattacker.core.config.delegate.GeneralDelegate;
2222
import de.rub.nds.tlsattacker.core.config.delegate.HeartbeatDelegate;
@@ -28,8 +28,6 @@
2828
import de.rub.nds.tlsattacker.core.config.delegate.StarttlsDelegate;
2929
import de.rub.nds.tlsattacker.core.config.delegate.TimeoutDelegate;
3030
import de.rub.nds.tlsattacker.core.config.delegate.TransportHandlerDelegate;
31-
import de.rub.nds.tlsattacker.core.config.delegate.WorkflowInputDelegate;
32-
import de.rub.nds.tlsattacker.core.config.delegate.WorkflowOutputDelegate;
3331
import de.rub.nds.tlsattacker.core.config.delegate.WorkflowTypeDelegate;
3432
import de.rub.nds.tlsattacker.core.workflow.factory.WorkflowTraceType;
3533

@@ -56,10 +54,6 @@ public class ClientCommandConfig extends TLSDelegateConfig {
5654
@ParametersDelegate
5755
private TimeoutDelegate timeoutDelegate;
5856
@ParametersDelegate
59-
private WorkflowInputDelegate workflowInputDelegate;
60-
@ParametersDelegate
61-
private WorkflowOutputDelegate workflowOutputDelegate;
62-
@ParametersDelegate
6357
private WorkflowTypeDelegate workflowTypeDelegate;
6458
@ParametersDelegate
6559
private HeartbeatDelegate heartbeatDelegate;
@@ -68,12 +62,16 @@ public class ClientCommandConfig extends TLSDelegateConfig {
6862
@ParametersDelegate
6963
private FilterDelegate filterDelegate;
7064
@ParametersDelegate
71-
private ConfigOutputDelegate configOutputDelegate;
72-
@ParametersDelegate
7365
private ListDelegate listDelegate;
7466
@ParametersDelegate
7567
private StarttlsDelegate starttlsDelegate;
7668

69+
@Parameter(names = "-workflow_input", description = "A path to a workflow trace that should be exeucted")
70+
private String workflowInput = null;
71+
@Parameter(names = "-workflow_output",
72+
description = "A path in which the executed workflow trace should be stored in")
73+
private String workflowOutput = null;
74+
7775
public ClientCommandConfig(GeneralDelegate delegate) {
7876
super(delegate);
7977
this.ciphersuiteDelegate = new CipherSuiteDelegate();
@@ -84,13 +82,10 @@ public ClientCommandConfig(GeneralDelegate delegate) {
8482
this.signatureAndHashAlgorithmDelegate = new SignatureAndHashAlgorithmDelegate();
8583
this.transportHandlerDelegate = new TransportHandlerDelegate();
8684
this.timeoutDelegate = new TimeoutDelegate();
87-
this.workflowInputDelegate = new WorkflowInputDelegate();
88-
this.workflowOutputDelegate = new WorkflowOutputDelegate();
8985
this.workflowTypeDelegate = new WorkflowTypeDelegate();
9086
this.heartbeatDelegate = new HeartbeatDelegate();
9187
this.certificateDelegate = new CertificateDelegate();
9288
this.filterDelegate = new FilterDelegate();
93-
this.configOutputDelegate = new ConfigOutputDelegate();
9489
this.listDelegate = new ListDelegate();
9590
this.starttlsDelegate = new StarttlsDelegate();
9691
this.compressionDelegate = new CompressionDelegate();
@@ -103,14 +98,11 @@ public ClientCommandConfig(GeneralDelegate delegate) {
10398
addDelegate(protocolVersionDelegate);
10499
addDelegate(clientDelegate);
105100
addDelegate(signatureAndHashAlgorithmDelegate);
106-
addDelegate(workflowInputDelegate);
107-
addDelegate(workflowOutputDelegate);
108101
addDelegate(workflowTypeDelegate);
109102
addDelegate(transportHandlerDelegate);
110103
addDelegate(timeoutDelegate);
111104
addDelegate(certificateDelegate);
112105
addDelegate(filterDelegate);
113-
addDelegate(configOutputDelegate);
114106
addDelegate(starttlsDelegate);
115107
}
116108

@@ -123,4 +115,13 @@ public Config createConfig() {
123115
}
124116
return config;
125117
}
118+
119+
public String getWorkflowInput() {
120+
return workflowInput;
121+
}
122+
123+
public String getWorkflowOutput() {
124+
return workflowOutput;
125+
}
126+
126127
}

TLS-Client/src/main/java/de/rub/nds/tlsattacker/client/main/TlsClient.java

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515
import de.rub.nds.tlsattacker.core.config.Config;
1616
import de.rub.nds.tlsattacker.core.config.delegate.GeneralDelegate;
1717
import de.rub.nds.tlsattacker.core.config.delegate.ListDelegate;
18-
import de.rub.nds.tlsattacker.core.exceptions.ConfigurationException;
1918
import de.rub.nds.tlsattacker.core.exceptions.WorkflowExecutionException;
2019
import de.rub.nds.tlsattacker.core.state.State;
2120
import de.rub.nds.tlsattacker.core.workflow.WorkflowExecutor;
2221
import de.rub.nds.tlsattacker.core.workflow.WorkflowExecutorFactory;
22+
import de.rub.nds.tlsattacker.core.workflow.WorkflowTrace;
23+
import de.rub.nds.tlsattacker.core.workflow.WorkflowTraceSerializer;
24+
import java.io.File;
25+
import java.io.FileInputStream;
2326
import org.apache.logging.log4j.LogManager;
2427
import org.apache.logging.log4j.Logger;
2528

@@ -47,20 +50,35 @@ public static void main(String[] args) {
4750

4851
try {
4952
Config tlsConfig = config.createConfig();
53+
WorkflowTrace trace = null;
54+
if (config.getWorkflowInput() != null) {
55+
LOGGER.debug("Reading workflow trace from " + config.getWorkflowInput());
56+
trace =
57+
WorkflowTraceSerializer.secureRead(new FileInputStream(new File(config.getWorkflowInput())));
58+
}
5059
TlsClient client = new TlsClient();
51-
client.startTlsClient(tlsConfig);
60+
State state = client.startTlsClient(tlsConfig, trace);
61+
if (config.getWorkflowOutput() != null) {
62+
trace = state.getWorkflowTrace();
63+
LOGGER.debug("Writing workflow trace to " + config.getWorkflowOutput());
64+
WorkflowTraceSerializer.write(new File(config.getWorkflowOutput()), trace);
65+
}
5266
} catch (Exception e) {
5367
LOGGER.error("Encountered an uncaught Exception aborting. See debug for more info.", e);
5468
}
5569
} catch (ParameterException e) {
56-
LOGGER.error("Could not parse provided parameters. " + e.getLocalizedMessage());
57-
LOGGER.debug(e);
70+
LOGGER.error("Could not parse provided parameters. " + e.getLocalizedMessage(), e);
5871
commander.usage();
5972
}
6073
}
6174

62-
public void startTlsClient(Config config) {
63-
State state = new State(config);
75+
public State startTlsClient(Config config, WorkflowTrace trace) {
76+
State state;
77+
if (trace == null) {
78+
state = new State(config);
79+
} else {
80+
state = new State(config, trace);
81+
}
6482
WorkflowExecutor workflowExecutor =
6583
WorkflowExecutorFactory.createWorkflowExecutor(config.getWorkflowExecutorType(), state);
6684

@@ -71,5 +89,6 @@ public void startTlsClient(Config config) {
7189
"The TLS protocol flow was not executed completely, follow the debug messages for more information.");
7290
LOGGER.debug(ex.getLocalizedMessage(), ex);
7391
}
92+
return state;
7493
}
7594
}

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/config/Config.java

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -497,21 +497,6 @@ public static Config createEmptyConfig() {
497497
@XmlElementWrapper
498498
private List<RequestItemV2> statusRequestV2RequestList;
499499

500-
/**
501-
* If we should use a workflow trace specified in File
502-
*/
503-
private String workflowInput = null;
504-
505-
/**
506-
* If set, save the workflow trace to this file after trace execution.
507-
*/
508-
private String workflowOutput = null;
509-
510-
/**
511-
* If set, save the actually used config to this file after trace execution.
512-
*/
513-
private String configOutput = null;
514-
515500
/**
516501
* The Type of workflow trace that should be generated
517502
*/
@@ -2643,30 +2628,6 @@ public void setWorkflowTraceType(WorkflowTraceType workflowTraceType) {
26432628
this.workflowTraceType = workflowTraceType;
26442629
}
26452630

2646-
public String getWorkflowOutput() {
2647-
return workflowOutput;
2648-
}
2649-
2650-
public void setWorkflowOutput(String workflowOutput) {
2651-
this.workflowOutput = workflowOutput;
2652-
}
2653-
2654-
public String getConfigOutput() {
2655-
return configOutput;
2656-
}
2657-
2658-
public void setConfigOutput(String configOutput) {
2659-
this.configOutput = configOutput;
2660-
}
2661-
2662-
public String getWorkflowInput() {
2663-
return workflowInput;
2664-
}
2665-
2666-
public void setWorkflowInput(String workflowInput) {
2667-
this.workflowInput = workflowInput;
2668-
}
2669-
26702631
public NamedGroup getDefaultSelectedNamedGroup() {
26712632
return defaultSelectedNamedGroup;
26722633
}

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/config/delegate/ConfigOutputDelegate.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/config/delegate/WorkflowInputDelegate.java

Lines changed: 0 additions & 40 deletions
This file was deleted.

TLS-Core/src/main/java/de/rub/nds/tlsattacker/core/config/delegate/WorkflowOutputDelegate.java

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)