Esempio n. 1
0
 public static string GetServiceStartType(string serviceName)
 {
     try
     {
         return(Registry.LocalMachine.OpenSubKey("SYSTEM").OpenSubKey("CurrentControlSet").OpenSubKey("Services").OpenSubKey(serviceName, true).GetValue("Start").ToString());
     }
     catch (Exception exception)
     {
         LogTextHelper.Error(exception);
         return(string.Empty);
     }
 }
Esempio n. 2
0
 public static bool ChangeServiceStartType(int startType, string serviceName)
 {
     try
     {
         Registry.LocalMachine.OpenSubKey("SYSTEM").OpenSubKey("CurrentControlSet").OpenSubKey("Services").OpenSubKey(serviceName, true).SetValue("Start", startType);
     }
     catch (Exception exception)
     {
         LogTextHelper.Error(exception);
         return(false);
     }
     return(true);
 }
Esempio n. 3
0
        public static bool ValidUrlPostData()
        {
            bool flag = false;

            for (int i = 0; i < HttpContext.Current.Request.Form.Count; i++)
            {
                if (flag = HasInjectionData(HttpContext.Current.Request.Form[i].ToString()))
                {
                    LogTextHelper.Info("检测出POST恶意数据: 【" + HttpContext.Current.Request.Form[i].ToString() + "】 URL: 【" + HttpContext.Current.Request.RawUrl + "】来源: 【" + HttpContext.Current.Request.UserHostAddress + "】");
                    return(flag);
                }
            }
            return(flag);
        }
Esempio n. 4
0
 public static void SaveOneInchPic(Image image, Color transColor, float dpi, string path)
 {
     try
     {
         image = image.Clone() as Image;
         ((Bitmap)image).SetResolution(dpi, dpi);
         ImageCodecInfo    codecInfo     = GetCodecInfo("image/jpeg");
         EncoderParameters encoderParams = new EncoderParameters(2);
         encoderParams.Param[0] = new EncoderParameter(Encoder.Quality, 100);
         encoderParams.Param[1] = new EncoderParameter(Encoder.ColorDepth, 0x20);
         image.Save(path, codecInfo, encoderParams);
         image.Dispose();
     }
     catch (Exception exception)
     {
         LogTextHelper.Error(exception);
     }
 }
Esempio n. 5
0
 public static bool StartService(string serviceName)
 {
     try
     {
         ServiceController controller = new ServiceController(serviceName);
         if (controller.Status == ServiceControllerStatus.Running)
         {
             return(true);
         }
         TimeSpan timeout = TimeSpan.FromMilliseconds(10000.0);
         controller.Start();
         controller.WaitForStatus(ServiceControllerStatus.Running, timeout);
     }
     catch (Exception exception)
     {
         LogTextHelper.Error(exception);
         return(false);
     }
     return(true);
 }
Esempio n. 6
0
 public static void ExecuteCommandSync(object command)
 {
     try
     {
         ProcessStartInfo info = new ProcessStartInfo("cmd", "/c " + command)
         {
             RedirectStandardOutput = true,
             UseShellExecute        = false,
             CreateNoWindow         = true
         };
         Process process = new Process {
             StartInfo = info
         };
         process.Start();
         Console.WriteLine(process.StandardOutput.ReadToEnd());
     }
     catch (Exception exception)
     {
         LogTextHelper.Error(exception);
     }
 }
Esempio n. 7
0
 public static void ExecuteCommandAsync(string command)
 {
     try
     {
         new Thread(new ParameterizedThreadStart(DosHelper.ExecuteCommandSync))
         {
             IsBackground = true, Priority = ThreadPriority.AboveNormal
         }.Start(command);
     }
     catch (ThreadStartException exception)
     {
         LogTextHelper.Error(exception);
     }
     catch (ThreadAbortException exception2)
     {
         LogTextHelper.Error(exception2);
     }
     catch (Exception exception3)
     {
         LogTextHelper.Error(exception3);
     }
 }