Skip to content

Commit

Permalink
Added getWebServiceName() method to NetworkServiceUtil.java to retrie…
Browse files Browse the repository at this point in the history
…ve the hidden service and allow scanner to brute force against it

PiperOrigin-RevId: 550923473
Change-Id: Ic80fd8edf27cb9ef88e7a289ab656af0dc008196
  • Loading branch information
Tsunami Team authored and copybara-github committed Jul 25, 2023
1 parent d8f9387 commit 573624d
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ public static String getServiceName(NetworkService networkService) {
return Ascii.toLowerCase(networkService.getServiceName());
}

public static String getWebServiceName(NetworkService networkService) {
if (isWebService(networkService)
&& networkService.getServiceContext().getWebServiceContext().hasSoftware()) {
return Ascii.toLowerCase(
networkService.getServiceContext().getWebServiceContext().getSoftware().getName());
}
return Ascii.toLowerCase(networkService.getServiceName());
}

public static NetworkService buildUriNetworkService(String uriString) {
try {
URI uri = new URI(uriString);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,34 @@ public void getServiceName_whenWebServiceWithSoftware_returnsServiceName() {
.isEqualTo("wordpress");
}

@Test
public void getWebServiceName_whenWebServiceWithSoftware_returnsWebServiceName() {
assertThat(
NetworkServiceUtils.getWebServiceName(
NetworkService.newBuilder()
.setNetworkEndpoint(forIpAndPort("127.0.0.1", 8080))
.setServiceName("http")
.setServiceContext(
ServiceContext.newBuilder()
.setWebServiceContext(
WebServiceContext.newBuilder()
.setSoftware(Software.newBuilder().setName("jenkins"))))
.build()))
.isEqualTo("jenkins");
}

@Test
public void getServiceName_whenWebServiceNoContext_returnsServiceName() {
assertThat(
NetworkServiceUtils.getWebServiceName(
NetworkService.newBuilder()
.setNetworkEndpoint(forIpAndPort("127.0.0.1", 8080))
.setServiceName("http")
.setSoftware(Software.newBuilder().setName("nothttp"))
.build()))
.isEqualTo("http");
}

@Test
public void buildWebApplicationRootUrl_whenHttpWithoutRoot_buildsExpectedUrl() {
assertThat(
Expand Down

0 comments on commit 573624d

Please sign in to comment.