de.rub.nds.tlsattacker.attacks.config.HeartbleedCommandConfig Maven / Gradle / Ivy
/**
* TLS-Attacker - A Modular Penetration Testing Framework for TLS
*
* Copyright 2014-2021 Ruhr University Bochum, Paderborn University, Hackmanit GmbH
*
* Licensed under Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0.txt
*/
package de.rub.nds.tlsattacker.attacks.config;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParametersDelegate;
import de.rub.nds.tlsattacker.core.config.Config;
import de.rub.nds.tlsattacker.core.config.delegate.CipherSuiteDelegate;
import de.rub.nds.tlsattacker.core.config.delegate.ClientDelegate;
import de.rub.nds.tlsattacker.core.config.delegate.GeneralDelegate;
import de.rub.nds.tlsattacker.core.config.delegate.ProtocolVersionDelegate;
import de.rub.nds.tlsattacker.core.config.delegate.StarttlsDelegate;
import de.rub.nds.tlsattacker.core.constants.AlgorithmResolver;
import de.rub.nds.tlsattacker.core.constants.CipherSuite;
import de.rub.nds.tlsattacker.core.constants.HeartbeatMode;
import de.rub.nds.tlsattacker.core.constants.KeyExchangeAlgorithm;
/**
*
*/
public class HeartbleedCommandConfig extends AttackConfig {
/**
*
*/
public static final String ATTACK_COMMAND = "heartbleed";
@Parameter(names = "-payload_length", description = "Payload length sent in the client heartbeat message")
private Integer payloadLength = 20000;
@ParametersDelegate
private ClientDelegate clientDelegate;
@ParametersDelegate
private CipherSuiteDelegate ciphersuiteDelegate;
@ParametersDelegate
private ProtocolVersionDelegate protocolVersionDelegate;
@ParametersDelegate
private StarttlsDelegate starttlsDelegate;
/**
*
* @param delegate
*/
public HeartbleedCommandConfig(GeneralDelegate delegate) {
super(delegate);
clientDelegate = new ClientDelegate();
ciphersuiteDelegate = new CipherSuiteDelegate();
protocolVersionDelegate = new ProtocolVersionDelegate();
starttlsDelegate = new StarttlsDelegate();
addDelegate(clientDelegate);
addDelegate(ciphersuiteDelegate);
addDelegate(protocolVersionDelegate);
addDelegate(starttlsDelegate);
}
/**
*
* @return
*/
public Integer getPayloadLength() {
return payloadLength;
}
/**
*
* @param payloadLength
*/
public void setPayloadLength(Integer payloadLength) {
this.payloadLength = payloadLength;
}
/**
*
* @return
*/
@Override
public boolean isExecuteAttack() {
return false;
}
/**
*
* @return
*/
@Override
public Config createConfig() {
Config config = super.createConfig();
config.setAddHeartbeatExtension(true);
config.setHeartbeatMode(HeartbeatMode.PEER_ALLOWED_TO_SEND);
config.setAddRenegotiationInfoExtension(true);
config.setAddServerNameIndicationExtension(true);
config.setAddSignatureAndHashAlgorithmsExtension(true);
config.setQuickReceive(true);
config.setStopActionsAfterFatal(true);
config.setStopReceivingAfterFatal(true);
config.setEarlyStop(true);
boolean containsEc = false;
for (CipherSuite suite : config.getDefaultClientSupportedCipherSuites()) {
KeyExchangeAlgorithm keyExchangeAlgorithm = AlgorithmResolver.getKeyExchangeAlgorithm(suite);
if (keyExchangeAlgorithm != null && keyExchangeAlgorithm.name().toUpperCase().contains("EC")) {
containsEc = true;
break;
}
}
config.setAddECPointFormatExtension(containsEc);
config.setAddEllipticCurveExtension(containsEc);
return config;
}
}