Skip to content

Commit 92a69af

Browse files
committed
Added empty intolerance probe
1 parent c40a9b9 commit 92a69af

File tree

1 file changed

+97
-0
lines changed

1 file changed

+97
-0
lines changed
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
package de.rub.nds.tlsscanner.probe;
2+
3+
import de.rub.nds.tlsattacker.core.config.Config;
4+
import de.rub.nds.tlsattacker.core.constants.CipherSuite;
5+
import de.rub.nds.tlsattacker.core.constants.ExtensionType;
6+
import de.rub.nds.tlsattacker.core.constants.HandshakeMessageType;
7+
import de.rub.nds.tlsattacker.core.constants.NamedCurve;
8+
import de.rub.nds.tlsattacker.core.constants.ProtocolVersion;
9+
import de.rub.nds.tlsattacker.core.exceptions.WorkflowExecutionException;
10+
import de.rub.nds.tlsattacker.core.state.State;
11+
import de.rub.nds.tlsattacker.core.workflow.WorkflowExecutor;
12+
import de.rub.nds.tlsattacker.core.workflow.WorkflowExecutorFactory;
13+
import de.rub.nds.tlsattacker.core.workflow.WorkflowTraceUtil;
14+
import de.rub.nds.tlsattacker.core.workflow.action.executor.WorkflowExecutorType;
15+
import de.rub.nds.tlsattacker.core.workflow.factory.WorkflowTraceType;
16+
import de.rub.nds.tlsscanner.config.ScannerConfig;
17+
import de.rub.nds.tlsscanner.constants.ProbeType;
18+
import static de.rub.nds.tlsscanner.probe.TlsProbe.LOGGER;
19+
import de.rub.nds.tlsscanner.report.result.ExtensionResult;
20+
import de.rub.nds.tlsscanner.report.result.ProbeResult;
21+
import java.util.ArrayList;
22+
import java.util.Arrays;
23+
import java.util.LinkedList;
24+
import java.util.List;
25+
26+
/**
27+
*
28+
* @author Robert Merget - [email protected]
29+
*/
30+
public class IntoleranceProbe extends TlsProbe {
31+
32+
public IntoleranceProbe(ScannerConfig config) {
33+
super(ProbeType.INTOLERANCES, config, 0);
34+
}
35+
36+
@Override
37+
public ProbeResult executeTest() {
38+
List<ExtensionType> allSupportedExtensions = getSupportedExtensions();
39+
return new ExtensionResult(allSupportedExtensions);
40+
}
41+
42+
public List<ExtensionType> getSupportedExtensions() {
43+
List<ExtensionType> allSupportedExtensions = new LinkedList<>();
44+
List<ExtensionType> commonExtensions = getCommonExtension();
45+
if (commonExtensions != null) {
46+
allSupportedExtensions.addAll(commonExtensions);
47+
}
48+
return allSupportedExtensions;
49+
}
50+
51+
private List<ExtensionType> getCommonExtension() {
52+
Config tlsConfig = getScannerConfig().createConfig();
53+
List<CipherSuite> cipherSuites = new LinkedList<>();
54+
cipherSuites.addAll(Arrays.asList(CipherSuite.values()));
55+
cipherSuites.remove(CipherSuite.TLS_FALLBACK_SCSV);
56+
tlsConfig.setQuickReceive(true);
57+
tlsConfig.setDefaultClientSupportedCiphersuites(cipherSuites);
58+
tlsConfig.setHighestProtocolVersion(ProtocolVersion.TLS12);
59+
tlsConfig.setEnforceSettings(false);
60+
tlsConfig.setEarlyStop(true);
61+
tlsConfig.setStopRecievingAfterFatal(true);
62+
tlsConfig.setStopActionsAfterFatal(true);
63+
tlsConfig.setWorkflowTraceType(WorkflowTraceType.SHORT_HELLO);
64+
65+
// Dont send extensions if we are in sslv2
66+
tlsConfig.setAddECPointFormatExtension(true);
67+
tlsConfig.setAddEllipticCurveExtension(true);
68+
tlsConfig.setAddHeartbeatExtension(true);
69+
tlsConfig.setAddMaxFragmentLengthExtenstion(true);
70+
tlsConfig.setAddServerNameIndicationExtension(true);
71+
tlsConfig.setAddSignatureAndHashAlgrorithmsExtension(true);
72+
tlsConfig.setAddAlpnExtension(true);
73+
tlsConfig.setAlpnAnnouncedProtocols(new String[]{"http/1.1", "spdy/1", "spdy/2", "spdy/3", "stun.turn", "stun.nat-discovery", "h2", "h2c", "webrtc", "c-webrtc", "ftp", "imap", "pop3", "managesieve"});
74+
tlsConfig.setAddEncryptThenMacExtension(true);
75+
tlsConfig.setAddExtendedMasterSecretExtension(true);
76+
tlsConfig.setAddRenegotiationInfoExtension(true);
77+
tlsConfig.setAddSessionTicketTLSExtension(true);
78+
tlsConfig.setAddTruncatedHmacExtension(true);
79+
80+
List<NamedCurve> namedCurves = Arrays.asList(NamedCurve.values());
81+
tlsConfig.setNamedCurves(namedCurves);
82+
State state = new State(tlsConfig);
83+
WorkflowExecutor workflowExecutor = WorkflowExecutorFactory.createWorkflowExecutor(WorkflowExecutorType.DEFAULT,
84+
state);
85+
try {
86+
workflowExecutor.executeWorkflow();
87+
} catch (WorkflowExecutionException ex) {
88+
LOGGER.debug(ex);
89+
}
90+
if (WorkflowTraceUtil.didReceiveMessage(HandshakeMessageType.SERVER_HELLO, state.getWorkflowTrace())) {
91+
return new ArrayList(state.getTlsContext().getNegotiatedExtensionSet());
92+
} else {
93+
LOGGER.debug("Did not receive a ServerHello, something went wrong or the Server has some intolerance");
94+
return null;
95+
}
96+
}
97+
}

0 commit comments

Comments
 (0)