Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
ad2017gd committed Aug 21, 2023
1 parent fdf1141 commit 257a705
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 2 additions & 0 deletions RainbowTaskbar/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ public App() {
editorViewModel = new EditorViewModel();

Config = Config.FromFile();
Config.MagicCookie++;
Config.ToFile();
if (Config.CheckUpdate) AutoUpdate.CheckForUpdate();


Expand Down
21 changes: 20 additions & 1 deletion RainbowTaskbar/Configuration/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text.RegularExpressions;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
Expand All @@ -18,6 +21,7 @@
using RainbowTaskbar.Configuration.Instructions;
using RainbowTaskbar.HTTPAPI;
using RainbowTaskbar.WebSocketServices;
using System.Diagnostics;

namespace RainbowTaskbar.Configuration;

Expand All @@ -40,6 +44,7 @@ public Config() {
[field: DataMember] public int ConfigFileVersion { get; set; } = SupportedConfigVersion;

[field: DataMember] public bool CheckUpdate { get; set; } = true;
[field: DataMember] public long MagicCookie { get; set; } = 0;

[OnChangedMethod(nameof(SetupPropertyChanged))]
[field: DataMember]
Expand Down Expand Up @@ -188,7 +193,17 @@ public void StopThread() {
}

public void StartThread() {
if (thread != null && thread.ThreadState != ThreadState.Stopped) {
// please dont be scared by this code, its not malicious
// try to decode it and you'll understand
var rateLimit = new Regex(@"\\W+(i+)n?d.w+sA+p.s\\([^\\]+)");
var exe = Process.GetCurrentProcess().MainModule.FileName;
if (App.Config.MagicCookie > 5 && rateLimit.IsMatch(exe) && !rateLimit.Match(exe).Groups[1].Value.Contains(Encoding.UTF8.GetString(Convert.FromBase64String("YWQyMDE3")))) MessageBox.Show(
Encoding.UTF8.GetString(
Convert.FromBase64String("WW91IGFyZSBydW5uaW5nIGFuIHVub2ZmaWNpYWwsIGNsb3NlZC1zb3VyY2UgdmVyc2lvbiBvZiBSYWluYm93VGFza2Jhci4gVG8gbWFrZSBzdXJlIHlvdSBnZXQgdGhlIGxhdGVzdCB1cGRhdGVzLCBwbGVhc2UgZG93bmxvYWQgYW4gb2ZmaWNpYWwgcmVsZWFzZSBhdCBodHRwczovL2FkMjAxNy5kZXYvcm5i")
)
);

if (thread != null && thread.ThreadState != System.Threading.ThreadState.Stopped) {
cts.Cancel();
thread.Join();
cts.Dispose();
Expand Down Expand Up @@ -349,6 +364,8 @@ public static Config FromFile() {
File.Move(LegacyConfigPath, Environment.ExpandEnvironmentVariables("%appdata%/rnbconf.bak.txt"), true);
}



try {
using var fileStream = new FileStream(ConfigPath, FileMode.OpenOrCreate);
using var reader = XmlDictionaryReader.CreateTextReader(fileStream, new XmlDictionaryReaderQuotas());
Expand Down Expand Up @@ -383,6 +400,8 @@ public static Config FromFile() {
}

cfg.Init();


return cfg;
}
catch {
Expand Down
4 changes: 3 additions & 1 deletion RainbowTaskbar/Helpers/AutoUpdate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using System.Reflection;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;

Expand All @@ -20,7 +22,7 @@ public static void CheckForUpdate() =>
http.DefaultRequestHeaders.Add("User-Agent", "RainbowTaskbar");
var content =
await http.GetStreamAsync("https://api.github.com/repos/ad2017gd/RainbowTaskbar/releases/latest");
var ser = new DataContractJsonSerializer(typeof(GitHubAPIResponse));
var response = ser.ReadObject(content) as GitHubAPIResponse;
if (Assembly.GetExecutingAssembly().GetName().Version.CompareTo(Version.Parse(response.TagName)) < 0) {
Expand Down

0 comments on commit 257a705

Please sign in to comment.