Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ INC := -I include
OS := $(shell uname)


build: $(TARGET) bin/poc
build: $(TARGET) bin/poc bin/kext_extract

$(TARGET): $(OBJECTS)
@mkdir -p $(LIBDIR)
Expand Down Expand Up @@ -42,5 +42,8 @@ clean:
bin/poc: poc/poc.cpp
@echo " $(CC) -L$(LIBDIR) -o $@ $< -lopenmach $(INC)"; $(CC) -L$(LIBDIR) -o $@ $< -lopenmach $(INC)

bin/kext_extract: poc/kext_extract.cpp
@echo " $(CC) -L$(LIBDIR) -o $@ $< -lopenmach $(INC)"; $(CC) -L$(LIBDIR) -o $@ $< -lopenmach $(INC)

.PHONY: clean

28 changes: 28 additions & 0 deletions poc/kext_extract.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <stdio.h>
#include <stdint.h>
#include <vector>
#include <iostream>
#include "MachO.hpp"
#include "FileReader.hpp"

int main(int argc, char *argv[])
{

if (argc < 3) {
printf("./kext_extract <kext_name> <kernel_path> [<output_dir>]\n");
return -1;
}

MachO bin(argv[2]);
std::string output_filename;

if (argc == 3)
output_filename = std::string("./" + std::string(argv[1]) + ".kext");
else
output_filename = std::string(std::string(argv[3]) + "/" + std::string(argv[1]) + ".kext");
std::cout<<output_filename<<std::endl;

bin.dumpKext((char *) argv[1], (char *) output_filename.c_str());

return 0;
}