Skip to content

Commit a0e97ff

Browse files
Heartbleed attack, better logging
1 parent 0b6a4ae commit a0e97ff

File tree

1 file changed

+28
-17
lines changed

1 file changed

+28
-17
lines changed

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

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
11
/**
22
* TLS-Attacker - A Modular Penetration Testing Framework for TLS.
33
*
4-
* Copyright (C) 2015 Chair for Network and Data Security,
5-
* Ruhr University Bochum
6-
* (juraj.somorovsky@rub.de)
4+
* Copyright (C) 2015 Chair for Network and Data Security, Ruhr University
5+
* Bochum (juraj.somorovsky@rub.de)
76
*
8-
* Licensed under the Apache License, Version 2.0 (the "License");
9-
* you may not use this file except in compliance with the License.
10-
* You may obtain a copy of the License at
7+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
8+
* use this file except in compliance with the License. You may obtain a copy of
9+
* the License at
1110
*
1211
* http://www.apache.org/licenses/LICENSE-2.0
1312
*
1413
* Unless required by applicable law or agreed to in writing, software
15-
* distributed under the License is distributed on an "AS IS" BASIS,
16-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17-
* See the License for the specific language governing permissions and
18-
* limitations under the License.
14+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
15+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
16+
* License for the specific language governing permissions and limitations under
17+
* the License.
1918
*/
2019
package de.rub.nds.tlsattacker.attacks.impl;
2120

@@ -30,6 +29,7 @@
3029
import de.rub.nds.tlsattacker.tls.constants.ConnectionEnd;
3130
import de.rub.nds.tlsattacker.tls.protocol.heartbeat.HeartbeatMessage;
3231
import de.rub.nds.tlsattacker.tls.constants.ProtocolMessageType;
32+
import de.rub.nds.tlsattacker.tls.exceptions.WorkflowExecutionException;
3333
import de.rub.nds.tlsattacker.tls.util.LogLevel;
3434
import de.rub.nds.tlsattacker.tls.workflow.TlsContext;
3535
import de.rub.nds.tlsattacker.tls.workflow.WorkflowExecutor;
@@ -70,16 +70,27 @@ public void executeAttack(ConfigHandler configHandler) {
7070
hb.setPayload(payload);
7171
hb.setPayloadLength(payloadLength);
7272

73-
workflowExecutor.executeWorkflow();
73+
try {
74+
workflowExecutor.executeWorkflow();
75+
} catch (WorkflowExecutionException ex) {
76+
LOGGER.info(
77+
"The TLS protocol flow was not executed completely, follow the debug messages for more information.",
78+
ex);
79+
}
7480

75-
HeartbeatMessage lastMessage = (HeartbeatMessage) trace.getProtocolMessages().get(
76-
trace.getProtocolMessages().size() - 1);
77-
if (lastMessage.getMessageIssuer() == ConnectionEnd.SERVER) {
78-
LOGGER.log(LogLevel.CONSOLE_OUTPUT,
79-
"The server responds with a heartbeat message, although the client heartbeat message contains an invalid ");
81+
if (trace.containsServerFinished()) {
82+
HeartbeatMessage lastMessage = (HeartbeatMessage) trace.getProtocolMessages().get(
83+
trace.getProtocolMessages().size() - 1);
84+
if (lastMessage.getMessageIssuer() == ConnectionEnd.SERVER) {
85+
LOGGER.log(LogLevel.CONSOLE_OUTPUT,
86+
"Vulnerable. The server responds with a heartbeat message, although the client heartbeat message contains an invalid ");
87+
} else {
88+
LOGGER.log(LogLevel.CONSOLE_OUTPUT,
89+
"(Most probably) Not vulnerable. The server does not respond with a heartbeat message, it is not vulnerable");
90+
}
8091
} else {
8192
LOGGER.log(LogLevel.CONSOLE_OUTPUT,
82-
"The server does not respond with a heartbeat message, it is not vulnerable");
93+
"Correct TLS handshake cannot be executed, no Server Finished message found. Check the server configuration.");
8394
}
8495

8596
tlsContexts.add(tlsContext);

0 commit comments

Comments
 (0)