This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void AllowListener(string URL) | |
{ | |
string command = $"http add urlacl url={ new Uri(URL).AbsoluteUri } user=Everyone"; | |
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("netsh", command) { Verb = "runas" }); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#region Objectify | |
public string WriteObject(List<KeyValuePair<string, object>> RawData) | |
{ | |
var ParsedData = new StringBuilder(); | |
foreach (var Item in RawData) | |
ParsedData.Append($"{Sanify(Item.Key)}:{Sanify(Item.Value)}:{Sanify(Item.Value.GetType().FullName)}\n"); | |
return ParsedData.ToString(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string FormatJson(string json) | |
{ | |
const string indentString = " "; | |
int indentation = 0; | |
int quoteCount = 0; | |
var result = | |
from ch in json | |
let quotes = ch == '"' ? quoteCount++ : quoteCount | |
let lineBreak = ch == ',' && quotes % 2 == 0 ? ch + Environment.NewLine + string.Concat(Enumerable.Repeat(indentString, indentation)) : null | |
let openChar = ch == '{' || ch == '[' ? ch + Environment.NewLine + string.Concat(Enumerable.Repeat(indentString, ++indentation)) : ch.ToString() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool ValidateIPv4(string IP) | |
{ | |
if (String.IsNullOrWhiteSpace(IP)) return false; | |
string[] splitValues = IP.Split('.'); | |
if (splitValues.Length != 4) return false; | |
return splitValues.All(r => byte.TryParse(r, out _)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string Base64Encode(string Text) | |
{ | |
return System.Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(Text)); | |
} | |
public string Base64Decode(string EncodedData) | |
{ | |
return System.Text.Encoding.UTF8.GetString(System.Convert.FromBase64String(EncodedData)); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public byte[] EncryptString_AES(string Data, string Key) | |
{ | |
byte[] PaddedKey = StringToPaddedBytes(Key); | |
byte[] Encrypted; | |
byte[] IV; | |
using (System.Security.Cryptography.Aes AES = System.Security.Cryptography.Aes.Create()) | |
using (var MemEncrypt = new System.IO.MemoryStream()) | |
{ | |
AES.Mode = System.Security.Cryptography.CipherMode.CBC; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string GetWebString(string URL) | |
{ | |
var client = new System.Net.WebClient() {Encoding = System.Text.Encoding.UTF8}; | |
client.Headers.Add("user-agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36"); | |
return client.DownloadString(URL); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public string InsertText(string Line, string Text, int PositionPercent) | |
{ | |
int Index = 0; | |
char[] LineArr = Line.ToCharArray(); | |
double Position = ((double)Line.Length / 100) * PositionPercent; | |
for (int i = 0; i < Line.Length; i++) | |
{ | |
if (i >= Position && Index < Text.Length) | |
{ | |
LineArr[i] = Text[Index]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool CheckPort(string Address, int Port, int Timeout) | |
{ | |
using (var Client = new System.Net.Sockets.TcpClient()) | |
{ | |
var Open = Client.BeginConnect(Address, Port, null, null).AsyncWaitHandle.WaitOne(TimeSpan.FromMilliseconds(Timeout)); | |
Client.Close(); | |
return Open; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int[] GenSeq(int Start, int End, int Step) | |
{ | |
List<int> Seq = new List<int>(); | |
for (int i = Start; i < End; i = i + Step) | |
Seq.Add(i); | |
return Seq.ToArray(); | |
} |