This repository has been archived by the owner on May 16, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
needs more documentation though temp wtf just happened informative commit message woa
- Loading branch information
Lenni Hein
committed
Dec 1, 2018
1 parent
b6e0faf
commit 7808b2f
Showing
16 changed files
with
265 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <stdint.h> | ||
|
||
#define __MSG_SIZE__ 0x40 | ||
#define __REQ_SIZE__ 0x10 | ||
|
||
typedef struct MESSAGE | ||
{ | ||
char str[64]; | ||
}MESSAGE; | ||
|
||
typedef struct REQUEST | ||
{ | ||
uint64_t control; | ||
uint64_t value; | ||
}REQUEST; | ||
|
||
// careful with stack alignment | ||
// https://stackoverflow.com/a/5435890/8114293 | ||
// #define __REQ_SIZE__ sizeof(struct REQUEST) | ||
|
||
// REQUESTS | ||
|
||
// control | ||
|
||
#define __EOF__ 0x00 | ||
#define __REQ_REP__ 0x01 | ||
#define __CMD__ 0x02 | ||
#define __RECEIVED__ 0x03 | ||
#define __DATA_SIZE__ 0x04 | ||
#define __VALUE__ 0x05 | ||
#define __UNRECOGN__ 0x06 | ||
|
||
// value | ||
|
||
#define __ANY__ 0x00 | ||
#define __EXIT__ 0x01 | ||
|
||
#define __PEEK_REG__ 0x11 | ||
|
||
#define __NEXT_SYSCALL__ 0x21 // TODO |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#include "assertion.h" | ||
|
||
void __assertion_failed__(char *file, int line, char *msg, int do_exit) | ||
{ | ||
fprintf(stderr, "ASSERT%s: %s : %i\n", do_exit ? " " : "(soft)", file, line); | ||
if(msg) fprintf(stderr, "MESSAGE%s: %s\n", do_exit ? " " : " ", msg); | ||
if(do_exit) exit(EXIT_FAILURE); | ||
} | ||
|
||
void print_bytes(void *ptr, int size) | ||
{ | ||
unsigned char *p = ptr; | ||
int i; | ||
for (i=0; i<size; i++) { | ||
printf("0x%02hhX ", p[i]); | ||
} | ||
printf("\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#define assert(expr, msg) \ | ||
if (!(expr)) \ | ||
__assertion_failed__(__FILE__, __LINE__, msg, 1) | ||
|
||
#define assert_soft(expr, msg) if(!(expr))__assertion_failed__(__FILE__,__LINE__,msg,0) | ||
|
||
void __assertion_failed__(char *file, int line, char *msg, int do_exit); | ||
|
||
void print_bytes(void *ptr, int size); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#include "functions.h" | ||
|
||
void peek_reg(pid_t pid, int fd) | ||
{ | ||
int err; | ||
REQUEST req; | ||
req.control = __RECEIVED__; | ||
req.value = __ANY__; | ||
write(fd, &req, __REQ_SIZE__); | ||
|
||
err = read(fd, &req, __REQ_SIZE__); | ||
assert(err == __REQ_SIZE__, ""); | ||
|
||
int rax = ptrace(PTRACE_PEEKUSER, pid, req.value, NULL); | ||
|
||
req.control = __VALUE__; | ||
req.value = rax; | ||
write(fd, &req, __REQ_SIZE__); | ||
|
||
printf("> Peek Reg\n"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Functions | ||
* | ||
* every function has the same signature (apart from the name). | ||
* | ||
* void FUNCTION_NAME(pid_t pid, int fd); | ||
* | ||
*/ | ||
|
||
#include "api.h" | ||
#include "khh.h" | ||
|
||
void peek_reg(pid_t pid, int fd); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
#include "khh.h" | ||
#include "functions.h" | ||
|
||
int init_net(); // initialises berkeley socket server | ||
|
||
void init_log(); // closes `stdout` and redirects every output to `stdout` to `log.txt` | ||
|
||
pid_t init_tracee(char* str); // starts and traces tracee | ||
pid_t init_tracee(char *str); // starts and traces tracee | ||
|
||
void debug_loop(pid_t pid, int fd); |
Oops, something went wrong.