Skip to content

Commit 47d5f45

Browse files
authored
Merge pull request #48 from RUB-NDS/bbrework
BB and Padding Oracle Rework Changes
2 parents 41ae831 + 2093337 commit 47d5f45

Some content is hidden

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

60 files changed

+2187
-434
lines changed

nbactions.xml

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<actions>
3-
<action>
4-
<actionName>run</actionName>
5-
<packagings>
6-
<packaging>jar</packaging>
7-
</packagings>
8-
<goals>
9-
<goal>process-classes</goal>
10-
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
11-
</goals>
12-
<properties>
13-
<exec.args>-classpath %classpath de.rub.nds.tlsscanner.Main -connect scotthelme.co.uk -threads 20 -danger 0</exec.args>
14-
<exec.executable>java</exec.executable>
15-
</properties>
16-
</action>
17-
<action>
18-
<actionName>debug</actionName>
19-
<packagings>
20-
<packaging>jar</packaging>
21-
</packagings>
22-
<goals>
23-
<goal>process-classes</goal>
24-
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
25-
</goals>
26-
<properties>
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>
28-
<exec.executable>java</exec.executable>
29-
<jpda.listen>true</jpda.listen>
30-
</properties>
31-
</action>
32-
<action>
33-
<actionName>profile</actionName>
34-
<packagings>
35-
<packaging>jar</packaging>
36-
</packagings>
37-
<goals>
38-
<goal>process-classes</goal>
39-
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
40-
</goals>
41-
<properties>
42-
<exec.args>-classpath %classpath de.rub.nds.tlsscanner.Main -connect scotthelme.co.uk -threads 20 -danger 0</exec.args>
43-
<exec.executable>java</exec.executable>
44-
</properties>
45-
</action>
46-
</actions>
3+
<action>
4+
<actionName>run</actionName>
5+
<packagings>
6+
<packaging>jar</packaging>
7+
</packagings>
8+
<goals>
9+
<goal>process-classes</goal>
10+
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
11+
</goals>
12+
<properties>
13+
<exec.args>-classpath %classpath de.rub.nds.tlsscanner.Main -connect localhost -threads 20 -danger 0</exec.args>
14+
<exec.executable>java</exec.executable>
15+
</properties>
16+
</action>
17+
<action>
18+
<actionName>debug</actionName>
19+
<packagings>
20+
<packaging>jar</packaging>
21+
</packagings>
22+
<goals>
23+
<goal>process-classes</goal>
24+
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
25+
</goals>
26+
<properties>
27+
<exec.args>-Xdebug -Xrunjdwp:transport=dt_socket,server=n,address=${jpda.address} -classpath %classpath de.rub.nds.tlsscanner.Main -connect localhost -threads 20 -danger 0</exec.args>
28+
<exec.executable>java</exec.executable>
29+
<jpda.listen>true</jpda.listen>
30+
</properties>
31+
</action>
32+
<action>
33+
<actionName>profile</actionName>
34+
<packagings>
35+
<packaging>jar</packaging>
36+
</packagings>
37+
<goals>
38+
<goal>process-classes</goal>
39+
<goal>org.codehaus.mojo:exec-maven-plugin:1.2.1:exec</goal>
40+
</goals>
41+
<properties>
42+
<exec.args>-classpath %classpath de.rub.nds.tlsscanner.Main -connect localhost -threads 20 -danger 0</exec.args>
43+
<exec.executable>java</exec.executable>
44+
</properties>
45+
</action>
46+
</actions>

pom.xml

