华为 HG526 破解实录(一)Cfg文件加解密工具
前些日子去中国电信装了E169套餐,
送了一个华为HG526无线路由猫和
一个中兴xxx型号滴网络机顶盒(还没开始捣鼓),
当然无线路由猫一如既往滴是阉割版。
在搜索一番之后,开始了我滴破解之旅。
1、打开猫滴管理页面,并用telecomadmin和nE7jA%5m登陆;
2、把一个U盘插到猫上
3、打开管理=》设备管理,备份配置
4、打开U盘滴ctce8_hg526.cfg,发现全是乱码。
经过一番分析,
写出一下加解密程序;
1 #include <stdio.h>
2 #include <stdlib.h>
3
4 enum ErrCode
5 {
6 EC_Ok,
7 EC_ArgErr,
8 EC_OptionErr,
9 EC_CantOpenInFile,
10 EC_CantOpenOutFile,
11 };
12
13 enum OpCode
14 {
15 OC_Decode,
16 OC_Encode,
17 };
18
19 int main(int argc, char *argv[])
20 {
21 int r = EC_Ok;
22 FILE *f_in = 0, *f_out = 0;
23
24 do
25 {
26
27 if (argc != 4)
28 {
29 r = EC_ArgErr;
30 break;
31 }
32
33 int op;
34 if (*argv[1] == 'd' || *argv[1] == 'D')
35 {
36 op = OC_Decode;
37 }
38 else if (*argv[1] == 'e' || *argv[1] == 'E')
39 {
40 op = OC_Encode;
41 }
42 else
43 {
44 r = EC_OptionErr;
45 break;
46 }
47
48 f_in = fopen(argv[2], "rb");
49 if (!f_in)
50 {
51 r = EC_CantOpenInFile;
52 break;
53 }
54
55 f_out = fopen(argv[3], "wb");
56 if (!f_out)
57 {
58 r = EC_CantOpenOutFile;
59 break;
60 }
61
62 int buf = 0;
63 switch (op)
64 {
65 case OC_Encode:
66 {
67 while (fread(&buf, 1, 1, f_in))
68 {
69 buf <<= 1;
70 if (buf > 127) buf -= 127;
71 fwrite(&buf, 1, 1, f_out);
72 }
73 }
74 break;
75 case OC_Decode:
76 {
77 while (fread(&buf, 1, 1, f_in))
78 {
79 if (buf & 0x01) buf += 127;
80 buf >>= 1;
81
82 fwrite(&buf, 1, 1, f_out);
83 }
84 }
85 break;
86 }
87 }
88 while(0);
89
90 switch(r)
91 {
92 case EC_Ok:
93 {
94 printf("Convert Ok.\n");
95 }
96 break;
97 case EC_ArgErr:
98 case EC_OptionErr:
99 {
100 printf("Hg526Cfg <d|e> infile outfile\n");
101 }
102 break;
103 case EC_CantOpenInFile:
104 {
105 printf("Can't Open InFile: %s\n", argv[2]);
106 }
107 break;
108 case EC_CantOpenOutFile:
109 {
110 printf("Can't Open OutFile: %s\n", argv[3]);
111 }
112 break;
113 };
114
115 if (f_in) fclose(f_in);
116 if (f_out) fclose(f_out);
117
118 return r;
119 }
2 #include <stdlib.h>
3
4 enum ErrCode
5 {
6 EC_Ok,
7 EC_ArgErr,
8 EC_OptionErr,
9 EC_CantOpenInFile,
10 EC_CantOpenOutFile,
11 };
12
13 enum OpCode
14 {
15 OC_Decode,
16 OC_Encode,
17 };
18
19 int main(int argc, char *argv[])
20 {
21 int r = EC_Ok;
22 FILE *f_in = 0, *f_out = 0;
23
24 do
25 {
26
27 if (argc != 4)
28 {
29 r = EC_ArgErr;
30 break;
31 }
32
33 int op;
34 if (*argv[1] == 'd' || *argv[1] == 'D')
35 {
36 op = OC_Decode;
37 }
38 else if (*argv[1] == 'e' || *argv[1] == 'E')
39 {
40 op = OC_Encode;
41 }
42 else
43 {
44 r = EC_OptionErr;
45 break;
46 }
47
48 f_in = fopen(argv[2], "rb");
49 if (!f_in)
50 {
51 r = EC_CantOpenInFile;
52 break;
53 }
54
55 f_out = fopen(argv[3], "wb");
56 if (!f_out)
57 {
58 r = EC_CantOpenOutFile;
59 break;
60 }
61
62 int buf = 0;
63 switch (op)
64 {
65 case OC_Encode:
66 {
67 while (fread(&buf, 1, 1, f_in))
68 {
69 buf <<= 1;
70 if (buf > 127) buf -= 127;
71 fwrite(&buf, 1, 1, f_out);
72 }
73 }
74 break;
75 case OC_Decode:
76 {
77 while (fread(&buf, 1, 1, f_in))
78 {
79 if (buf & 0x01) buf += 127;
80 buf >>= 1;
81
82 fwrite(&buf, 1, 1, f_out);
83 }
84 }
85 break;
86 }
87 }
88 while(0);
89
90 switch(r)
91 {
92 case EC_Ok:
93 {
94 printf("Convert Ok.\n");
95 }
96 break;
97 case EC_ArgErr:
98 case EC_OptionErr:
99 {
100 printf("Hg526Cfg <d|e> infile outfile\n");
101 }
102 break;
103 case EC_CantOpenInFile:
104 {
105 printf("Can't Open InFile: %s\n", argv[2]);
106 }
107 break;
108 case EC_CantOpenOutFile:
109 {
110 printf("Can't Open OutFile: %s\n", argv[3]);
111 }
112 break;
113 };
114
115 if (f_in) fclose(f_in);
116 if (f_out) fclose(f_out);
117
118 return r;
119 }
可执行程序下载:Hg526Cfg_Release_MT_MaxSpeed
今天晚上就写到里吧,这将是一个系列文章,一步步打造属于自己滴全定制无线猫