diff --git a/CMakeLists.txt b/CMakeLists.txt index 326151a..7c8a79d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,10 @@ cmake_minimum_required(VERSION 3.10) project(checkm8_tool) enable_language(C ASM) -include(${CMAKE_ROOT}/Modules/ExternalProject.cmake) - -include_directories(c8_remote/include) include_directories(include) -add_subdirectory(c8_remote/lib) +# set up checkm8_remote add_subdirectory(c8_remote) + +# targets for external tools +add_executable(tool_corr_strip tools/correlation/strip/main.c) \ No newline at end of file diff --git a/c8_remote/CMakeLists.txt b/c8_remote/CMakeLists.txt index 5959791..2c69603 100644 --- a/c8_remote/CMakeLists.txt +++ b/c8_remote/CMakeLists.txt @@ -5,6 +5,7 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_C_FLAGS "-g -Wall") include_directories(include) +add_subdirectory(lib) add_executable(checkm8_remote main.c src/usb_helpers.c src/exploit.c src/payload.c src/command.c) target_link_libraries(checkm8_remote usb-1.0 pthread udev m) diff --git a/c8_remote/main.c b/c8_remote/main.c index 0438d2a..badc1b2 100644 --- a/c8_remote/main.c +++ b/c8_remote/main.c @@ -4,6 +4,7 @@ #include #include #include +#include #include "dev/types.h" #include "util/experiments.h" @@ -106,12 +107,26 @@ void run_corr_exp(struct pwned_device *dev, char *fname) unsigned char key[16]; unsigned char key_sched[176]; + sprintf(fname, "KEY"); + outfile = fopen(fname, "w"); + if(outfile == NULL) + { + printf("failed to open key file\n"); + return; + } + + srand(time(NULL)); for(i = 0; i < 16; i++) { msg[i] = 0; - key[i] = 0x0; + key[i] = random(); + fprintf(outfile, "%02x", key[i]); } + fprintf(outfile, "\n"); + fflush(outfile); + fclose(outfile); + expand_key(key, key_sched, 11, c); addr_async_buf = setup_corr_exp(dev, key); diff --git a/tools/correlation/strip/main.c b/tools/correlation/strip/main.c new file mode 100644 index 0000000..9dbb4c4 --- /dev/null +++ b/tools/correlation/strip/main.c @@ -0,0 +1,83 @@ +#include +#include +#include + +struct entry +{ + unsigned char msg[16]; + unsigned char pad0; + + unsigned char timing; + unsigned char pad1[2]; +} __attribute__ ((packed)); + +int main(int argc, char *argv[]) +{ + FILE *infile, *timingfile, *msgfile; + char fname[128], c1[128], c2[128], *path, *name; + + strcpy(c1, argv[1]); + strcpy(c2, argv[1]); + + int count = 0; + unsigned long read; + struct entry e; + + if(argc != 2) + { + printf("usage: strip [fname]\n"); + return -1; + } + + path = dirname(c1); + name = basename(c2); + + infile = fopen(argv[1], "rb"); + if(infile == NULL) + { + printf("failed to open file %s\n", argv[1]); + return -1; + } + + sprintf(fname, "%s/timing_%s", path, name); + timingfile = fopen(fname, "wb"); + if(timingfile == NULL) + { + printf("failed to open timing output\n"); + return -1; + } + + sprintf(fname, "%s/msg_%s", path, name); + msgfile = fopen(fname, "wb"); + if(msgfile == NULL) + { + printf("failed to open message output\n"); + return -1; + } + + while(!(ferror(infile) || feof(infile))) + { + read = fread(&e, sizeof(struct entry), 1, infile); + if(read != 1) + break; + + fwrite(&e.timing, 1, 1, timingfile); + if(count % (1024 * 256) == 0) + { + fwrite(&e.msg, 16, 1, msgfile); + printf("stripped %i entries\n", count); + } + + count++; + } + + printf("strip finished with ferror %i feof %i\n", ferror(infile), feof(infile)); + + fflush(timingfile); + fflush(msgfile); + + fclose(infile); + fclose(timingfile); + fclose(msgfile); + return 0; +} \ No newline at end of file diff --git a/tools/chroot-pi.sh b/tools/scripts/chroot-pi.sh similarity index 100% rename from tools/chroot-pi.sh rename to tools/scripts/chroot-pi.sh diff --git a/tools/enable_wireshark_usb.sh b/tools/scripts/enable_wireshark_usb.sh similarity index 100% rename from tools/enable_wireshark_usb.sh rename to tools/scripts/enable_wireshark_usb.sh diff --git a/tools/iphone.rules b/tools/scripts/iphone.rules similarity index 100% rename from tools/iphone.rules rename to tools/scripts/iphone.rules diff --git a/tools/profile.py b/tools/scripts/profile.py similarity index 100% rename from tools/profile.py rename to tools/scripts/profile.py