-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
72 lines (69 loc) · 2.66 KB
/
Program.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace NifKiller
{
class Program
{
static void Main(string[] args)
{
Process[] proccesses = Process.GetProcessesByName("BlackShot");
int bsProcID = proccesses.FirstOrDefault().Id;
if (bsProcID == 0)
{
Console.WriteLine("Failed To Find BlackShot Process");
Console.ReadKey();
Environment.Exit(0);
}
string handlepath = Directory.GetCurrentDirectory() + "\\handle.exe";
Console.WriteLine(handlepath);
// Query nif handle info
if(!File.Exists(handlepath))
{
Console.WriteLine("Cannot find handle utility");
Console.ReadKey();
Environment.Exit(0);
}
string reply = Util.runCommand(handlepath, "-p BlackShot.exe");
// Parse The Info
List<string> _HandleIds = new List<string>();
using (StringReader reader = new StringReader(reply))
{
string line;
while ((line = reader.ReadLine()) != null)
{
Console.WriteLine(line);
if (line.Contains(".nif"))
{
char[] Id = new char[4];
line.CopyTo(2, Id, 0, 4);
// Check for actual length because some handles either have 3 or 4 characters/digits
if (Id[Id.Length - 1] == ':')
_HandleIds.Add(new string(Id).Remove(3));
_HandleIds.Add(new string(Id));
}
}
if(_HandleIds.Count == 0)
{
Console.WriteLine("Cannot find nif handles");
System.Threading.Thread.Sleep(4000);
Environment.Exit(0);
}
// Now that we have the nif handle ids we just call handle.exe with proper arguments and just close them
foreach (string handleid in _HandleIds)
{
Util.runCommand(handlepath, "-c 0x" + handleid + " -y -pid " + bsProcID);
}
Console.ForegroundColor = ConsoleColor.Green;
Console.WriteLine("Successfully Killed All Nif Handles!");
Console.ResetColor();
System.Threading.Thread.Sleep(4000);
}
}
}
}