Skip to content

Commit 70b3ddb

Browse files
authored
Merge pull request #42 from RUB-NDS/new_probes
New probes
2 parents b6b9227 + 894bc81 commit 70b3ddb

File tree

90 files changed

+4195
-964
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+4195
-964
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
target/
22
apps/
3+
log/
34
pom.xml.tag
45
pom.xml.releaseBackup
56
pom.xml.versionsBackup

checkstyle.xml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<!-- Checks that each Java package has a Javadoc file used for commenting. -->
4343
<!-- See http://checkstyle.sf.net/config_javadoc.html#JavadocPackage -->
4444
<module name="JavadocPackage">
45-
<property name="allowLegacy" value="true"/>
45+
<property name="allowLegacy" value="true"/>
4646
</module>
4747

4848
<!-- Checks whether files end with a new line. -->
@@ -96,15 +96,15 @@
9696
<!-- Checks for Headers -->
9797
<!-- See http://checkstyle.sf.net/config_header.html -->
9898
<!-- <module name="Header"> -->
99-
<!-- The follow property value demonstrates the ability -->
100-
<!-- to have access to ANT properties. In this case it uses -->
101-
<!-- the ${basedir} property to allow Checkstyle to be run -->
102-
<!-- from any directory within a project. See property -->
103-
<!-- expansion, -->
104-
<!-- http://checkstyle.sf.net/config.html#properties -->
105-
<!-- <property -->
106-
<!-- name="headerFile" -->
107-
<!-- value="${basedir}/java.header"/> -->
99+
<!-- The follow property value demonstrates the ability -->
100+
<!-- to have access to ANT properties. In this case it uses -->
101+
<!-- the ${basedir} property to allow Checkstyle to be run -->
102+
<!-- from any directory within a project. See property -->
103+
<!-- expansion, -->
104+
<!-- http://checkstyle.sf.net/config.html#properties -->
105+
<!-- <property -->
106+
<!-- name="headerFile" -->
107+
<!-- value="${basedir}/java.header"/> -->
108108
<!-- </module> -->
109109

110110

@@ -118,9 +118,9 @@
118118

119119
<!-- Checks for Size Violations. -->
120120
<!-- See http://checkstyle.sf.net/config_sizes.html -->
121-
<module name="LineLength">
122-
<property name="max" value="120"/>
123-
</module>
121+
<module name="LineLength">
122+
<property name="max" value="120"/>
123+
</module>
124124
<module name="MethodLength"/>
125125
<module name="ParameterNumber"/>
126126

maven-eclipse-codestyle.xml

Lines changed: 289 additions & 289 deletions
Large diffs are not rendered by default.

nbactions.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
1111
</goals>
1212
<properties>
13-
<exec.args>-classpath %classpath de.rub.nds.tlsscanner.Main -connect 127.0.0.1:4433</exec.args>
13+
<exec.args>-classpath %classpath de.rub.nds.tlsscanner.Main -connect scotthelme.co.uk -threads 20 -danger 0</exec.args>
1414
<exec.executable>java</exec.executable>
1515
</properties>
1616
</action>
@@ -24,7 +24,7 @@
2424
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
2525
</goals>
2626
<properties>
27-
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath de.rub.nds.tlsscanner.Main -connect 127.0.0.1:4433</exec.args>
27+
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath de.rub.nds.tlsscanner.Main -connect scotthelme.co.uk -threads 20 -danger 0</exec.args>
2828
<exec.executable>java</exec.executable>
2929
<jpda.listen>true</jpda.listen>
3030
</properties>
@@ -39,7 +39,7 @@
3939
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
4040
</goals>
4141
<properties>
42-
<exec.args>-classpath %classpath de.rub.nds.tlsscanner.Main -connect 127.0.0.1:4433</exec.args>
42+
<exec.args>-classpath %classpath de.rub.nds.tlsscanner.Main -connect scotthelme.co.uk -threads 20 -danger 0</exec.args>
4343
<exec.executable>java</exec.executable>
4444
</properties>
4545
</action>

