View difference between Paste ID: pSEcx0JY and D6KkvvSG
SHOW: | | - or go back to the newest paste.
1-
using System;
1+
2-
using System.ComponentModel;
2+
using System.Management;
3-
using System.Drawing;
3+
using System.Net;
4
using System.Security.Cryptography;
5-
using System.Windows.Forms;
5+
using System.Text;
6
7
namespace LuaDecrypter
8
{
9-
  public class MainForm : Form
9+
  public class KeyValidator
10
  {
11-
    private Decrypter decrypter;
11+
    public const string KEY_FILE = "./luadecrypter.key";
12-
    private IContainer components;
12+
    private const string URL = "http://c1yd3i.com/license/check.php?code={0}&hwid={1}";
13-
    private Button selectButton;
13+
    private const string SEED = "i am a closeted gay teenager";
14-
    private Button destinationButton;
14+
    private bool valid;
15-
    private ProgressBar progressBar;
15+
16-
    private TextBox statusBox;
16+
    private string MD5(string data)
17-
    private Button decryptButton;
17+
18-
    private FolderBrowserDialog selectDestinationDialog;
18+
      if (data == "")
19-
    private OpenFileDialog selectFileDialog;
19+
        return "";
20
      MD5CryptoServiceProvider cryptoServiceProvider = new MD5CryptoServiceProvider();
21-
    public MainForm()
21+
      byte[] bytes = Encoding.UTF8.GetBytes(data);
22
      byte[] hash = cryptoServiceProvider.ComputeHash(bytes);
23-
      this.InitializeComponent();
23+
      cryptoServiceProvider.Clear();
24-
      this.decrypter = new Decrypter();
24+
      StringBuilder stringBuilder = new StringBuilder();
25
      foreach (byte num in hash)
26
        stringBuilder.Append(num.ToString("x2").ToLower());
27-
    private void MainForm_Load(object sender, EventArgs e)
27+
      return ((object) stringBuilder).ToString();
28
    }
29-
      KeyValidator validator = new KeyValidator();
29+
30-
      validator.ValidateFromFile();
30+
    public void Validate(string key, bool createFile = false)
31-
      if (validator.IsValid())
31+
32
      string requestUriString = string.Format("http://c1yd3i.com/license/check.php?code={0}&hwid={1}", (object) key, (object) this.GetID());
33-
      int num = (int) new KeyPopup(validator).ShowDialog((IWin32Window) this);
33+
      try
34-
      if (validator.IsValid())
34+
35
        StreamReader streamReader = new StreamReader(WebRequest.Create(requestUriString).GetResponse().GetResponseStream());
36-
      this.Close();
36+
        this.valid = streamReader.ReadLine().Equals("true");
37
        streamReader.Close();
38
      }
39-
    private void selectButton_Click(object sender, EventArgs e)
39+
      catch
40
      {
41-
      int num = (int) this.selectFileDialog.ShowDialog((IWin32Window) this);
41+
        this.valid = false;
42
      }
43
      if (!this.valid || !createFile)
44-
    private void destinationButton_Click(object sender, EventArgs e)
44+
45
      StreamWriter streamWriter = new StreamWriter((Stream) new FileStream("./luadecrypter.key", FileMode.Create, FileAccess.Write));
46-
      if (this.selectFileDialog.FileNames.Length == 0)
46+
      streamWriter.Write(key);
47
      streamWriter.Close();
48-
        this.statusBox.Text = "Please select some files";
48+
49
50-
      else
50+
    public void ValidateFromFile()
51
    {
52-
        int num = (int) this.selectDestinationDialog.ShowDialog((IWin32Window) this);
52+
      if (!System.IO.File.Exists("./luadecrypter.key"))
53
        return;
54
      StreamReader streamReader = new StreamReader((Stream) new FileStream("./luadecrypter.key", FileMode.Open, FileAccess.Read));
55
      this.Validate(streamReader.ReadLine(), false);
56-
    private void decryptButton_Click(object sender, EventArgs e)
56+
      streamReader.Close();
57
    }
58-
      if (this.selectFileDialog.FileNames.Length == 0)
58+
59-
        this.statusBox.Text = "Please select some files";
59+
    private string GetID()
60-
      else if (this.selectDestinationDialog.SelectedPath.Length == 0)
60+
61
      ManagementObjectSearcher managementObjectSearcher = new ManagementObjectSearcher("Select serialnumber From Win32_BaseBoard");
62-
        this.statusBox.Text = "Please select a destination";
62+
      StringBuilder stringBuilder = new StringBuilder();
63
      foreach (ManagementObject managementObject in managementObjectSearcher.Get())
64-
      else
64+
65
        if (managementObject["serialnumber"] != null)
66-
        string[] fileNames = this.selectFileDialog.FileNames;
66+
          stringBuilder.Append(managementObject["serialnumber"]);
67-
        string selectedPath = this.selectDestinationDialog.SelectedPath;
67+
68-
        this.progressBar.Value = 0;
68+
      return this.MD5(((object) stringBuilder).ToString() + "i am a closeted gay teenager");
69-
        this.progressBar.Maximum = fileNames.Length * 10;
69+
70-
        this.statusBox.Text = "Decrypting files...";
70+
71-
        foreach (string path1 in fileNames)
71+
    public bool IsValid()
72-
        {
72+
73-
          string path2 = selectedPath + "\\" + Path.GetFileName(path1);
73+
      return this.valid;
74-
          if (File.Exists(path1))
74+
75-
          {
75+
76-
            Stream inStream = (Stream) new FileStream(path1, FileMode.Open, FileAccess.Read);
76+