diff --git a/NetFunctions.cpp b/NetFunctions.cpp index 2b52815..241e08c 100644 --- a/NetFunctions.cpp +++ b/NetFunctions.cpp @@ -67,17 +67,26 @@ uint8_t sendspoof(std::string lsDMAC, std::string lsGWMAC, std::string lsDADDR, { pcpp::PcapLiveDevice* dev = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByIp(testv4); if (nullptr == dev) + { std::cout << "Couldn't find interface by provided IP address or name" << std::endl; + } if (!dev->open()) + { std::cout << "!Couldn't open the device." << std::endl; + } else { std::cout << "Trying to send packet for "; - if (true ==lstcp) - std::cout << "TCP" << std::endl; + if (true == lstcp) + { + std::cout << "TCP" << std::endl; + } else + { std::cout << "UDP" << std::endl; + } int sentCount = dev->sendPacket(&newPacket); + std::this_thread::sleep_for(std::chrono::milliseconds(250)); //250ms delay to assure correct processing in series of requests } free(lsbuffer); return 0; diff --git a/main.cpp b/main.cpp index 17a2265..38e5ce6 100644 --- a/main.cpp +++ b/main.cpp @@ -33,6 +33,8 @@ int main(int argc, char* argv[]) getDevices(); //Interfaces will be added to DEVS vector. OutputInterface = FindAppropriateDevice(DEVS, DADDR); //Will return WinDev object with interface from the same network + + if (DGWAY.empty()) { DGWAY = OutputInterface.gwayip; @@ -52,7 +54,7 @@ int main(int argc, char* argv[]) } else { - std::cerr << "Source MAC wasn't specified. Aborting..." << std::endl; + std::cerr << "Source MAC wasn't specified, and no interface with matching subnet was found. Aborting..." << std::endl; return EXIT_FAILURE; } } @@ -62,7 +64,7 @@ int main(int argc, char* argv[]) { SMAC = MacVecToStringWithDelimiters(OutputInterface.macaddrvec, ':'); std::vector targetmac; - std::cout << std::endl << "Destination MAC not found, making an ARP request..." << std::endl; + std::cout << std::endl << "Destination MAC address not found, making an ARP request..." << std::endl; sendarp(OutputInterface, DADDR, targetmac); DMAC = MVTSWD(targetmac, ':'); } @@ -73,7 +75,7 @@ int main(int argc, char* argv[]) if (GWMAC.empty()) { std::vector gwaymacvec; - std::cout << std::endl << "Gateway MAC not found, making an ARP request..." << std::endl; + std::cout << std::endl << "Gateway MAC address not found, making an ARP request..." << std::endl; sendarp(OutputInterface, DGWAY, gwaymacvec); if (!gwaymacvec.empty()) { @@ -86,7 +88,7 @@ int main(int argc, char* argv[]) if (GWMAC.empty()) { std::vector gwaymacvec; - std::cout << std::endl << "Gateway MAC not found, making an ARP request..." << std::endl; + std::cout << std::endl << "Gateway MAC address not found, making an ARP request..." << std::endl; sendarp(OutputInterface, DGWAY, gwaymacvec); if (!gwaymacvec.empty()) { @@ -119,8 +121,8 @@ int main(int argc, char* argv[]) { std::cout << "Nat-PMP request sent" << std::endl; } - } + system("PAUSE"); return 0; }