-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathdecryptor.cs
966 lines (873 loc) · 54.1 KB
/
decryptor.cs
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
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Diagnostics;
using System.Text;
namespace Reference
{
public class Decrypt
{
private static byte[] EncTblSW = {
0x63, 0x7C, 0x77, 0x7B, 0xF2, 0x6B, 0x6F, 0xC5, 0x30, 0x01, 0x67, 0x2B, 0xFE, 0xD7, 0xAB, 0x76,
0xCA, 0x82, 0xC9, 0x7D, 0xFA, 0x59, 0x47, 0xF0, 0xAD, 0xD4, 0xA2, 0xAF, 0x9C, 0xA4, 0x72, 0xC0,
0xB7, 0xFD, 0x93, 0x26, 0x36, 0x3F, 0xF7, 0xCC, 0x34, 0xA5, 0xE5, 0xF1, 0x71, 0xD8, 0x31, 0x15,
0x04, 0xC7, 0x23, 0xC3, 0x18, 0x96, 0x05, 0x9A, 0x07, 0x12, 0x80, 0xE2, 0xEB, 0x27, 0xB2, 0x75,
0x09, 0x83, 0x2C, 0x1A, 0x1B, 0x6E, 0x5A, 0xA0, 0x52, 0x3B, 0xD6, 0xB3, 0x29, 0xE3, 0x2F, 0x84,
0x53, 0xD1, 0x00, 0xED, 0x20, 0xFC, 0xB1, 0x5B, 0x6A, 0xCB, 0xBE, 0x39, 0x4A, 0x4C, 0x58, 0xCF,
0xD0, 0xEF, 0xAA, 0xFB, 0x43, 0x4D, 0x33, 0x85, 0x45, 0xF9, 0x02, 0x7F, 0x50, 0x3C, 0x9F, 0xA8,
0x51, 0xA3, 0x40, 0x8F, 0x92, 0x9D, 0x38, 0xF5, 0xBC, 0xB6, 0xDA, 0x21, 0x10, 0xFF, 0xF3, 0xD2,
0xCD, 0x0C, 0x13, 0xEC, 0x5F, 0x97, 0x44, 0x17, 0xC4, 0xA7, 0x7E, 0x3D, 0x64, 0x5D, 0x19, 0x73,
0x60, 0x81, 0x4F, 0xDC, 0x22, 0x2A, 0x90, 0x88, 0x46, 0xEE, 0xB8, 0x14, 0xDE, 0x5E, 0x0B, 0xDB,
0xE0, 0x32, 0x3A, 0x0A, 0x49, 0x06, 0x24, 0x5C, 0xC2, 0xD3, 0xAC, 0x62, 0x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 0xD8, 0xAB, 0x00, 0x8C, 0xBC, 0xD3, 0x0A, 0xF7, 0xE4, 0x58, 0x05, 0xB8, 0xB3, 0x45, 0x06,
0xD0, 0x2C, 0x1E, 0x8F, 0xCA, 0x3F, 0x0F, 0x02, 0xC1, 0xAF, 0xBD, 0x03, 0x01, 0x13, 0x8A, 0x6B,
0x3A, 0x91, 0x11, 0x41, 0x4F, 0x67, 0xDC, 0xEA, 0x97, 0xF2, 0xCF, 0xCE, 0xF0, 0xB4, 0xE6, 0x73,
0x96, 0xAC, 0x74, 0x22, 0xE7, 0xAD, 0x35, 0x85, 0xE2, 0xF9, 0x37, 0xE8, 0x1C, 0x75, 0xDF, 0x6E,
0x47, 0xF1, 0x1A, 0x71, 0x1D, 0x29, 0xC5, 0x89, 0x6F, 0xB7, 0x62, 0x0E, 0xAA, 0x18, 0xBE, 0x1B,
0xFC, 0x56, 0x3E, 0x4B, 0xC6, 0xD2, 0x79, 0x20, 0x9A, 0xDB, 0xC0, 0xFE, 0x78, 0xCD, 0x5A, 0xF4,
0x1F, 0xDD, 0xA8, 0x33, 0x88, 0x07, 0xC7, 0x31, 0xB1, 0x12, 0x10, 0x59, 0x27, 0x80, 0xEC, 0x5F,
0x60, 0x51, 0x7F, 0xA9, 0x19, 0xB5, 0x4A, 0x0D, 0x2D, 0xE5, 0x7A, 0x9F, 0x93, 0xC9, 0x9C, 0xEF,
0xA0, 0xE0, 0x3B, 0x4D, 0xAE, 0x2A, 0xF5, 0xB0, 0xC8, 0xEB, 0xBB, 0x3C, 0x83, 0x53, 0x99, 0x61,
0x17, 0x2B, 0x04, 0x7E, 0xBA, 0x77, 0xD6, 0x26, 0xE1, 0x69, 0x14, 0x63, 0x55, 0x21, 0x0C, 0x7D
};
private static uint[] CmnTblRc = {
0x01000000, 0x02000000,
0x04000000, 0x08000000,
0x10000000, 0x20000000,
0x40000000, 0x80000000,
0x1b000000, 0x36000000
};
// private static uint[] CmnTblRc = { 1, 2, 4, 8, 16, 32, 64, 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, 0x59, 0xDF, 0xD2, 0x55, 0x3F, 0x73, 0xF2, 0x18, 0x79, 0xCE, 0x14, 0x73, 0xBF, 0x37, 0xC7,
0x53, 0xEA, 0xCD, 0xF7, 0x5F, 0x5B, 0xAA, 0xFD, 0xDF, 0x14, 0x6F, 0x3D, 0x78, 0x86, 0xDB, 0x44,
0xCA, 0x81, 0xF3, 0xAF, 0xB9, 0x3E, 0xC4, 0x68, 0x38, 0x2C, 0x34, 0x24, 0xC2, 0x5F, 0x40, 0xA3,
0x16, 0x72, 0xC3, 0x1D, 0xBC, 0x0C, 0x25, 0xE2, 0x28, 0x8B, 0x49, 0x3C, 0xFF, 0x41, 0x95, 0x0D,
0x39, 0x71, 0x01, 0xA8, 0x08, 0xDE, 0xB3, 0x0C, 0xD8, 0x9C, 0xE4, 0xB4, 0x64, 0x90, 0xC1, 0x56,
0x7B, 0x61, 0x84, 0xCB, 0xD5, 0x70, 0xB6, 0x32, 0x48, 0x74, 0x5C, 0x6C, 0xD0, 0x42, 0x57, 0xB8
}; // 0x30
private static void extr_bytestream(byte[] src, out byte[] byte_field, int ini, int fin)
{
byte_field = new byte[(fin - ini)];
Array.Copy(src, ini, byte_field, 0L, fin - ini);
}
private static void extr_add_bytestream(byte[] src, byte[] add, out byte[] byte_field, int ini, int fin)
{
int len = fin - ini;
byte_field = new byte[(add.Length + len)];
Array.Copy(src, ini, byte_field, 0L, len);
Array.Copy(add, 0L, byte_field, len, add.Length);
}
private static void extr_double_add_bytestream(byte[] src, byte[] add1, byte[] add2, out byte[] byte_field, int ini, int fin)
{
int len = fin - ini;
byte_field = new byte[add1.Length + len + add2.Length];
Array.Copy(src, ini, byte_field, 0L, len);
Array.Copy(add1, 0, byte_field, len, add1.Length);
Array.Copy(add2, 0, byte_field, len + add1.Length, add2.Length);
}
private static void marg_bytestream(byte[] byte_X, byte[] byte_Y, out byte[] byte_W) // 0x1003AE7E0
{
byte_W = new byte[byte_X.Length + byte_Y.Length];
Array.Copy(byte_X, 0L, byte_W, 0L, (byte_X.Length));
Array.Copy(byte_Y, 0L, byte_W, (byte_X.Length), byte_W.Length);
}
private static void marg_bytestream(byte[] byte_X, byte[] byte_Y, byte[] byte_Z, byte[] byte_W, out byte[] byte_O) // 0x1003AE8F4
{
int[] lenV = new int[4];
lenV[0] = (byte_X.Length);
lenV[1] = (byte_Y.Length);
lenV[2] = (byte_Z.Length);
lenV[3] = (byte_W.Length);
byte_O = new byte[(lenV[0] + lenV[1] + lenV[2] + lenV[3])];
int len = 0;
Array.Copy(byte_X, 0L, byte_O, len, lenV[0]);
len += lenV[0];
Array.Copy(byte_Y, 0L, byte_O, len, lenV[1]);
len += lenV[1];
Array.Copy(byte_Z, 0L, byte_O, len, lenV[2]);
len += lenV[2];
Array.Copy(byte_W, 0L, byte_O, len, lenV[3]);
len += lenV[3];
}
private static void ReverseByte(byte[] src) // 0x1003AEAB8
{
int len = (src.Length);
var v5 = new byte[(len)];
Array.Copy(src, 0L, v5, 0L, len);
var v7 = 0L;
var v8 = len - 1;
while (true)
{
(src[v8]) = (v5[v7]);
++v7;
--v8;
if (v7 >= len)
return;
}
}
public static void Main(byte[] input_bytestream, out byte[] output_bytestream, int range_ini, int range_fin) // 0x1003AEBCC
{
byte[] srcKey = {
0xE2, 0x05, 0x32, 0x62, 0x14, 0x46, 0x08, 0x37,
0x12, 0x09, 0x0A, 0x32, 0x79, 0x21, 0x2F, 0x63,
0x10, 0x11, 0x92, 0xF3, 0x53, 0x15, 0x63, 0x1E,
0xA6, 0x19, 0xC0, 0x4D, 0x7D, 0x62, 0x12, 0x3F
};
byte[] srcVec = {
0xC2, 0x24, 0x51, 0x60, 0xD4, 0x4F, 0x35, 0x71,
0x12, 0x27, 0x5A, 0x8B, 0x0C, 0x3D, 0x14, 0x5E
};
int input_len = input_bytestream.Length;
int len_wo_padding = input_len - 32;
/*
long v14 = (long)((uint)(1374389535L * v13 * range_ini >> 37) + ((ulong)((1374389535L * v13 * range_ini)) >> 63));
long v16 = 1374389535L * (v13 - (int)v14) / 16 * range_fin;
long v17 = (long)((uint)v14 + 16 * ((uint)(v16 >> 38) + ((ulong)v16 >> 63)));
int v18 = (int)((v16 >> 37) + (long)((ulong)v16 >> 63));
long v19 = (uint)(v14 + 16 * v18);
*/
int initial = len_wo_padding * range_ini / 100;
int cipher_size = len_wo_padding - initial;
if (cipher_size == 0)
{
cipher_size += 15;
};
int num_blocks = cipher_size / 16;
int num_encrypted = range_fin * num_blocks / 100;
int half = initial + (num_encrypted / 2) * 16;
int final = initial + num_encrypted * 16;
var byte_P = new byte[32];
var byte_P1 = new byte[16];
var byte_P2 = new byte[16];
extr_bytestream(input_bytestream, out byte_P, final, final + 32);
PDDEC(byte_P, byte_P1, byte_P2);
var left_pad = new byte[16];
byte[] second_half_encrypted;
byte[] second_half;
extr_add_bytestream(input_bytestream, byte_P2, out second_half_encrypted, half, final);
RJDEC(second_half_encrypted, left_pad, byte_P2, out second_half, srcKey, srcVec, 1);
Console.WriteLine("RJDEC worked in mode #1");
byte[] first_half_encrypted;
byte[] first_half;
extr_double_add_bytestream(input_bytestream, left_pad, byte_P1, out first_half_encrypted, initial + 16, half);
RJDEC(first_half_encrypted, left_pad, byte_P1, out first_half, srcKey, srcVec, 2);
Console.WriteLine("RJDEC worked in mode #2");
Array.Copy(input_bytestream, initial, byte_P, 0, 16);
Array.Copy(left_pad, 0, byte_P, 16, 16);
HTDEC(byte_P, srcKey, srcVec);
Console.WriteLine("HTDEC finished work");
byte[] v57;
marg_bytestream(byte_P, first_half, byte_P1, second_half, out v57);
ReverseByte(v57);
output_bytestream = new byte[(input_len - 32)];
byte[] v61;
byte[] v60;
extr_bytestream(input_bytestream, out v61, 0, (int)initial);
extr_bytestream(input_bytestream, out v60, (int)final + 32, (int)input_len);
int copy_index = 0;
Array.Copy(v61, 0L, output_bytestream, copy_index, (v61.Length));
copy_index += (v61.Length);
Array.Copy(v57, 0L, output_bytestream, copy_index, (v57.Length));
copy_index += (v57.Length);
Array.Copy(byte_P2, 0L, output_bytestream, copy_index, (byte_P2.Length));
copy_index += (byte_P2.Length);
Array.Copy(v60, 0L, output_bytestream, copy_index, (v60.Length));
return;
}
private static void RJDEC(byte[] src, byte[] padl, byte[] padr, out byte[] srcOut, byte[] srcKey, byte[] srcVec, int mode)
{
using (RijndaelManaged rijndaelManaged = new RijndaelManaged())
{
byte[] key;
int key_from;
var key_size = mode << 7;
rijndaelManaged.Mode = CipherMode.CBC;
rijndaelManaged.Padding = PaddingMode.PKCS7;
rijndaelManaged.KeySize = key_size;
rijndaelManaged.BlockSize = 128;
rijndaelManaged.IV = srcVec;
switch (mode)
{
case 2:
key = new byte[32];
key_from = 0;
break;
case 1:
key = new byte[16];
key_from = 8;
break;
default:
srcOut = null;
return;
}
Array.Copy(srcKey, key_from, key, 0, key_size / 8);
rijndaelManaged.Key = key;
var decrypted = new byte[src.Length];
srcOut = new byte[src.Length - 48];
using (ICryptoTransform decryptor = rijndaelManaged.CreateDecryptor())
{
using (MemoryStream memoryStream = new MemoryStream(src))
{
using (CryptoStream cryptoStream = new CryptoStream((Stream)memoryStream, decryptor, CryptoStreamMode.Read))
{
cryptoStream.Read(decrypted, 0, decrypted.Length);
Array.Copy(decrypted, 16, srcOut, 0, srcOut.Length);
Array.Copy(decrypted, 0, padl, 0, 16);
Array.Copy(decrypted, srcOut.Length + 16, padr, 0, 16);
}
}
}
}
}
private static void HTDEC(byte[] src, byte[] srcKey, byte[] srcVec) // 0x1003AF9B4
{
var v4 = srcVec;
var v5 = srcKey;
var v107 = src;
//var v109 = 0L;
//var v110 = 0L;
var v7 = new byte[(32)];
var v9 = new byte[(16)];
Array.Copy(srcKey, 8L, v7, 0L, 8L);
Array.Copy(srcKey, 24L, v7, 8L, 8L);
Array.Copy(srcKey, 0L, v7, 16L, 8L);
var v106 = v7;
Array.Copy(srcKey, 16L, v7, 24L, 8L);
var v11 = new byte[(4)]; //4
var v12 = 0L;
var v13 = 0L;
LABEL_4:
while (true)
{
for (int i = 0; i < 4; i++)
v11[3 - i] = (srcVec[v12 + i]);
uint v21 = (uint)BitConverter.ToUInt32(v11, 0);
v11 = BitConverter.GetBytes(~v21);
Array.Copy(v11, 0L, v9, 4 * v13, 4L);
v12 += 4L;
if (v13 <= 2)
{
v13++;
goto LABEL_4;
}
var v26 = new byte[(16)];
var v28 = new byte[(16)];
var v30 = new byte[(32)];
Array.Copy(v107, 0L, v30, 0L, 32L);
var v110 = new uint[(60)];
MakeDecKey(15, v106, v110);
var v33 = 0;
var v108 = v30;
LABEL_20:
Array.Copy(v30, v33, v28, 0L, 16L);
var v109 = new uint[(4)];
var v36 = new byte[(4)];
var v37 = v36;
// sth jump to label 33
for (int i=0;i<4;i++) {
Array.Copy(v28, 4*i, v37, 0L, 4);
uint v42 = BitConverter.ToUInt32(v37, 0);
v109[i] = UintReverseByte(v42);
}
LABEL_33:
CmnConvKey(v109, v110, 0);
var v48 = 0;
var v49 = 4;
while (true)
{
if (v48 == 13)
{
DecConvSWs(v109);
DecConvSRs(v109);
}
else
{
DecConvSWs(v109);
DecConvSRs(v109);
DecConvMCs(v109);
}
var tmp = v109[0];
v109[0] = v109[2];
v109[2] = tmp;
CmnConvKey(v109, v110, v49);
++v48;
v49 += 4;
if (v48 >= 14)
{
var v65 = new uint[(4)]; //4bytes
var v66 = v109;
v65[0] = UintReverseByte(v66[3]);
v65[1] = UintReverseByte((v66[2]));
v65[2] = UintReverseByte((v66[1]));
v65[3] = UintReverseByte((v66[0]));
Array.Copy(v9, 0L, v26, 0L, 16L); // copy modified srcVec
Array.Copy(BitConverter.GetBytes(v65[0]), 0L, v9, 0L, 4L);
Array.Copy(BitConverter.GetBytes(v65[1]), 0L, v9, 4L, 4L);
Array.Copy(BitConverter.GetBytes(v65[2]), 0L, v9, 8L, 4L);
Array.Copy(BitConverter.GetBytes(v65[3]), 0L, v9, 12L, 4L);
var v97 = 32L;
while (true)
{
var v98 = v97 - 32;
v26[v97-32] ^= v9[v97-32];
++v97;
if (v98 >= 15)
{
v30 = v108; // useless
Array.Copy(v26, 0L, v108, v33, 16L);
Array.Copy(v28, 0L, v9, 0L, 16L);
v33 = (v33 + 16);
if (v33 < 32)
goto LABEL_20;
Array.Copy(v108, 0L, v107, 0L, 32L);
return;
}
}
} //v48>=14
}// while 1
break;
} // while 1
}
private static void PDDEC(byte[] byte_P, byte[] byte_P1, byte[] byte_P2)
{
var v6 = byte_P;
var swapped = new byte[16];
Array.Copy(byte_P, 8, swapped, 0, 16);
var temp_bytes = new byte[4];
var v11 = 0L;
var v12 = 0L;
//LABEL_5:
while (true)
{
for (int i = 0; i < 4; i++)
temp_bytes[3 - i] = (swapped[v11 + i]);
// v12 loop from 0 to 2
uint v19 = BitConverter.ToUInt32(temp_bytes, 0);
temp_bytes = BitConverter.GetBytes(~v19);
Array.Copy(temp_bytes, 0, swapped, 4 * v12, 4);
v11 += 4;
if (v12 <= 2)
{
v12++;
//goto LABEL_5;
continue;
}
// here never go back again
Array.Copy(swapped, 0, v6, 8, 16);
//var v24 = 32;
for (int i = 0; i < 16; i++)
{
byte_P1[i] = v6[i];
byte_P2[i] = v6[i + 16];
}
return;
}
}
private static uint EncConvSW(uint srcval) // 0x1003B14E8
{
var v5 = srcval >> 24; // head 8 bits
uint v6 = (uint)(EncTblSW[v5] & 0xFF);
uint v10 = (uint)(EncTblSW[((srcval >> 16) & 0xFF)] & 0xFF);
uint v13 = (uint)((v6 << 24) | (v10 << 16) | ((EncTblSW[(srcval & 0xFFFF) >> 8] & 0xFF) << 8));
return v13 | (uint)(EncTblSW[srcval & 0xFF] & 0xFF);
}
private static uint EncConvSR(uint srcval3, uint srcval2, uint srcval1, uint srcval0)
{
return ((srcval3 & 0xFF000000 | srcval2 & 0xFFFFFF) & 0xFFFF0000 | srcval1) & 0xFFFFFF00 | srcval0;
}
private static void DecConvSWs(uint[] srctext) // 0x1003B0D94
{
for (int i = 0; i < 4; i++)
srctext[i] = DecConvSW(srctext[i]);
}
//todo
private static void DecConvSRs(uint[] srctext)// 0x1003B0F40
{
var v4 = new uint[4];
// copy srctext to v4, total 4 by 4 bytes
for (int i = 0; i < 4; i++)
v4[i] = (srctext[i]);
(srctext[0]) = (v4[2] & 0xFF0000) | (v4[1] & 0xFF000000) | (v4[3] & 0xFF00) | (v4[0] & 0xFF);
(srctext[1]) = (v4[3] & 0xFF0000) | (v4[2] & 0xFF000000) | (v4[0] & 0xFF00) | (v4[1] & 0xFF);
(srctext[2]) = (v4[0] & 0xFF0000) | (v4[3] & 0xFF000000) | (v4[1] & 0xFF00) | (v4[2] & 0xFF);
(srctext[3]) = (v4[1] & 0xFF0000) | (v4[0] & 0xFF000000) | (v4[2] & 0xFF00) | (v4[3] & 0xFF);
}
private static void DecConvMCs(uint[] srctext) // 0x1003B133C
{
for (int i = 0; i < 4; i++)
srctext[i] = DecConvMC(srctext[i]);
}
private static uint RotWord(uint srcval) // 0x1003B1F6C
{
var v5 = BitConverter.GetBytes(srcval);
var v7 = BitConverter.GetBytes(srcval);
// this is a one byte shift to the right
v5[0] = v7[3];
v5[1] = v7[0];
v5[2] = v7[1];
v5[3] = v7[2];
return BitConverter.ToUInt32(v5, 0);
}
private static uint DecConvSW(uint srcval)
{
var v5 = srcval >> 24;
var v6 = DecTblSW[v5] & 0xFF;
var v10 = (DecTblSW[(srcval >> 16) & 0xFF] & 0xFF);
uint v13 = (uint)((v6 << 24)
| (v10 << 16)
| ((DecTblSW[(srcval & 0xFFFF) >> 8] & 0xFF) << 8));
return v13 | (uint)(DecTblSW[srcval & 0xFF] & 0xFF);
}
private static uint DecConvMC(uint srcval) // 0x1003B17C4
{
uint v4 = EncConvSW(srcval);
var v7 = new uint[4];
v7[0] = (v4 >> 22) & 0x3FC;
v7[1] = (v4 >> 14) & 0x3FC;
v7[2] = (v4 >> 6) & 0x3FC;
v7[3] = 4 * (uint)(v4 & 0xFF);
var v15 = new byte[(4)];
for (int i = 0; i < 4; i++)
v15[i] = DecTblMC0[(int)v7[0] + i];
uint v40 = BitConverter.ToUInt32(v15, 0);
for (int i = 0; i < 4; i++)
v15[i] = (DecTblMC1[(int)v7[1] + i]);
uint v65 = BitConverter.ToUInt32(v15, 0);
for (int i = 0; i < 4; i++)
v15[i] = (DecTblMC2[(int)v7[2] + i]);
uint v90 = BitConverter.ToUInt32(v15, 0);
for (int i = 0; i < 4; i++)
v15[i] = (DecTblMC3[(int)v7[3] + i]);
uint v111 = v65 ^ v40;
uint v114 = v111 ^ v90;
uint result = v114 ^ (uint)BitConverter.ToUInt32(v15, 0);
return result;
}
private static uint UintReverseByte(uint srcval) // 0x1003B09A8
{
var v5 = new byte[(4)];
var v6 = BitConverter.GetBytes(srcval);
var v7 = 0;
while (true)
{
(v5[3 - v7]) = (v6[v7]);
//v13 = __OFSUB__(v7, 3LL);
//v12 = (v7++ - 3) < 0;
if (v7 == 3)
{
return BitConverter.ToUInt32(v5, 0);
}
v7++;
}
}
private static void CmnConvKey(uint[] text, uint[] Key, int Access) // 0x1003B0AF8
{
for (int i = 0; i < 4; i++)
text[i] ^= (Key[Access + i]);
var tmp = text[0];
var tmp1 = text[1];
// exchange anyway
text[0] = text[3];
text[3] = tmp;
text[1] =text[2];
text[2] = tmp1;
}
private static void MakeDecKey(int iNr, byte[] LocalKey, uint[] DecryptKey) // 0x1003B02A0
{
// iNr = 15
var v4 = DecryptKey;
var v5 = LocalKey;
var v120 = iNr;
var v7 = new uint[(60)];//!!!
var v9 = new byte[4];
var v10 = 0;
var v11 = 35;
LABEL_5:
while (true)
{
for (int i = 0; i < 4; i++)
(v9[i]) = (v5[v11 - 32 - i]);
int v19 = (int)BitConverter.ToUInt32(v9, 0);
(v7[v10]) = (uint)v19;
v11 += 4;
if (v10 <= 6) // feed v7 from 0 to 7
{
v10++;
goto LABEL_5;
}
if (v120 >= 3) // true
{
var v22 = 11;
long v23 = 2;
do // v23 running from 2 to 14, v22 running from 11 to 59
{ // v7 updates from 8,9,10,11 to 56 57 58 59
uint v25 = (uint)(v7[(v22 - 4)]); // running from 7 to 55
int v26;
if ((int)v23 >= 0) // true
v26 = (int)v23;
else
v26 = (int)v23 + 1;
var v27 = v23 - (v26 & 0xFFFFFFFE);
if (v27 == 1) // v23 running from 3 5 ... 13
{
v25 = EncConvSW(v25) & 0xFFFFFFFF; // lodword
}
else if (v27 == 0) // v23 running from 2 4 to 14
{
var v29 = RotWord(v25);
var v30 = EncConvSW(v29);
//
int v32;
if (v23 >= 0) // true
v32 = (int)v23;
else
v32 = (int)v23 + 1;
var v33 = (v32 >> 1) - 1; // v33 = v23/2 -1 from 0 to 6
v25 = ((CmnTblRc[v33]) ^ v30) & 0xFFFFFFFF;
}
v7[(v22 - 3 + 0)] = (v7[v22 - 11 + 0]) ^ v25; // running from 8,9,10,11
for (int i = 1; i < 4; i++)
{
(v7[(v22 - 3 + i)]) = (v7[(v22 - 4 + i)]) ^ (v7[(v22 - 11 + i)]);
}
//++v24;
++v23;
v22 += 4;
}
while (v23 < v120);
} // updates of v7 finished from 0 to 59
var v67 = v120 - 1;
var v68 = 0;
var v69 = 0L;
var v70 = 4 * v120 - 4; //4*15-4
while (true) //v69 running from 0 to 14, v68 running from 0 to 56
{ // v70 running from 56 to 0
for (int i = 0; i < 4; i++)
v4[(v68 + i)] = (v7[(v70 + i)]);
++v69;
v68 += 4;
v70 -= 4;
if (v69 >= v120)
break;
} // reverse v7 by 4 bytes to v4
var v87 = v67; //14
var v88 = 4;
var v89 = 1;
while (true) // v89 running from 1 to 13, v88 running from 4 to 52
{
for (int i = 0; i < 4; i++)
v4[(v88 + i)] = DecConvMC(v4[(v88 + i)]);
++v89;
v88 += 4;
if (v89 >= v87)
return;
}
}
}
class Program
{
static int Main(string[] args)
{
if (args.Length != 2)
{
Console.WriteLine("Missing Filename");
return 1;
}
string rawFileName = args[0];
string decryptedFileName = args[1];
byte[] file = File.ReadAllBytes(rawFileName);
using (MemoryStream memoryStream = new MemoryStream(file))
{
using (BinaryReader binaryReader = new BinaryReader((Stream)memoryStream))
{
int header = binaryReader.ReadInt32();
int version = (header & 0xFF00) >> 8;
if (version != 3)
{
Console.WriteLine("Expected version 3, got {0}", version);
return 1;
}
var data = binaryReader.ReadBytes(file.Length);
byte[] outbyte;
Decrypt.Main(data, out outbyte, 1, 100);
File.WriteAllBytes(decryptedFileName, outbyte);
}
}
return 0;
}
}
}
}