Permalink
Browse files

added single-command support.

  • Loading branch information...
1 parent 5f537b7 commit 829e98eb0752ece6172efaf3619aac3257b7fc32 @westbaer committed Apr 24, 2009
Showing with 33 additions and 4 deletions.
  1. +7 −4 README
  2. +26 −0 irecovery.c
View
11 README
@@ -5,10 +5,13 @@ iRecovery is a libusb-based commandline utility for Mac OS X and Linux (perhaps
It's completely open-source, the source-code is released under the terms of the GNU General Public License version 3.
The full license text can be found in the LICENSE file.
+It currently connects to 0x1281 (iPhone, iPhone 3G, iPod touch, iPod touch 2G: Recovery Mode/iBSS), 0x1227 (iPhone, iPhone 3G, iPod touch: WTF Mode; iPod touch 2G: DFU Mode).
+
== Usage ==
- ./iRecovery -s starts a shell.
- ./iRecovery -r usb reset.
- ./iRecovery -f <file> uploads a file.
+ ./iRecovery -s starts a shell.
+ ./iRecovery -r usb reset.
+ ./iRecovery -f <file> uploads a file.
+ ./iRecovery -c "command" send a single command.
+
-
View
@@ -242,10 +242,34 @@ void irecv_console() {
irecv_close(devPhone);
}
+void irecv_sendcmd(char *cmd) {
+ int length;
+ char *sendbuf;
+ irecv_init(RECV_MODE);
+
+ if(devPhone == 0) {
+ printf("No iPhone/iPod found.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ sendbuf = malloc(160);
+
+ length = (int)(((strlen(cmd)-1)/0x10)+1)*0x10;
+ memset(sendbuf, 0, length);
+ memcpy(sendbuf, cmd, strlen(cmd));
+ if(!usb_control_msg(devPhone, 0x40, 0, 0, 0, sendbuf, length, 1000)) {
+ printf("[!] %s", usb_strerror());
+ }
+
+ free(sendbuf);
+ irecv_close(devPhone);
+}
+
int irecv_usage(void) {
printf("./iRecovery [args]\n");
printf("\t-f <file>\t\tupload file.\n");
printf("\t-r\t\t\treset usb.\n");
+ printf("\t-c \"command\"\t\tsends a single command.\n");
printf("\t-s\t\t\tstarts a shell.\n\n");
}
@@ -269,6 +293,8 @@ int main(int argc, char *argv[]) {
}
irecv_sendfile(argv[2]);
+ } else if(strcmp(argv[1], "-c") == 0) {
+ irecv_sendcmd(argv[2]);
} else if(strcmp(argv[1], "-s") == 0) {
irecv_console();
} else if(strcmp(argv[1], "-r") == 0) {

0 comments on commit 829e98e

Please sign in to comment.