![]() |
Re: RegGetKeySecurity
Da steht doch
dwRevision [in] The revision level to assign to the security descriptor. This parameter must be SECURITY_DESCRIPTOR_REVISION. oder sehe ich das falsch?
Delphi-Quellcode:
Muss jetzt erstmal den SecurityDescriptor richtig erstellen bzw. Speicher zuweisen. Ich denke dort liegt der fehler.
.data
lpSubKey db "SOFTWARE\Classes\.7z\2",0 phkResult dd 0 .data? pSecurityDescriptor SECURITY_DESCRIPTOR <> .code start: xor eax,eax push offset phkResult push KEY_ALL_ACCESS push 0 push offset lpSubKey push HKEY_LOCAL_MACHINE call RegOpenKeyEx push offset pSecurityDescriptor call IsValidSecurityDescriptor test eax,eax ; EAX 00000000 (Das ist schonmal positiv) jnz @_ExitProcess push SECURITY_DESCRIPTOR_REVISION push offset pSecurityDescriptor call InitializeSecurityDescriptor push sizeof SECURITY_DESCRIPTOR push offset pSecurityDescriptor push DACL_SECURITY_INFORMATION push offset phkResult call RegGetKeySecurity push phkResult call RegCloseKey @_ExitProcess: push 0 call ExitProcess end start Das mit der Domäne kommt später, muss jetzt erst mal den SecurityDescriptor erstellen. Bevor da nicht alle EAX rückgabewerte der API überall auf 0 ist geht es nicht weiter. |
Re: RegGetKeySecurity
So, jetzt habe ich den code mal überarbeitet.
Ich initialisierte den "SecurityDescriptor" und prüfe diesen zum Schluss mit "IsValidSecurityDescriptor". EAX gibt mir als wert EAX = 00000001 zurück. Alles super, d.h. der initialisierte SecurityDescriptor ist Gültig. Kann jedoch mit dem API call "RegGetKeySecurity2 noch immer nicht die DACL in den SecurityDescriptor zurück geben lassen. Zugriffsverletzung. Könnte heulen. :wall: Habe ich vieleicht irgendwas übersehen? Mir fliegen bald die :shock: raus....
Delphi-Quellcode:
Zugriffsverletzung:
.data
lpSubKey db "SOFTWARE\Classes\.7z\2",0 phkResult dd 0 .data? pSecurityDescriptor SECURITY_DESCRIPTOR <> buffer_addr dd ? .code start: xor eax,eax nop nop push offset phkResult push KEY_ALL_ACCESS push 0 push offset lpSubKey push HKEY_LOCAL_MACHINE call RegOpenKeyEx ; EAX must zero nop nop xor eax,eax nop nop push SECURITY_DESCRIPTOR_MIN_LENGTH push GPTR call GlobalAlloc ; EAX must nonzero nop ; EAX = (new object handle) nop mov buffer_addr,eax nop nop xor eax,eax nop nop push SECURITY_DESCRIPTOR_REVISION push offset buffer_addr call InitializeSecurityDescriptor ; EAX must nonzero nop nop xor eax,eax nop nop push offset buffer_addr call IsValidSecurityDescriptor ; EAX must nonzero nop ; EAX = 00000001 nop xor eax,eax nop nop push sizeof buffer_addr push offset buffer_addr push DACL_SECURITY_INFORMATION push offset phkResult call RegGetKeySecurity nop nop push phkResult call RegCloseKey nop nop push offset buffer_addr call GlobalFree nop @_ExitProcess: push 0 call ExitProcess end start
Delphi-Quellcode:
EAX 00000004
ECX 00403017 RegAth.00403017 EDX 00000000 EBX 00000000 ESP 0012FF14 EBP 0012FF74 ESI 02000000 EDI 00000000 EIP 761BC7FD advapi32.761BC7FD C 0 ES 0023 32bit 0(FFFFFFFF) P 0 CS 001B 32bit 0(FFFFFFFF) A 0 SS 0023 32bit 0(FFFFFFFF) Z 0 DS 0023 32bit 0(FFFFFFFF) S 0 FS 003B 32bit 7FFDE000(FFF) T 0 GS 0000 NULL D 0 O 0 LastErr ERROR_SUCCESS (00000000) EFL 00010202 (NO,NB,NE,A,NS,PO,GE,G) ST0 empty 0.0 ST1 empty 0.0 ST2 empty 0.0 ST3 empty 0.0 ST4 empty 0.0 ST5 empty 0.0 ST6 empty 0.0 ST7 empty 0.0 3 2 1 0 E S P U O Z D I FST 0000 Cond 0 0 0 0 Err 0 0 0 0 0 0 0 0 (GT) FCW 027F Prec NEAR,53 Mask 1 1 1 1 1 1 |
Re: RegGetKeySecurity
wie gesagt, hab kein plan davon :>
um Luckies frage neu aufzugreiffen: warum eigentlich asm ? |
Re: RegGetKeySecurity
So, sieht gut aus. :cheer:
Jetzt funktioniert es ohne Zugriffsverletzung,... Jetzt bekomme ich bei dem Api Call "RegGetKeySecurity" nur noch ERROR_ACCESS_DENIED (00000005) zurück. Sehr seltsam, sogar unter Systemrechten. :coder2: Warum ich das in ASM mach? Gibt eigentlich keinen besonderen Grund, ich programmiere einfach gerne in ASM. Wenn ich ehrlich bin kann ich schon gar kein Delphi mehr. ;P
Delphi-Quellcode:
.data
lpSubKey db "SOFTWARE\Google",0 phkResult dd 0 .data? pSecurityDescriptor SECURITY_DESCRIPTOR <> buffer_addr dd ? buffer_size dd ? .code start: xor eax,eax nop nop push offset phkResult push KEY_ALL_ACCESS push 0 push offset lpSubKey push HKEY_CURRENT_USER call RegOpenKeyEx ; EAX must zero nop nop xor eax,eax nop nop push SECURITY_DESCRIPTOR_MIN_LENGTH push GPTR call GlobalAlloc ; EAX must nonzero nop ; EAX = (new object handle) nop mov buffer_addr,eax nop nop xor eax,eax nop nop push SECURITY_DESCRIPTOR_REVISION push offset buffer_addr call InitializeSecurityDescriptor ; EAX must nonzero nop nop xor eax,eax nop nop push offset buffer_addr call IsValidSecurityDescriptor ; EAX must nonzero nop ; EAX = 00000001 nop xor eax,eax nop nop mov eax,sizeof buffer_addr mov buffer_size,eax nop nop xor eax,eax nop nop push offset buffer_size push offset buffer_addr push DACL_SECURITY_INFORMATION push offset phkResult call RegGetKeySecurity nop cmp eax,ERROR_SUCCESS jne @_Error @_CleanUp: nop push phkResult call RegCloseKey nop nop push offset buffer_addr call GlobalFree nop @_ExitProcess: push 0 call ExitProcess @_Error: push 0 push 0 push 0 push 0 Call MessageBox jmp @_CleanUp end start |
Re: RegGetKeySecurity
Zitat:
Kann es sein dass dein XP von einem Domain Admin installiert wurde und du gerade mit nem lokalen Admin Account der nicht in der domain liegt arbeitest? Genau in dieser konstellation habe ich probleme mit ACCESS_DENIED |
Re: RegGetKeySecurity
Zitat:
Das witzige ist ja das ich mir Systemrechte erschlichen habe und nicht einmal mit Systemrechten funktioniert es. :roteyes: Habe Vista und arbeite nicht in einer Domäne. Habe gerade noch etwas gefunden, vielleicht muss ich noch Privilegien setzen. Siehe MSDN ganz unten ( ![]() Zitat:
![]() Denke nicht das es mit der Domäne zusammenhängt, dass braucht man glaub ich nur wenn man die SID des USERS etc. ermitteln möchte. :duck: Greatz EDIT: Before enabling any of these potentially dangerous privileges, determine that functions or operations in your code actually require the privileges. :stupid: EDIT2: So, das Programm hat nun Debug-Rechte! ![]() Jetzt kann ich auf den Schlüssel zugreifen,.. aber es kommt jetzt wieder zu einer Zugriffsverletzung. Bin echt gespannt ob ich das jemals in Griff bekomme. ;( |
Re: RegGetKeySecurity
Die Zugriffsverletzung ist behoben.
Es lag ganz einfach daran das ich den Schlüssel den ich angegeben habe das hier --> \ vergessen habe. "SOFTWARE\Google\",0 Wichtig zu wissen ist, wenn man mit dem API call "RegGetSecurity" z.B.: den DACL abfragen möchte, dann muss das Programm entsprechende Rechte besitzen. (siehe MSDN ![]() Meinem Programm habe ich "SeDebugPrivilege" zugteilt. @Volle, wenn du das bei dir auch machst, dann klappt es sicherlich auch mit deinem "ACCESS_DENIED" Problem! :angel: :dp: Der komplette Source-Code wird in kürze nachgereicht. Greatz Core |
Re: RegGetKeySecurity
ich werds versuchen, mal schauen was dann geht :P
|
Re: RegGetKeySecurity
Also irgendwas laeuft z.Z. total schief
ich hab versucht den Code den Luckie verlinkt hat in C++ zu uebersetzen. Ich bekomme beim aufruf von AccessCheck() den Errorcode 5 zurueck -> ACCESS_DENIED Nagut, dann fehlen mir evtl die erwaehnten debug rechte. Den spass eingebaut: AdjustTokenPrivileges() liefert 5 zurueck -> ACCESS_DENIED ich weis grad echt nich mehr weiter :P Eine Frage hab ich da noch: geht das ganze mit eingeschraenkten benutzerrechten ? Im moment bin ich zwar mit Adminrechten angemeldet, aber spaeter sollte das Prog mit eingeschraenkten Rechten laufen -> wenn das ueberhaupt nicht moeglich ist dann brauch ich garnicht weitermachen. |
Re: RegGetKeySecurity
Zitat:
Kurz: Es stellt sich mir die Frage nach dem Sinn, die Sicherheitsbeschreibung ermitteln zu müssen. In den meisten Fällen kommt man ohne aus. Bleibt also offen, was eigentlich erreicht werden soll... Edit: Definiere "mit eingeschraenkten Rechten". |
Alle Zeitangaben in WEZ +1. Es ist jetzt 06:48 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz