forked from alibaba/iOSSecAudit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
847 lines (802 loc) · 34.3 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
#author: june
'''
#from lib.device import *
from lib.taskutil import *
from lib.locaUtil import *
from optparse import OptionParser
from lib.CommandUtil import switch
import lib.globals as G
'''
from smartconsole import *
#import subprocess
#import os
'''
#----------------------------------------------------------------------
def all_in_one(task):
""""""
bundle_id = G.BUNDLE_IDENTIFER
if task is None:
ssh_config = G.SSH_CONFIG
if len(ssh_config) != 5:
G.log(G.ERROR, 'Wrong ssh config!')
return
G.log(G.INFO, '===>Connecting to device...')
#G.log(G.INFO, '===>Connect to device...')
task = TaskUtil(ssh_config[0], ssh_config[1], ssh_config[2], ssh_config[3], ssh_config[4])
if task.device is None:
#G.log(G.ERROR, 'Connect to device failed.')
G.log(G.INFO, 'Connect to device failed.')
return None
if G.CHENV_ENVIROMENT:
task.check_env()
if G.LIST_APPLICATION:
G.log(G.INFO, '===>List all applications...')
task.list_app()
if bundle_id is None:
G.log(G.ERROR, 'bundle identifier is None.')
#print 'ERROR: bundle identifier is None.'
return
if bundle_id is not None:
G.log(G.INFO, '===>Get detail info of app:\'{}\''.format(bundle_id))
task.app_detail_info(bundle_id)
if bundle_id is not None:
G.log(G.INFO, '===>Analyze binary...')
task.analyze_binary(bundle_id)
if bundle_id is not None and G.BINARY_DUMP_PATH is not None:
G.log(G.INFO, '===>Dump binary...')
task.dump_binary(bundle_id, G.BINARY_DUMP_PATH)
if bundle_id is not None and G.IPA_DUMP_PATH is not None:
G.log(G.INFO, '===>Dump ipa...')
task.dump_ipa(bundle_id, G.IPA_DUMP_PATH)
if bundle_id is not None and G.STORAGE_GREP_PATTERNS.count > 0:
print ''
for pattern in G.STORAGE_GREP_PATTERNS:
task.grep_storage_by_pattern(bundle_id, pattern)
task.keychain_grep(pattern)
if bundle_id is not None and G.APP_DIR_SAVE_PATH is not None:
G.log(G.INFO, '===>Downloading application...')
task.download_app_dict(bundle_id, G.APP_DIR_SAVE_PATH)
print ''
if bundle_id is not None and G.APP_STORAGE_SAVE_PATH is not None:
G.log(G.INFO, '===>Downloading application storage...')
task.download_app_storage(bundle_id, G.APP_STORAGE_SAVE_PATH)
'''
def main(args=None):
sh = Shell()
sh.interact()
'''
task = None
cmd = ''
bundle_id = None
while 1:
cmd = raw_input(">>>")
_args = LocalUtils().resolve_cmd(cmd)
if len(_args) < 1:
continue
for case in switch(_args[0]):
if case('h'):
pass
if case('help'):
cmds = []
if len(_args) > 1:
cmds = _args[1:]
LocalUtils().usage(cmds)
break
if case('ssh'):#connect device
#task = TaskUtil(host, user, password, sftp_port)
if len(_args) < 4 or len(_args) > 5:
G.log(G.INFO, G.WRONG_ARGS)
#print 'Wrong args.'
break
host = _args[1]
user = _args[2]
password = _args[3]
sftp_port = 22
if len(_args) == 5:
sftp_port = int(_args[4])
task = TaskUtil(host, user, password, sftp_port, "lan")
if task.device is None:
task = None
break
if case('usb'):#connect device
#task = TaskUtil(host, user, password, sftp_port)
if len(_args) == 4:
user = _args[1]
password = _args[2]
sftp_port = int(_args[3])
elif len(_args) == 3:
user = _args[1]
password = _args[2]
sftp_port = 2222
else:
G.log(G.INFO, G.WRONG_ARGS)
break
host = '127.0.0.1'
task = TaskUtil(host, user, password, sftp_port, "usb")
if task.device is None:
task = None
break
if case('la'):#list application
if task is not None:
task.list_app()
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('sd'):#show app detail
if task is not None:
#com.taobaobj.moneyshield
if len(_args) == 2:
bundle_id = _args[1]
if bundle_id is not None:
task.app_detail_info(bundle_id)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('ab'):#analyze binary
if task is not None:
#task.analyze_binary("com.taobaobj.moneyshield")
if len(_args) == 2:
bundle_id = _args[1]
if bundle_id is not None:
task.analyze_binary(bundle_id)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('las'):#list all starage file
if task is not None:
#task.list_starage_by_bundle_id("com.taobaobj.moneyshield")
if len(_args) == 2:
bundle_id = _args[1]
if bundle_id is not None:
task.list_starage_by_bundle_id(bundle_id)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('vpl'):#view a plist file
if task is not None:
#task.view_plist_by_filename("com.taobaobj.moneyshield", "/moneyshield.app/PlugIns/widget.appex/Info.plist")
if len(_args) == 3:
bundle_id = _args[1]
path = _args[2].decode("utf-8")
elif len(_args) == 2:
path = _args[1].decode("utf-8")
if bundle_id is not None:
task.view_plist_by_filename(bundle_id, path)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('gsp'):#grep pattern in a plist file
if task is not None:
#task.grep_storage_by_pattern("com.taobaobj.moneyshield", "DTSDKName", "/moneyshield.app/PlugIns/widget.appex/Info.plist")
if len(_args) == 4:
bundle_id = _args[1]
pattern = _args[2]
path = _args[3]
elif len(_args) == 3:
pattern = _args[1]
path = _args[2]
if bundle_id is not None:
task.grep_storage_by_pattern(bundle_id, pattern, path)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('gs'):#grep pattern in all storage
if task is not None:
#task.grep_storage_by_pattern("com.taobaobj.moneyshield", "DTSDKName")
if len(_args) == 3:
bundle_id = _args[1]
pattern = _args[2]
elif len(_args) == 2:
pattern = _args[1]
if bundle_id is not None:
task.grep_storage_by_pattern(bundle_id, pattern)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('vdb'):#view all content of a db file
if task is not None:
#task.view_sqlite_by_filename("com.taobaobj.moneyshield", "/Library/introspy-com.taobaobj.moneyshield.db")
if len(_args) == 3:
bundle_id = _args[1]
path = _args[2]
elif len(_args) == 2:
path = _args[1]
if bundle_id is not None:
task.view_sqlite_by_filename(bundle_id, path)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('ltb'):#list tablename in a db file
if task is not None:
#task.list_tablename_by_dbpath("com.taobaobj.moneyshield", "/Library/Caches/com.taobaobj.moneyshield/Cache.db")
if len(_args) == 3:
bundle_id = _args[1]
path = _args[2]
elif len(_args) == 2:
path = _args[1]
if bundle_id is not None:
task.list_tablename_by_dbpath(bundle_id, path)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('vtb'):#view all content in a tablename
if task is not None:
#task.select_all_from_tablename("com.taobaobj.moneyshield", "/Library/Caches/com.taobaobj.moneyshield/Cache.db", "cfurl_cache_response")
if len(_args) == 4:
bundle_id = _args[1]
path = _args[2]
tabname = _args[3]
elif len(_args) == 3:
path = _args[1]
tabname = _args[2]
if bundle_id is not None:
task.select_all_from_tablename(bundle_id, path, tabname)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('gtb'):#grep pattern in a tablename
if task is not None:
#task.grep_pattern_in_tablename(
#"com.taobaobj.moneyshield",
#"/Library/Caches/com.taobaobj.moneyshield/Cache.db",
#"cfurl_cache_response",
#"aliyun")
if len(_args) == 5:
bundle_id = _args[1]
path = _args[2]
tabname = _args[3]
pattern = _args[4]
elif len(_args) == 4:
path = _args[1]
tabname = _args[2]
pattern = _args[3]
else:
G.log(G.INFO, G.WRONG_ARGS)
break
if bundle_id is not None:
task.grep_pattern_in_tablename(bundle_id, path, tabname, pattern)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('gdbs'):#grep pattern in all db file
if task is not None:
#task.grep_pattern_in_sqlite("com.taobaobj.moneyshield", "aliyun")
if len(_args) == 3:
bundle_id = _args[1]
pattern = _args[2]
elif len(_args) == 2:
pattern = _args[1]
if bundle_id is not None:
task.grep_pattern_in_sqlite(bundle_id, pattern)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('gdb'):#grep pattern in a db file
if task is not None:
#task.grep_pattern_in_one_sqlite("com.taobaobj.moneyshield", "aliyun", "/Library/Caches/com.taobaobj.moneyshield/Cache.db")
if len(_args) == 4:
bundle_id = _args[1]
dbpath = _args[2]
pattern = _args[3]
elif len(_args) == 3:
dbpath = _args[1]
pattern = _args[2]
if bundle_id is not None:
task.grep_pattern_in_one_sqlite(bundle_id, pattern, dbpath)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('br'):#binary cookie reader
if task is not None:
#task.read_binary_cookie()
task.read_binary_cookie()
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('abr'):#application binary cookie reader
if task is not None:
#task.read_binary_cookie("com.taobaobj.moneyshield")
if len(_args) == 2:
bundle_id = _args[1]
if bundle_id is not None:
task.read_binary_cookie(bundle_id)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('vkc'):#view keyboard cache
if task is not None:
#task.read_keyboard_cache()
task.read_keyboard_cache()
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('skc'):#search keyboard cache
if task is not None:
#task.read_keyboard_cache("ert")
if len(_args) == 2:
pattern = _args[1]
task.read_keyboard_cache(pattern)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('panic'):#search keyboard cache
if task is not None:
#task.get_panic_log(local_path)
if len(_args) == 2:
local_path = _args[1]
task.get_panic_log(local_path)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('lsl'):#list shared libraries
if task is not None:
#task.get_shared_libraries("com.taobaobj.moneyshield")
if len(_args) == 2:
bundle_id = _args[1]
if bundle_id is not None:
task.get_shared_libraries(bundle_id)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('lbs'):#list binary strings
if task is not None:
#task.get_all_strings("com.taobaobj.moneyshield")
if len(_args) == 2:
bundle_id = _args[1]
if bundle_id is not None:
task.get_all_strings(bundle_id)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('gbs'):#grep pattern in binary strings
if task is not None:
#task.get_all_strings("com.taobaobj.moneyshield", "webkit")
if len(_args) == 3:
bundle_id = _args[1]
pattern = _args[2]
elif len(_args) == 2:
pattern = _args[1]
if bundle_id is not None:
task.get_all_strings(bundle_id, pattern)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('upload'):#upload file to device
if task is not None:
#task.upload_file("/var/root/debugserver", "~/tmp/x.ipa")
if len(_args) == 3:
remote_path = _args[1]
local_path = _args[2]
task.upload_file(local_path, remote_path)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('dnload'):#download file from device
if task is not None:
#task.download_file('~/tmp/Clutch', '/var/root/Clutch1')
if len(_args) == 3:
remote_path = _args[1]
local_path = _args[2]
task.download_file(local_path, remote_path)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('log'):#logging
if task is not None:
#task.logging()
_filter = None
if len(_args) == 2:
_filter = _args[1]
task.logging(_filter)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('wpb'):#watch pasteboard
if task is not None:
#task.watch_pasteboard()
task.watch_pasteboard()
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('kcd'):#keychain dump
if task is not None:
#task.keychain_dump()
task.keychain_dump()
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('kce'):#keychain edit
if task is not None:
#task.keychain_edit("198", "12345678")
#task.keychain_edit("198", "MTIwNzEyMDdsdQ==", True)
base64 = False
if len(_args) == 4:
dataID = _args[1]
newData = _args[2]
if _args[3] == 'base64':
base64 = True
elif len(_args) == 3:
dataID = _args[1]
newData = _args[2]
else:
G.log(G.INFO, G.WRONG_ARGS)
break
task.keychain_edit(dataID, newData, base64)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('kcdel'):#keychain delete
if task is not None:
#task.keychain_delete("62")
if len(_args) == 2:
dataID = _args[1]
task.keychain_delete(dataID)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('kcs'):#keychain search pattern
if task is not None:
#task.keychain_grep("xml")
if len(_args) == 2:
pattern = _args[1]
task.keychain_grep(pattern)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('dbn'):#dump binary
if task is not None:
#task.dump_binary("com.mimimix.tiaomabijia", "~/tmp/xxx")
if len(_args) == 3:
bundle_id = _args[1]
savePath = _args[2]
elif len(_args) == 2:
savePath = _args[1]
else:
G.log(G.INFO, G.WRONG_ARGS)
break
task.dump_binary(bundle_id, savePath)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('dipa'):#dump ipa
if task is not None:
#task.dump_ipa("com.mimimix.tiaomabijia", "~/tmp/")
if len(_args) == 3:
bundle_id = _args[1]
savePath = _args[2]
elif len(_args) == 2:
savePath = _args[1]
else:
G.log(G.INFO, G.WRONG_ARGS)
break
task.dump_ipa(bundle_id, savePath)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('cipa'):#crach all ipa files in a folder
if task is not None:
#task.crack_ipa_inpath('~/tmp/ipas', '~/tmp/dumppath')
if len(_args) == 3:
ipa_path = _args[1]
save_Path = _args[2]
else:
G.log(G.INFO, G.WRONG_ARGS)
break
task.crack_ipa_inpath(ipa_path, save_Path)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('iipa'):#install ipa
if task is not None:
#task.install_ipa("~/.ihack/C7E834A6-19DC-4A73-AC88-14B89F3D8620/com.mimimix.tiaomabijia.ipa")
if len(_args) == 2:
path = _args[1]
task.install_ipa(path)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('lapp'):#launch application
if task is not None:
#task.launch_app("com.mimimix.tiaomabijia")
if len(_args) == 2:
bundle_id = _args[1]
if bundle_id is not None:
task.launch_app(bundle_id)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('ibca'):#install burp cert
if task is not None:
task.install_burp_cert()
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('lca'):#list all certs
if task is not None:
task.list_all_certs()
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('dca'):#delete ca cert
if task is not None:
#task.delete_cert_by_id("1")
if len(_args) == 2:
cert_id = _args[1]
task.delete_cert_by_id(cert_id)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('aca'):#import cert to device
if task is not None:
#task.add_cert_by_path("/Users/june/Downloads/cacert.der")
if len(_args) == 2:
cert_path = _args[1]
task.add_cert_by_path(cert_path)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('pca'):#export cert to device
if task is not None:
#task.export_cert('/Users/june/tmp/cert')
if len(_args) == 2:
path = _args[1]
task.export_cert(path)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('fus'):#fuzz url scheme
if task is not None:
#task.fuzz_url_schema("com.taobaobj.moneyshield", 'qiandun://?token=%*%®istered=%*%')
if len(_args) == 3:
bundle_id = _args[1]
template = _args[2]
elif len(_args) == 2:
template = _args[1]
if bundle_id is not None:
task.fuzz_url_schema(bundle_id, template)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('chenv'):#check enviroment
#check enviroment
if task is not None:
task.check_env()
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('nonfat'):#parse Fat header file to non-Fat
#non fat
_output = None
if len(_args) == 3:
_output = _args[2]
_input = _args[1]
elif len(_args) == 2:
_input = _args[1]
else:
G.log(G.INFO, G.WRONG_ARGS)
break
LocalUtils().nonFat(_input, _output)
break
if case('mport'):#mapping local port to remote port
#LocalUtils().mapping_port(12346, 12346)
_output = None
if len(_args) == 3:
local_port = int(_args[2])
remote_port = int(_args[1])
else:
G.log(G.INFO, G.WRONG_ARGS)
break
LocalUtils().mapping_port(remote_port, local_port)
break
if case('dwa'):#download whole application
if task is not None:
#task.download_app_dict('com.taobaobj.moneyshield', '~/tmp')
if len(_args) == 3:
bundle_id = _args[1]
dest_dict = _args[2]
elif len(_args) == 2:
dest_dict = _args[1]
if bundle_id is not None:
task.download_app_dict(bundle_id, dest_dict)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('dws'):#download whole application storage
if task is not None:
#task.download_app_storage('com.taobaobj.moneyshield', '~/tmp')
if len(_args) == 3:
bundle_id = _args[1]
dest_dict = _args[2]
elif len(_args) == 2:
dest_dict = _args[1]
if bundle_id is not None:
task.download_app_storage(bundle_id, dest_dict)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('pid'):#get pid
if task is not None:
#task.get_pid_by_bundle_id('com.fotoable.pipcam')
if len(_args) == 2:
bundle_id = _args[1]
if bundle_id is not None:
task.get_pid_by_bundle_id(bundle_id)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('dbgsvr'):#debugserver on a process, waiting for debugger
if task is not None:
#task.debugserver('com.fotoable.pipcam')
if len(_args) == 2:
bundle_id = _args[1]
if bundle_id is not None:
task.debugserver(bundle_id)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('clzdp'):#class-dump
if task is not None:
#task.clzdp('cn.xiaochuankeji.tieba', '~/tmp/')
if len(_args) == 3:
bundle_id = _args[1]
save_path = _args[2]
elif len(_args) == 2:
save_path = _args[1]
if bundle_id is not None:
task.clzdp(bundle_id, save_path)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('stop'):#stop thread
if task is not None:
#task.stop_thread_by_key(key)
if len(_args) == 2:
key = _args[1]
task.stop_thread_by_key(key)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('wclzdp'):#weak_classdump
if task is not None:
#task.weak_classdump('cn.xiaochuankeji.tieba', '~/tmp/')
if len(_args) == 3:
bundle_id = _args[1]
save_path = _args[2]
elif len(_args) == 2:
save_path = _args[1]
if bundle_id is not None:
task.weak_classdump(bundle_id, save_path)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('cycript'):#run cycript file on the remote device inside an application
if task is not None:
#task.cycript_file('cn.xiaochuankeji.tieba', '~/tmp/test.cy')
if len(_args) == 3:
bundle_id = _args[1]
cy_file = _args[2]
elif len(_args) == 2:
cy_file = _args[1]
if bundle_id is not None:
task.cycript_file(bundle_id, cy_file)
else:
G.log(G.INFO, G.WRONG_ARGS)
break
G.log(G.INFO, G.CONNECT_DEVICE_FIRST)
break
if case('go'):#lazy is good.
all_in_one(task)
break
if case('clche'):#clear local cache files
task.clear_cache()
break
if case('e'):#quit
pass
if case('exit'):#quit
pass
if case('q'):#quit
pass
if case('quit'):#quit
G.log(G.INFO, 'Exit safely.')
if task is not None:
task.exit_safely()
exit(0)
break
if case('cprt'):#copyright
G.copyright()
break
if case(): # default, could also just omit condition or 'if True'
G.log(G.INFO, "Command not support!")
G.log(G.INFO, "Try \"help\".")
'''
if __name__ == '__main__':
print "\n",
print "#**********************************************************************************************#"
print "# #"
print "# iOS Security Audit Toolkit %s #" % (G.VERSION_CODE)
print "# #"
print "# Alibaba YunOS System Security #"
print "# %s #" % (G.AUTHOR_MAIL)
print "# #"
print "#**********************************************************************************************#\n"
print "Type \"help\", \"cprt\" for more information."
'''
parser = OptionParser()
parser.add_option("-f", "--file", dest="filename",
help="write report to FILE", metavar="FILE")
parser.add_option("-q", "--quiet",
action="store_false", dest="verbose", default=True,
help="don't print status messages to stdout")
(options, args) = parser.parse_args()
'''
main()