-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathMain.java
More file actions
72 lines (68 loc) · 3.27 KB
/
Main.java
File metadata and controls
72 lines (68 loc) · 3.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* TLS-Scanner - A TLS configuration and analysis tool based on TLS-Attacker
*
* Copyright 2017-2023 Ruhr University Bochum, Paderborn University, Technology Innovation Institute, and Hackmanit GmbH
*
* Licensed under Apache License, Version 2.0
* http://www.apache.org/licenses/LICENSE-2.0.txt
*/
package de.rub.nds.tlsscanner.serverscanner;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.ParameterException;
import de.rub.nds.scanner.core.report.AnsiColor;
import de.rub.nds.tlsattacker.core.config.delegate.GeneralDelegate;
import de.rub.nds.tlsattacker.core.exceptions.ConfigurationException;
import de.rub.nds.tlsscanner.core.report.DefaultPrintingScheme;
import de.rub.nds.tlsscanner.serverscanner.config.ServerScannerConfig;
import de.rub.nds.tlsscanner.serverscanner.execution.TlsServerScanner;
import de.rub.nds.tlsscanner.serverscanner.report.ServerReport;
import de.rub.nds.tlsscanner.serverscanner.report.ServerReportPrinter;
import java.io.IOException;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
public class Main {
private static final Logger LOGGER = LogManager.getLogger();
public static void main(String[] args) throws IOException {
ServerScannerConfig config = new ServerScannerConfig(new GeneralDelegate());
JCommander commander = new JCommander(config);
try {
commander.parse(args);
if (config.getGeneralDelegate().isHelp()) {
commander.usage();
return;
}
// Cmd was parsable
try (TlsServerScanner scanner = new TlsServerScanner(config)) {
long time = System.currentTimeMillis();
LOGGER.info("Performing Scan, this may take some time...");
ServerReport report = scanner.scan();
LOGGER.info(
AnsiColor.RESET.getCode()
+ "Scanned in: "
+ ((System.currentTimeMillis() - time) / 1000)
+ "s\n"
+ new ServerReportPrinter(
report,
config.getExecutorConfig().getReportDetail(),
DefaultPrintingScheme.getDefaultPrintingScheme(),
!config.getExecutorConfig().isNoColor())
.getFullReport());
} catch (ConfigurationException e) {
LOGGER.error("Encountered a ConfigurationException aborting.", e);
} catch (RuntimeException e) {
if (e.getCause()
instanceof
de.rub.nds.tlsattacker.core.exceptions.TransportHandlerConnectException) {
LOGGER.error(
"Scanner terminated due to connection failure: {}",
e.getCause().getMessage());
} else {
LOGGER.error("Scanner terminated unexpectedly", e);
}
}
} catch (ParameterException e) {
LOGGER.error("Could not parse provided parameters", e);
commander.usage();
}
}
}