Jmeter:IP 欺骗不起作用 [英] Jmeter: IP spoofing not working

查看:24
本文介绍了Jmeter:IP 欺骗不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要测试 IP 欺骗,我遵循以下步骤:

  1. 打开 CMD 并执行 nslookup www.xyz.com.asdfg-staging.net
  2. 这会给出IP地址,在hosts文件的底部添加这个IP地址.这里C:WindowsSystem32driversetc
  3. 打开 Jmeter 并在 Http Sample 中添加此 IP,如下所示:

如链接中所述 如何在 jmeter 中设置 IP 欺骗?使用多个 ip 地址发送请求到我的应用程序使用 apache-JMeter(IP 欺骗)4. 运行测试,我只在 View Results Tree 监听器中看到红色错误,但我没有遵循第 3 步,那么只有绿色.

我期望的是欺骗 IP",即我在主机文件中添加的 IP 地址应该出现在 View Results Tree 侦听器的 Request 选项卡中.

我在这里做错了什么?上面分享的教程还要求编辑 IPv4 属性,这真的是实现我想要的东西的必要条件吗?

解决方案

IP 欺骗是针对客户端地址进行的.在您的屏幕截图中,您试图在 HOST 标头中找到欺骗 IP 的值,该值通常指向实际的服务器主机名,而不是 IP.

未在 IPv4 字段中分配值的场景 1,针对 myhost.test.com 进行了测试

请求头:连接:关闭内容类型:应用程序/json内容长度:162主机:myhost.test.com用户代理:Apache-HttpClient/4.5.2 (Java/1.8.0_111)

源地址字段设置为 10.1.153.90 的场景 2

请求头:连接:关闭内容类型:应用程序/json内容长度:162主机:myhost.test.com用户代理:Apache-HttpClient/4.5.2 (Java/1.8.0_111)**X-本地地址:/10.1.153.90**

在我看来,您似乎试图将您的服务器 IP 欺骗为服务提供商提供的特定 IP,以便您只使用 Akamai 登台环境那样的 IP.在这种情况下,使用为服务器(而不是客户端)分配的 IP 设置 C:WindowsSystem32driversetchosts 文件将在 JMeter 之外工作,并由操作系统(而不是 JMeter)处理.

1.54.163.146 myhost.test.com

在操作系统级别,您的操作系统将负责将针对 myhost.test.com 的请求发送到您在上面在 C:WindowsSystem32driversetchosts 文件中提供的 IP

要查看实际 IP 地址,请添加预处理器(beanshell 或等效程序)并添加以下行

import java.net.InetAddress;InetAddress 地址 = InetAddress.getByName("myhost.test.com");log.info("Address=" + address.getHostAddress());

如果你想测量这个IP地址所花费的请求时间,你可以把它放在一个变量中并将它添加到你的采样器名称中

import java.net.InetAddress;InetAddress 地址 = InetAddress.getByName("myhost.test.com");log.info("Address=" + address.getHostAddress());vars.put("addressused", address.getHostAddress());

然后将 ${addressused} 附加到您的采样器名称.它将根据samplername+ipaddress 来衡量交易

To test IP Spoofing I am following below steps:

  1. Open CMD and do nslookup www.xyz.com.asdfg-staging.net
  2. This will give the IP address , add this IP address at the bottom of hosts file.Here C:WindowsSystem32driversetc
  3. Open Jmeter and add this IP in Http Sample as shown below:

As instrcuted in links How to setup IP spoofing in jmeter? and send requests with multiple ip address to my application using apache-JMeter(IP Spoofing) 4. Run the tests and I only see red errors in View Results Tree listener but I do not follows step #3 then there are only greens.

What I am expecting is "spoofed IP" i.e. the IP adress that I added in host file should be present in Request tab of View Results Tree listener.

What am I doing wrong here? The tutorials that shared above also asked to edit IPv4 properties , is that really mandatory to achieve what I am looking for?

解决方案

IP Spoofing is done for the client side addresses. In your screenshot, you are trying to find the value of the spoofed IP in the HOST header which usually points to the actual server hostname and not the IP.

Scenario 1 with no values assigned in IPv4 field with test done against myhost.test.com

Request Headers:
Connection: close
Content-Type: application/json
Content-Length: 162
Host: myhost.test.com
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_111)

Scenario 2 with Source Address field set to 10.1.153.90

Request Headers:
Connection: close
Content-Type: application/json
Content-Length: 162
Host: myhost.test.com
User-Agent: Apache-HttpClient/4.5.2 (Java/1.8.0_111)
**X-LocalAddress: /10.1.153.90**

To me, it looks like you are trying to spoof your server IP to a specific IP provided by the service provider so that you hit only that like Akamai staging environment. In that case, setting your C:WindowsSystem32driversetchosts file with the assigned IP for your server (not the client) will work outside JMeter and is handled by the OS (not JMeter).

1.54.163.146 myhost.test.com

At the OS level, your OS will take care of sending requests addressed for myhost.test.com to the IP that you gave above in C:WindowsSystem32driversetchosts file

To see the actual IP address, add a pre-processor (beanshell or equivalent) and add the below lines

import java.net.InetAddress;

InetAddress address = InetAddress.getByName("myhost.test.com"); 
log.info("Address=" + address.getHostAddress()); 

If you want to measure your request time taken by this IP addresses, you can put it in a variable and add that in your sampler name

import java.net.InetAddress;

InetAddress address = InetAddress.getByName("myhost.test.com"); 
log.info("Address=" + address.getHostAddress()); 
vars.put("addressused",  address.getHostAddress()); 

Then append ${addressused} to your samplername. It will measure the transaction based on samplername+ipaddress

这篇关于Jmeter:IP 欺骗不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