diff --git a/include/exploit.h b/include/exploit.h index 96541db..69a55b1 100644 --- a/include/exploit.h +++ b/include/exploit.h @@ -66,21 +66,6 @@ class PacketBuilder { static pcpp::PPPoEDiscoveryLayer *getPPPoEDiscoveryLayer(const pcpp::Packet &packet, uint8_t type); }; -class LcpEchoHandler { -public: - explicit LcpEchoHandler(const std::string &iface); - - void run(); - - void stop(); - - ~LcpEchoHandler(); - -private: - pcpp::PcapLiveDevice *dev; - bool running{}; -}; - class Exploit { public: Exploit() = default; diff --git a/src/exploit.cpp b/src/exploit.cpp index c5950d9..5a8f3f2 100644 --- a/src/exploit.cpp +++ b/src/exploit.cpp @@ -82,57 +82,6 @@ struct Cookie { #define startBlockingCapture(cb) if(dev->startCaptureBlockingMode(cb, nullptr, this->timeout) != 1) { return running ? RETURN_FAIL : RETURN_STOP; } #define startBlockingCaptureWithCookie(cb, cookie) if(dev->startCaptureBlockingMode(cb, cookie, this->timeout) != 1) { return running ? RETURN_FAIL : RETURN_STOP; } -LcpEchoHandler::LcpEchoHandler(const std::string &iface) { - dev = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDeviceByName(iface); - if (dev == nullptr) { - std::cout << "[-] LcpEchoHandler Cannot find interface with name of '" << iface << "'" << std::endl; - exit(1); - } - - pcpp::PcapLiveDevice::DeviceConfiguration config; - config.direction = pcpp::PcapLiveDevice::PCPP_IN; - config.packetBufferTimeoutMs = 1; - if (!dev->open(config)) { - std::cout << "[-] LcpEchoHandler Cannot open device" << std::endl; - exit(1); - } - - if (!dev->setFilter("pppoes && !ip")) { - std::cout << "[-] LcpEchoHandler cannot set filter" << std::endl; - } -} - -void LcpEchoHandler::run() { - running = true; - dev->startCaptureBlockingMode( - [](pcpp::RawPacket *packet, pcpp::PcapLiveDevice *device, void *cookie) -> bool { - auto *self = (LcpEchoHandler *) cookie; - pcpp::Packet parsedPacket(packet, pcpp::PPPoESession); - auto *pppLayer = PacketBuilder::getPPPoESessionLayer(parsedPacket, PCPP_PPP_LCP); - if (!pppLayer) return !self->running; - if (pppLayer->getLayerPayload()[0] != ECHO_REQ) return !self->running; - auto *etherLayer = parsedPacket.getLayerOfType(); - if (!etherLayer) return !self->running; - - auto &&echoReply = PacketBuilder::lcpEchoReply(etherLayer->getDestMac(), etherLayer->getSourceMac(), - pppLayer->getPPPoEHeader()->sessionId, - pppLayer->getLayerPayload()[1], // id - 0); // todo: check if we need to echo back the correct magic number ? - // correct magic number: *(uint32_t *) &pppLayer->getLayerPayload()[4] - self->dev->sendPacket(&echoReply); - return !self->running; - }, this, 0); -} - -void LcpEchoHandler::stop() { - running = false; -} - -LcpEchoHandler::~LcpEchoHandler() { - this->stop(); - this->dev->close(); -} - int Exploit::setFirmwareVersion(FirmwareVersion version) { switch (version) { case FirmwareVersion::FIRMWARE_700_702: