Go Back   BWHacks > Development > Reverse Engineering

Reverse Engineering Game hacking discussion and open source development.

Reply
 
LinkBack Thread Tools

Old 08-07-2008, 09:10 AM   #1 (permalink)
K? Pŕo?ćtiόnŹ
=)
Senior Member
Retired Staff Member

Messiah
 
K? Pŕo?ćtiόnŹ's Avatar
 
Join Date: Oct 2004
Location: Okinawa
Posts: 9,347
K? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond repute
Send a message via AIM to K? Pŕo?ćtiόnŹ
Default Giving my process the SeDebugPrivilege

.data?
Code:
    ThisProcessToken dd ?
    ThisProcessTokPriv TOKEN_PRIVILEGES <>
.code
Code:
        invoke GetCurrentProcess
        invoke OpenProcessToken,eax,TOKEN_ALL_ACCESS,addr ThisProcessToken
        .if eax==0
            invoke MessageBox,0,CTXT("Could not retrieve process token."),CTXT("Error"),MB_ICONERROR
            invoke SendMessage,hWin,WM_CLOSE,0,0
        .endif
        invoke LookupPrivilegeValue,0,CTXT("SeDebugPrivilege"),addr ThisProcessTokPriv.Privileges.Luid
        .if eax==0
            invoke MessageBox,0,CTXT("Could not get local debug value."),CTXT("Error"),MB_ICONERROR
            invoke SendMessage,hWin,WM_CLOSE,0,0
        .endif
        mov ThisProcessTokPriv.PrivilegeCount, 1
           mov ThisProcessTokPriv.Privileges.Attributes, SE_PRIVILEGE_ENABLED
           invoke AdjustTokenPrivileges, ThisProcessToken,0, ADDR ThisProcessTokPriv, NULL, NULL, NULL
           .if eax!=0
               invoke MessageBox,0,CTXT("Could not adjust token privileges."),CTXT("Error"),MB_ICONERROR
            invoke SendMessage,hWin,WM_CLOSE,0,0
           .endif
It gives me the error that it couldnt adjust the token privileges. I had it working for a while and it just started giving me that error. I rebooted my computer twice and tried it each time but it still gives me the error.
__________________
K? Pŕo?ćtiόnŹ 15 0FF11|\|3   Reply With Quote
Advertisement
 
Advertisement
Advertisement Sponsored links


Old 08-07-2008, 09:16 AM   #2 (permalink)
hypn
inactive
Gold Member

Disciple
 
hypn's Avatar
 
Join Date: Sep 2005
Location: South Africa
Posts: 510
hypn has disabled reputation
Default

here's my code (worked last time I used it):

Code:
.const
szDebugName 		db 'SeDebugPrivilege',0

.data?
stTkp				TOKEN_PRIVILEGES <>
hToken				dd ?

and my function:

Code:
GetDebugPriv proc

	invoke GetCurrentProcess
	invoke OpenProcessToken,eax,TOKEN_ADJUST_PRIVILEGES or TOKEN_QUERY,addr hToken
	invoke LookupPrivilegeValue,NULL,offset szDebugName,addr stTkp.Privileges[0].Luid
	mov stTkp.PrivilegeCount,1
	mov stTkp.Privileges[0].Attributes,SE_PRIVILEGE_ENABLED
	invoke AdjustTokenPrivileges,hToken,FALSE,addr stTkp,NULL,NULL,NULL
	invoke CloseHandle,hToken
	ret

GetDebugPriv endp
perhaps it's the [0] you're missing, before the ".Luid"?

Quote:
invoke LookupPrivilegeValue,0,CTXT("SeDebugPrivilege"),ad dr ThisProcessTokPriv.Privileges.Luid

VS

invoke LookupPrivilegeValue,NULL,offset szDebugName,addr stTkp.Privileges[0].Luid
otherwise our code's pretty much the same...
__________________
http://www.hypn.za.net
hypn 15 0FF11|\|3   Reply With Quote

Old 08-07-2008, 09:22 AM   #3 (permalink)
K? Pŕo?ćtiόnŹ
=)
Senior Member
Retired Staff Member

Messiah
 
K? Pŕo?ćtiόnŹ's Avatar
 
Join Date: Oct 2004
Location: Okinawa
Posts: 9,347
K? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond repute
Send a message via AIM to K? Pŕo?ćtiόnŹ
Default

Wtf-uzzle. The only difference I see is the access mask and the [0]'s. Yours works for me so Im going to make those changes and see if it works then.
__________________
K? Pŕo?ćtiόnŹ 15 0FF11|\|3   Reply With Quote

Old 08-07-2008, 09:26 AM   #4 (permalink)
K? Pŕo?ćtiόnŹ
=)
Senior Member
Retired Staff Member

Messiah
 
K? Pŕo?ćtiόnŹ's Avatar
 
Join Date: Oct 2004
Location: Okinawa
Posts: 9,347
K? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond reputeK? Pŕo?ćtiόnŹ has a reputation beyond repute
Send a message via AIM to K? Pŕo?ćtiόnŹ
Default

Well, I made those changes and I still get that error. Damn.

EDIT: Well I feel rather silly, I went back and looked at the docs for AdjustTokenPrivileges, and it seems that if the return value is 0 then it failed, not non zero >_>;

Problem solved, thanks for your help hypn.
__________________
K? Pŕo?ćtiόnŹ 15 0FF11|\|3   Reply With Quote

Old 08-07-2008, 10:09 PM   #5 (permalink)
Suteki

Deviant
 
Join Date: Jun 2007
Posts: 151
Suteki is on a distinguished road
Default

