forked from Gajeel32/UnixcornTweakingUtility
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.cs
More file actions
206 lines (193 loc) · 7.47 KB
/
Copy pathUtils.cs
File metadata and controls
206 lines (193 loc) · 7.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
using System;
using System.Collections.Specialized;
using System.IO;
using System.Management;
using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace UnixcornTweakingUtility
{
class Utils
{
public static string Windows7 = "7";
public static string Windows8 = "8";
public static string Windows10 = "10";
public static string getMotherboardId()
{
string serial = "";
try
{
using (ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT SerialNumber FROM Win32_BaseBoard"))
{
ManagementObjectCollection moc = mos.Get();
foreach (ManagementObject mo in moc)
{
serial = mo["SerialNumber"].ToString();
}
return serial;
}
}
catch
{
return serial;
}
}
public static string getLicenseKey()
{
using (MD5 md5 = MD5.Create())
{
byte[] inputBytes = Encoding.ASCII.GetBytes(getMotherboardId() + 1337);
byte[] hashBytes = md5.ComputeHash(inputBytes);
StringBuilder sb = new StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("X2"));
}
return sb.ToString();
}
}
public static bool isLicensed()
{
try
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://raw.githubusercontent.com/un1xcorn/UnixcornTweakingUtility-Licenses/main/licenses.txt");
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
request.Proxy = null;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
if (reader.ReadToEnd().Contains(getLicenseKey()))
{
return true;
}
return false;
}
}
catch
{
return false;
}
}
public static bool isLatestUpdate()
{
try
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://raw.githubusercontent.com/un1xcorn/UnixcornTweakingUtility-Licenses/main/version.txt");
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
request.Proxy = null;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
if (reader.ReadToEnd().Replace("\n", "") == Program.version)
{
return true;
}
return false;
}
}
catch
{
return true;
}
}
public static string getWindowsVersion()
{
string version = "";
try
{
using (ManagementObjectSearcher mos = new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem"))
{
ManagementObjectCollection moc = mos.Get();
foreach (ManagementObject mo in moc)
{
version = mo["Caption"].ToString();
}
if (version.Contains("7"))
return "7";
if (version.Contains("8"))
return "8";
else
return "10";
}
}
catch
{
return version;
}
}
public static bool DownloadFile(string url, string filename)
{
try
{
using (WebClient client = new WebClient())
{
client.DownloadFile(new Uri(url), filename);
}
return true;
}
catch
{
return false;
}
}
public static bool sendWebhookLog(string webhook)
{
try
{
using (WebClient dcWeb = new WebClient())
{
NameValueCollection discord = new NameValueCollection();
discord.Add("username", "Users connection logger");
discord.Add("content", "License key: " + getLicenseKey() + "\nIP Address: " + new WebClient().DownloadString("https://api.ipify.org"));
dcWeb.UploadValues(webhook, discord);
}
return true;
}
catch
{
return false;
}
}
public static string getDecryptedWebhook()
{
string encrypted_webhook = "";
try
{
ServicePointManager.Expect100Continue = true;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://raw.githubusercontent.com/un1xcorn/UnixcornTweakingUtility-Licenses/main/webhook.txt");
request.AutomaticDecompression = DecompressionMethods.GZip | DecompressionMethods.Deflate;
request.Proxy = null;
using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
using (Stream stream = response.GetResponseStream())
using (StreamReader reader = new StreamReader(stream))
{
encrypted_webhook = reader.ReadToEnd().Replace("\n", "");
}
}
catch
{
return "";
}
byte[] src = Convert.FromBase64String(encrypted_webhook);
RijndaelManaged aes = new RijndaelManaged();
byte[] key = Encoding.ASCII.GetBytes("/k5j}L.|N?mt5>6fCp(oCr<(G|PJZ(ah");
aes.KeySize = 256;
aes.Padding = PaddingMode.PKCS7;
aes.Mode = CipherMode.ECB;
using (ICryptoTransform decrypt = aes.CreateDecryptor(key, null))
{
byte[] dest = decrypt.TransformFinalBlock(src, 0, src.Length);
decrypt.Dispose();
string decrypted_webhook = Encoding.UTF8.GetString(dest);
return decrypted_webhook;
}
}
}
}