Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Decompiled with JetBrains decompiler
- // Type: Rabbit.Utility
- // Assembly: Rabbit, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
- // MVID: 4341403A-9FDD-43C4-92F1-08327F8D1D7C
- // Assembly location: F:\content\Rabbit (2)\Rabbit.exe
- using Microsoft.VisualBasic;
- using Microsoft.VisualBasic.CompilerServices;
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Drawing.Drawing2D;
- using System.Drawing.Imaging;
- using System.IO;
- using System.Linq;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- using System.Runtime.Serialization.Formatters.Binary;
- using System.Security.Cryptography;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading;
- namespace Rabbit
- {
- public class Utility
- {
- public static object HLock = RuntimeHelpers.GetObjectValue(new object());
- [SpecialName]
- private static Random \u0024STATIC\u0024RandomNumber\u002402888\u0024Generator;
- [SpecialName]
- private static StaticLocalInitFlag \u0024STATIC\u0024RandomNumber\u002402888\u0024Generator\u0024Init;
- [SpecialName]
- private static Random \u0024STATIC\u0024RandomString\u002402E82\u0024Generator;
- [SpecialName]
- private static StaticLocalInitFlag \u0024STATIC\u0024RandomString\u002402E82\u0024Generator\u0024Init;
- [SpecialName]
- private static Random \u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator;
- [SpecialName]
- private static StaticLocalInitFlag \u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator\u0024Init;
- [DllImport("r.dll", CallingConvention = CallingConvention.StdCall)]
- public static extern void x4([MarshalAs(UnmanagedType.BStr)] out string output, [MarshalAs(UnmanagedType.BStr), In] string Input, [MarshalAs(UnmanagedType.BStr), In] string Serial, [MarshalAs(UnmanagedType.BStr), In] string Unique);
- [DllImport("r64.dll", CallingConvention = CallingConvention.StdCall)]
- public static extern void x64([MarshalAs(UnmanagedType.BStr)] out string output, [MarshalAs(UnmanagedType.BStr), In] string Input, [MarshalAs(UnmanagedType.BStr), In] string Serial, [MarshalAs(UnmanagedType.BStr), In] string Unique);
- public static object Expart(string stpart, string ndpart, string source, int negative)
- {
- object obj1;
- try
- {
- object obj2 = (object) stpart;
- object obj3 = (object) Microsoft.VisualBasic.Strings.InStr(source, Conversions.ToString(RuntimeHelpers.GetObjectValue(obj2)), CompareMethod.Binary);
- object obj4 = (object) Microsoft.VisualBasic.Strings.Mid(source, Conversions.ToInteger(RuntimeHelpers.GetObjectValue(obj3))).ToString();
- object obj5 = (object) Microsoft.VisualBasic.Strings.InStr(Conversions.ToString(RuntimeHelpers.GetObjectValue(obj4)), ndpart, CompareMethod.Binary);
- obj1 = (object) Microsoft.VisualBasic.Strings.Replace(Conversions.ToString((object) Microsoft.VisualBasic.Strings.Mid(Conversions.ToString(RuntimeHelpers.GetObjectValue(obj4)), 1, Conversions.ToInteger(RuntimeHelpers.GetObjectValue(Operators.SubtractObject(RuntimeHelpers.GetObjectValue(obj5), (object) negative))))), Conversions.ToString(RuntimeHelpers.GetObjectValue(obj2)), "", 1, -1, CompareMethod.Binary);
- }
- catch (Exception ex)
- {
- ProjectData.SetProjectError(ex);
- ProjectData.ClearProjectError();
- }
- return obj1;
- }
- public static string OneLine(string Text)
- {
- Text = Regex.Replace(Text, "\\r\\n?|\\n", "");
- return Text;
- }
- public static object Hmac256(string input)
- {
- object objectValue = RuntimeHelpers.GetObjectValue(Utility.HLock);
- ObjectFlowControl.CheckForSyncLockOnValueType(objectValue);
- bool lockTaken = false;
- object obj;
- try
- {
- Monitor.Enter(objectValue, ref lockTaken);
- string output = "";
- try
- {
- Utility.x4(out output, input, L.S, L.B);
- obj = (object) output.ToLower();
- goto label_11;
- }
- catch (Exception ex1)
- {
- ProjectData.SetProjectError(ex1);
- try
- {
- Utility.x64(out output, input, L.S, L.B);
- obj = (object) output.ToLower();
- ProjectData.ClearProjectError();
- goto label_11;
- }
- catch (Exception ex2)
- {
- ProjectData.SetProjectError(ex2);
- ProjectData.ClearProjectError();
- }
- ProjectData.ClearProjectError();
- }
- }
- finally
- {
- if (lockTaken)
- Monitor.Exit(objectValue);
- }
- obj = (object) "";
- label_11:
- return obj;
- }
- public static string ByteToString(byte[] buff)
- {
- string str = "";
- int num = checked (buff.Length - 1);
- int index = 0;
- while (index <= num)
- {
- str += buff[index].ToString("X2");
- checked { ++index; }
- }
- return str;
- }
- public static Bitmap ResizeImage(Image image, int width, int height)
- {
- Bitmap bitmap1;
- try
- {
- Rectangle destRect = new Rectangle(0, 0, width, height);
- Bitmap bitmap2 = new Bitmap(width, height);
- bitmap2.SetResolution(image.HorizontalResolution, image.VerticalResolution);
- using (Graphics graphics = Graphics.FromImage((Image) bitmap2))
- {
- graphics.CompositingMode = CompositingMode.SourceCopy;
- graphics.CompositingQuality = CompositingQuality.HighQuality;
- graphics.InterpolationMode = InterpolationMode.HighQualityBicubic;
- graphics.SmoothingMode = SmoothingMode.HighQuality;
- graphics.PixelOffsetMode = PixelOffsetMode.HighQuality;
- using (ImageAttributes imageAttr = new ImageAttributes())
- {
- imageAttr.SetWrapMode(WrapMode.TileFlipXY);
- graphics.DrawImage(image, destRect, 0, 0, image.Width, image.Height, GraphicsUnit.Pixel, imageAttr);
- }
- }
- bitmap1 = bitmap2;
- }
- catch (Exception ex)
- {
- ProjectData.SetProjectError(ex);
- bitmap1 = (Bitmap) image;
- ProjectData.ClearProjectError();
- }
- return bitmap1;
- }
- public static int FindBytes(byte[] src, byte[] find)
- {
- int num1 = -1;
- int index1 = 0;
- int num2 = checked (src.Length - 1);
- int index2 = 0;
- while (index2 <= num2)
- {
- if ((int) src[index2] == (int) find[index1])
- {
- if (index1 == checked (find.Length - 1))
- {
- num1 = checked (index2 - index1);
- break;
- }
- checked { ++index1; }
- }
- else
- index1 = (int) src[index2] != (int) find[0] ? 0 : 1;
- checked { ++index2; }
- }
- return num1;
- }
- public static byte[] ReplaceBytes(byte[] src, byte[] search, byte[] repl)
- {
- byte[] src1 = src;
- byte[] numArray = (byte[]) null;
- for (int bytes = Utility.FindBytes(src, search); bytes >= 0; bytes = Utility.FindBytes(src1, search))
- {
- numArray = numArray != null ? src1 : src;
- src1 = new byte[checked (numArray.Length - search.Length + (repl.Length - 1) + 1)];
- Buffer.BlockCopy((Array) numArray, 0, (Array) src1, 0, bytes);
- Buffer.BlockCopy((Array) repl, 0, (Array) src1, bytes, repl.Length);
- Buffer.BlockCopy((Array) numArray, checked (bytes + search.Length), (Array) src1, checked (bytes + repl.Length), checked (numArray.Length - bytes + search.Length));
- }
- return src1;
- }
- public static Array ArrayFromTxt(string path)
- {
- Array array = (Array) new string[2]
- {
- "",
- ""
- };
- try
- {
- if (File.Exists(path))
- {
- StreamReader streamReader = new StreamReader(path);
- array = (Array) Regex.Split(streamReader.ReadToEnd(), "\\r?\\n|\\r");
- streamReader.Close();
- }
- }
- catch (Exception ex)
- {
- ProjectData.SetProjectError(ex);
- ProjectData.ClearProjectError();
- }
- return array;
- }
- public static string GuidByString(string text)
- {
- string lower;
- try
- {
- using (MD5 md5 = MD5.Create())
- lower = new Guid(md5.ComputeHash(Encoding.Default.GetBytes(text))).ToString().ToLower();
- }
- catch (Exception ex)
- {
- ProjectData.SetProjectError(ex);
- lower = ex.Message.ToLower();
- ProjectData.ClearProjectError();
- }
- return lower;
- }
- public static object Strip(string des)
- {
- string[] strArray = new string[31]
- {
- ".",
- ",",
- "<",
- ">",
- ":",
- "?",
- "\"",
- "/",
- "{",
- "[",
- "}",
- "]",
- "`",
- "~",
- "!",
- "@",
- "#",
- "$",
- "%",
- "^",
- "&",
- "*",
- "(",
- ")",
- "_",
- "-",
- "+",
- "=",
- "|",
- " ",
- "\\"
- };
- string Expression = des;
- int num1 = 0;
- int num2 = checked (strArray.Length - 1);
- int index = 0;
- while (index <= num2)
- {
- while (num1 != 29)
- {
- des = Microsoft.VisualBasic.Strings.Replace(Expression, strArray[index], "", 1, -1, CompareMethod.Binary);
- checked { ++num1; }
- Expression = des;
- }
- num1 = 0;
- checked { ++index; }
- }
- return (object) Expression.Replace(" ", "");
- }
- public static string GenTimeStamp()
- {
- return Microsoft.VisualBasic.Strings.Mid(Conversions.ToString((DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds), 1, 10);
- }
- public static int RandomNumber(int Min, int Max)
- {
- if (Utility.\u0024STATIC\u0024RandomNumber\u002402888\u0024Generator\u0024Init == null)
- Interlocked.CompareExchange<StaticLocalInitFlag>(ref Utility.\u0024STATIC\u0024RandomNumber\u002402888\u0024Generator\u0024Init, new StaticLocalInitFlag(), (StaticLocalInitFlag) null);
- bool lockTaken = false;
- try
- {
- Monitor.Enter((object) Utility.\u0024STATIC\u0024RandomNumber\u002402888\u0024Generator\u0024Init, ref lockTaken);
- if (Utility.\u0024STATIC\u0024RandomNumber\u002402888\u0024Generator\u0024Init.State == (short) 0)
- {
- Utility.\u0024STATIC\u0024RandomNumber\u002402888\u0024Generator\u0024Init.State = (short) 2;
- Utility.\u0024STATIC\u0024RandomNumber\u002402888\u0024Generator = new Random();
- }
- else if (Utility.\u0024STATIC\u0024RandomNumber\u002402888\u0024Generator\u0024Init.State == (short) 2)
- throw new IncompleteInitialization();
- }
- finally
- {
- Utility.\u0024STATIC\u0024RandomNumber\u002402888\u0024Generator\u0024Init.State = (short) 1;
- if (lockTaken)
- Monitor.Exit((object) Utility.\u0024STATIC\u0024RandomNumber\u002402888\u0024Generator\u0024Init);
- }
- return Utility.\u0024STATIC\u0024RandomNumber\u002402888\u0024Generator.Next(Min, Max);
- }
- public static string RandomInt(int len)
- {
- StringBuilder stringBuilder = new StringBuilder();
- string[] strArray = new string[10]
- {
- "1",
- "2",
- "3",
- "4",
- "5",
- "6",
- "7",
- "8",
- "9",
- "0"
- };
- Information.UBound((Array) strArray, 1);
- int num1 = len;
- int num2 = 1;
- while (num2 <= num1)
- {
- stringBuilder.Append(strArray[Conversion.Int(Utility.RandomNumber(0, strArray.Length))]);
- checked { ++num2; }
- }
- return stringBuilder.ToString();
- }
- public static string RandomString(int size, bool lowerCase)
- {
- StringBuilder stringBuilder = new StringBuilder();
- if (Utility.\u0024STATIC\u0024RandomString\u002402E82\u0024Generator\u0024Init == null)
- Interlocked.CompareExchange<StaticLocalInitFlag>(ref Utility.\u0024STATIC\u0024RandomString\u002402E82\u0024Generator\u0024Init, new StaticLocalInitFlag(), (StaticLocalInitFlag) null);
- bool lockTaken = false;
- try
- {
- Monitor.Enter((object) Utility.\u0024STATIC\u0024RandomString\u002402E82\u0024Generator\u0024Init, ref lockTaken);
- if (Utility.\u0024STATIC\u0024RandomString\u002402E82\u0024Generator\u0024Init.State == (short) 0)
- {
- Utility.\u0024STATIC\u0024RandomString\u002402E82\u0024Generator\u0024Init.State = (short) 2;
- Utility.\u0024STATIC\u0024RandomString\u002402E82\u0024Generator = new Random();
- }
- else if (Utility.\u0024STATIC\u0024RandomString\u002402E82\u0024Generator\u0024Init.State == (short) 2)
- throw new IncompleteInitialization();
- }
- finally
- {
- Utility.\u0024STATIC\u0024RandomString\u002402E82\u0024Generator\u0024Init.State = (short) 1;
- if (lockTaken)
- Monitor.Exit((object) Utility.\u0024STATIC\u0024RandomString\u002402E82\u0024Generator\u0024Init);
- }
- int num1 = checked (size - 1);
- int num2 = 0;
- while (num2 <= num1)
- {
- char ch = Convert.ToChar(Convert.ToInt32(26.0 * Utility.\u0024STATIC\u0024RandomString\u002402E82\u0024Generator.NextDouble() + 65.0));
- stringBuilder.Append(ch);
- checked { ++num2; }
- }
- if (lowerCase)
- return Microsoft.VisualBasic.Strings.Replace(stringBuilder.ToString().ToLower(), "[", "", 1, -1, CompareMethod.Binary);
- return Microsoft.VisualBasic.Strings.Replace(stringBuilder.ToString(), "[", "", 1, -1, CompareMethod.Binary);
- }
- public static string GetRandomHexNumber(int digits)
- {
- if (Utility.\u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator\u0024Init == null)
- Interlocked.CompareExchange<StaticLocalInitFlag>(ref Utility.\u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator\u0024Init, new StaticLocalInitFlag(), (StaticLocalInitFlag) null);
- bool lockTaken = false;
- try
- {
- Monitor.Enter((object) Utility.\u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator\u0024Init, ref lockTaken);
- if (Utility.\u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator\u0024Init.State == (short) 0)
- {
- Utility.\u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator\u0024Init.State = (short) 2;
- Utility.\u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator = new Random();
- }
- else if (Utility.\u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator\u0024Init.State == (short) 2)
- throw new IncompleteInitialization();
- }
- finally
- {
- Utility.\u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator\u0024Init.State = (short) 1;
- if (lockTaken)
- Monitor.Exit((object) Utility.\u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator\u0024Init);
- }
- byte[] buffer = new byte[checked ((int) Math.Round(unchecked ((double) digits / 2.0 - 1.0)) + 1)];
- Utility.\u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator.NextBytes(buffer);
- byte[] numArray = buffer;
- Func<byte, string> selector;
- // ISSUE: reference to a compiler-generated field
- if (Utility._Closure\u0024__.\u0024I19\u002D0 != null)
- {
- // ISSUE: reference to a compiler-generated field
- selector = Utility._Closure\u0024__.\u0024I19\u002D0;
- }
- else
- {
- // ISSUE: reference to a compiler-generated field
- Utility._Closure\u0024__.\u0024I19\u002D0 = selector = (Func<byte, string>) (x => x.ToString("X2"));
- }
- string str = string.Concat(((IEnumerable<byte>) numArray).Select<byte, string>(selector).ToArray<string>());
- if (digits % 2 == 0)
- return str;
- return str + Utility.\u0024STATIC\u0024GetRandomHexNumber\u002401E8\u0024Generator.Next(16).ToString("X");
- }
- public static void Wait(int interval)
- {
- Thread.Sleep(checked (interval * 1000));
- }
- public static void KillThreads(ref List<Thread> ThreadList)
- {
- while (true)
- {
- try
- {
- int num = 0;
- List<Thread>.Enumerator enumerator;
- try
- {
- enumerator = ThreadList.GetEnumerator();
- while (enumerator.MoveNext())
- {
- Thread current = enumerator.Current;
- if (current.IsAlive)
- {
- checked { ++num; }
- current.Abort();
- Thread.Sleep(100);
- }
- }
- }
- finally
- {
- enumerator.Dispose();
- }
- if (num <= 0)
- break;
- }
- catch (Exception ex)
- {
- ProjectData.SetProjectError(ex);
- ProjectData.ClearProjectError();
- break;
- }
- }
- }
- public static string IP2Long(string ip)
- {
- string[] strArray = ip.Split('.');
- if (((IEnumerable<string>) strArray).Count<string>() == 4)
- return Conversions.ToString(Conversions.ToDouble(strArray[0]) * 16777216.0 + Conversions.ToDouble(strArray[1]) * 65536.0 + Conversions.ToDouble(strArray[2]) * 256.0 + Conversions.ToDouble(strArray[3]));
- return "";
- }
- public static string Spin(string content)
- {
- string str1;
- string str2;
- try
- {
- if (string.IsNullOrEmpty(content))
- {
- str1 = "";
- goto label_12;
- }
- else
- {
- int length1 = content.IndexOf("{");
- int num1 = content.IndexOf("}");
- if (length1 == -1 && num1 == -1 || (length1 == -1 || num1 < length1))
- {
- str1 = content;
- goto label_12;
- }
- else if (num1 == -1)
- {
- int num2 = (int) Interaction.MsgBox((object) "Please make sure that all of the brackets have proper open / close matches", MsgBoxStyle.OkOnly, (object) null);
- str1 = "";
- goto label_12;
- }
- else
- {
- string str3 = Utility.Spin(content.Substring(checked (length1 + 1), checked (content.Length - length1 + 1)));
- int length2 = str3.IndexOf("}");
- if (length2 == -1)
- {
- int num2 = (int) Interaction.MsgBox((object) "Please make sure that all of the brackets have proper open / close matches", MsgBoxStyle.OkOnly, (object) null);
- str1 = "";
- goto label_12;
- }
- else
- {
- string[] strArray = str3.Substring(0, length2).Split('|');
- string str4 = strArray[Utility.RandomNumber(0, strArray.Length)];
- str2 = content.Substring(0, length1) + str4 + Utility.Spin(str3.Substring(checked (length2 + 1), checked (str3.Length - length2 + 1)));
- }
- }
- }
- }
- catch (Exception ex)
- {
- ProjectData.SetProjectError(ex);
- str1 = "";
- ProjectData.ClearProjectError();
- goto label_12;
- }
- str1 = str2;
- label_12:
- return str1;
- }
- public static void WriteToBinaryFile<T>(string filePath, T objectToWrite, bool append = false)
- {
- using (Stream serializationStream = (Stream) File.Open(filePath, append ? FileMode.Append : FileMode.Create))
- new BinaryFormatter().Serialize(serializationStream, (object) objectToWrite);
- }
- public static T ReadFromBinaryFile<T>(string filePath)
- {
- using (Stream serializationStream = (Stream) File.Open(filePath, FileMode.Open))
- return Conversions.ToGenericParameter<T>(new BinaryFormatter().Deserialize(serializationStream));
- }
- public static ArrayList RemoveDups(ArrayList items)
- {
- ArrayList arrayList = new ArrayList();
- try
- {
- foreach (object obj in items)
- {
- string str = Conversions.ToString(obj);
- if (!arrayList.Contains((object) str.Trim()))
- arrayList.Add((object) str.Trim());
- }
- }
- finally
- {
- IEnumerator enumerator;
- if (enumerator is IDisposable)
- (enumerator as IDisposable).Dispose();
- }
- arrayList.Sort();
- return arrayList;
- }
- public static void Shuffle<T>(IList<T> list)
- {
- Random random = new Random();
- int num = checked (list.Count - 1);
- int minValue = 0;
- while (minValue <= num)
- {
- int index = random.Next(minValue, list.Count);
- if (minValue != index)
- {
- T obj = list[minValue];
- list[minValue] = list[index];
- list[index] = obj;
- }
- checked { ++minValue; }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement