• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

system/corennnnn


Commit MetaInfo

修订版ae54f1fba842ddd55b65a428333f0cec62a66fc0 (tree)
时间2009-05-09 12:30:47
作者Jack Palevich <jackpal@goog...>
CommiterJack Palevich

Log Message

Continue deobfuscation.

Add a license.

Indent the code.
Add includes for external functions.
Improve function prototypes.
Start adding the correct type to things that are pointers.
Start fixing compiler warnings.

Instead of directly executing the compiled code (which only works on x86 Linux),
write the internal compiler state to stdout. This makes it easier to test whether
or not our refactoring is breaking anything.

Return a zero status on success.

Add error checking for a missing input file.

更改概述

差异

--- a/libacc/acc.c
+++ b/libacc/acc.c
@@ -1,430 +1,495 @@
1+/*
2+ **
3+ ** Copyright 2009, The Android Open Source Project
4+ **
5+ ** Licensed under the Apache License, Version 2.0 (the "License");
6+ ** you may not use this file except in compliance with the License.
7+ ** You may obtain a copy of the License at
8+ **
9+ ** http://www.apache.org/licenses/LICENSE-2.0
10+ **
11+ ** Unless required by applicable law or agreed to in writing, software
12+ ** distributed under the License is distributed on an "AS IS" BASIS,
13+ ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ ** See the License for the specific language governing permissions and
15+ ** limitations under the License.
16+ */
17+
18+/* Based upon the freeware version of the Obfuscated Tiny C Compiler
19+ * by Francis Bellard.
20+ */
21+
122 #include <stdio.h>
23+#include <stdlib.h>
24+#include <string.h>
225
3-int d,z,C,h,P,K,ac,q,G,v,Q,R,D,L,W,M;
4-E(e){
5-*(char*) D++=e;
6-}
7-o (){
8-if( L){
9-h=*(char*) L++;
10-if( h == 2){
11-L=0;
12-h=W;
13-}
14-}
15-else h=fgetc(Q);
16-}
17-X (){
18-return isalnum(h)|h == 95;
19-}
20-Y (){
21-if( h == 92){
22-o ();
23-if( h == 110)h=10;
24-}
25-}
26-ad(){
27-int e,j,m;
28-while( isspace(h)|h == 35){
29-if( h == 35){
30-o ();
31-ad();
32-if( d == 536){
33-ad();
34-E(32);
35-*(int*) d=1;
36-*(int*)(d +4)=D;
37-}
38-while( h!=10){
39-E(h);
40-o ();
41-}
42-E(h);
43-E(2);
44-}
45-o ();
46-}
47-C=0;
48-d=h;
49-if( X ()){
50-E(32);
51-M=D;
52-while( X ()){
53-E(h);
54-o ();
55-}
56-if( isdigit(d)){
57-z=strtol(M,0,0);
58-d=2;
59-}
60-else{
61-*(char*) D=32;
62-d=strstr(R,M-1)-R;
63-*(char*) D=0;
64-d=d*8+256;
65-if( d>536){
66-d=P+d;
67-if( *(int*) d == 1){
68-L=*(int*)(d +4);
69-W=h;
70-o ();
71-ad();
72-}
73-}
74-}
75-}
76-else{
77-o ();
78-if( d == 39){
79-d=2;
80-Y ();
81-z=h;
82-o ();
83-o ();
84-}
85-else if( d == 47&h == 42){
86-o ();
87-while( h){
88-while( h!=42)o ();
89-o ();
90-if( h == 47)h=0;
91-}
92-o ();
93-ad();
94-}
95-else{
96-e="++#m--%am*@R<^1c/@%[_[H3c%@%[_[H3c+@.B#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!='g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b";
97-while( j=*(char*) e++){
98-m= *(char*) e++;
99-z=0;
100-while((C=*(char*) e++-98)<0)z=z*64+C+64;
101-if( j == d&(m == h|m == 64)){
102-if( m == h){
103-o ();
104-d=1;
105-}
106-break;
107-}
108-}
109-}
110-}
111-}
112-ae( g){
113-while( g&&g!=-1){
114-*(char*) q++=g;
115-g=g>>8;
116-}
117-}
118-A(e){
119-int g;
120-while( e){
121-g=*(int*) e;
122-*(int*) e=q-e-4;
123-e=g;
124-}
125-}
126-s(g,e){
127-ae( g);
128-*(int*) q=e;
129-e=q;
130-q=q +4;
131-return e;
132-}
133-H(e){
134-s(184,e);
135-}
136-B(e){
137-return s(233,e);
138-}
139-S(j,e){
140-ae( 1032325);
141-return s(132+j,e);
142-}
143-Z(e){
144-ae( 49465);
145-H(0);
146-ae( 15);
147-ae( e+144);
148-ae( 192);
149-}
150-N(j,e){
151-ae( j+131);
152-s((e<512)<<7|5,e);
153-}
154-T (j){
155-int g,e,m,aa;
156-g=1;
157-if( d == 34){
158-H(v);
159-while( h!=34){
160-Y ();
161-*(char*) v++=h;
162-o ();
163-}
164-*(char*) v=0;
165-v=v +4&-4;
166-o ();
167-ad();
168-}
169-else{
170-aa=C;
171-m= z;
172-e=d;
173-ad();
174-if( e == 2){
175-H(m);
176-}
177-else if( aa == 2){
178-T(0);
179-s(185,0);
180-if( e == 33)Z(m);
181-else ae( m);
182-}
183-else if( e == 40){
184-w ();
185-ad();
186-}
187-else if( e == 42){
188-ad();
189-e=d;
190-ad();
191-ad();
192-if( d == 42){
193-ad();
194-ad();
195-ad();
196-ad();
197-e=0;
198-}
199-ad();
200-T(0);
201-if( d == 61){
202-ad();
203-ae( 80);
204-w ();
205-ae( 89);
206-ae( 392+(e == 256));
207-}
208-else if( e){
209-if( e == 256)ae( 139);
210-else ae( 48655);
211-q++;
212-}
213-}
214-else if( e == 38){
215-N(10,*(int*) d);
216-ad();
217-}
218-else{
219-g=*(int*) e;
220-if(!g)g=dlsym(0,M);
221-if( d == 61&j){
222-ad();
223-w ();
224-N(6,g);
225-}
226-else if( d!= 40){
227-N(8,g);
228-if( C == 11){
229-N(0,g);
230-ae( z);
231-ad();
232-}
233-}
234-}
235-}
236-if( d == 40){
237-if( g == 1)ae( 80);
238-m= s(60545,0);
239-ad();
240-j=0;
241-while( d!= 41){
242-w ();
243-s(2393225,j);
244-if( d == 44)ad();
245-j=j +4;
246-}
247-*(int*) m= j;
248-ad();
249-if(!g){
250-e=e +4;
251-*(int*) e=s(232,*(int*) e);
252-}
253-else if( g == 1){
254-s(2397439,j);
255-j=j +4;
256-}
257-else{
258-s(232,g-q-5);
259-}
260-if( j)s(50305,j);
261-}
262-}
263-O (j){
264-int e,g,m;
265-if( j--== 1)T(1);
266-else{
267-O (j);
268-m= 0;
269-while( j == C){
270-g=d;
271-e=z;
272-ad();
273-if( j>8){
274-m= S(e,m);
275-O (j);
276-}
277-else{
278-ae( 80);
279-O (j);
280-ae( 89);
281-if( j == 4|j == 5){
282-Z(e);
283-}
284-else{
285-ae( e);
286-if( g == 37)ae( 146);
287-}
288-}
289-}
290-if( m&&j>8){
291-m= S(e,m);
292-H(e^1);
293-B(5);
294-A(m);
295-H(e);
296-}
297-}
298-}
299-w (){
300-O(11);
301-}
302-U (){
303-w ();
304-return S(0,0);
305-}
306-I (j){
307-int m,g,e;
308-if( d == 288){
309-ad();
310-ad();
311-m= U ();
312-ad();
313-I (j);
314-if( d == 312){
315-ad();
316-g=B(0);
317-A(m);
318-I (j);
319-A(g);
320-}
321-else{
322-A(m);
323-}
26+int d, z, C, h, P, K, q, G, L, W;
27+char* ac;
28+char* v;
29+char* D;
30+char* M;
31+char* R;
32+FILE* Q;
33+
34+void ab (int j);
35+void w();
36+
37+void E(e) {
38+ *(char*) D++=e;
32439 }
325-else if( d == 352|d == 504){
326-e=d;
327-ad();
328-ad();
329-if( e == 352){
330-g=q;
331-m= U ();
40+
41+o() {
42+ if (L) {
43+ h = *(char*) L++;
44+ if (h == 2) {
45+ L = 0;
46+ h = W;
47+ }
48+ } else
49+ h = fgetc(Q);
33250 }
333-else{
334-if( d!= 59)w ();
335-ad();
336-g=q;
337-m= 0;
338-if( d!= 59)m= U ();
339-ad();
340-if( d!= 41){
341-e=B(0);
342-w ();
343-B(g-q-5);
344-A(e);
345-g=e +4;
51+
52+X() {
53+ return isalnum(h) | h == 95;
34654 }
55+
56+Y() {
57+ if (h == 92) {
58+ o();
59+ if (h == 110)
60+ h = 10;
61+ }
34762 }
348-ad();
349-I(&m);
350-B(g-q-5);
351-A(m);
63+
64+void ad() {
65+ int j, m;
66+ while (isspace(h) | h == 35) {
67+ if (h == 35) {
68+ o();
69+ ad();
70+ if (d == 536) {
71+ ad();
72+ E(32);
73+ *(int*) d = 1;
74+ *(int*) (d + 4) = (int) D;
75+ }
76+ while (h != 10) {
77+ E(h);
78+ o();
79+ }
80+ E(h);
81+ E(2);
82+ }
83+ o();
84+ }
85+ C = 0;
86+ d = h;
87+ if (X()) {
88+ E(32);
89+ M = D;
90+ while (X()) {
91+ E(h);
92+ o();
93+ }
94+ if (isdigit(d)) {
95+ z = strtol(M, 0, 0);
96+ d = 2;
97+ } else {
98+ *(char*) D = 32;
99+ d = strstr(R, M - 1) - R;
100+ *(char*) D = 0;
101+ d = d * 8 + 256;
102+ if (d > 536) {
103+ d = P + d;
104+ if (*(int*) d == 1) {
105+ L = *(int*) (d + 4);
106+ W = h;
107+ o();
108+ ad();
109+ }
110+ }
111+ }
112+ } else {
113+ o();
114+ if (d == 39) {
115+ d = 2;
116+ Y();
117+ z = h;
118+ o();
119+ o();
120+ } else if (d == 47 & h == 42) {
121+ o();
122+ while (h) {
123+ while (h != 42)
124+ o();
125+ o();
126+ if (h == 47)
127+ h = 0;
128+ }
129+ o();
130+ ad();
131+ } else {
132+ char* e = "++#m--%am*@R<^1c/@%[_[H3c%@%[_[H3c+@.B#d-@%:_^BKd<<Z/03e>>`/03e<=0f>=/f<@.f>@1f==&g!='g&&k||#l&@.BCh^@.BSi|@.B+j~@/%Yd!@&d*@b";
133+ while (j = *(char*) e++) {
134+ m = *(char*) e++;
135+ z = 0;
136+ while ((C = *(char*) e++ - 98) < 0)
137+ z = z * 64 + C + 64;
138+ if (j == d & (m == h | m == 64)) {
139+ if (m == h) {
140+ o();
141+ d = 1;
142+ }
143+ break;
144+ }
145+ }
146+ }
147+ }
352148 }
353-else if( d == 123){
354-ad();
355-ab(1);
356-while( d!= 125)I (j);
357-ad();
149+
150+void ae( g) {
151+ while( g&&g!=-1) {
152+ *(char*) q++=g;
153+ g=g>>8;
154+ }
358155 }
359-else{
360-if( d == 448){
361-ad();
362-if( d!= 59)w ();
363-K=B(K);
156+
157+void A(e) {
158+ int g;
159+ while( e) {
160+ g=*(int*) e;
161+ *(int*) e=q-e-4;
162+ e=g;
163+ }
364164 }
365-else if( d == 400){
366-ad();
367-*(int*) j=B(*(int*) j);
165+
166+int s( g, e) {
167+ ae(g);
168+ *(int*) q = e;
169+ e = q;
170+ q = q + 4;
171+ return e;
368172 }
369-else if( d!= 59)w ();
370-ad();
173+
174+int H(e) {
175+ s(184,e);
371176 }
177+
178+int B(e) {
179+ return s(233,e);
372180 }
373-ab (j){
374-int m;
375-while( d == 256|d!=-1&!j){
376-if( d == 256){
377-ad();
378-while( d!= 59){
379-if( j){
380-G=G +4;
381-*(int*) d=-G;
181+
182+S( j, e) {
183+ ae(1032325);
184+ return s(132 + j, e);
382185 }
383-else{
384-*(int*) d=v;
385-v=v +4;
186+
187+void Z(e) {
188+ ae( 49465);
189+ H(0);
190+ ae( 15);
191+ ae( e+144);
192+ ae( 192);
386193 }
387-ad();
388-if( d == 44)ad();
194+
195+void N( j, e) {
196+ ae(j + 131);
197+ s((e < 512) << 7 | 5, e);
389198 }
390-ad();
199+
200+void T (j) {
201+ int g,e,m,aa;
202+ g=1;
203+ if( d == 34) {
204+ H(v);
205+ while( h!=34) {
206+ Y ();
207+ *(char*) v++=h;
208+ o ();
209+ }
210+ *(char*) v=0;
211+ v= (char*) (((int)v) +4&-4);
212+ o ();
213+ ad();
214+ }
215+ else {
216+ aa=C;
217+ m= z;
218+ e=d;
219+ ad();
220+ if( e == 2) {
221+ H(m);
222+ }
223+ else if( aa == 2) {
224+ T(0);
225+ s(185,0);
226+ if( e == 33)Z(m);
227+ else ae( m);
228+ }
229+ else if( e == 40) {
230+ w ();
231+ ad();
232+ }
233+ else if( e == 42) {
234+ ad();
235+ e=d;
236+ ad();
237+ ad();
238+ if( d == 42) {
239+ ad();
240+ ad();
241+ ad();
242+ ad();
243+ e=0;
244+ }
245+ ad();
246+ T(0);
247+ if( d == 61) {
248+ ad();
249+ ae( 80);
250+ w ();
251+ ae( 89);
252+ ae( 392+(e == 256));
253+ }
254+ else if( e) {
255+ if( e == 256)ae( 139);
256+ else ae( 48655);
257+ q++;
258+ }
259+ }
260+ else if( e == 38) {
261+ N(10,*(int*) d);
262+ ad();
263+ }
264+ else {
265+ g=*(int*) e;
266+ if(!g)g=dlsym(0,M);
267+ if( d == 61&j) {
268+ ad();
269+ w ();
270+ N(6,g);
271+ }
272+ else if( d!= 40) {
273+ N(8,g);
274+ if( C == 11) {
275+ N(0,g);
276+ ae( z);
277+ ad();
278+ }
279+ }
280+ }
281+ }
282+ if( d == 40) {
283+ if( g == 1)ae( 80);
284+ m= s(60545,0);
285+ ad();
286+ j=0;
287+ while( d!= 41) {
288+ w ();
289+ s(2393225,j);
290+ if( d == 44)ad();
291+ j=j +4;
292+ }
293+ *(int*) m= j;
294+ ad();
295+ if(!g) {
296+ e=e +4;
297+ *(int*) e=s(232,*(int*) e);
298+ }
299+ else if( g == 1) {
300+ s(2397439,j);
301+ j=j +4;
302+ }
303+ else {
304+ s(232,g-q-5);
305+ }
306+ if( j)s(50305,j);
307+ }
391308 }
392-else{
393-A(*(int*)(d +4));
394-*(int*) d=q;
395-ad();
396-ad();
397-m= 8;
398-while( d!= 41){
399-*(int*) d=m;
400-m= m +4;
401-ad();
402-if( d == 44)ad();
309+
310+void O (j) {
311+ int e,g,m;
312+ if( j--== 1)T(1);
313+ else {
314+ O (j);
315+ m= 0;
316+ while( j == C) {
317+ g=d;
318+ e=z;
319+ ad();
320+ if( j>8) {
321+ m= S(e,m);
322+ O (j);
323+ }
324+ else {
325+ ae( 80);
326+ O (j);
327+ ae( 89);
328+ if( j == 4|j == 5) {
329+ Z(e);
330+ }
331+ else {
332+ ae( e);
333+ if( g == 37)ae( 146);
334+ }
335+ }
336+ }
337+ if( m&&j>8) {
338+ m= S(e,m);
339+ H(e^1);
340+ B(5);
341+ A(m);
342+ H(e);
343+ }
344+ }
403345 }
404-ad();
405-K=G=0;
406-ae( 15042901);
407-m= s(60545,0);
408-I(0);
409-A(K);
410-ae( 50121);
411-*(int*) m= G;
346+
347+void w() {
348+ O(11);
412349 }
350+
351+U() {
352+ w();
353+ return S(0, 0);
413354 }
355+
356+void I (j) {
357+ int m,g,e;
358+ if( d == 288) {
359+ ad();
360+ ad();
361+ m= U ();
362+ ad();
363+ I (j);
364+ if( d == 312) {
365+ ad();
366+ g=B(0);
367+ A(m);
368+ I (j);
369+ A(g);
370+ }
371+ else {
372+ A(m);
373+ }
374+ }
375+ else if( d == 352|d == 504) {
376+ e=d;
377+ ad();
378+ ad();
379+ if( e == 352) {
380+ g=q;
381+ m= U ();
382+ }
383+ else {
384+ if( d!= 59)w ();
385+ ad();
386+ g=q;
387+ m= 0;
388+ if( d!= 59)m= U ();
389+ ad();
390+ if( d!= 41) {
391+ e=B(0);
392+ w ();
393+ B(g-q-5);
394+ A(e);
395+ g=e +4;
396+ }
397+ }
398+ ad();
399+ I(&m);
400+ B(g-q-5);
401+ A(m);
402+ }
403+ else if( d == 123) {
404+ ad();
405+ ab(1);
406+ while( d!= 125)I (j);
407+ ad();
408+ }
409+ else {
410+ if( d == 448) {
411+ ad();
412+ if( d!= 59)w ();
413+ K=B(K);
414+ }
415+ else if( d == 400) {
416+ ad();
417+ *(int*) j=B(*(int*) j);
418+ }
419+ else if( d!= 59)w ();
420+ ad();
421+ }
414422 }
415-main(g,e){
416-Q=__stdinp;
417-if( g-->1){
418-e=e +4;
419-Q=fopen(*(int*) e,"r");
423+
424+void ab (int j) {
425+ int m;
426+ while( d == 256 | d != -1 & !j ) {
427+ if( d == 256) {
428+ ad();
429+ while( d!= 59) {
430+ if( j ) {
431+ G=G +4;
432+ *(int*) d=-G;
433+ }
434+ else {
435+ *(char**) d = v;
436+ v=v +4;
437+ }
438+ ad();
439+ if( d == 44)ad();
440+ }
441+ ad();
442+ }
443+ else {
444+ A(*(int*)(d +4));
445+ *(int*) d=q;
446+ ad();
447+ ad();
448+ m= 8;
449+ while( d!= 41) {
450+ *(int*) d=m;
451+ m= m +4;
452+ ad();
453+ if( d == 44)ad();
454+ }
455+ ad();
456+ K=G=0;
457+ ae( 15042901);
458+ m= s(60545,0);
459+ I(0);
460+ A(K);
461+ ae( 50121);
462+ *(int*) m= G;
463+ }
464+ }
420465 }
421-D=strcpy(R =calloc(1,99999)," int if else while break return for define main ")+48;
422-v =calloc(1,99999);
423-q=ac =calloc(1,99999);
424-P =calloc(1,99999);
425-o ();
426-ad();
427-ab(0);
428-return(*(int(*)())*(int*)(P+592))(g,e);
466+
467+int main( int argc, char** argv) {
468+ Q = stdin;
469+ if (argc-- > 1) {
470+ char* file = argv[1];
471+ argv += 1;
472+ Q = fopen(file, "r");
473+ if (Q == NULL) {
474+ fprintf(stderr, "Could not open file \"%s\"\n", file);
475+ return -1;
476+ }
477+ }
478+ D = strcpy(R = calloc(1, 99999),
479+ " int if else while break return for define main ") + 48;
480+ v = calloc(1, 99999);
481+ q = ac = calloc(1, 99999);
482+ P = calloc(1, 99999);
483+ o();
484+ ad();
485+ ab(0);
486+#if 1
487+ fwrite(R, 1, 99999, stdout);
488+ fwrite(ac, 1, 99999, stdout);
489+ fwrite(P, 1, 99999, stdout);
490+ return 0;
491+#else
492+ return (*(int(*)()) *(int*) (P + 592))(argc, argv);
493+#endif
429494 }
430495