Python "scapy": fake ip unable to cheat tcpdump - wireshark

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

Related

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.

Check network interface ip version ios

I am trying to understand what my active network interface ip version is - IPv4 or IPv6. I am using the next instructions http://www.brianjcoleman.com/tutorial-how-to-test-your-app-for-ipv6-compatibility/ to test my app for IPv6 compatibility.
I checked all resources available here (for example Swift - Get device's IP Address, how to get ip address of iphone programmatically, What exactly means iOS networking interface name? what's pdp_ip ? what's ap?), it helped to get a list of available interfaces. When my iPhone is connected to IPv4 WiFi network, the list is the next:
"awdl0/ipv6" = "fe80::14ce:f9ff:fe2a:44df";
"en0/ipv4" = "192.168.1.190";
"en0/ipv6" = "fdba:ae3c:c993::19cd:be51:e41b:632e";
"lo0/ipv4" = "127.0.0.1";
"lo0/ipv6" = "fe80::1";
"pdp_ip0/ipv4" = "100.83.148.33";
"utun0/ipv6" = "fe80::e94e:c3b6:ff73:1ded";
When it is connected to IPv6 WiFi network, the list is the next:
"awdl0/ipv6" = "fe80::14ce:f9ff:fe2a:44df";
"en0/ipv4" = "169.254.127.94";
"en0/ipv6" = "2001:2::aab1:7dd5:c5dc:16dd:b678";
"lo0/ipv4" = "127.0.0.1";
"lo0/ipv6" = "fe80::1";
"pdp_ip0/ipv4" = "100.83.148.33";
"utun0/ipv6" = "fe80::e94e:c3b6:ff73:1ded";
In both cases I have en0/ipv4 and en0/ipv6, so it is not clear for me how to make a decision programmatically what ip version of my network actually is.
Any help is very appreciated. Thanks in advance.
The first, and most important, thing to understand is that you're almost always "on" both an IPv4 and IPv6 network (unless one of them has been disabled). Failure to receive a DHCP address does not mean you're not "on" a network. It just means there's no DHCP server talking to you (it is completely legitimate to have a network with no DHCP server). The fact that no one else is on this network with you doesn't mean you're not on a network, either. You can be on the network alone. And you are.
Pedantic, but important to understanding what's going on. What you usually mean is "do I have a 'publicly' routable address on this network." And what most people really mean (and is a radically different question and often very hard to answer) is "what's my 'primary' network?" (This is particularly difficult because your "primary" network might be different depending on what address you're trying to reach.)
But to the practical question that you probably want to answer, which is "do I have an assigned and probably routable IPv4/6 address?" To that, you have to look at the address you have, and see what it's assigned to. My preferred list is Wikipedia's Reserved IP addresses. Looking at that, we can consider each address above.
IPv4 network
"awdl0/ipv6" = "fe80::14ce:f9ff:fe2a:44df"; # fe80 => Link local (not routable)
"en0/ipv4" = "192.168.1.190"; # 192.168 => Private network (but *probably* NAT)
"en0/ipv6" = "fdba:ae3c:c993::19cd:be51:e41b:632e"; # fdba => Unique local address (not routable)
"lo0/ipv4" = "127.0.0.1"; # 127 => Host loopback (not routable)
"lo0/ipv6" = "fe80::1"; # fe80 => Host loopback (not routable)
"pdp_ip0/ipv4" = "100.83.148.33"; # 100.83 => Service provider (not useful to you)
"utun0/ipv6" = "fe80::e94e:c3b6:ff73:1ded"; # fe80 => Host loopback (not routable)
IPv6 network
"awdl0/ipv6" = "fe80::14ce:f9ff:fe2a:44df"; # Loopback
"en0/ipv4" = "169.254.127.94"; # Link local (not routable)
"en0/ipv6" = "2001:2::aab1:7dd5:c5dc:16dd:b678"; # 2001 => "Teredo tunnel" (IPv6 routable over IPv4)
"lo0/ipv4" = "127.0.0.1"; # loopback
"lo0/ipv6" = "fe80::1"; # loopback
"pdp_ip0/ipv4" = "100.83.148.33"; # Service provider
"utun0/ipv6" = "fe80::e94e:c3b6:ff73:1ded"; # loopback
In particular you usually want to be looking at that en0 (first ethernet interface, which on an iPhone is WiFi). And you can see in the first case you have:
"en0/ipv4" = "192.168.1.190"; # 192.168 => Private network (but *probably* NAT)
"en0/ipv6" = "fdba:ae3c:c993::19cd:be51:e41b:632e"; # fdba => Unique local address (not routable)
And in the second case you have:
"en0/ipv4" = "169.254.127.94"; # Link local (not routable)
"en0/ipv6" = "2001:2::aab1:7dd5:c5dc:16dd:b678"; # 2001 => "Teredo tunnel" (IPv6 routable over IPv4)
And that's how you know which one is routable. You have to check what range it's in. (To the question: "Why can't it just say 'you're on the Internet?', a major part of the answer is that the spec doesn't define "the Internet." The Internet is just one particular network that happens to be very large. Also, most IPv4 addresses you see are going to be private anyway, and technically aren't on "the Internet." The network card has no idea whether or not there's a NAT somewhere that bridges from the private network to the public one.)
BTW, when I say "not routable," that doesn't mean it's not your primary address. For example, you can have an entire network based on link-local addresses (I've done it lots of times). But those addresses won't route (i.e. they won't be forwarded past the current network segment), so for most common uses it's ok to consider them "not a real address." Similarly, I've built "networks" entirely out of host-only addresses, but since they don't route past the current machine, they usually aren't what people mean by "the network."

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());

LoadRunner IP address binding to vuser

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");

How to get IP when connected to Wifi on BlackBerry?

I'm trying to my application to retrieve the IP address when it's connected to the Wifi network but I'm not too sure how to get that done.
I've looked at RadioInfo and there's a function getIPAddress(int apnId). Is this the right one?
I've also looked at WLANInfo but that one doesn't seem to have any IP related functions.
Anyone can help me with this?
klyubin wrote:
[...] the best solution (as it relies on documented behavior) is to open a udp socket (or TCP server socket) over WiFi and query its IP address. Another hack is to get the APN ID for the "MagicRudyAPN.rim" using getAccessPointNumber, and then query its IP address using getIPAddress. MagicRudyAPN.rim seems to be a virtual/fake APN for accessing/addressing the IP tunnel to the WiFi network.
int apnId = RadioInfo.getAccessPointNumber("MagicRudyAPN.rim");
byte[] ipByte = RadioInfo.getIPAddress(apnId);
String ip = "";
for (int i = 0; i < ipByte.length; i++) {
int temp = (ipByte[i] & 0xff);
if (i < 3)
ip = ip.concat("" + temp + ".");
else {
ip = ip.concat("" + temp);
}
}

Resources