add a stripping tool and a random key experiment

This commit is contained in:
2020-02-28 16:28:13 -05:00
parent 0320e5cea7
commit 662c228b7e
8 changed files with 104 additions and 5 deletions

View File

@@ -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)

View File

@@ -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)

View File

@@ -4,6 +4,7 @@
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#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);

View File

@@ -0,0 +1,83 @@
#include <stdio.h>
#include <string.h>
#include <libgen.h>
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;
}