Skip to content

Commit e4e30f8

Browse files
Tsunami Teamcopybara-github
authored andcommitted
Support overriding User-Agent in Tsunami scans
PiperOrigin-RevId: 629314902 Change-Id: I890db7a29024824b4d298b4397b4a89397c87038
1 parent 08ee18d commit e4e30f8

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

google/fingerprinters/web/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,12 @@ task runFingerprintFileConverter(type: JavaExec) {
122122
classpath = sourceSets.main.runtimeClasspath
123123
mainClass = 'com.google.tsunami.plugins.fingerprinters.web.tools.FingerprintFileConverter'
124124
}
125+
126+
// Force the JRE flavor of Guava for tasks that don't advertise themselves as targeting the JRE.
127+
// https://github.com/google/guava/releases/tag/v32.1.0
128+
// https://github.com/square/okio/issues/647
129+
configurations.all { configuration ->
130+
if (name == "compileClasspath" || name == "runtimeClasspath" || name == "compileProtoPath" || name == "testCompileProtoPath" || name == "testCompileClasspath" || name == "testRuntimeClasspath") {
131+
attributes.attribute(Attribute.of("org.gradle.jvm.environment", String), "standard-jvm")
132+
}
133+
}

google/portscan/nmap/src/main/java/com/google/tsunami/plugins/portscan/nmap/NmapPortScanner.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import com.google.tsunami.common.command.CommandExecutionThreadPool;
2828
import com.google.tsunami.common.data.NetworkEndpointUtils;
2929
import com.google.tsunami.common.data.NetworkServiceUtils;
30+
import com.google.tsunami.common.net.http.HttpClientCliOptions;
3031
import com.google.tsunami.plugin.PluginType;
3132
import com.google.tsunami.plugin.PortScanner;
3233
import com.google.tsunami.plugin.annotations.PluginInfo;
@@ -79,6 +80,7 @@ public final class NmapPortScanner implements PortScanner {
7980
private final Executor commandExecutor;
8081
private final NmapPortScannerConfigs configs;
8182
private final NmapPortScannerCliOptions cliOptions;
83+
private final HttpClientCliOptions httpClientCliOptions;
8284

8385
private ScanTarget scanTarget;
8486

@@ -87,11 +89,13 @@ public final class NmapPortScanner implements PortScanner {
8789
NmapClient nmapClient,
8890
@CommandExecutionThreadPool Executor commandExecutor,
8991
NmapPortScannerConfigs configs,
90-
NmapPortScannerCliOptions cliOptions) {
92+
NmapPortScannerCliOptions cliOptions,
93+
HttpClientCliOptions httpClientCliOptions) {
9194
this.nmapClient = checkNotNull(nmapClient);
9295
this.commandExecutor = checkNotNull(commandExecutor);
9396
this.configs = checkNotNull(configs);
9497
this.cliOptions = checkNotNull(cliOptions);
98+
this.httpClientCliOptions = checkNotNull(httpClientCliOptions);
9599
}
96100

97101
@Override
@@ -110,7 +114,7 @@ public PortScanningReport scan(ScanTarget scanTarget) {
110114
.withVersionDetectionIntensity(5)
111115
.withScript("banner")
112116
.withScript("ssl-enum-ciphers")
113-
.withScript("http-methods", "http.useragent=TsunamiSecurityScanner")
117+
.withScript("http-methods", "http.useragent=" + httpClientCliOptions.userAgent)
114118
.withTimingTemplate(TimingTemplate.AGGRESSIVE)
115119
.withTargetNetworkEndpoint(scanTarget.getNetworkEndpoint())
116120
.run(commandExecutor);

0 commit comments

Comments
 (0)