lol those pesky 0's and non 0's ;/
__________________
Quote:
Originally Posted by Dunkelvolk 10-07-2007, 07:29 PM
please molder you have only 16 years old
and you dont have any idea about computer
i am enginner of computers lol

your hacks sucks stupid
Suteki 15 0FF11|\|3   Reply With Quote

Old 08-08-2008, 09:08 AM   #6 (permalink)
hypn
inactive
Gold Member

Disciple
 
hypn's Avatar
 
Join Date: Sep 2005
Location: South Africa
Posts: 510
hypn has disabled reputation
Default

hahah, cool - glad you got it sorted
__________________
http://www.hypn.za.net
hypn 15 0FF11|\|3   Reply With Quote

Old 09-26-2008, 05:59 AM   #7 (permalink)
Dyndrilliac

Enlightened
 
Dyndrilliac's Avatar
 
Join Date: Jun 2005
Location: Jacksonville, FL, USA
Posts: 2,586
Dyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant future
Send a message via AIM to Dyndrilliac Send a message via MSN to Dyndrilliac Send a message via Yahoo to Dyndrilliac
Default

Don't mean to necro-post, but I was cleaning out my documents folders and found something relevant to this thread, and I wanted to add a thread pointer to the guide's index for this topic.
Code:
bool SetDebugPrivileges() {

	LUID Luid;
	TOKEN_PRIVILEGES tpToken;
	HANDLE hToken;

	if (!OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY | TOKEN_ADJUST_PRIVILEGES, &hToken)) {
		return false;
	}

	if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &Luid)) {
		CloseHandle (hToken);
		return false;
	}

	tpToken.PrivilegeCount = 1;
	tpToken.Privileges[0].Luid = Luid;
	tpToken.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;

	if (!AdjustTokenPrivileges(hToken, false, &tpToken, NULL, NULL, NULL)) {
		CloseHandle(hToken);
		return false;
	}

	CloseHandle(hToken);
	return true;

}
__________________
Ultimate Guide/Resource/Tutorial/Book Thread
Technobabble! - My Blog About All Things Technological
Quote:
Originally Posted by Edsger W. Dijkstra
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.

Last edited by Dyndrilliac : 09-28-2008 at 12:00 AM.
Dyndrilliac 15 0FF11|\|3   Reply With Quote

Old 09-27-2008, 02:49 PM   #8 (permalink)
ZoiD
Senior Member
Gold Member
Moderator

Deviant
 
ZoiD's Avatar
 
Join Date: Sep 2005
Location: 0xC0DEDBAD
Posts: 145
ZoiD has a spectacular aura about
Send a message via ICQ to ZoiD Send a message via AIM to ZoiD Send a message via MSN to ZoiD
Default

Dyndrilliac you have to close hToken even if return value is 'true' since the handle was opened inside that function.

Not being snide ;p My code shared same issue.
Code:
BOOL EnableDebugPrivledges( void )
{
	HANDLE	hToken;
	LUID	Luid;
	TOKEN_PRIVILEGES tpToken;
	BOOL bRet = FALSE;

	// enable the SeDebugPrivilege
	if( 0 != OpenProcessToken( GetCurrentProcess( ) ,TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken ) && 
		0 != LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &Luid ) )
	{
		tpToken.PrivilegeCount			= 1;
		tpToken.Privileges[ 0 ].Luid		= Luid;
		tpToken.Privileges[ 0 ].Attributes	= SE_PRIVILEGE_ENABLED;
		bRet = 0 != AdjustTokenPrivileges( hToken, FALSE, &tpToken, NULL, NULL, NULL );

		CloseHandle( hToken );
	}

	return bRet;
}
In my ver, If LookupPrivilegeValue fails it will just jmp over and not close the handle.
__________________
Quote:
Destiny; A tyrant’s authority for crime and fool’s excuse for failure.
Quote:
...man had been created with a hole in his heart, a hole that no power, riches, or knowledge could fill. And in his infinite greed, man dreamed of expanding his dominion over the entire earth.
ZoiD 15 0FF11|\|3   Reply With Quote

Old 09-28-2008, 12:02 AM   #9 (permalink)
Dyndrilliac

Enlightened
 
Dyndrilliac's Avatar
 
Join Date: Jun 2005
Location: Jacksonville, FL, USA
Posts: 2,586
Dyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant futureDyndrilliac has a brilliant future
Send a message via AIM to Dyndrilliac Send a message via MSN to Dyndrilliac Send a message via Yahoo to Dyndrilliac
Default

Fixed Thanks for pointing that out, it was incredibly old code and I didn't look it over thoroughly before posting it.
__________________
Ultimate Guide/Resource/Tutorial/Book Thread
Technobabble! - My Blog About All Things Technological
Quote:
Originally Posted by Edsger W. Dijkstra
It is practically impossible to teach good programming to students that have had a prior exposure to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.
Dyndrilliac 15 0FF11|\|3   Reply With Quote
Sponsored links
Advertisement
 
Advertisement
Advertisement

Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Process Explorer: GTFO Task Manager gamepin126 System & Utilities 9 09-13-2008 06:07 AM
SeDebugPrivilege in VB6 ATH500 Starcraft Hacking Related 2 09-04-2007 04:39 PM
Mirosoft C# ProMasser Programming 3 08-01-2007 03:09 PM
Whats the easiest way to determine which process you are in? Dyndrilliac Programming 10 08-06-2006 02:07 AM
SC Process Handle llafnwod Starcraft Hacking Related 10 10-19-2004 05:57 AM


All times are GMT. The time now is 02:11 AM.


vBulletin style developed by Transverse Styles

Powered by vBulletin Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright © 2004-2008 BWHacksAd Management by RedTyger