-
Notifications
You must be signed in to change notification settings - Fork 3
/
partitioncopyroot.c
executable file
·59 lines (47 loc) · 2.15 KB
/
partitioncopyroot.c
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
#include "partitioncopyroot.h"
int partitionCopyAuto(char *targetPartition){
char command[512] = "\0";
//forward the android tcp to host tcp
system("adb forward tcp:8175 tcp:8175");
//run adb shell, dd the selected partition and pipe
//the output to netcat 8175
strcpy(command, "xterm -e 'echo Sending Data && ");
strcat(command, "adb shell su -c \"\"dd if=/dev/block/");
strcat(command, targetPartition);
strcat(command, " | nc -l -p 8175\"\"' && ");
//close android forward and kill netcat
strcat(command, "pgrep -x nc | xargs kill -SIGINT && ");
strcat(command, "adb forward --remove-all & ");
//run netcat and save device partition to deviceImage.img
strcat(command, "sleep 5 && xterm -e 'echo Receiving Data && ");
strcat(command, "nc localhost 8175 > deviceImage.img'");
// printf("%s\n", command);
system(command);
printf("Done! Press enter to continue\n");
return 0;
}
int partitionCopyManual(char *targetPartition){
char command1[256] = "\0";
char command2[256] = "\0";
//forward the android tcp to host tcp
strcpy(command1, " adb forward tcp:8175 tcp:8175\n");
//run adb shell, dd the selected partition and pipe
//the output to netcat 8175
strcat(command1, " adb shell su -c \"\"dd if=/dev/block/");
strcat(command1, targetPartition);
strcat(command1, " | nc -l -p 8175\"\" ");
// strcat(command, "&& pgrep -x nc | xargs kill -SIGINT");
//run netcat and save device partition to deviceImage.img
strcat(command2, " nc localhost 8175 > deviceImage.img");
printf("\nOpen new terminal window and enter the command below\n");
printf("%s\n\n", command1);
printf("If you get 'nc: Address already in use', turn airplane mode\n");
printf("on or off. Then repeat 'adb shell su' command\n");
printf("\nThen open another terminal window and enter the command below\n");
printf("%s\n\n", command2);
printf("Check your working directory\n");
printf("if 'deviceImage.img' file stop increase in size\n");
printf("it is likely that clone process is complete\n\n");
printf("Done! Press enter to continue\n");
return 0;
}