Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.54 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3. using System.IO;
  4. using System.IO.Compression;
  5. using System.Linq;
  6. using System.Net;
  7. using System.Text;
  8. using System.Xml;
  9.  
  10. namespace ConsoleApplication87
  11. {
  12.     class Program
  13.     {
  14.         static void Main(string[] args)
  15.         {
  16.             string baseUrl = args.Last();
  17.  
  18.             Console.Write(">");
  19.  
  20.             var wc = new WebClient();
  21.  
  22.             byte[] propSwf = wc.DownloadData(baseUrl + "assets/flash/properties.swf");
  23.             Console.Write("*");
  24.  
  25.             propSwf[0] = 0x50;
  26.             propSwf[1] = 0x4B;
  27.             propSwf[2] = 0x03;
  28.             propSwf[3] = 0x04;
  29.  
  30.             var pms = new MemoryStream();
  31.             new ZipArchive(new MemoryStream(propSwf)).Entries[0].Open().CopyTo(pms);
  32.             var propXml = Encoding.UTF8.GetString(pms.ToArray().Skip(3).ToArray());
  33.  
  34.             XmlDocument doc = new XmlDocument();
  35.             doc.LoadXml(propXml);
  36.  
  37.             int pageCount = doc.SelectNodes("/Properties/bookProperties/pages/elements/page").Count;
  38.  
  39.             byte[] fbSwf = wc.DownloadData(baseUrl + "flash/flippingbook.swf");
  40.             Console.Write("*");
  41.  
  42.             var ms = new MemoryStream(fbSwf);
  43.             var msInner = new MemoryStream();
  44.             ms.Seek(10, SeekOrigin.Begin);
  45.             var z = new DeflateStream(ms, CompressionMode.Decompress);
  46.             z.CopyTo(msInner);
  47.             msInner.Seek(0x7ED9B, SeekOrigin.Begin);
  48.             byte[] keyRaw = new byte[32];
  49.             msInner.Read(keyRaw, 0, 32);
  50.             string key = Encoding.ASCII.GetString(keyRaw);
  51.  
  52.             int so = 8 + int.Parse(key.Substring(0, 2), NumberStyles.HexNumber) % 8;
  53.             int sx = int.Parse(key.Substring(4, 2), NumberStyles.HexNumber);
  54.  
  55.             Directory.CreateDirectory("pages");
  56.  
  57.             for (int i = 1; i <= pageCount; i++)
  58.             {
  59.                 var fileName = "page" + i.ToString("0000") + "_l.jpg";
  60.                 var filePath = "pages\\" + fileName;
  61.                 if (File.Exists(filePath))
  62.                     continue;
  63.  
  64.                 byte[] v = wc.DownloadData(baseUrl + "assets/flash/pages/" + fileName);
  65.  
  66.                 int a = so;
  67.                 int x = sx + 1;
  68.                 while (a < v.Length)
  69.                 {
  70.                     v[a] = (byte)(v[a] ^ x++);
  71.                     a = a + ((a ^ sx) & 3) + 1;
  72.                 }
  73.  
  74.                 File.WriteAllBytes(filePath, v);
  75.                 Console.Write(".");
  76.             }
  77.             Console.WriteLine("Done");
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement