Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Globalization;
- using System.IO;
- using System.IO.Compression;
- using System.Linq;
- using System.Net;
- using System.Text;
- using System.Xml;
- namespace ConsoleApplication87
- {
- class Program
- {
- static void Main(string[] args)
- {
- string baseUrl = args.Last();
- Console.Write(">");
- var wc = new WebClient();
- byte[] propSwf = wc.DownloadData(baseUrl + "assets/flash/properties.swf");
- Console.Write("*");
- propSwf[0] = 0x50;
- propSwf[1] = 0x4B;
- propSwf[2] = 0x03;
- propSwf[3] = 0x04;
- var pms = new MemoryStream();
- new ZipArchive(new MemoryStream(propSwf)).Entries[0].Open().CopyTo(pms);
- var propXml = Encoding.UTF8.GetString(pms.ToArray().Skip(3).ToArray());
- XmlDocument doc = new XmlDocument();
- doc.LoadXml(propXml);
- int pageCount = doc.SelectNodes("/Properties/bookProperties/pages/elements/page").Count;
- byte[] fbSwf = wc.DownloadData(baseUrl + "flash/flippingbook.swf");
- Console.Write("*");
- var fms = new MemoryStream(fbSwf);
- fms.Seek(10, SeekOrigin.Begin);
- var z = new DeflateStream(fms, CompressionMode.Decompress);
- var ufms = new MemoryStream();
- z.CopyTo(ufms);
- var ufm = ufms.ToArray();
- bool encrypted = true;
- if (ufm[0x7EDBC] == 0x66)
- ufms.Seek(0x7ED9B, SeekOrigin.Begin);
- else if (ufm[0x7ED9B] == 0x66)
- encrypted = false;
- else if (ufm[0x81458] == 0x54)
- ufms.Seek(0x81411, SeekOrigin.Begin);
- else
- {
- Console.WriteLine("Fail");
- return;
- }
- int so = 0;
- int sx = 0;
- if (encrypted)
- {
- byte[] keyRaw = new byte[32];
- ufms.Read(keyRaw, 0, 32);
- string key = Encoding.ASCII.GetString(keyRaw);
- so = 8 + int.Parse(key.Substring(0, 2), NumberStyles.HexNumber) % 8;
- sx = int.Parse(key.Substring(4, 2), NumberStyles.HexNumber);
- }
- Directory.CreateDirectory("pages");
- for (int i = 1; i <= pageCount; i++)
- {
- var fileName = "page" + i.ToString("0000") + "_l.jpg";
- var filePath = "pages\\" + fileName;
- if (File.Exists(filePath))
- {
- Console.Write("-");
- continue;
- }
- byte[] v = wc.DownloadData(baseUrl + "assets/flash/pages/" + fileName);
- if (encrypted)
- {
- int a = so;
- int x = sx + 1;
- while (a < v.Length)
- {
- v[a] = (byte)(v[a] ^ x++);
- a = a + ((a ^ sx) & 3) + 1;
- }
- }
- File.WriteAllBytes(filePath, v);
- Console.Write(".");
- }
- Console.WriteLine("Done");
- }
- }
- }
Add Comment
Please, Sign In to add comment