Skip to content

Commit

Permalink
Added 250ms delay for PMP requests
Browse files Browse the repository at this point in the history
  • Loading branch information
easymoney322 committed Jun 22, 2023
1 parent befabd1 commit a603630
Showing 2 changed files with 18 additions and 7 deletions.
13 changes: 11 additions & 2 deletions NetFunctions.cpp
Original file line number Diff line number Diff line change
@@ -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;
12 changes: 7 additions & 5 deletions main.cpp
Original file line number Diff line number Diff line change
@@ -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 <uint8_t> 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 <uint8_t> 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 <uint8_t> 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;
}

0 comments on commit a603630

Please sign in to comment.