Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added single-command support.

  • Loading branch information...
commit 829e98eb0752ece6172efaf3619aac3257b7fc32 1 parent 5f537b7
Nicolas Haunold authored

Showing 2 changed files with 33 additions and 4 deletions. Show diff stats Hide diff stats

  1. +7 4 README
  2. +26 0 irecovery.c
11 README
@@ -5,10 +5,13 @@ iRecovery is a libusb-based commandline utility for Mac OS X and Linux (perhaps
5 5 It's completely open-source, the source-code is released under the terms of the GNU General Public License version 3.
6 6 The full license text can be found in the LICENSE file.
7 7
  8 +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).
  9 +
8 10 == Usage ==
9 11
10   - ./iRecovery -s starts a shell.
11   - ./iRecovery -r usb reset.
12   - ./iRecovery -f <file> uploads a file.
  12 + ./iRecovery -s starts a shell.
  13 + ./iRecovery -r usb reset.
  14 + ./iRecovery -f <file> uploads a file.
  15 + ./iRecovery -c "command" send a single command.
  16 +
13 17
14   -
26 irecovery.c
@@ -242,10 +242,34 @@ void irecv_console() {
242 242 irecv_close(devPhone);
243 243 }
244 244
  245 +void irecv_sendcmd(char *cmd) {
  246 + int length;
  247 + char *sendbuf;
  248 + irecv_init(RECV_MODE);
  249 +
  250 + if(devPhone == 0) {
  251 + printf("No iPhone/iPod found.\n");
  252 + exit(EXIT_FAILURE);
  253 + }
  254 +
  255 + sendbuf = malloc(160);
  256 +
  257 + length = (int)(((strlen(cmd)-1)/0x10)+1)*0x10;
  258 + memset(sendbuf, 0, length);
  259 + memcpy(sendbuf, cmd, strlen(cmd));
  260 + if(!usb_control_msg(devPhone, 0x40, 0, 0, 0, sendbuf, length, 1000)) {
  261 + printf("[!] %s", usb_strerror());
  262 + }
  263 +
  264 + free(sendbuf);
  265 + irecv_close(devPhone);
  266 +}
  267 +
245 268 int irecv_usage(void) {
246 269 printf("./iRecovery [args]\n");
247 270 printf("\t-f <file>\t\tupload file.\n");
248 271 printf("\t-r\t\t\treset usb.\n");
  272 + printf("\t-c \"command\"\t\tsends a single command.\n");
249 273 printf("\t-s\t\t\tstarts a shell.\n\n");
250 274 }
251 275
@@ -269,6 +293,8 @@ int main(int argc, char *argv[]) {
269 293 }
270 294
271 295 irecv_sendfile(argv[2]);
  296 + } else if(strcmp(argv[1], "-c") == 0) {
  297 + irecv_sendcmd(argv[2]);
272 298 } else if(strcmp(argv[1], "-s") == 0) {
273 299 irecv_console();
274 300 } else if(strcmp(argv[1], "-r") == 0) {

0 comments on commit 829e98e

Please sign in to comment.
Something went wrong with that request. Please try again.