LoadRunner IP address binding to vuser - load-testing

After last system update it require unique ip address authentication for each user. After some googling I find IP wizard and info about IP Spoffing. Right now LR offers a function, that set random ip address to vuser for each script run.
Here is a question:
How to set static ip address to vuser by its login to the system?
Like I have a pool that contains ip address and login and when vuser login to system it already have binded ip from pool.

By using the below functions you can get and set the IP address of the specific VUser. This could be done in vuser_init() or beginning of 1st action in script.
char *lr_get_vuser_ip( );
The lr_get_vuser_ip function returns the IPv4 address of a Vuser. When performing IP spoofing, each Vuser can use a different address. This function allows you to determine the current Vuser's IP address.
If the IP was set with the web_set_sockets_option function using the IP_ADDRESS_BY_INDEX option, lr_get_vuser_ip returns that IP.
To get an IPv6 address, use lr_get_attrib_string("ipv6")
Return Values
If this function succeeds , it returns a pointer to a string holding the IP address of the Vuser. If it fails, or if working with multiple IP addresses is disabled, it returns NULL.
and
int web_set_sockets_option( const char *option, const char *value );
Return Values
This function returns LR_PASS (0) on success, and LR_FAIL (1) on failure.
Example
The web_set_sockets() function can be used like this:
// Set current VUser IP address to 10.0.0.1
web_set_sockets_option("USER_IP_ADDRESS", "10.0.0.1");

Related

Can I uniquely identify a client machine in an ASP.NET application

Is there a way to uniquely identify a user that has logged on my application based on his device/machine ?
In a lot of cases, the IP is enough, but in case when the client has multiple machines behind a NAT, then the same IP is exposed, so I can't tell them apart. it should have same id irrespective of browser.
for e.g. If the user logs in on his account with computer A, then log in on the same account with computer B that share the same router, I need to get id apart those two devices.
I don't know if this is possible, but it would be life saving if it is.
I was faced with this problem where I wanted to ask for Google Authenticator on sign in but only once for each device used by a user. I used a function to give me a device id based on the hostname, the MAC address, and the IP address. I know the MAC address isn't always reliable so I thought combining the data into one string might be a way round it. Our application is limited to <100 users and most of them access from the office or home so I feel it should be good enough.
I put the IP address function (which gets the IPV4) into a separate function as I check whether they are in office (on 192.168..) or external before checking the device ID. The list of device ID's associated with a user is stored in a SQL table and checked after username/password entry but before log in is completed to decide whether to request a 2FA code.
Here's the code:
dim thisDeviceId as String=GetClientDeviceId()
public Function GetClientDeviceId() As string
Dim mac As String = String.Empty
For Each netInterface In NetworkInterface.GetAllNetworkInterfaces()
If _
netInterface.NetworkInterfaceType = NetworkInterfaceType.Wireless80211 OrElse
netInterface.NetworkInterfaceType = NetworkInterfaceType.Ethernet Then
Dim address = netInterface.GetPhysicalAddress()
mac = BitConverter.ToString(address.GetAddressBytes())
End If
Next
return string.Format("{0}-{1}-{2}",dns.GetHostEntry(HttpContext.current.Request.ServerVariables("REMOTE_ADDR")).HostName, mac,GetClientDeviceIpAddress())
End Function
public Function GetClientDeviceIpAddress() As string
Dim ipv4Address As String = String.Empty
For Each currentIpAddress As IPAddress In Dns.GetHostAddresses(Dns.GetHostName())
If currentIpAddress.AddressFamily.ToString() = System.Net.Sockets.AddressFamily.InterNetwork.ToString() Then
ipv4Address = currentIpAddress.ToString()
Exit For
End If
Next
return ipv4Address
End Function
Even though it's not bulletproof and could be improved upon it might help someone.

Python "scapy": fake ip unable to cheat tcpdump

