Skip to content

Commit dae2556

Browse files
Added vulnerability detection before attack exection to get the oracle type.
Performed minor modifications
1 parent 3a07a47 commit dae2556

File tree

4 files changed

+16
-21
lines changed

4 files changed

+16
-21
lines changed

Attacks/src/main/java/de/rub/nds/tlsattacker/attacks/config/BleichenbacherCommandConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class BleichenbacherCommandConfig extends AttackConfig {
4545
+ "FULL results in a comprehensive server evaluation.")
4646
private Type type = Type.FAST;
4747
@Parameter(names = "-msgPkcsConform", description = "Used by the real Bleichenbacher attack. Indicates whether the original "
48-
+ "message that we are going to decrypt is PKCS#1 conform or not (more precisely, whether it starts with 0x00 0x02.", arity = 1)
48+
+ "message that we are going to decrypt is PKCS#1 conform or not (more precisely, whether it starts with 0x00 0x02).", arity = 1)
4949
private boolean msgPkcsConform = true;
5050

5151
public BleichenbacherCommandConfig(GeneralDelegate delegate) {

Attacks/src/main/java/de/rub/nds/tlsattacker/attacks/impl/BleichenbacherAttacker.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,7 @@ public State executeTlsFlow(BleichenbacherWorkflowType type, byte[] encryptedPMS
6565

6666
@Override
6767
public Boolean isVulnerable() {
68-
RSAPublicKey publicKey;
69-
publicKey = (RSAPublicKey) CertificateFetcher.fetchServerPublicKey(tlsConfig);
68+
RSAPublicKey publicKey = (RSAPublicKey) CertificateFetcher.fetchServerPublicKey(tlsConfig);
7069
if (publicKey == null) {
7170
LOGGER.info("Could not retrieve PublicKey from Server - is the Server running?");
7271
return null;
@@ -149,8 +148,16 @@ private ResponseFingerprint getFingerprint(BleichenbacherWorkflowType type, byte
149148

150149
@Override
151150
public void executeAttack() {
152-
RSAPublicKey publicKey;
153-
publicKey = (RSAPublicKey) CertificateFetcher.fetchServerPublicKey(tlsConfig);
151+
// needs to execute the isVulnerable method to configure the workflow
152+
// type
153+
boolean vulnerable = isVulnerable();
154+
LOGGER.info("Using the following oracle type: {}", vulnerableType);
155+
156+
if (!vulnerable) {
157+
LOGGER.warn("The server is not vulnerable to the Bleichenbacher attack");
158+
return;
159+
}
160+
RSAPublicKey publicKey = (RSAPublicKey) CertificateFetcher.fetchServerPublicKey(tlsConfig);
154161
if (publicKey == null) {
155162
LOGGER.info("Could not retrieve PublicKey from Server - is the Server running?");
156163
return;

Attacks/src/main/java/de/rub/nds/tlsattacker/attacks/pkcs1/VectorFingerprintPair.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010

1111
import de.rub.nds.tlsattacker.attacks.util.response.ResponseFingerprint;
1212

13-
/**
14-
*
15-
* @author Robert Merget - robert.merget@rub.de
16-
*/
1713
public class VectorFingerprintPair {
1814

1915
private ResponseFingerprint fingerprint;

Attacks/src/main/java/de/rub/nds/tlsattacker/attacks/pkcs1/oracles/RealDirectMessagePkcs1Oracle.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@
88
*/
99
package de.rub.nds.tlsattacker.attacks.pkcs1.oracles;
1010

11-
import de.rub.nds.modifiablevariable.bytearray.ByteArrayModificationFactory;
12-
import de.rub.nds.modifiablevariable.bytearray.ModifiableByteArray;
1311
import de.rub.nds.tlsattacker.attacks.config.AttackConfig;
1412
import de.rub.nds.tlsattacker.attacks.pkcs1.BleichenbacherWorkflowGenerator;
1513
import de.rub.nds.tlsattacker.attacks.pkcs1.BleichenbacherWorkflowType;
@@ -18,31 +16,25 @@
1816
import de.rub.nds.tlsattacker.attacks.util.response.ResponseExtractor;
1917
import de.rub.nds.tlsattacker.attacks.util.response.ResponseFingerprint;
2018
import de.rub.nds.tlsattacker.core.config.Config;
21-
import de.rub.nds.tlsattacker.core.constants.HandshakeMessageType;
22-
import de.rub.nds.tlsattacker.core.constants.RunningModeType;
2319
import de.rub.nds.tlsattacker.core.exceptions.WorkflowExecutionException;
24-
import de.rub.nds.tlsattacker.core.protocol.message.RSAClientKeyExchangeMessage;
2520
import de.rub.nds.tlsattacker.core.state.State;
2621
import de.rub.nds.tlsattacker.core.workflow.WorkflowExecutor;
2722
import de.rub.nds.tlsattacker.core.workflow.WorkflowExecutorFactory;
2823
import de.rub.nds.tlsattacker.core.workflow.WorkflowTrace;
29-
import de.rub.nds.tlsattacker.core.workflow.WorkflowTraceUtil;
30-
import de.rub.nds.tlsattacker.core.workflow.factory.WorkflowConfigurationFactory;
31-
import de.rub.nds.tlsattacker.core.workflow.factory.WorkflowTraceType;
3224
import de.rub.nds.tlsattacker.util.MathHelper;
3325
import java.io.IOException;
3426
import java.security.PublicKey;
3527
import java.security.interfaces.RSAPublicKey;
3628

3729
public class RealDirectMessagePkcs1Oracle extends Pkcs1Oracle {
3830

39-
private AttackConfig attackConfig;
31+
private final AttackConfig attackConfig;
4032

4133
private final ResponseFingerprint validResponseContent;
4234

4335
private final ResponseFingerprint invalidResponseContent;
4436

45-
private BleichenbacherWorkflowType type;
37+
private final BleichenbacherWorkflowType type;
4638

4739
public RealDirectMessagePkcs1Oracle(PublicKey pubKey, AttackConfig config,
4840
ResponseFingerprint validResponseContent, ResponseFingerprint invalidResponseContent,
@@ -85,7 +77,7 @@ public boolean checkPKCSConformity(final byte[] msg) {
8577
}
8678

8779
} catch (WorkflowExecutionException e) {
88-
e.printStackTrace();
80+
LOGGER.debug(e.getLocalizedMessage(), e);
8981
}
9082
return conform;
9183
}
@@ -95,7 +87,7 @@ private ResponseFingerprint getFingerprint(State state) {
9587
ResponseFingerprint fingerprint = ResponseExtractor.getFingerprint(state);
9688
return fingerprint;
9789
} else {
98-
LOGGER.warn("Could not execute Workflow. Something went wrong... Check the debug output for more information");
90+
LOGGER.debug("Could not execute Workflow. Something went wrong... Check the debug output for more information");
9991
}
10092
return null;
10193
}

0 commit comments

Comments
 (0)