@@ -771,19 +771,24 @@ int Exploit::stage1() {
771771 * and the PS4 unilaterally ends the PPPoE session.
772772 * To avoid this situation, respond to the PPPoE ECHO_REQ here
773773 */
774- dev->startCapture ([](pcpp::RawPacket *packet, pcpp::PcapLiveDevice *device, void *cookie) {
775- pcpp::Packet parsedPacket (packet, pcpp::PPPoESession);
776- auto *pppLayer = PacketBuilder::getPPPoESessionLayer (parsedPacket, PCPP_PPP_LCP);
777- if (!pppLayer) return ;
778- if (pppLayer->getLayerPayload ()[0 ] != ECHO_REQ) return ;
779- auto *etherLayer = parsedPacket.getLayerOfType <pcpp::EthLayer>();
780- if (!etherLayer) return ;
781- auto &&echoReply = PacketBuilder::lcpEchoReply (etherLayer->getDestMac (), etherLayer->getSourceMac (),
782- pppLayer->getPPPoEHeader ()->sessionId ,
783- pppLayer->getLayerPayload ()[1 ], // id
784- htole32 (*(uint32_t * ) & pppLayer->getLayerPayload ()[4 ])); // magic number
785- device->sendPacket (&echoReply);
786- }, nullptr );
774+ try {
775+ dev->startCapture ([](pcpp::RawPacket *packet, pcpp::PcapLiveDevice *device, void *cookie) {
776+ pcpp::Packet parsedPacket (packet, pcpp::PPPoESession);
777+ auto *pppLayer = PacketBuilder::getPPPoESessionLayer (parsedPacket, PCPP_PPP_LCP);
778+ if (!pppLayer) return ;
779+ if (pppLayer->getLayerPayload ()[0 ] != ECHO_REQ) return ;
780+ auto *etherLayer = parsedPacket.getLayerOfType <pcpp::EthLayer>();
781+ if (!etherLayer) return ;
782+ auto &&echoReply = PacketBuilder::lcpEchoReply (etherLayer->getDestMac (), etherLayer->getSourceMac (),
783+ pppLayer->getPPPoEHeader ()->sessionId ,
784+ pppLayer->getLayerPayload ()[1 ], // id
785+ htole32 (*(uint32_t * ) &
786+ pppLayer->getLayerPayload ()[4 ])); // magic number
787+ device->sendPacket (&echoReply);
788+ }, nullptr );
789+ } catch (const std::system_error &e) {
790+ std::cout << " Cannot create new thread" << e.what () << std::endl;
791+ }
787792
788793 /* *
789794 * Send invalid packet to trigger a printf in the kernel. For some
@@ -805,7 +810,7 @@ int Exploit::stage1() {
805810 TIME_END_PERIOD ();
806811 }
807812
808- dev->stopCapture ();
813+ if (dev-> captureActive ()) dev->stopCapture ();
809814 std::cout << " \r [+] Pinning to CPU 0...done" << std::endl;
810815
811816 // LCP fails sometimes without the wait
@@ -1026,10 +1031,10 @@ int Exploit::stage4() {
10261031
10271032 // Calculate checksum
10281033 std::vector<uint8_t > temp (udpLayer.getHeaderLen ());
1029- (*(uint16_t *) &(temp)[0 ]) = udpHeader->portSrc ;
1030- (*(uint16_t *) &(temp)[2 ]) = udpHeader->portDst ;
1031- (*(uint16_t *) &(temp)[4 ]) = udpHeader->length ;
1032- (*(uint16_t *) &(temp)[6 ]) = 0 ;
1034+ (*(uint16_t * ) & (temp)[0 ]) = udpHeader->portSrc ;
1035+ (*(uint16_t * ) & (temp)[2 ]) = udpHeader->portDst ;
1036+ (*(uint16_t * ) & (temp)[4 ]) = udpHeader->length ;
1037+ (*(uint16_t * ) & (temp)[6 ]) = 0 ;
10331038 temp.insert (temp.end (), this ->stage2_bin .begin (), this ->stage2_bin .end ());
10341039 uint16_t checksumRes = pcpp::computePseudoHdrChecksum (temp.data (),
10351040 temp.size (),
@@ -1108,6 +1113,7 @@ struct Tunnel<M, N> {
11081113 friend T &stopThread (U &u) {
11091114 return u.*M;
11101115 }
1116+
11111117 friend Q &pcapHandle (V &u) {
11121118 return u.*N;
11131119 }
@@ -1117,6 +1123,7 @@ template
11171123struct Tunnel <&pcpp::PcapLiveDevice::m_StopThread, &pcpp::IPcapDevice::m_PcapDescriptor>;
11181124
11191125std::atomic<bool > &stopThread (pcpp::PcapLiveDevice &);
1126+
11201127pcap_t *&pcapHandle (pcpp::IPcapDevice &);
11211128
11221129void Exploit::stop () {
0 commit comments