Skip to content

Commit

Permalink
macOS: list more information about interface
Browse files Browse the repository at this point in the history
  • Loading branch information
xfangfang committed May 13, 2024
1 parent 2a3a87f commit 1bca1e8
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ This project depends on [pcap](https://github.com/the-tcpdump-group/libpcap), cm
You can also add cmake option `-DUSE_SYSTEM_PCAP=OFF` to compile pcap from source (can be used when cross-compiling).

```shell
# native build (macOS, Linux, mingw)
# native build (macOS, Linux)
cmake -B build
cmake --build build pppwn

Expand All @@ -50,7 +50,7 @@ cmake --build build pppwn

# cross compile for Windows
# https://npcap.com/dist/npcap-sdk-1.13.zip
cmake -B build -DZIG_TARGET=x86_64-windows-gnu -DUSE_SYSTEM_PCAP=OFF -DPacket_ROOT=<path to npcap sdk>
cmake -B build -DZIG_TARGET=x86_64-windows-gnu -DPCAP_ROOT=<path to npcap sdk>
cmake --build build pppwn
```

Expand Down
4 changes: 4 additions & 0 deletions include/defines.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,14 @@

#define CR0_ORI CR0_PG | CR0_AM | CR0_WP | CR0_NE | CR0_ET | CR0_TS | CR0_MP | CR0_PE

#undef VM_PROT_READ
#define VM_PROT_READ 0x01
#undef VM_PROT_WRITE
#define VM_PROT_WRITE 0x02
#undef VM_PROT_EXECUTE
#define VM_PROT_EXECUTE 0x04

#undef VM_PROT_ALL
#define VM_PROT_ALL (VM_PROT_READ | VM_PROT_WRITE | VM_PROT_EXECUTE)

#define LLE_STATIC 0x0002
Expand Down
33 changes: 31 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <string>
#include <PcapLiveDeviceList.h>
#include <clipp.h>
#if defined(__APPLE__)
#include <SystemConfiguration/SystemConfiguration.h>
#endif

#include "exploit.h"

Expand Down Expand Up @@ -57,8 +60,8 @@ std::vector<uint8_t> readBinary(const std::string &filename) {
}

int startExploit(const std::string &interface, enum FirmwareVersion fw,
const std::string &stage1, const std::string &stage2,
bool retry) {
const std::string &stage1, const std::string &stage2,
bool retry) {
Exploit exploit;
if (exploit.setFirmwareVersion(fw)) cleanup(1);
if (exploit.setInterface(interface)) cleanup(1);
Expand All @@ -74,10 +77,36 @@ int startExploit(const std::string &interface, enum FirmwareVersion fw,

void listInterfaces() {
std::cout << "[+] interfaces: " << std::endl;
#if defined(__APPLE__)
CFArrayRef interfaces = SCNetworkInterfaceCopyAll();
if (!interfaces) {
std::cerr << "[-] Failed to get interfaces" << std::endl;
exit(1);
}
CFIndex serviceCount = CFArrayGetCount(interfaces);
char buffer[1024];
for (CFIndex i = 0; i < serviceCount; ++i) {
auto interface = (SCNetworkInterfaceRef) CFArrayGetValueAtIndex(interfaces, i);
auto serviceName = SCNetworkInterfaceGetLocalizedDisplayName(interface);
auto bsdName = SCNetworkInterfaceGetBSDName(interface);
if (bsdName) {
CFStringGetCString(bsdName, buffer, sizeof(buffer), kCFStringEncodingUTF8);
printf("\t%s ", buffer);
if (serviceName) {
CFStringGetCString(serviceName, buffer, sizeof(buffer), kCFStringEncodingUTF8);
printf("%s", buffer);
}
printf("\n");
}
}
CFRelease(interfaces);
#else
std::vector<pcpp::PcapLiveDevice *> devList = pcpp::PcapLiveDeviceList::getInstance().getPcapLiveDevicesList();
for (pcpp::PcapLiveDevice *dev: devList) {
if (dev->getLoopback()) continue;
std::cout << "\t" << dev->getName() << " " << dev->getDesc() << std::endl;
}
#endif
exit(0);
}

Expand Down

0 comments on commit 1bca1e8

Please sign in to comment.