diff options
| author | 2024-11-15 00:18:05 +0100 | |
|---|---|---|
| committer | 2024-11-15 00:18:05 +0100 | |
| commit | ba829e6f1a62bdad7866572d1e2cff1836ced742 (patch) | |
| tree | 5c4b23e376c90a664fe7089998e0a3e3c19a2552 | |
| parent | 5aebbc0c694d1048712505195c32a17c3091d417 (diff) | |
| download | libimobiledevice-ba829e6f1a62bdad7866572d1e2cff1836ced742.tar.gz libimobiledevice-ba829e6f1a62bdad7866572d1e2cff1836ced742.tar.bz2 | |
tools: Add --insecure option to idevicenotificationproxy tool
| -rw-r--r-- | docs/idevicenotificationproxy.1 | 15 | ||||
| -rw-r--r-- | tools/idevicenotificationproxy.c | 22 |
2 files changed, 27 insertions, 10 deletions
diff --git a/docs/idevicenotificationproxy.1 b/docs/idevicenotificationproxy.1 index 56dd0b0..627ee5d 100644 --- a/docs/idevicenotificationproxy.1 +++ b/docs/idevicenotificationproxy.1 | |||
| @@ -12,19 +12,22 @@ Post or observe notifications on an iOS device from the command line. | |||
| 12 | .SH OPTIONS | 12 | .SH OPTIONS |
| 13 | .TP | 13 | .TP |
| 14 | .B \-u, \-\-udid UDID | 14 | .B \-u, \-\-udid UDID |
| 15 | target specific device by UDID. | 15 | Target specific device by UDID. |
| 16 | .TP | ||
| 17 | .B \-i, \-\-insecure | ||
| 18 | Connect to insecure notification proxy (for non-paired devices). | ||
| 16 | .TP | 19 | .TP |
| 17 | .B \-n, \-\-network | 20 | .B \-n, \-\-network |
| 18 | connect to network device. | 21 | Connect to network device. |
| 19 | .TP | 22 | .TP |
| 20 | .B \-d, \-\-debug | 23 | .B \-d, \-\-debug |
| 21 | enable communication debugging. | 24 | Enable communication debugging. |
| 22 | .TP | 25 | .TP |
| 23 | .B \-h, \-\-help | 26 | .B \-h, \-\-help |
| 24 | prints usage information. | 27 | Prints usage information. |
| 25 | .TP | 28 | .TP |
| 26 | .B \-v, \-\-version | 29 | .B \-v, \-\-version |
| 27 | prints version information. | 30 | Prints version information. |
| 28 | 31 | ||
| 29 | .SH COMMANDS | 32 | .SH COMMANDS |
| 30 | .TP | 33 | .TP |
| @@ -38,6 +41,8 @@ observe notification IDs in the foreground until CTRL+C or signal is received. | |||
| 38 | 41 | ||
| 39 | Martin Szulecki | 42 | Martin Szulecki |
| 40 | 43 | ||
| 44 | Nikias Bassen | ||
| 45 | |||
| 41 | .SH ON THE WEB | 46 | .SH ON THE WEB |
| 42 | https://libimobiledevice.org | 47 | https://libimobiledevice.org |
| 43 | 48 | ||
diff --git a/tools/idevicenotificationproxy.c b/tools/idevicenotificationproxy.c index d1e25c1..00da916 100644 --- a/tools/idevicenotificationproxy.c +++ b/tools/idevicenotificationproxy.c | |||
| @@ -2,7 +2,8 @@ | |||
| 2 | * idevicenotificationproxy.c | 2 | * idevicenotificationproxy.c |
| 3 | * Simple client for the notification_proxy service | 3 | * Simple client for the notification_proxy service |
| 4 | * | 4 | * |
| 5 | * Copyright (c) 2009-2015 Martin Szulecki All Rights Reserved. | 5 | * Copyright (c) 2018-2024 Nikias Bassen, All Rights Reserved. |
| 6 | * Copyright (c) 2009-2015 Martin Szulecki, All Rights Reserved. | ||
| 6 | * | 7 | * |
| 7 | * This library is free software; you can redistribute it and/or | 8 | * This library is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU Lesser General Public | 9 | * modify it under the terms of the GNU Lesser General Public |
| @@ -75,6 +76,7 @@ static void print_usage(int argc, char **argv, int is_error) | |||
| 75 | "\n" | 76 | "\n" |
| 76 | "The following OPTIONS are accepted:\n" | 77 | "The following OPTIONS are accepted:\n" |
| 77 | " -u, --udid UDID target specific device by UDID\n" | 78 | " -u, --udid UDID target specific device by UDID\n" |
| 79 | " -i, --insecure use insecure notification proxy (non-paired device)\n" | ||
| 78 | " -n, --network connect to network device\n" | 80 | " -n, --network connect to network device\n" |
| 79 | " -d, --debug enable communication debugging\n" | 81 | " -d, --debug enable communication debugging\n" |
| 80 | " -h, --help prints usage information\n" | 82 | " -h, --help prints usage information\n" |
| @@ -102,6 +104,7 @@ int main(int argc, char *argv[]) | |||
| 102 | int i = 0; | 104 | int i = 0; |
| 103 | const char* udid = NULL; | 105 | const char* udid = NULL; |
| 104 | int use_network = 0; | 106 | int use_network = 0; |
| 107 | int insecure = 0; | ||
| 105 | int cmd = CMD_NONE; | 108 | int cmd = CMD_NONE; |
| 106 | char* cmd_arg = NULL; | 109 | char* cmd_arg = NULL; |
| 107 | 110 | ||
| @@ -114,6 +117,7 @@ int main(int argc, char *argv[]) | |||
| 114 | { "debug", no_argument, NULL, 'd' }, | 117 | { "debug", no_argument, NULL, 'd' }, |
| 115 | { "help", no_argument, NULL, 'h' }, | 118 | { "help", no_argument, NULL, 'h' }, |
| 116 | { "udid", required_argument, NULL, 'u' }, | 119 | { "udid", required_argument, NULL, 'u' }, |
| 120 | { "insecure", no_argument, NULL, 'i' }, | ||
| 117 | { "network", no_argument, NULL, 'n' }, | 121 | { "network", no_argument, NULL, 'n' }, |
| 118 | { "version", no_argument, NULL, 'v' }, | 122 | { "version", no_argument, NULL, 'v' }, |
| 119 | { NULL, 0, NULL, 0} | 123 | { NULL, 0, NULL, 0} |
| @@ -127,7 +131,7 @@ int main(int argc, char *argv[]) | |||
| 127 | #endif | 131 | #endif |
| 128 | 132 | ||
| 129 | /* parse cmdline args */ | 133 | /* parse cmdline args */ |
| 130 | while ((c = getopt_long(argc, argv, "dhu:nv", longopts, NULL)) != -1) { | 134 | while ((c = getopt_long(argc, argv, "dhu:inv", longopts, NULL)) != -1) { |
| 131 | switch (c) { | 135 | switch (c) { |
| 132 | case 'd': | 136 | case 'd': |
| 133 | idevice_set_debug_level(1); | 137 | idevice_set_debug_level(1); |
| @@ -143,6 +147,9 @@ int main(int argc, char *argv[]) | |||
| 143 | case 'n': | 147 | case 'n': |
| 144 | use_network = 1; | 148 | use_network = 1; |
| 145 | break; | 149 | break; |
| 150 | case 'i': | ||
| 151 | insecure = 1; | ||
| 152 | break; | ||
| 146 | case 'h': | 153 | case 'h': |
| 147 | print_usage(argc, argv, 0); | 154 | print_usage(argc, argv, 0); |
| 148 | return 0; | 155 | return 0; |
| @@ -214,12 +221,17 @@ int main(int argc, char *argv[]) | |||
| 214 | goto cleanup; | 221 | goto cleanup; |
| 215 | } | 222 | } |
| 216 | 223 | ||
| 217 | if (LOCKDOWN_E_SUCCESS != (ret = lockdownd_client_new_with_handshake(device, &client, TOOL_NAME))) { | 224 | if (insecure) { |
| 218 | fprintf(stderr, "ERROR: Could not connect to lockdownd, error code %d\n", ret); | 225 | ret = lockdownd_client_new(device, &client, TOOL_NAME); |
| 226 | } else { | ||
| 227 | ret = lockdownd_client_new_with_handshake(device, &client, TOOL_NAME); | ||
| 228 | } | ||
| 229 | if (LOCKDOWN_E_SUCCESS != ret) { | ||
| 230 | fprintf(stderr, "ERROR: Could not connect to lockdownd: %s (%d)\n", lockdownd_strerror(ret), ret); | ||
| 219 | goto cleanup; | 231 | goto cleanup; |
| 220 | } | 232 | } |
| 221 | 233 | ||
| 222 | ret = lockdownd_start_service(client, NP_SERVICE_NAME, &service); | 234 | ret = lockdownd_start_service(client, (insecure) ? "com.apple.mobile.insecure_notification_proxy" : NP_SERVICE_NAME, &service); |
| 223 | 235 | ||
| 224 | lockdownd_client_free(client); | 236 | lockdownd_client_free(client); |
| 225 | 237 | ||