Lines changed: 8 additions & 3 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.4</version>
6+
<version>2.5</version>
77
<packaging>jar</packaging>
88
<dependencies>
99
<dependency>
1010
<groupId>de.rub.nds.tlsattacker</groupId>
1111
<artifactId>TLS-Core</artifactId>
12-
<version>2.6</version>
12+
<version>2.7</version>
1313
</dependency>
1414
<dependency>
1515
<groupId>de.rub.nds.tlsattacker</groupId>
1616
<artifactId>Attacks</artifactId>
17-
<version>2.6</version>
17+
<version>2.7</version>
1818
</dependency>
1919
<dependency>
2020
<groupId>junit</groupId>
@@ -27,6 +27,11 @@
2727
<artifactId>progressbar</artifactId>
2828
<version>0.7.1</version>
2929
</dependency>
30+
<dependency>
31+
<groupId>com.googlecode.json-simple</groupId>
32+
<artifactId>json-simple</artifactId>
33+
<version>1.1.1</version>
34+
</dependency>
3035
</dependencies>
3136
<profiles>
3237
<profile>

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
* @author robert
1717
*/
1818
public class ConsoleLogger {
19+
1920
public static final Logger CONSOLE = LogManager.getLogger("ConsoleLogger");
2021

2122
private ConsoleLogger() {

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import java.io.IOException;
1919
import org.apache.logging.log4j.LogManager;
2020
import org.apache.logging.log4j.Logger;
21+
import org.apache.logging.log4j.ThreadContext;
2122

2223
/**
2324
*
@@ -38,23 +39,24 @@ public static void main(String[] args) throws IOException {
3839
}
3940
// Cmd was parsable
4041
try {
42+
if (config.getGeneralDelegate().isDebug()) {
43+
ThreadContext.put("ROUTINGKEY", "special");
44+
}
4145
TlsScanner scanner = new TlsScanner(config);
4246
long time = System.currentTimeMillis();
4347
LOGGER.info("Performing Scan, this may take some time...");
4448
SiteReport report = scanner.scan();
45-
LOGGER.info("Scanned in:" + ((System.currentTimeMillis()-time)/1000) + "s\n");
46-
if(!config.getGeneralDelegate().isDebug()){
49+
LOGGER.info("Scanned in:" + ((System.currentTimeMillis() - time) / 1000) + "s\n");
50+
if (!config.getGeneralDelegate().isDebug()) {
4751
// ANSI escape sequences to erase the progressbar
4852
ConsoleLogger.CONSOLE.info(AnsiEscapeSequence.ANSI_ONE_LINE_UP + AnsiEscapeSequence.ANSI_ERASE_LINE);
4953
}
50-
ConsoleLogger.CONSOLE.info("Scanned in: " + ((System.currentTimeMillis()-time)/1000) + "s\n" + report.getFullReport(config.getReportDetail()));
54+
ConsoleLogger.CONSOLE.info("Scanned in: " + ((System.currentTimeMillis() - time) / 1000) + "s\n" + report.getFullReport(config.getReportDetail()));
5155
} catch (ConfigurationException E) {
52-
LOGGER.info("Encountered a ConfigurationException aborting.");
53-
LOGGER.warn(E);
56+
LOGGER.error("Encountered a ConfigurationException aborting.", E);
5457
}
5558
} catch (ParameterException E) {
56-
LOGGER.info("Could not parse provided parameters");
57-
LOGGER.debug(E);
59+
LOGGER.error("Could not parse provided parameters", E);
5860
commander.usage();
5961
}
6062
}

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

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import de.rub.nds.tlsscanner.report.result.ProbeResult;
1616
import de.rub.nds.tlsscanner.report.SiteReport;
1717
import de.rub.nds.tlsscanner.probe.TlsProbe;
18+
import de.rub.nds.tlsscanner.probe.stats.ExtractedValueContainer;
1819
import de.rub.nds.tlsscanner.report.after.AfterProbe;
1920
import java.util.LinkedList;
2021
import java.util.List;
@@ -86,9 +87,7 @@ private SiteReport scan(ScannerConfig config, ScanJob scanJob, ProgressBar pb) {
8687
try {
8788
resultList.add(probeResult.get());
8889
} catch (InterruptedException | ExecutionException ex) {
89-
LOGGER.warn("Encoutered Exception while retrieving probeResult");
90-
ex.printStackTrace();
91-
LOGGER.warn(ex);
90+
LOGGER.error("Encoutered Exception while retrieving probeResult", ex);
9291
}
9392
}
9493

@@ -130,20 +129,39 @@ private SiteReport scan(ScannerConfig config, ScanJob scanJob, ProgressBar pb) {
130129
try {
131130
resultList.add(probeResult.get());
132131
} catch (InterruptedException | ExecutionException ex) {
133-
LOGGER.warn("Encoutered Exception while retrieving probeResult");
134-
ex.printStackTrace();
135-
LOGGER.warn(ex);
132+
LOGGER.error("Encoutered Exception while retrieving probeResult", ex);
136133
}
137134
}
138135
// mergeData phase 2
139136
for (ProbeResult result : resultList) {
140137
result.merge(report);
141138
}
142-
//phase 3 - afterprobes
139+
//phase 3 - collect statistics
140+
List<TlsProbe> allProbes = scanJob.getJoinedProbes();
141+
List<ExtractedValueContainer> globalContainerList = new LinkedList<>();
142+
for (TlsProbe probe : allProbes) {
143+
List<ExtractedValueContainer> tempContainerList = probe.getWriter().getCumulatedExtractedValues();
144+
for (ExtractedValueContainer tempContainer : tempContainerList) {
145+
//Try to find the original container , if it not found add it
146+
ExtractedValueContainer targetContainer = null;
147+
for (ExtractedValueContainer globalContainer : globalContainerList) {
148+
if (tempContainer.getType() == globalContainer.getType()) {
149+
targetContainer = globalContainer;
150+
break;
151+
}
152+
}
153+
if (targetContainer == null) {
154+
targetContainer = new ExtractedValueContainer(tempContainer.getType());
155+
globalContainerList.add(targetContainer);
156+
}
157+
targetContainer.getExtractedValueList().addAll(tempContainer.getExtractedValueList());
158+
}
159+
}
160+
report.setExtractedValueContainerList(globalContainerList);
161+
//phase 4 - afterprobes
143162
for (AfterProbe afterProbe : scanJob.getAfterProbes()) {
144163
afterProbe.analyze(report);
145164
}
146-
executor.shutdown();
147165
LOGGER.info("Finished scan for: " + hostname);
148166
return report;
149167
}
@@ -152,7 +170,7 @@ private void checkProbesDone(List<Future<ProbeResult>> futureResults, ProgressBa
152170
boolean isNotReady = true;
153171
int done = 0;
154172
int tempDone = 0;
155-
while (isNotReady) {
173+
while (isNotReady && futureResults.size() > 0) {
156174
tempDone = 0;
157175
for (Future<ProbeResult> probeResult : futureResults) {
158176
if (probeResult.isDone()) {

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

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

1111
import de.rub.nds.tlsscanner.probe.TlsProbe;
1212
import de.rub.nds.tlsscanner.report.after.AfterProbe;
13+
import java.util.LinkedList;
1314
import java.util.List;
1415

1516
/**
@@ -39,4 +40,11 @@ public List<TlsProbe> getPhaseTwoTestList() {
3940
public List<AfterProbe> getAfterProbes() {
4041
return afterList;
4142
}
43+
44+
public List<TlsProbe> getJoinedProbes() {
45+
List<TlsProbe> probeList = new LinkedList<>();
46+
probeList.addAll(phaseOneTestList);
47+
probeList.addAll(phaseTwoTestList);
48+
return probeList;
49+
}
4250
}

0 commit comments

Comments
 (0)