I use "scapy" to launch SYN flood attack.
Below code generate a fake IP as source IP
The attacker computer's wireshark capture the generated fake IP as source IP, but
the victims computer's tcpdump capture attacker's real IP(NOT the fake IP)
Is scapy unable to cheat tcpdump? or something error with my code?
IP_Packet = IP()
IP_Packet.src = randomIP() #generate a fake IP as source IP
IP_Packet.dst = dstIP
TCP_Packet = TCP()
TCP_Packet.sport = s_port
TCP_Packet.dport = dstPort
TCP_Packet.flags = "S"
TCP_Packet.seq = s_eq
TCP_Packet.window = w_indow
send(IP_Packet / TCP_Packet, verbose=0)
If the victim computer isn't on the same network as the attacker, your router is likely replacing the source IP during the NAT translation. the Victim is receiving the (correct) public IP address, instead of the (spoofed) private IP address

Retrieve IP Address of the Default Printer Driver in UWP

We have a requirement to get the printer IP Address configured in the default printer driver in Control Panel in our UWP app.
I was able to retrieve the "System.DeviceInterface.PrinterPortName" by fetching interface class GUID and passing this above property for retrieval.
But I couldn't get "System.Devices.IpAddress" similarly.
Code pasted below for PortName.
I badly need the IP address as the port name is user's choice and could be modified to any name removing the IP address.
Kindly help sharing working code to retrieve the IP Address using above property or any other way in UWP app.
Below is Working Code for Port Name, Kindly help to fetch IP Address of the same port similarly.
string aqsFilter = "System.Devices.InterfaceClassGuid:=\"{0ecef634-6ef0-472a-8085-5ad023ecbccd}\"";
string[] propertiesToRetrieve = new string[] { "System.DeviceInterface.PrinterPortName"};
DeviceInformationCollection deviceInfoCollection = await DeviceInformation.FindAllAsync(aqsFilter, propertiesToRetrieve);
foreach (DeviceInformation deviceInfo in deviceInfoCollection)
{
if (deviceInfo.IsDefault == true)
{
string strPortName = (string)deviceInfo.Properties["System.DeviceInterface.PrinterPortName"];
if (!string.IsNullOrEmpty(strPortName))
{
strPortName = await ParsePortName(strPortName);
if (!string.IsNullOrEmpty(strPortName))
{
_strIPAddress = strPortName;
}
}
break;
}
}
This is not endorsed because the IP address can change and so it is unreliable.
That being said, if your printer is installed using wsd, it is technically supported
E.g.,
DEVPKEY_PNPX_IpAddress DEVPROP_TYPE_STRING_LIST 32 "10.137.192.202"
But there is no way to reliably use this without a lot of various scenario checks since the IP address may change.
Furthermore, looking at this example, you are not hitting the DAF providers but looking for devices. You are using 0ecef634-6ef0-472a-8085-5ad023ecbccd which is the printer class guid. It also does not look like IP address is propagated in the PnP Explorer property bag so the IP address is not accessible.

In Hyperledger, do the membership service, validating peer, and non-validating peer require public OR private IP address to work?

Given the following Hyperledger set-up:
Company A
- 1 membership service
- 1 VP
- 1 NVP
Company B
- 1 VP
- 1 NVP
Note: To simplify the scenario, there are no VPN or port forwarding in the set-up.
Will the membership service and VPs require a public IP address to work? Can the NVPs use only private IP address provided that they have a network connection to their corresponding VPs?
The address just needs to be resolvable by the source service. That said, for peers (if company A peers and company B peers must validate eachother), ensure the advertised address is resolvable.
To determine the advertised address, visit :7050/network/peers on one of the peers (with rest enabled). One can change this address via CORE_PEER_ADDRESS=x.x.x.x:7051 and CORE_PEER_ADDRESSAUTODETECT=false ENV variables.

Using agent name instead of IP as Address in SNMP4J

I'm trying to make a program that sends SNMP queries to some switches in the network.
Using the Net-snmp tools, I can send get requests to the switch using its name, and it works fine. But SNMP4J requires an IP address in CommunityTarget, so I get an IllegalArgumentException.
This is the relevant part of the code:
TransportMapping transport = new DefaultUdpTransportMapping();
transport.listen();
CommunityTarget comtarget = new CommunityTarget();
comtarget.setCommunity(new OctetString("public"));
comtarget.setVersion(SnmpConstants.version1);
comtarget.setAddress(new UdpAddress("switchName")); // exception happens here
comtarget.setRetries(2);
comtarget.setTimeout(1000);
How can I work around this?
You can get the IP address by using DNS resolution, like this answer says:
InetAddress address = InetAddress.getByName(switchName);
System.out.println(address.getHostAddress());

Resources