Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
i am developing an MITM for windows. I am using winpcap. I did correctly the arp spoofing and the ip fordwarding to the victims of my network. The problem of winpcap is that you cant control the packets, you need sockets to do this.
With winpcap you read incoming packets, you filter them, change them and send to router ok, easy. The problem comes when you need to act as a server. For example, if we want to supplant an executable we need to serve our own exe. And we cant use sockets to serve our file to the victims because we are using winpcap, we must create all the packet and send it with pcap_sendpacket(), we must hear the victim responses, how?, the only way is waiting all incoming packets from all victims and from different protocols and to filter all searching our ACK, for all packets tcp in the download.
Is this way viable? Or shall i create a server in each sniffer port and to do this with sockets?. Mmmm ideas pls. What is better, and what would you do?
Thanks and sorry for my English :)
Regards!.
Yes, this is possible. Here are the steps that you need to take to do this successfully.
Identify an unused IP address on the subnet. If you try to use the address that is already bound you will be racing against and fighting the IP stack in the host OS. Since it knows nothing of the connections that you're managing/spoofing, it will send RST packets in reaction to almost every response packet that you receive (Note, I'm assuming that you're using TCP)
Select a MAC that you will use. You actually can use the same MAC as the host OS network stack, which will allow you to operate without actually putting the interface into promiscuous mode. The host OS will not interfere since the Layer 2 addresses will not match the host OS's knowledge of the Layer 2 address, but you will still have to supply ARP replies for your Layer 2 address when other host look for you.
Effectively, write your own IP stack. Yes, you will be responsible for calculating checksums, tracking session state and everything else.
A far easier approach that you seem to be resistant to is to use Scapy. Scapy abstracts much of this for you, allowing you to focus on the logic of what it is you're actually trying to do. For example, Scapy will take care of the checksums for you if you'd like it to.
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
Essentially I've been trying to relay messages between two computers using c/c++ using standard socket programming. Everything works fine on LAN. The issue is making the connection using something like external ip address. I searched online and saw methods that mention ensuring the router is configured for "port forwarding". However, I was wondering how do peer to peer communication apps like qTox overcome this barrier, since they do not require that technical step? To summarize, how can I connect two sockets between two computers that are NOT on the same network?
here is some methods we usually use to solve the problem.
If you can use a server in WLAN as relay or central controller, it's quite simple. The computers connect to the server, the server change messages for them and can do many more operations.
If you don't want to use a server, then here is a problem: NAT devices may drop those packets which haven't established a connection according to their type. Here are four types: full cone NAT, restricted NAT, port restricted NAT and symmetric NAT. And here are some methods for this circumstance
2.1 Use NAT traversal algorithm, but they may not work well in symmetric NAT.
2.2 Use STUN/TURN/ICE to realise NAT traverse, it's quite reliable but need to learn how to use them.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I have the next doubt: I have Arduino UNO, or Arduino Mega, and ESP8266 wifi module. Now I want to communicate a program in C/C++ under ubuntu with Arduino by wifi to control a servo motor.
What should I do? I want indications but codes are welcome too.
Thanks.
This should be really simple, but here are a few ways:
Use both Arduino and ESP8266 (AT commands), which I do NOT recommend.
Use only the ESP8266, because it is much more powerful than an ATMEGA328(the Arduino processor), plus you can use it with the same interface (and pretty much the same code), see this.
Now a bit more info for the second option (I personally recommend the latter):
You can connect both your pc and the esp8266 to the same wifi and use either TCP or UDP for communications (it will be a little work to find the server's ip though - btw, either device can be the server, so the other is the client)
You can also use the esp8266 on the AP mode (it creates a wifi network) and set the server on it with a fixed ip and port, then you connect to this network on your pc and use a socket (either UDP or TCP, again) to exchange messages. BTW: your pc will not have internet access while connected to the esp8266
Ok, one more option (much more complicated, I think): you can create a webserver (or use an existing one, like many MQTT server avaliable for free tests) and connect both your c++ application and esp8266 to it, and then communicate using the server services (publish and subscribe for example, for MQTT).
If you want some code the link in this answer has a lot of examples and also a great community.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to develop a server for an application of mine in C++. I'm not really familiar with networking concepts. This server is going be a simple one and I'll use one of the networking libraries out there. I just couldn't figure out the necessary keywords to research the following issue:
Let's say that there are 100 users on 100 different computers, all sharing the same internet connection, behind the same router. They all decide to open my client to connect to my server. How do you deal with this issue if you want to keep the connections open and on the same port.
For the purposes of your server, it doesn't make any difference whether those 100 connections are all coming from the same computer, from the same router, or from totally separate networks.
While the server side of the connection will use the same port for all of these, each connection will have a different combination of client side IP address and port. In the case you describe, where all 100 are behind the same router using the same IP address, the router will take care of making sure they all have different client side port numbers. You can read about network address translation (NAT) if you want to learn the details about one common way that is done.
This kind of server programming is not easy and requires network skills. You can have a look at this tutorial. It's C and unix, but it shows the function you'll need to use:
socket interface for network access
listening/accepting new connextion
forking new processes to handle the different clients (although in C++ you'd probebly look for multithreading which is more efficient for this kind of task).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I want to get the list of all IP addresses (i.e devices) present in a local area network. I don't want to use nmap, other networking tools. And also I don't want to ping each Ip address in a sub-net range and find live IP addresses? Is there any way by using C, C++?
No.
Of course you're going to have to use some "networking tools" in order to figure this out, how do you expect the machine on which you are to know about other machines otherwise?
One approach might be to query the DHCP server, but that won't reveal devices with static IPs, and so on.
Any reliable method wil involve communicating with the devices in question in some fashion.
There is no reliable way to determine all hosts in a LAN. There are many means of guessing your neighbors, each with its own advantages and drawbacks. But you will never be sure you get all hosts. e.g you can try to ping a broadcast, but someone could not reply to the ping. So there is no reliable way to do it. There are some ways which rely on commands in a terminal.
You can try using nmap. Although it needs to install nmap:
nmap -sP 192.168.1.*
This does a simple ping scan in the entire subnet to see which all host's are online.
Or you can also try the following steps (Does not require installing nmap):
Type “ipconfig” at command prompt. This will give you ip address of
your own machine. For example, your machine ip address is 192.168.1.6
So your broadcast IP address is 192.168.1.255.
Ping your broadcast IP address “ping 192.168.1.255” (may require -b
on linux)
Now type “arp –a” You will get the list of all IP addresses on your
segment.
You can start the arp or nmap with the appropriate arguments in your application using some toolkit.
In Qt you can use QProcess to accomplish them like:
QProcess myProcess;
QString program = "arp";
QStringList arguments;
arguments << "-a";
myProcess.start(program, arguments);
myProcess.waitForFinished();
QByteArray result = myProcess.readAllStandardOutput ();
const QString all(result);
You can use libpcap to sniff network packets in promiscuous mode on a central location and extract source IP. Challenge is identifying a central location where to put this sniffer.
Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
This application sends data periodically to a server. What I need to do is setup a testing environment on the local developing machine so that I can check the correct packets are being sent in each situation. I thought a good approach would be a server VM set up on the local computer which would receive the packets and respond just like the real thing, but the problem is how do I route the packets of an application running on windows to a VM machine. I don't want to modify my application code. I just want to have windows pass on the packets it receives from the application to the VM or otherwise another application that will do the testing. Is this possible? If not, please let me know about any other solution(s) to this problem.
If you're running a decent VM you should be able to give it an IP address visible from the host, and configure it so that you can run web servers on it, ssh to it, etc.
Look at the networking features of your VM. Or find a tutorial on how to do this, such as this one for VirtualBox:
http://www.tolaris.com/2009/03/05/using-host-networking-and-nat-with-virtualbox/
Well it's some kind of a hack but you can use ARP Poisoning (man in the middle attack) to sniff packets. There is a tool named Cain & Abel which can do this for you. I've used this tool to sniff packets between two non-pc machines. Use at your own risk and if your anti-virus tool alerts, know that the tool has no virus but what it does is detected as one.
Edit: Please note that my approach doesn't require a VM server.