Skip to content

Commit

Permalink
Remove unused LcpEchoHandler
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed May 24, 2024
1 parent 4ff6a3d commit 8866b72
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 66 deletions.
15 changes: 0 additions & 15 deletions include/exploit.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
51 changes: 0 additions & 51 deletions src/exploit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<pcpp::EthLayer>();
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:
Expand Down

0 comments on commit 8866b72

Please sign in to comment.