Advertisement
Guest User

CodeVest.sh

a guest
Feb 27th, 2018
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.49 KB | None | 0 0
  1. using System;
  2. using System.Collections.Specialized;
  3. using System.Diagnostics;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Net;
  7. using System.Reflection;
  8. using System.Runtime.CompilerServices;
  9. using System.Security.Cryptography;
  10. using System.Text;
  11. using System.Threading;
  12. using System.Timers;
  13. using System.Windows.Forms;
  14. using Microsoft.VisualBasic;
  15. using Microsoft.VisualBasic.CompilerServices;
  16. using WindowsApplication1.My;
  17.  
  18. namespace WindowsApplication1.CodeVest
  19. {
  20. // Token: 0x02000008 RID: 8
  21. internal class CodeVest
  22. {
  23. // Token: 0x14000001 RID: 1
  24. // (add) Token: 0x06000024 RID: 36 RVA: 0x00033B30 File Offset: 0x00031F30
  25. // (remove) Token: 0x06000025 RID: 37 RVA: 0x00033B4C File Offset: 0x00031F4C
  26. public event CodeVest.RunHookHandler RunHookSuccess
  27. {
  28. [MethodImpl(MethodImplOptions.Synchronized)]
  29. add
  30. {
  31. this.RunHookSuccessEvent = (CodeVest.RunHookHandler)Delegate.Combine(this.RunHookSuccessEvent, value);
  32. }
  33. [MethodImpl(MethodImplOptions.Synchronized)]
  34. remove
  35. {
  36. this.RunHookSuccessEvent = (CodeVest.RunHookHandler)Delegate.Remove(this.RunHookSuccessEvent, value);
  37. }
  38. }
  39.  
  40. // Token: 0x14000002 RID: 2
  41. // (add) Token: 0x06000026 RID: 38 RVA: 0x00033B68 File Offset: 0x00031F68
  42. // (remove) Token: 0x06000027 RID: 39 RVA: 0x00033B84 File Offset: 0x00031F84
  43. public event CodeVest.RunHookHandler RunHookFail
  44. {
  45. [MethodImpl(MethodImplOptions.Synchronized)]
  46. add
  47. {
  48. this.RunHookFailEvent = (CodeVest.RunHookHandler)Delegate.Combine(this.RunHookFailEvent, value);
  49. }
  50. [MethodImpl(MethodImplOptions.Synchronized)]
  51. remove
  52. {
  53. this.RunHookFailEvent = (CodeVest.RunHookHandler)Delegate.Remove(this.RunHookFailEvent, value);
  54. }
  55. }
  56.  
  57. // Token: 0x1700000B RID: 11
  58. // (get) Token: 0x06000028 RID: 40 RVA: 0x00033BA0 File Offset: 0x00031FA0
  59. public string UserName
  60. {
  61. get
  62. {
  63. return this._Username;
  64. }
  65. }
  66.  
  67. // Token: 0x1700000C RID: 12
  68. // (get) Token: 0x06000029 RID: 41 RVA: 0x00033BB4 File Offset: 0x00031FB4
  69. public DateTime ExpirationDate
  70. {
  71. get
  72. {
  73. return this.valid_till;
  74. }
  75. }
  76.  
  77. // Token: 0x1700000D RID: 13
  78. // (get) Token: 0x0600002A RID: 42 RVA: 0x00033BC8 File Offset: 0x00031FC8
  79. public TimeSpan TimeRemaining
  80. {
  81. get
  82. {
  83. if (this.valid_till.Subtract(DateTime.Now).Days < 0)
  84. {
  85. return TimeSpan.Zero;
  86. }
  87. return this.valid_till.Subtract(DateTime.Now);
  88. }
  89. }
  90.  
  91. // Token: 0x1700000E RID: 14
  92. // (get) Token: 0x0600002B RID: 43 RVA: 0x00033C08 File Offset: 0x00032008
  93. public CodeVest.LicenseTypes LicenseType
  94. {
  95. get
  96. {
  97. return this._license_type;
  98. }
  99. }
  100.  
  101. // Token: 0x1700000F RID: 15
  102. // (get) Token: 0x0600002C RID: 44 RVA: 0x00033C1C File Offset: 0x0003201C
  103. public bool LicenseExpires
  104. {
  105. get
  106. {
  107. return true;
  108. }
  109. }
  110.  
  111. // Token: 0x17000010 RID: 16
  112. // (get) Token: 0x0600002D RID: 45 RVA: 0x00033C2C File Offset: 0x0003202C
  113. public string MachineId
  114. {
  115. get
  116. {
  117. return this.hardwareId;
  118. }
  119. }
  120.  
  121. // Token: 0x0600002E RID: 46 RVA: 0x00033C40 File Offset: 0x00032040
  122. public CodeVest()
  123. {
  124. this._Version = new Version(0, 2, 1, 1);
  125. CodeVest.cv = this;
  126. this._PreferredMetadataEndPoint = "https://codevest.sh/codevest_api.php";
  127. this._AlternateMetadataEndPoint = "http://codevest.sh/codevest_api2.php";
  128. }
  129.  
  130. // Token: 0x0600002F RID: 47 RVA: 0x00033C74 File Offset: 0x00032074
  131. public void Initialize(string productId, string key)
  132. {
  133. this.Initialize(productId, key, new CodeVest.codeVestSettings());
  134. }
  135.  
  136. // Token: 0x06000030 RID: 48 RVA: 0x00033C84 File Offset: 0x00032084
  137. public static void ClipboardTimerHandler(object sender, ElapsedEventArgs e)
  138. {
  139. Thread thread = new Thread(delegate()
  140. {
  141. if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text))
  142. {
  143. string text = Clipboard.GetText();
  144. if (Operators.CompareString(text, Encoding.ASCII.GetString(CodeVest._PrivateKey_new), false) == 0 | Operators.CompareString(text, Encoding.ASCII.GetString(CodeVest._PrivateKey_first), false) == 0)
  145. {
  146. Clipboard.SetText(text.Substring(0, 5) + text.Substring(6));
  147. }
  148. }
  149. });
  150. thread.SetApartmentState(ApartmentState.STA);
  151. thread.Start();
  152. thread.Join();
  153. }
  154.  
  155. // Token: 0x17000011 RID: 17
  156. // (get) Token: 0x06000031 RID: 49 RVA: 0x00033CBC File Offset: 0x000320BC
  157. // (set) Token: 0x06000032 RID: 50 RVA: 0x00033CD0 File Offset: 0x000320D0
  158. public virtual WebClient client
  159. {
  160. get
  161. {
  162. return this._client;
  163. }
  164. [MethodImpl(MethodImplOptions.Synchronized)]
  165. set
  166. {
  167. DownloadProgressChangedEventHandler value2 = new DownloadProgressChangedEventHandler(this.download_progress);
  168. if (this._client != null)
  169. {
  170. this._client.DownloadProgressChanged -= value2;
  171. }
  172. this._client = value;
  173. if (this._client != null)
  174. {
  175. this._client.DownloadProgressChanged += value2;
  176. }
  177. }
  178. }
  179.  
  180. // Token: 0x06000033 RID: 51 RVA: 0x00033D1C File Offset: 0x0003211C
  181. public void updateApp(string url)
  182. {
  183. this.client = new WebClient();
  184. try
  185. {
  186. if (Operators.CompareString(url.Substring(0, 1), "@", false) == 0)
  187. {
  188. if (File.Exists(Path.GetTempPath() + "codevest_update.exe"))
  189. {
  190. File.Delete(Path.GetTempPath() + "codevest_update.exe");
  191. }
  192. MyProject.Forms.frmCVUpdate.Show();
  193. this.client.DownloadFileAsync(new Uri(url.Substring(1)), Path.GetTempPath() + "codevest_update.exe");
  194. }
  195. else
  196. {
  197. this.client.DownloadFileAsync(new Uri(url), Path.GetTempPath() + "codevest_update.exe");
  198. Process.Start(Path.GetTempPath() + "codevest_update.exe");
  199. }
  200. }
  201. catch (Exception ex)
  202. {
  203. MessageBox.Show("The update can't be found, please make sure that any security software is disabled and lastly use a VPN !");
  204. Environment.Exit(0);
  205. }
  206. for (;;)
  207. {
  208. Application.DoEvents();
  209. }
  210. }
  211.  
  212. // Token: 0x06000034 RID: 52 RVA: 0x00033E18 File Offset: 0x00032218
  213. private void download_progress(object sender, DownloadProgressChangedEventArgs e)
  214. {
  215. checked
  216. {
  217. int value = (int)Math.Round((double)e.BytesReceived / 1000000.0);
  218. int value2 = (int)Math.Round((double)e.TotalBytesToReceive / 1000000.0);
  219. MyProject.Forms.frmCVUpdate.Label1.Text = string.Concat(new string[]
  220. {
  221. "Download:",
  222. Conversions.ToString(value),
  223. " MB / ",
  224. Conversions.ToString(value2),
  225. "MB"
  226. });
  227. MyProject.Forms.frmCVUpdate.ProgressBar1.Value = e.ProgressPercentage;
  228. MyProject.Forms.frmCVUpdate.Label2.Text = Conversions.ToString(MyProject.Forms.frmCVUpdate.ProgressBar1.Value) + "%";
  229. if (MyProject.Forms.frmCVUpdate.ProgressBar1.Value == 100)
  230. {
  231. try
  232. {
  233. if (File.Exists(Path.GetTempPath() + "codevest_update.exe"))
  234. {
  235. string text = AppDomain.CurrentDomain.BaseDirectory + AppDomain.CurrentDomain.FriendlyName;
  236. if (File.Exists(text + ".bck"))
  237. {
  238. File.Delete(text + ".bck");
  239. }
  240. File.Move(text, text + ".bck");
  241. File.Move(Path.GetTempPath() + "codevest_update.exe", text);
  242. if (File.Exists(text))
  243. {
  244. Process.Start(text);
  245. }
  246. else
  247. {
  248. Interaction.MsgBox("There seems to be an error, make sure any security software is disabled, lastly use a VPN !", MsgBoxStyle.OkOnly, null);
  249. }
  250. Environment.Exit(0);
  251. }
  252. }
  253. catch (Exception ex)
  254. {
  255. }
  256. }
  257. }
  258. }
  259.  
  260. // Token: 0x06000035 RID: 53 RVA: 0x00033FD4 File Offset: 0x000323D4
  261. public void Initialize(string productId, string Privatekey, CodeVest.codeVestSettings settings)
  262. {
  263. if (this._Authenticator != null)
  264. {
  265. throw new Exception("Loader has already been initialized.");
  266. }
  267. if (settings == null)
  268. {
  269. throw new ArgumentNullException("settings");
  270. }
  271. this._k = "";
  272. this._ProductId = productId;
  273. this._PrivateKey = Privatekey;
  274. CodeVest._timer = new System.Timers.Timer(3000.0);
  275. CodeVest._timer.Elapsed += CodeVest.ClipboardTimerHandler;
  276. CodeVest._timer.Enabled = true;
  277. CodeVest._PrivateKey_first = Encoding.ASCII.GetBytes(FingerPrint.GetMD5("o6806a42kbM7c5K%!>" + Privatekey).Substring(0, 14));
  278. CodeVest._PrivateKey_new = CodeVest._PrivateKey_first;
  279. this.hardwareId = FingerPrint.Value();
  280. NameValueCollection nameValueCollection = new NameValueCollection();
  281. NameValueCollection nameValueCollection2 = new NameValueCollection();
  282. while (Operators.CompareString(nameValueCollection2["success"], "1", false) != 0)
  283. {
  284. frmCVLogin frmCVLogin = new frmCVLogin();
  285. DialogResult dialogResult = frmCVLogin.ShowDialog();
  286. if (dialogResult == DialogResult.OK)
  287. {
  288. nameValueCollection["username"] = frmCVLogin.username;
  289. nameValueCollection["password"] = frmCVLogin.password;
  290. nameValueCollection["fn"] = "login";
  291. nameValueCollection2 = this.HTTP_request(nameValueCollection);
  292. if (Operators.CompareString(nameValueCollection2["error"], "1", false) == 0)
  293. {
  294. MessageBox.Show(nameValueCollection2["msg"]);
  295. }
  296. }
  297. else
  298. {
  299. Environment.Exit(-1);
  300. }
  301. }
  302. if (Operators.CompareString(nameValueCollection2["startup_message"], "", false) != 0)
  303. {
  304. MessageBox.Show(nameValueCollection2["startup_message"]);
  305. }
  306. DateTime.TryParse(nameValueCollection2["valid_till"], out this.valid_till);
  307. this._license_type = (CodeVest.LicenseTypes)Conversions.ToByte(Enum.Parse(typeof(CodeVest.LicenseTypes), nameValueCollection2["license_type"]));
  308. this._Username = nameValueCollection["username"];
  309. this._Password = nameValueCollection["password"];
  310. if (Operators.CompareString(nameValueCollection2["last_version"], Assembly.GetEntryAssembly().GetName().Version.ToString(4), false) != 0)
  311. {
  312. if (Operators.CompareString(nameValueCollection2["force_update"], "2", false) != 0)
  313. {
  314. if (Operators.CompareString(nameValueCollection2["force_update"], "1", false) == 0)
  315. {
  316. this.updateApp(nameValueCollection2["update_url"]);
  317. }
  318. else if (MessageBox.Show(string.Concat(new string[]
  319. {
  320. "New version available. Do you want to update from",
  321. Assembly.GetEntryAssembly().GetName().Version.ToString(4),
  322. " to ",
  323. nameValueCollection2["last_version"],
  324. "?"
  325. }), "CodeVest", MessageBoxButtons.YesNo) == DialogResult.Yes)
  326. {
  327. this.updateApp(nameValueCollection2["update_url"]);
  328. }
  329. }
  330. }
  331. }
  332.  
  333. // Token: 0x06000036 RID: 54 RVA: 0x000342A4 File Offset: 0x000326A4
  334. public void runHook()
  335. {
  336. NameValueCollection nameValueCollection = new NameValueCollection();
  337. NameValueCollection nameValueCollection2 = new NameValueCollection();
  338. nameValueCollection["username"] = this._Username;
  339. nameValueCollection["password"] = this._Password;
  340. nameValueCollection["fn"] = "login";
  341. nameValueCollection2 = this.HTTP_request(nameValueCollection);
  342. if (Operators.CompareString(nameValueCollection2["error"], "1", false) == 0)
  343. {
  344. CodeVest.RunHookHandler runHookHandler = this.RunHookFailEvent;
  345. if (runHookHandler != null)
  346. {
  347. runHookHandler(this, new EventArgs());
  348. }
  349. }
  350. else
  351. {
  352. CodeVest.RunHookHandler runHookHandler = this.RunHookSuccessEvent;
  353. if (runHookHandler != null)
  354. {
  355. runHookHandler(this, new EventArgs());
  356. }
  357. }
  358. }
  359.  
  360. // Token: 0x06000037 RID: 55 RVA: 0x00034340 File Offset: 0x00032740
  361. public string getGlobalSecureVariable(string name)
  362. {
  363. NameValueCollection nameValueCollection = new NameValueCollection();
  364. NameValueCollection nameValueCollection2 = new NameValueCollection();
  365. nameValueCollection["fn"] = "getVar";
  366. nameValueCollection["varName"] = name;
  367. nameValueCollection2 = this.HTTP_request(nameValueCollection);
  368. if (Operators.CompareString(nameValueCollection2["success"], "1", false) == 0)
  369. {
  370. return nameValueCollection2["value"];
  371. }
  372. return "";
  373. }
  374.  
  375. // Token: 0x06000038 RID: 56 RVA: 0x000343A8 File Offset: 0x000327A8
  376. public string getSecureVariable(string name)
  377. {
  378. NameValueCollection nameValueCollection = new NameValueCollection();
  379. NameValueCollection nameValueCollection2 = new NameValueCollection();
  380. nameValueCollection["username"] = this._Username;
  381. nameValueCollection["password"] = this._Password;
  382. nameValueCollection["fn"] = "getVar";
  383. nameValueCollection["varName"] = name;
  384. nameValueCollection2 = this.HTTP_request(nameValueCollection);
  385. if (Operators.CompareString(nameValueCollection2["success"], "1", false) == 0)
  386. {
  387. return nameValueCollection2["value"];
  388. }
  389. return "";
  390. }
  391.  
  392. // Token: 0x06000039 RID: 57 RVA: 0x00034434 File Offset: 0x00032834
  393. public bool setSecureVariable(string name, string value)
  394. {
  395. NameValueCollection nameValueCollection = new NameValueCollection();
  396. NameValueCollection nameValueCollection2 = new NameValueCollection();
  397. nameValueCollection["username"] = this._Username;
  398. nameValueCollection["password"] = this._Password;
  399. nameValueCollection["fn"] = "setVar";
  400. nameValueCollection["varName"] = name;
  401. nameValueCollection["varValue"] = value;
  402. nameValueCollection2 = this.HTTP_request(nameValueCollection);
  403. return Operators.CompareString(nameValueCollection2["success"], "1", false) == 0;
  404. }
  405.  
  406. // Token: 0x0600003A RID: 58 RVA: 0x000344BC File Offset: 0x000328BC
  407. public bool blocLicense()
  408. {
  409. NameValueCollection nameValueCollection = new NameValueCollection();
  410. NameValueCollection nameValueCollection2 = new NameValueCollection();
  411. nameValueCollection["username"] = this._Username;
  412. nameValueCollection["password"] = this._Password;
  413. nameValueCollection["fn"] = "blockLic";
  414. nameValueCollection2 = this.HTTP_request(nameValueCollection);
  415. return Operators.CompareString(nameValueCollection2["success"], "1", false) == 0;
  416. }
  417.  
  418. // Token: 0x0600003B RID: 59 RVA: 0x0003452C File Offset: 0x0003292C
  419. public bool setGlobalSecureVariable(string name, string value)
  420. {
  421. NameValueCollection nameValueCollection = new NameValueCollection();
  422. NameValueCollection nameValueCollection2 = new NameValueCollection();
  423. nameValueCollection["fn"] = "setVar";
  424. nameValueCollection["varName"] = name;
  425. nameValueCollection["varValue"] = value;
  426. nameValueCollection2 = this.HTTP_request(nameValueCollection);
  427. return Operators.CompareString(nameValueCollection2["success"], "1", false) == 0;
  428. }
  429.  
  430. // Token: 0x0600003C RID: 60 RVA: 0x00034594 File Offset: 0x00032994
  431. public NameValueCollection HTTP_request(NameValueCollection values)
  432. {
  433. WebClient webClient = new WebClient();
  434. NameValueCollection nameValueCollection = new NameValueCollection();
  435. NameValueCollection nameValueCollection2 = new NameValueCollection();
  436. NameValueCollection nameValueCollection3 = new NameValueCollection();
  437. webClient.Proxy = new WebProxy();
  438. nameValueCollection3["hardware_id"] = this.hardwareId;
  439. nameValueCollection3["hid"] = FingerPrint.fingerPrintDebug;
  440. nameValueCollection3["fn"] = "get_key";
  441. if (Operators.CompareString(values["username"], "", false) != 0)
  442. {
  443. this._Username = values["username"];
  444. this._Password = values["password"];
  445. }
  446. nameValueCollection3["username"] = this._Username;
  447. nameValueCollection3["password"] = this._Password;
  448. string text = "";
  449. int num = 0;
  450. checked
  451. {
  452. int num2 = nameValueCollection3.AllKeys.Count<string>() - 1;
  453. for (int i = num; i <= num2; i++)
  454. {
  455. text = string.Concat(new string[]
  456. {
  457. text,
  458. nameValueCollection3.GetKey(i),
  459. "=",
  460. nameValueCollection3.Get(i).Replace("\n", "\r\r"),
  461. "\n"
  462. });
  463. }
  464. nameValueCollection.Add("data", this.EncryptStringAES(text, this._PrivateKey));
  465.  
  466. byte[] bytes = webClient.UploadValues(string.Concat(new string[]
  467. {
  468. this._PreferredMetadataEndPoint,
  469. "?p_id=",
  470. this._ProductId,
  471. "&v=",
  472. this._Version.ToString(4),
  473. "&k=",
  474. this._k,
  475. "&get_key=1"
  476. }), "POST", nameValueCollection);
  477. string @string = Encoding.ASCII.GetString(bytes);
  478. string text2 = this.DecryptStringAES(@string, this._PrivateKey);
  479. if (text2.Length > 5 & (text2.IndexOf("ror=1") < 1 & text2.IndexOf("ccess=1") < 1))
  480. {
  481. CodeVest._PrivateKey_new = CodeVest._PrivateKey_first;
  482. nameValueCollection2.Add("data", this.EncryptStringAES(text, this._PrivateKey));
  483. bytes = webClient.UploadValues(string.Concat(new string[]
  484. {
  485. this._PreferredMetadataEndPoint,
  486. "?p_id=",
  487. this._ProductId,
  488. "&v=",
  489. this._Version.ToString(4),
  490. "&get_key=1"
  491. }), "POST", nameValueCollection2);
  492. @string = Encoding.ASCII.GetString(bytes);
  493. text2 = this.DecryptStringAES(@string, this._PrivateKey);
  494. if (text2.Length > 5 & (text2.IndexOf("ror=1") < 1 & text2.IndexOf("ccess=1") < 1))
  495. {
  496. MessageBox.Show("Application license error");
  497. Environment.Exit(1);
  498. }
  499. }
  500. string[] array = text2.Split(new char[]
  501. {
  502. '\n'
  503. });
  504. NameValueCollection nameValueCollection4 = new NameValueCollection();
  505. foreach (string text3 in array)
  506. {
  507. if (text3.Length > 0 && Operators.CompareString(Conversions.ToString(text3[0]), "\0", false) != 0)
  508. {
  509. nameValueCollection4.Set(text3.Split(new char[]
  510. {
  511. '='
  512. }).ElementAt(0), text3.Split(new char[]
  513. {
  514. '='
  515. }).ElementAt(1).Replace("\r\r", "\n"));
  516. }
  517. }
  518. if (Operators.CompareString(nameValueCollection4["error"], "1", false) == 0)
  519. {
  520. MessageBox.Show(nameValueCollection4["msg"]);
  521. }
  522. else
  523. {
  524. CodeVest._PrivateKey_new = Encoding.ASCII.GetBytes(nameValueCollection4["key"]);
  525. this._k = nameValueCollection4["key_id"];
  526. }
  527. return this.HTTP_direct_request(values);
  528. }
  529. }
  530.  
  531. // Token: 0x0600003D RID: 61 RVA: 0x00034998 File Offset: 0x00032D98
  532. public NameValueCollection HTTP_direct_request(NameValueCollection values)
  533. {
  534. WebClient webClient = new WebClient();
  535. NameValueCollection nameValueCollection = new NameValueCollection();
  536. webClient.Proxy = new WebProxy();
  537. values["hardware_id"] = this.hardwareId;
  538. values["hid"] = FingerPrint.fingerPrintDebug;
  539. string text = "";
  540. int num = 0;
  541. checked
  542. {
  543. int num2 = values.AllKeys.Count<string>() - 1;
  544. for (int i = num; i <= num2; i++)
  545. {
  546. text = string.Concat(new string[]
  547. {
  548. text,
  549. values.GetKey(i),
  550. "=",
  551. values.Get(i).Replace("\n", "\r\\n\r"),
  552. "\n"
  553. });
  554. }
  555. nameValueCollection.Add("data", this.EncryptStringAES(text, this._PrivateKey));
  556. byte[] bytes = webClient.UploadValues(string.Concat(new string[]
  557. {
  558. this._PreferredMetadataEndPoint,
  559. "?p_id=",
  560. this._ProductId,
  561. "&v=",
  562. this._Version.ToString(4),
  563. "&k=",
  564. this._k,
  565. (Operators.CompareString(values["fn"], "get_key", false) == 0) ? "&get_key=1" : ""
  566. }), "POST", nameValueCollection);
  567. string @string = Encoding.ASCII.GetString(bytes);
  568. string text2 = this.DecryptStringAES(@string, this._PrivateKey);
  569. if (text2.Length > 5 & (text2.IndexOf("ror=1") < 1 & text2.IndexOf("ccess=1") < 1))
  570. {
  571. MessageBox.Show("Application license error");
  572. Environment.Exit(1);
  573. }
  574. string[] array = text2.Split(new char[]
  575. {
  576. '\n'
  577. });
  578. NameValueCollection nameValueCollection2 = new NameValueCollection();
  579. foreach (string text3 in array)
  580. {
  581. if (text3.Length > 0 && Operators.CompareString(Conversions.ToString(text3[0]), "\0", false) != 0)
  582. {
  583. nameValueCollection2.Set(text3.Split(new char[]
  584. {
  585. '='
  586. }).ElementAt(0), text3.Split(new char[]
  587. {
  588. '='
  589. }).ElementAt(1).Replace("\r\\n\r", "\n"));
  590. }
  591. }
  592. return nameValueCollection2;
  593. }
  594. }
  595.  
  596. // Token: 0x0600003E RID: 62 RVA: 0x00034C18 File Offset: 0x00033018
  597. public string EncryptStringAES(string plainText, string sharedSecret)
  598. {
  599. if (string.IsNullOrEmpty(plainText))
  600. {
  601. throw new ArgumentNullException("plainText");
  602. }
  603. if (string.IsNullOrEmpty(sharedSecret))
  604. {
  605. throw new ArgumentNullException("sharedSecret");
  606. }
  607. Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(sharedSecret, CodeVest._PrivateKey_new);
  608. RijndaelManaged rijndaelManaged = new RijndaelManaged();
  609. rijndaelManaged.BlockSize = 256;
  610. rijndaelManaged.Mode = CipherMode.ECB;
  611. rijndaelManaged.Padding = PaddingMode.Zeros;
  612. rijndaelManaged.IV = Encoding.ASCII.GetBytes("2017+-04+-2017+T+12:12:230000000");
  613. rijndaelManaged.Key = rfc2898DeriveBytes.GetBytes(checked((int)Math.Round((double)rijndaelManaged.KeySize / 8.0)));
  614. ICryptoTransform transform = rijndaelManaged.CreateEncryptor(rijndaelManaged.Key, rijndaelManaged.IV);
  615. MemoryStream memoryStream = new MemoryStream();
  616. CryptoStream cryptoStream = new CryptoStream(memoryStream, transform, CryptoStreamMode.Write);
  617. StreamWriter streamWriter = new StreamWriter(cryptoStream);
  618. streamWriter.AutoFlush = true;
  619. streamWriter.Write(plainText);
  620. streamWriter.Flush();
  621. cryptoStream.FlushFinalBlock();
  622. string result = Convert.ToBase64String(memoryStream.ToArray(), Base64FormattingOptions.None);
  623. if (rijndaelManaged != null)
  624. {
  625. rijndaelManaged.Clear();
  626. }
  627. return result;
  628. }
  629.  
  630. // Token: 0x0600003F RID: 63 RVA: 0x00034D18 File Offset: 0x00033118
  631. private static string DecryptStringFromBytes(byte[] cipherText, byte[] key)
  632. {
  633. if (cipherText == null || cipherText.Length <= 0)
  634. {
  635. throw new ArgumentNullException("cipherText");
  636. }
  637. if (key == null || key.Length <= 0)
  638. {
  639. throw new ArgumentNullException("key");
  640. }
  641. RijndaelManaged rijndaelManaged = new RijndaelManaged();
  642. rijndaelManaged.BlockSize = 256;
  643. rijndaelManaged.Key = key;
  644. rijndaelManaged.Mode = CipherMode.ECB;
  645. rijndaelManaged.Padding = PaddingMode.Zeros;
  646. rijndaelManaged.IV = new byte[]
  647. {
  648. 0,
  649. 0,
  650. 0,
  651. 0,
  652. 0,
  653. 0,
  654. 0,
  655. 0,
  656. 0,
  657. 0,
  658. 0,
  659. 0,
  660. 0,
  661. 0,
  662. 0,
  663. 0,
  664. 0,
  665. 0,
  666. 0,
  667. 0,
  668. 0,
  669. 0,
  670. 0,
  671. 0,
  672. 0,
  673. 0,
  674. 0,
  675. 0,
  676. 0,
  677. 0,
  678. 0,
  679. 0
  680. };
  681. ICryptoTransform transform = rijndaelManaged.CreateDecryptor(rijndaelManaged.Key, rijndaelManaged.IV);
  682. MemoryStream stream = new MemoryStream(cipherText);
  683. CryptoStream stream2 = new CryptoStream(stream, transform, CryptoStreamMode.Read);
  684. StreamReader streamReader = new StreamReader(stream2);
  685. return streamReader.ReadToEnd();
  686. }
  687.  
  688. // Token: 0x06000040 RID: 64 RVA: 0x00034E7C File Offset: 0x0003327C
  689. public string DecryptStringAES(string cipherText, string sharedSecret)
  690. {
  691. if (string.IsNullOrEmpty(cipherText))
  692. {
  693. throw new ArgumentNullException("cipherText");
  694. }
  695. if (string.IsNullOrEmpty(sharedSecret))
  696. {
  697. throw new ArgumentNullException("sharedSecret");
  698. }
  699. RijndaelManaged rijndaelManaged = null;
  700. string result = null;
  701. try
  702. {
  703. Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes(sharedSecret, CodeVest._PrivateKey_new);
  704. byte[] buffer = Convert.FromBase64String(cipherText);
  705. MemoryStream stream = new MemoryStream(buffer);
  706. rijndaelManaged = new RijndaelManaged();
  707. rijndaelManaged.Key = rfc2898DeriveBytes.GetBytes(checked((int)Math.Round((double)rijndaelManaged.KeySize / 8.0)));
  708. rijndaelManaged.BlockSize = 256;
  709. rijndaelManaged.Mode = CipherMode.ECB;
  710. rijndaelManaged.Padding = PaddingMode.Zeros;
  711. rijndaelManaged.IV = Encoding.ASCII.GetBytes("2017+-04+-2017+T+12:12:230000000");
  712. ICryptoTransform transform = rijndaelManaged.CreateDecryptor(rijndaelManaged.Key, rijndaelManaged.IV);
  713. CryptoStream stream2 = new CryptoStream(stream, transform, CryptoStreamMode.Read);
  714. StreamReader streamReader = new StreamReader(stream2);
  715. result = streamReader.ReadToEnd();
  716. }
  717. catch (Exception ex)
  718. {
  719. MessageBox.Show("Server error or encoding error: " + ex.Message);
  720. }
  721. finally
  722. {
  723. if (rijndaelManaged != null)
  724. {
  725. rijndaelManaged.Clear();
  726. }
  727. }
  728. return result;
  729. }
  730.  
  731. // Token: 0x06000041 RID: 65 RVA: 0x00034FA8 File Offset: 0x000333A8
  732. private static byte[] ReadByteArray(Stream s)
  733. {
  734. byte[] array = new byte[0];
  735. if (s.Read(array, 0, array.Length) != array.Length)
  736. {
  737. throw new SystemException("Stream did not contain properly formatted byte array");
  738. }
  739. byte[] array2 = new byte[checked(BitConverter.ToInt32(array, 0) - 1 + 1)];
  740. if (s.Read(array2, 0, array2.Length) != array2.Length)
  741. {
  742. throw new SystemException("Did not read byte array properly");
  743. }
  744. return array2;
  745. }
  746.  
  747. // Token: 0x0400000C RID: 12
  748. public static CodeVest cv = null;
  749.  
  750. // Token: 0x0400000D RID: 13
  751. private CodeVest.RunHookHandler RunHookSuccessEvent;
  752.  
  753. // Token: 0x0400000E RID: 14
  754. private CodeVest.RunHookHandler RunHookFailEvent;
  755.  
  756. // Token: 0x0400000F RID: 15
  757. public DateTime valid_till;
  758.  
  759. // Token: 0x04000010 RID: 16
  760. private static System.Timers.Timer _timer;
  761.  
  762. // Token: 0x04000011 RID: 17
  763. private CodeVest.LicenseTypes _license_type;
  764.  
  765. // Token: 0x04000012 RID: 18
  766. private Version _Version;
  767.  
  768. // Token: 0x04000013 RID: 19
  769. private string _PreferredMetadataEndPoint;
  770.  
  771. // Token: 0x04000014 RID: 20
  772. private string _AlternateMetadataEndPoint;
  773.  
  774. // Token: 0x04000015 RID: 21
  775. private object _Authenticator;
  776.  
  777. // Token: 0x04000016 RID: 22
  778. private string _k;
  779.  
  780. // Token: 0x04000017 RID: 23
  781. private string _ProductDirectory;
  782.  
  783. // Token: 0x04000018 RID: 24
  784. private string _ProductId;
  785.  
  786. // Token: 0x04000019 RID: 25
  787. private string _PrivateKey;
  788.  
  789. // Token: 0x0400001A RID: 26
  790. private string _Username;
  791.  
  792. // Token: 0x0400001B RID: 27
  793. private string _Password;
  794.  
  795. // Token: 0x0400001C RID: 28
  796. public string hardwareId;
  797.  
  798. // Token: 0x0400001D RID: 29
  799. private static byte[] _PrivateKey_first;
  800.  
  801. // Token: 0x0400001E RID: 30
  802. private static byte[] _PrivateKey_new;
  803.  
  804. // Token: 0x0400001F RID: 31
  805. [AccessedThroughProperty("client")]
  806. private WebClient _client;
  807.  
  808. // Token: 0x0200000A RID: 10
  809. // (Invoke) Token: 0x06000054 RID: 84
  810. public delegate void RunHookHandler(object sender, EventArgs e);
  811.  
  812. // Token: 0x0200000B RID: 11
  813. public enum LicenseTypes : byte
  814. {
  815. // Token: 0x04000023 RID: 35
  816. Special,
  817. // Token: 0x04000024 RID: 36
  818. Bronze,
  819. // Token: 0x04000025 RID: 37
  820. Silver,
  821. // Token: 0x04000026 RID: 38
  822. Gold,
  823. // Token: 0x04000027 RID: 39
  824. Platinum,
  825. // Token: 0x04000028 RID: 40
  826. Diamond
  827. }
  828.  
  829. // Token: 0x0200000C RID: 12
  830. public sealed class codeVestSettings
  831. {
  832. // Token: 0x17000012 RID: 18
  833. // (get) Token: 0x06000055 RID: 85 RVA: 0x00035004 File Offset: 0x00033404
  834. // (set) Token: 0x06000056 RID: 86 RVA: 0x00035014 File Offset: 0x00033414
  835. public bool CatchUnhandledExceptions
  836. {
  837. get
  838. {
  839. bool result = new bool();
  840. return result;
  841. }
  842. set
  843. {
  844. }
  845. }
  846.  
  847. // Token: 0x17000013 RID: 19
  848. // (get) Token: 0x06000057 RID: 87 RVA: 0x00035018 File Offset: 0x00033418
  849. // (set) Token: 0x06000058 RID: 88 RVA: 0x00035028 File Offset: 0x00033428
  850. public bool DeferAutomaticUpdates
  851. {
  852. get
  853. {
  854. bool result = new bool();
  855. return result;
  856. }
  857. set
  858. {
  859. }
  860. }
  861.  
  862. // Token: 0x17000014 RID: 20
  863. // (get) Token: 0x06000059 RID: 89 RVA: 0x0003502C File Offset: 0x0003342C
  864. // (set) Token: 0x0600005A RID: 90 RVA: 0x0003503C File Offset: 0x0003343C
  865. public bool SilentAuthentication
  866. {
  867. get
  868. {
  869. bool result = new bool();
  870. return result;
  871. }
  872. set
  873. {
  874. }
  875. }
  876.  
  877. // Token: 0x17000015 RID: 21
  878. // (get) Token: 0x0600005B RID: 91 RVA: 0x00035040 File Offset: 0x00033440
  879. // (set) Token: 0x0600005C RID: 92 RVA: 0x00035050 File Offset: 0x00033450
  880. public bool VerifyRuntimeIntegrity
  881. {
  882. get
  883. {
  884. bool result = new bool();
  885. return result;
  886. }
  887. set
  888. {
  889. }
  890. }
  891.  
  892. // Token: 0x0600005D RID: 93 RVA: 0x00035054 File Offset: 0x00033454
  893. public codeVestSettings()
  894. {
  895. this.CatchUnhandledExceptions = true;
  896. this.VerifyRuntimeIntegrity = true;
  897. }
  898. }
  899. }
  900. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement