C++ to PB. Headaches, white nights, etc..

Everything else that doesn't fall into one of the other PB categories.
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Unfortunately not. KarlKox translated it to PB (many thanks) and I am now using his code with some other code I found. I have MSVC here but it's not installed.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

okay, anyway looking forward to this lib :wink:
Success to you :D

best Henrik
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Thank you :D.
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

The archive was updated.
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

@KarlKoX .. Nooow It's working ...Very cool, Thank Yooou KarLKoX :D

best Henrik
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Well the Dll is working thats cool

But i'm Freaking still not able to ObtainSeDebugPrivilege on ex. Explorer.exe
it failes allready OpenProcessToken_()
Inf0byt3's PureAV need to get access to any process in oder to ex. kill them and it seems he is not able to on my system,
:evil:

Still Thank you KarLKoX :D
Best Henrik
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

I tried it with explorer and in fact, there is a problem with the privilege and with the import iat function name, with explorer they are imported by ordinal (not by name), i ll see what i can do :)
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Inf0Byt3
PureBasic Fanatic
PureBasic Fanatic
Posts: 2236
Joined: Fri Dec 09, 2005 12:15 pm
Location: Elbonia

Post by Inf0Byt3 »

Thank you very much!
None are more hopelessly enslaved than those who falsely believe they are free. (Goethe)
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Thats Nice KarLKoX :D
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

I tried with explorer and now the privilege is ok but the dll is not mapped to the process ... i tried pausing the thread, injecting the dll and resuming the thread but with no success :(
I will continue to search and let you know when i find a solution.
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

KarLKoX wrote:I tried with explorer and now the privilege is ok but the dll is not mapped to the process ... i tried pausing the thread, injecting the dll and resuming the thread but with no success :(
Okay :cry:
I will continue to search and let you know when i find a solution.


I'm glad/relieved you don't give up so easily, i would'nt stand a chance here :oops:
.... xplorer and now the privilege is ok

Is it a new source, i messed the last one up so badly, but i can't see the changes in the one i just downloaded, i try to messe around some more :D it can only crash my pc 8)

Thanks KarLKoX
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

In the ObtainSeDebugPrivilege, change the two

Code: Select all

If GetLastError_() <> #ERROR_SUCCESS
to (for the first)

Code: Select all

"If AdjustTokenPrivileges_(hToken, #False, @TokenPrivileges, SizeOf(TOKEN_PRIVILEGES), @PreviousTokenPrivileges, @dwPreviousTokenPrivilegesSize) <= 0"
and for the second

Code: Select all

If AdjustTokenPrivileges_(hToken, #False, @PreviousTokenPrivileges, dwPreviousTokenPrivilegesSize, #Null, #Null) <= 0
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

Okay
should i drop the.

Code: Select all

If GetLastError_() <> #ERROR_SUCCESS 
I changed the code as you said, but on my pc it failes here: with
OpenProcessToken False!

Code: Select all

dwPreviousTokenPrivilegesSize = SizeOf(TOKEN_PRIVILEGES)
  result = OpenProcessToken_(hProcess, #TOKEN_ADJUST_PRIVILEGES | #TOKEN_QUERY, @hToken)
  If result = #False
  PrintN("OpenProcessToken False!")
    ProcedureReturn #False
  Else  
  PrintN("OpenProcessToken True")
  EndIf
Best Henrik
Henrik
Enthusiast
Enthusiast
Posts: 404
Joined: Sat Apr 26, 2003 5:08 pm
Location: Denmark

Post by Henrik »

this is odd, is'nt this wrong

Code: Select all

Procedure DoHook(pid.l,UnHook.b,hFreeModule.l)
... bla
hProcess = OpenProcess_(#PROCESS_ALL_ACCESS, #False, pid)
  ObtainSeDebugPrivilege(hProcess) ; *** <----- Not pid ***
  ;hProcess = OpenProcess_(#PROCESS_ALL_ACCESS, #False, pid)
...

Procedure ObtainSeDebugPrivilege(hProcess.l)
... bla

  PrintN("hProcess = "+Str(hProcess))
  result = OpenProcessToken_(hProcess, #TOKEN_ADJUST_PRIVILEGES | #TOKEN_QUERY, @hToken)

  If result = #False
    PrintN("OpenProcessToken False")
    ProcedureReturn #False
  Else  
    PrintN("OpenProcessToken True  "+Str(result))
  EndIf
The pid for explorer.exe is = 1436 but the hProcess is = 40 : now the OpenProcessToken i returning true
.
AdjustTokenPrivileges seems to return true, but no go ?

Best Henrik
KarLKoX
Enthusiast
Enthusiast
Posts: 681
Joined: Mon Oct 06, 2003 7:13 pm
Location: France
Contact:

Post by KarLKoX »

The archive was updated with some changes.
About the odd, read well the code, i never wrote this, but i set first the privilege with the pid, the param for the ObtainSeDebugPrivilege is just named hProcess but the hProcess is the pid :)
Btw, it should never work for the pid this is why with the modified source you will see that i use GetCurrentProcess_() instead to set the privilege to our process wich then should be able to be used to the target process.
"Qui baise trop bouffe un poil." P. Desproges

http://karlkox.blogspot.com/
Post Reply