pom.xml

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
<modelVersion>4.0.0</modelVersion>
44
<artifactId>TLS-Scanner</artifactId>
55
<groupId>de.rub.nds.tlsscanner</groupId>
6-
<version>2.3</version>
6+
<version>2.4</version>
77
<packaging>jar</packaging>
88
<dependencies>
99
<dependency>
1010
<groupId>de.rub.nds.tlsattacker</groupId>
1111
<artifactId>TLS-Core</artifactId>
12-
<version>2.5</version>
12+
<version>2.6</version>
1313
</dependency>
1414
<dependency>
1515
<groupId>de.rub.nds.tlsattacker</groupId>
1616
<artifactId>Attacks</artifactId>
17-
<version>2.5</version>
17+
<version>2.6</version>
1818
</dependency>
1919
<dependency>
2020
<groupId>junit</groupId>
@@ -23,6 +23,29 @@
2323
<scope>test</scope>
2424
</dependency>
2525
</dependencies>
26+
<profiles>
27+
<profile>
28+
<id>default</id>
29+
<activation>
30+
<activeByDefault>true</activeByDefault>
31+
</activation>
32+
<properties>
33+
<includegroups>de.rub.nds.tlsattacker.util.tests.SlowTests,de.rub.nds.tlsattacker.util.tests.IntegrationTests</includegroups>
34+
</properties>
35+
</profile>
36+
<profile>
37+
<id>docker-it</id>
38+
<activation>
39+
<property>
40+
<name>env</name>
41+
<value>dev</value>
42+
</property>
43+
</activation>
44+
<properties>
45+
<includegroups>de.rub.nds.tlsattacker.util.tests.SlowTests,de.rub.nds.tlsattacker.util.tests.IntegrationTests,de.rub.nds.tlsattacker.util.tests.DockerTests</includegroups>
46+
</properties>
47+
</profile>
48+
</profiles>
2649
<build>
2750
<finalName>TLS-Scanner</finalName>
2851
<plugins>
@@ -96,7 +119,23 @@
96119
<plugin>
97120
<groupId>org.apache.maven.plugins</groupId>
98121
<artifactId>maven-failsafe-plugin</artifactId>
99-
<version>2.19.1</version>
122+
<version>2.20.1</version>
123+
<configuration>
124+
<!-- By default, the Failsafe plugin excludes various files. We have to override that. -->
125+
<includes>
126+
<include>**/*.java</include>
127+
</includes>
128+
<!-- Integration tests and slow tests are started -->
129+
<groups>${includegroups}</groups>
130+
</configuration>
131+
<executions>
132+
<execution>
133+
<goals>
134+
<goal>integration-test</goal>
135+
<goal>verify</goal>
136+
</goals>
137+
</execution>
138+
</executions>
100139
</plugin>
101140
<plugin>
102141
<groupId>org.apache.maven.plugins</groupId>

src/main/java/de/rub/nds/tlsscanner/Main.java

Lines changed: 3 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,11 @@
1010

1111
import com.beust.jcommander.JCommander;
1212
import com.beust.jcommander.ParameterException;
13-
import de.rub.nds.tlsattacker.core.config.Config;
1413
import de.rub.nds.tlsattacker.core.config.delegate.GeneralDelegate;
1514
import de.rub.nds.tlsattacker.core.exceptions.ConfigurationException;
1615
import de.rub.nds.tlsscanner.config.ScannerConfig;
1716
import de.rub.nds.tlsscanner.report.SiteReport;
18-
import de.rub.nds.tlsscanner.report.SiteReportPrinter;
19-
import java.io.BufferedReader;
20-
import java.io.File;
21-
import java.io.FileNotFoundException;
22-
import java.io.FileReader;
2317
import java.io.IOException;
24-
import org.apache.logging.log4j.Level;
2518
import org.apache.logging.log4j.LogManager;
2619
import org.apache.logging.log4j.Logger;
2720

@@ -48,33 +41,16 @@ public static void main(String[] args) throws IOException {
4841
long time = System.currentTimeMillis();
4942
LOGGER.info("Performing Scan, this may take some time...");
5043
SiteReport report = scanner.scan();
51-
LOGGER.info("Scanned in:" + ((System.currentTimeMillis()-time)/1000) + "s");
52-
LOGGER.info(report.getFullReport());
44+
LOGGER.info("Scanned in:" + ((System.currentTimeMillis() - time) / 1000) + "s");
45+
LOGGER.info(report.getFullReport(config.getReportDetail()));
5346
} catch (ConfigurationException E) {
5447
LOGGER.info("Encountered a ConfigurationException aborting.");
55-
LOGGER.debug(E);
48+
LOGGER.warn(E);
5649
}
5750
} catch (ParameterException E) {
5851
LOGGER.info("Could not parse provided parameters");
5952
LOGGER.debug(E);
6053
commander.usage();
6154
}
6255
}
63-
64-
public static void scanFile(File f) throws FileNotFoundException, IOException
65-
{
66-
GeneralDelegate delegate = new GeneralDelegate();
67-
delegate.setLogLevel(Level.WARN);
68-
delegate.applyDelegate(Config.createConfig());
69-
BufferedReader reader = new BufferedReader(new FileReader(f));
70-
String line = null;
71-
line = reader.readLine();
72-
while((line = reader.readLine()) != null)
73-
{
74-
String host = line.split(",")[2];
75-
TlsScanner scanner = new TlsScanner(host,false);
76-
scanner.scan();
77-
}
78-
System.exit(0);
79-
}
8056
}
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/**
2+
* TLS-Scanner - A TLS Configuration Analysistool based on TLS-Attacker
3+
*
4+
* Copyright 2014-2017 Ruhr University Bochum / Hackmanit GmbH
5+
*
6+
* Licensed under Apache License 2.0
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*/
9+
package de.rub.nds.tlsscanner;
10+
11+
import de.rub.nds.tlsattacker.core.workflow.NamedThreadFactory;
12+
import de.rub.nds.tlsattacker.core.config.delegate.ClientDelegate;
13+
import de.rub.nds.tlsscanner.config.ScannerConfig;
14+
import de.rub.nds.tlsscanner.constants.ProbeType;
15+
import de.rub.nds.tlsscanner.report.result.ProbeResult;
16+
import de.rub.nds.tlsscanner.report.SiteReport;
17+
import de.rub.nds.tlsscanner.probe.TlsProbe;
18+
import de.rub.nds.tlsscanner.report.after.AfterProbe;
19+
import java.util.LinkedList;
20+
import java.util.List;
21+
import java.util.concurrent.ExecutionException;
22+
import java.util.concurrent.ExecutorService;
23+
import java.util.concurrent.Executors;
24+
import java.util.concurrent.Future;
25+
import org.apache.logging.log4j.LogManager;
26+
import org.apache.logging.log4j.Logger;
27+
28+
/**
29+
*
30+
* @author Robert Merget - [email protected]
31+
*/
32+
public class MultiThreadedScanJobExecutor extends ScanJobExecutor {
33+
34+
private static final Logger LOGGER = LogManager.getLogger(MultiThreadedScanJobExecutor.class.getName());
35+
36+
private final ExecutorService executor;
37+
38+
public MultiThreadedScanJobExecutor(int threadCount, String prefix) {
39+
executor = Executors.newFixedThreadPool(threadCount, new NamedThreadFactory(prefix));
40+
}
41+
42+
public MultiThreadedScanJobExecutor(ExecutorService executor) {
43+
this.executor = executor;
44+
}
45+
46+
public SiteReport execute(ScannerConfig config, ScanJob scanJob) {
47+
List<ProbeType> probeTypes = new LinkedList<>();
48+
49+
List<Future<ProbeResult>> futureResults = new LinkedList<>();
50+
for (TlsProbe probe : scanJob.getPhaseOneTestList()) {
51+
if (probe.getDanger() <= config.getDangerLevel()) {
52+
futureResults.add(executor.submit(probe));
53+
probeTypes.add(probe.getType());
54+
}
55+
}
56+
List<ProbeResult> resultList = new LinkedList<>();
57+
for (Future<ProbeResult> probeResult : futureResults) {
58+
try {
59+
resultList.add(probeResult.get());
60+
} catch (InterruptedException | ExecutionException ex) {
61+
LOGGER.warn("Encoutered Exception while retrieving probeResult");
62+
ex.printStackTrace();
63+
LOGGER.warn(ex);
64+
}
65+
}
66+
67+
ClientDelegate clientDelegate = (ClientDelegate) config.getDelegate(ClientDelegate.class);
68+
String hostname = clientDelegate.getHost();
69+
SiteReport report = new SiteReport(hostname, probeTypes, config.isNoColor());
70+
report.setServerIsAlive(Boolean.TRUE);
71+
for (ProbeResult result : resultList) {
72+
result.merge(report);
73+
}
74+
//Finished phase one starting phase 2
75+
//Now all basic tests are merged into the site report, so we launch phase 2 so the scanner
76+
//has access to basic server configuration
77+
for (TlsProbe probe : scanJob.getPhaseTwoTestList()) {
78+
probe.adjustConfig(report);
79+
}
80+
futureResults = new LinkedList<>();
81+
resultList = new LinkedList<>();
82+
for (TlsProbe probe : scanJob.getPhaseTwoTestList()) {
83+
if (probe.getDanger() <= config.getDangerLevel()) {
84+
probeTypes.add(probe.getType());
85+
if (probe.shouldBeExecuted(report)) {
86+
futureResults.add(executor.submit(probe));
87+
} else if (!config.isImplementation()) {
88+
ProbeResult result = probe.getNotExecutedResult();
89+
if (result != null) {
90+
resultList.add(result);
91+
}
92+
}
93+
}
94+
}
95+
for (Future<ProbeResult> probeResult : futureResults) {
96+
try {
97+
resultList.add(probeResult.get());
98+
} catch (InterruptedException | ExecutionException ex) {
99+
LOGGER.warn("Encoutered Exception while retrieving probeResult");
100+
ex.printStackTrace();
101+
LOGGER.warn(ex);
102+
}
103+
}
104+
// mergeData phase 2
105+
for (ProbeResult result : resultList) {
106+
result.merge(report);
107+
}
108+
//phase 3 - afterprobes
109+
for (AfterProbe afterProbe : scanJob.getAfterProbes()) {
110+
afterProbe.analyze(report);
111+
}
112+
return report;
113+
}
114+
115+
@Override
116+
public void shutdown() {
117+
executor.shutdown();
118+
}
119+
}

src/main/java/de/rub/nds/tlsscanner/ScanJob.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111
import de.rub.nds.tlsscanner.probe.TlsProbe;
1212
import de.rub.nds.tlsscanner.report.after.AfterProbe;
13-
import java.util.LinkedList;
1413
import java.util.List;
1514

1615
/**

0 commit comments

Comments
 (0)