我正在为我的一位客户进行“主机标头注入”攻击。问题是,使用 Burp Suite,他们捕获请求并修改 Host 标头,如下所示。该应用程序是 Java Servlet,托管在 apache(Web 服务器)+ weblogic(应用程序服务器)上 原始请求
GET /myContext/testServlet?rq=home&tenId=123456 HTTP/1.1
Host: beta.testinglab.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Run Code Online (Sandbox Code Playgroud)
修改请求
GET /myContext/testServlet?rq=home&tenId=123456 HTTP/1.1
Host: www.google.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Firefox/31.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Run Code Online (Sandbox Code Playgroud)
在服务器端,即使在修改“主机标头”之后,请求也会提交到“beta.testinglab.com”,当我在服务器上使用时,request.getRequestUrl()它会给我“www.google.com”。无论如何,有没有办法找出所请求的原始主机是什么。该请求旨在纠正主机内部重定向问题。
我无法维护预定义的主机条目列表,因为该应用程序是由很多租户定制的。
有没有其他方法可以通过更改服务器配置来修复此攻击?
我有一个测试类可以调用它TestSomething,一个测试对象可以调用它SomeObject。
现在,我在每项新的单项测试中都需要该对象,这意味着我在我的代码中有一个@BeforeEach将该对象加载到字段中:
import me.test.SomeObject;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class TestSomething {
private SomeObject someObject;
@BeforeEach
public void load() {
someObject = new SomeObject();
}
@Test
public void test1() {
boolean result = someObject.checkForSomething();
Assertions.assertEquals(true, result);
}
@Test
public void test2() {
boolean result = someObject.checkForSomethingElse();
Assertions.assertEquals(false, result);
}
Run Code Online (Sandbox Code Playgroud)
来自测试模块的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>test</artifactId>
<groupId>me.test</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<properties>
<projectVersion>1.0.0</projectVersion>
<maven.deploy.skip>false</maven.deploy.skip>
</properties>
<artifactId>Tests</artifactId>
<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId> …Run Code Online (Sandbox Code Playgroud)