From c2249545efe5451f25e08fbc57e19b9c91a855c5 Mon Sep 17 00:00:00 2001 From: Joshua Hill Date: Wed, 16 Jun 2010 03:38:47 -0400 Subject: Changed debug variable to be a static global variable to allow set once always enabled style debug flag Added -e flag to load and execute a premade script file along with a sample script --- src/irecovery.c | 42 ++++++++++++---- src/libirecovery.c | 142 +++++++++++++++++++++++++++++++++++++++++++---------- 2 files changed, 149 insertions(+), 35 deletions(-) (limited to 'src') diff --git a/src/irecovery.c b/src/irecovery.c index baae17e..c282cda 100644 --- a/src/irecovery.c +++ b/src/irecovery.c @@ -27,13 +27,13 @@ #define debug(...) if(verbose) fprintf(stderr, __VA_ARGS__) enum { - kResetDevice, kStartShell, kSendCommand, kSendFile, kSendExploit + kResetDevice, kStartShell, kSendCommand, kSendFile, kSendExploit, kSendScript }; static unsigned int quit = 0; static unsigned int verbose = 0; -void print_progress_bar(const char* operation, double progress); +void print_progress_bar(double progress); int received_cb(irecv_client_t client, const irecv_event_t* event); int progress_cb(irecv_client_t client, const irecv_event_t* event); int precommand_cb(irecv_client_t client, const irecv_event_t* event); @@ -61,7 +61,7 @@ void parse_command(irecv_client_t client, unsigned char* command, unsigned int s if (!strcmp(cmd, "/upload")) { char* filename = strtok(NULL, " "); - debug("Sending %s\n", filename); + debug("Uploading files %s\n", filename); if (filename != NULL) { irecv_send_file(client, filename); } @@ -69,12 +69,21 @@ void parse_command(irecv_client_t client, unsigned char* command, unsigned int s if (!strcmp(cmd, "/exploit")) { char* filename = strtok(NULL, " "); - debug("Sending %s\n", filename); + debug("Sending exploit %s\n", filename); if (filename != NULL) { irecv_send_file(client, filename); } irecv_send_exploit(client); - } + } else + + if (!strcmp(cmd, "/execute")) { + char* filename = strtok(NULL, " "); + debug("Executing script %s\n", filename); + if (filename != NULL) { + irecv_execute_script(client, filename); + } + } + free(action); } @@ -171,12 +180,12 @@ int postcommand_cb(irecv_client_t client, const irecv_event_t* event) { int progress_cb(irecv_client_t client, const irecv_event_t* event) { if (event->type == IRECV_PROGRESS) { - print_progress_bar(event->data, event->progress); + print_progress_bar(event->progress); } return 0; } -void print_progress_bar(const char* operation, double progress) { +void print_progress_bar(double progress) { int i = 0; if(progress < 0) { return; @@ -186,7 +195,7 @@ void print_progress_bar(const char* operation, double progress) { progress = 100; } - printf("\r%s [", operation); + printf("\r["); for(i = 0; i < 50; i++) { if(i < progress / 2) { printf("="); @@ -212,6 +221,7 @@ void print_usage() { printf("\t-h\t\tShow this help.\n"); printf("\t-r\t\tReset client.\n"); printf("\t-s\t\tStart interactive shell.\n"); + printf("\t-e