예제 #1
0
파일: Program.cs 프로젝트: Setz0r/Onyx
        static void TestJunk()
        {
            //hashstring: 72BDF6261A0B4EE38EC41C57AB6AAC25
            //keystring: 0000000000000000000000000000000058E05DAD

            //encrypted packet data: 3F003E00DB0200002667BF5F010028010000000000000000280100007 3B0330A3 1924FB87 38FDB7A3 FB7E6B0B A0ADA8BED DF1D113A 80B364929AA24715002ACF3D9F1A381B102F2D18F008B9AD2815
            //[BLOCK: 0] :           3F003E00DB0200002667BF5F010028010000000000000000280100000 10428AF6 498804E7 38FDB7A3 FB7E6B0B A0ADA8BED DF1D113A 80B364929AA24715002ACF3D9F1A381B102F2D18F008B9AD2815
            //[BLOCK: 2] :           3F003E00DB0200002667BF5F010028010000000000000000280100000 10428AF6 498804E4 F4749784 89F9CFDB A0ADA8BED DF1D113A 80B364929AA24715002ACF3D9F1A381B102F2D18F008B9AD2815
            //[BLOCK: 4] :           3F003E00DB0200002667BF5F010028010000000000000000280100000 10428AF6 498804E4 F4749784 89F9CFD8 D2D8FEFD6 5E271F3A 80B364929AA24715002ACF3D9F1A381B102F2D18F008B9AD2815
            //[BLOCK: 6] :           3F003E00DB0200002667BF5F010028010000000000000000280100000 10428AF6 498804E4 F4749784 89F9CFD8 D2D8FEFD6 5E271F12 74BEFC26799FF515002ACF3D9F1A381B102F2D18F008B9AD2815
            //[BLOCK: 8] :           3F003E00DB0200002667BF5F010028010000000000000000280100000 10428AF6 498804E4 F4749784 89F9CFD8 D2D8FEFD6 5E271F12 74BEFC26799FF500000023ED01BD271B102F2D18F008B9AD2815
            //[BLOCK: 10] :          3F003E00DB0200002667BF5F010028010000000000000000280100000 10428AF6 498804E4 F4749784 89F9CFD8 D2D8FEFD6 5E271F12 74BEFC26799FF500000023ED01BD27BA727F92EBB505C6AD2815
            //3F003E00DB0200002667BF5F01002801000000000000000028010000 01 04 28 AF 64 98 80 4E 4F 47 49 78 48 9F 9C FD 8D2D8FEFD6 5E271F12 74BEFC26799FF500000023ED01BD27BA727F92EBB505C6AD2815
            //byte[] responseData = Utility.StringToByteArray("0100000098020000672CBF5F00C91900FEFDC17779000000200000000A2E0100300001000000000044550000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000200970E41CBE8616ACEA95F9839B80D10000000057494E0001000101B751DEC81A5FF70D65298AF38FF99335");
            //byte[] responseData = Utility.StringToByteArray("02000100230000008F28BF5F01C9190000000000000000002000000098C50558238A946B04A25B4846873FF50030620B1C1478C23E");
            //int checksum = Utility.Checksum(responseData.Skip(0x1C).ToArray(),responseData.Length - (28 + 16), responseData.Skip(responseData.Length-16).ToArray());
            //List<UInt32> vec = new List<uint>();
            //bool test = Compression.ReadToVector("decompress.dat", ref vec);
            Compression.Initialize();

            int checksum = 0;
            //string packetbytes = "3F003E00DB0200002667BF5F0100280100000000000000002801000073B0330A31924FB8738FDB7A3FB7E6B0BA0ADA8BEDDF1D113A80B364929AA24715002ACF3D9F1A381B102F2D18F008B9AD2815";
            //byte[] packet = Utility.StringToByteArray(packetbytes);

            //string keybytes = "0000000000000000000000000000000058E05DAD";
            //byte[] key = Utility.StringToByteArray(keybytes);

            //Blowfish blowfish = new Blowfish();
            //Buffer.BlockCopy(key,0,blowfish.key,0,20);

            //byte[] hash = Crypto.SetupHashKey(key);

            //Crypto.BlowfishInitialize(hash, 16, ref blowfish.P, ref blowfish.S);

            //Crypto.DecryptPacket(blowfish, ref packet);

            //string decryptedstr = Utility.ByteArrayToString(packet,"").ToUpper();


            //buffsize: 81, refpos: 61, packetdatasize: 259


            //actual packetdatasize: 40

            //string decryptedData = "03000100880200001D60C45F013C212C0000000000000000A213870401884C6EF7C0BCCEFF083039BF0EB8B33A34C09DD5A5289DF3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8B6C70960E0D37F9F6FF9F009D31831D58D0D351121ED26724A0CBC9E3BBA577E9EB4732C95E2260CEAA72FF1FFAC76481F3FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFBFDCB12F2A08901CEE13C970D1F0E8F7C87FE7FFFFFF7F34FAE6BCFAFFFFFFEEFD07EEFC7E729D9B89040000C0AF10A966C06B51C37220BF9B45A814";

            string compressed = "013207E6362929024486EFA52835296A7D87817F11500202BB34A4E6160DD1100DD1100DD1100DD1100DD1100DD1100DD1100DD1100DD1100DD1100DD1100DD1100DD1100DD1100DD1100DD1900E0D478463B29F63F0F7FDF7BD8C9C912D411FCAF0FFFF4DBF08DFDC2EDA26E9D0F0FFFF7F892AE930709BFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF2F1D066EA7FAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1F2BB81B6D1F2F1A45A368148DA251348A46D1281A45A368148DA251348A46D1281A45A368148DA251348A46D1281A45A368148DA251348A46D1F8FFFFFFFFFFFFFFFFFFFFFFFFFFFFFF8F3CFFDDD2A1616B1AE17F132EF37FB3444EA8A52135B7688886688886688886688886688886688886688886688886688886688886688886688886688886688886688886688886746838221C93FD1C83BFEFBFEF65E48C6C09FA5086FFFF6FFA3130B9A1390626B707DD3130B975A63130B9097C0C4C6E84BC636072A3771C0393DB9F48636072038E760C4C6E239BC7C0E4F6BD5163607203056C0C4C6E09E51F03935B06C31898DC887BF4C60C0000";

            //01C633A96F16ABD2A1E1A65ACF02428E7A4A50923CA44FFAA2F5BCC7DFCF7EC6C7EE5FFD7EF94B518AD882480590469761BF342929024486EFA52835296A7D87817F115002022B8112288112F8FFAA91E4086DE4BE3FFFEF5E8AC8402C2000C4E2FFFF2F3FB4B47D2F23E7BF7AF34E1F888647954450430DB5447E97086A0F4A249144124924979EE5D533B6D74670D19624D19043D19024D1908468F81F5120B7A62578F5FF57471259F50C837F8CE611E69E933B3A982F09D18088864CD2C3AA077CE723E0FE145962504B0DA39E2915C9FEFFCDFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
            byte[] compressedbytes = Utility.StringToByteArray(compressed);
            string compressedstr   = Utility.ByteArrayToString(compressedbytes);

            Console.WriteLine(compressedstr);
            string decompressedtarget = "090008004F010000AF18CB5F01009803000000000000000098030000010488B6670121473DBD92F0903EE98BD6F31EDFAD3DB6A4AD3FBFBFFC26B45743010100006F70858A5657768ABF76357636619243";

            byte[] decompressedtargetbytes = Utility.StringToByteArray(decompressedtarget);

            //0800080098030000AF18CB5F010000000000000000000000000000002016080001000000000000005A000107000000000000000000000000000000000000000000000000000000002016080001000000000000005A000108000000000000000000000000000000000000000000000000000000002016080001000000000000005A000109000000000000000000000000000000000000000000000000000000002016080001000000000000005A00010A000000000000000000000000000000000000000000000000000000002016080001000000000000005A00010B000000000000000000000000000000000000000000000000000000002016080001000000000000006A00010C00004000000000080012000000000000000000000000000000000000201608000100000000000000E100010D000040000000000A0013000000000000000000000000000000000000201608000100000000000000DE00010E000000000000000000000000000000000000000000000000000000001F080800010000009244001B050000001F08080001000000B1450032050000001F08080001000000E93A0018050000001F080800010000002C380015050000001F08080001000000073B001D050000001F08080001000000163B001E050000001F08080001000000C73B001F050000001F0808000100000068330033050000001F08080001000000BD3B0026050000001F08080001000000D5390020050000001F0808000100000085390021050000001F0808000100000097340022050000001F0808000100000032390023050000001F0808000100000034350027050000001D04080001000000417C0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000005E5A08001500000000000000000000000000000000000000000015154004151540041515400415154004151540041515400429294004151540041515400415154004151540041515400415154004151540041515400415154004151540041515400415154004000000000000000000000000000000000000000000000000000000000000000000000000000033000000000000006400000000000000010000001011000400000000000000000000000000000000716608000201C400010000000000000063180700AA0014040A1028084A267FC54A2693C94A2683C74A267FC54A2693C942124400FA0000002C912400338924C80A0001F398581280D88825C8030000FA96581200E34722C8000000FA913C128068C91DC8070000FA96F81100C8122D00000000FA2C1D3300688921C80B0000FA96581200E450420000FA001F2CB134006A891EC8000000FA96381200848822C8002E00F28C2812006B0923C8000000FA9658128064091DC8001900EE96201200CA123500000000FA2C053400716608000201C400010D00000000000063180700AA0014040A1028084A267FC54A2693C94A2683C74A267FC54A2693C96AC91FC800D100C896581200C69244000000FA002CB13400964924C80000FA009958120066091FC80000F8B49658120066490DC80000DBCB96581200164900C8000026E296381200CC5224C8000000FA2CB13200170200C8000000FA649011808E8C22C8000000FAC89412008E0C1EBB000000FAC8381200AE8F3EC8000000FAFAE81300AE8F3EC3000000FAFAE813008E3EFA00000000FAE8A33F000B0E0800010000000000000000000000000000000000000000000000
            //                                                        2016080001000000000000005A000107000000000000000000000000000000000000000000000000000000002016080001000000000000005A000108000000000000000000000000000000000000000000000000000000002016080001000000000000005A000109000000000000000000000000000000000000000000000000000000002016080001000000000000005A00010A000000000000000000000000000000000000000000000000000000002016080001000000000000005A00010B000000000000000000000000000000000000000000000000000000002016080001000000000000006A00010C00004000000000080012000000000000000000000000000000000000201608000100000000000000E100010D000040000000000A0013000000000000000000000000000000000000201608000100000000000000DE00010E000000000000000000000000000000000000000000000000000000001F080800010000009244001B050000001F08080001000000B1450032050000001F08080001000000E93A0018050000001F080800010000002C380015050000001F08080001000000073B001D050000001F08080001000000163B001E050000001F08080001000000C73B001F050000001F0808000100000068330033050000001F08080001000000BD3B0026050000001F08080001000000D5390020050000001F0808000100000085390021050000001F0808000100000097340022050000001F0808000100000032390023050000001F0808000100000034350027050000001D04080001000000417C0800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030000005E5A08001500000000000000000000000000000000000000000015154004151540041515400415154004151540041515400429294004151540041515400415154004151540041515400415154004151540041515400415154004151540041515400415154004000000000000000000000000000000000000000000000000000000000000000000000000000033000000000000006400000000000000010000001011000400000000000000000000000000000000716608000201C400010000000000000063180700AA0014040A1028084A267FC54A2693C94A2683C74A267FC54A2693C942124400FA0000002C912400338924C80A0001F398581280D88825C8030000FA96581200E34722C8000000FA913C128068C91DC8070000FA96F81100C8122D00000000FA2C1D3300688921C80B0000FA96581200E450420000FA001F2CB134006A891EC8000000FA96381200848822C8002E00F28C2812006B0923C8000000FA9658128064091DC8001900EE96201200CA123500000000FA2C053400716608000201C400010D00000000000063180700AA0014040A1028084A267FC54A2693C94A2683C74A267FC54A2693C96AC91FC800D100C896581200C69244000000FA002CB13400964924C80000FA009958120066091FC80000F8B49658120066490DC80000DBCB96581200164900C8000026E296381200CC5224C8000000FA2CB13200170200C8000000FA649011808E8C22C8000000FAC89412008E0C1EBB000000FAC8381200AE8F3EC8000000FAFAE81300AE8F3EC3000000FAFAE813008E3EFA00000000FAE8A33F000B0E0800010000000000000000000000000000000000000000000000
            //01000100EC000000D70ECB5F000000000000000000000000000000004F040100000000000A8201004455000000040040E17A9541AAF168C1AE478542000000002828640000840000000000000001000000000000F800000000000000D70ECB5F67919A230000F800040153106520533053408750486100704C80700070007000700000000000000000000000000001007824362A000000001C0000000000000000000000020000005365747A6F72000000000000000000000000000000000000000000002E5A400020A003000000000000000001000000000A000003FEFF0F00014B2525254B314B25324B4B4B4B4B1941003F0041003A00400045004700F1FFF5FFF1FFF0FF12001100360080040000AA0000000100000000000000000000000000000001000000081A0100BF0E54970FC07D2E56C00000F0FF5FFF8CB8E7A68762051F1A352530C9FDE31700000000000000000000000000000000
            //                                                        4F040100000000000A8201004455000000040040E17A9541AAF168C1AE478542000000002828640000840000000000000001000000000000F800000000000000D70ECB5F67919A230000F800040153106520533053408750486100704C80700070007000700000000000000000000000000001007824362A000000001C0000000000000000000000020000005365747A6F72000000000000000000000000000000000000000000002E5A400020A003000000000000000001000000000A000003FEFF0F00014B2525254B314B25324B4B4B4B4B1941003F0041003A00400045004700F1FFF5FFF1FFF0FF12001100360080040000AA0000000100000000000000000000000000000001000000081A0100BF0E54970FC07D2E56C00000F0FF5FFF8CB8E7A68762051F1A352530C9FDE317000000000000000000000000000000000015000000
            //01C633A96F16ABD2A1E1A65ACF02428E7A4A50923CA44FFAA2F5BCC7DFCF7EC6C7EE5FFD7EF943C5801888080C7D28C37E69525204880CDF4B516A52D4FA0E03FF22A00404560225500225F0FF55A03904C8C87D87FEDFBD14918158400088C5FFFF5FEE7ED2F6BD8C9CFFEACD3B7D201A1E5512410D35D412F95D22A83D289144124924915C7A9657CFD85E1BC1455B9244430E454392444312A2E17F4481DC9A96E0D5FF5F1D4964D5330CFE319A47987B4EEEE860BE244403221A32490FAB1EF09D8F80FB536489412D358C7AA65424FBFFCF9B060000

            ByteRef packetref      = new ByteRef(compressedbytes);
            uint    PacketDataSize = packetref.GetUInt32(packetref.Length - 4);

            //byte[] decompressed = Utility.Decompress(cb);
            byte[] decompressed = new byte[2520];
            int    count        = Compression.Decompress(compressedbytes, PacketDataSize, ref decompressed, 2520);


            string decompressedstr = Utility.ByteArrayToString(decompressed.Take(count).ToArray());

            Console.WriteLine(decompressedstr);

            byte[]  recompress     = new byte[2520];
            int     countb         = Compression.Compress(decompressed.Take(count).ToArray(), (uint)count, ref recompress, (uint)2520);
            int     compressedsize = Compression.CompressedSize(countb);
            ByteRef compressedData = new ByteRef(recompress.Take(compressedsize).ToArray());

            compressedData.Append(BitConverter.GetBytes(count));

            string recompressedstr = Utility.ByteArrayToString(compressedData.Get());

            Console.WriteLine(recompressedstr);


            checksum = Utility.Checksum(decompressedtargetbytes.Skip(0x1C).ToArray(), decompressedtargetbytes.Length - (28 + 16), decompressedtargetbytes.Skip(decompressedtargetbytes.Length - 16).ToArray());

            //checksum = Utility.Checksum(packet.Skip(0x1C).ToArray(), packet.Length - (28 + 16), packet.Skip(packet.Length - 16).ToArray());
            if (checksum != 0)
            {
                Logger.Error("checksum f****d");
            }
        }