Autor |
Beitrag |
LittleBen
Beiträge: 258
Erhaltene Danke: 4
Win 7, Mac OS
Delphi 7
|
Verfasst: Mi 07.11.12 22:02
Guten Abend,
gibt es eine Funktion, mit der man anhand der PID (oder des Handles) feststellen kann, ob der Prozess über Adminrechten verfügt?
Die Funktion zum Überprüfen, ob der User diese Rechte hat, ist mir bekannt.
Viele Grüße,
Littleben
|
|
ChrisCross
Beiträge: 124
Erhaltene Danke: 12
Windows 10 64 bit
Delphi XE6 Starter
|
Verfasst: Mi 07.11.12 22:27
www.delphi-treff.de/...tratorrechte-pruefen
Meinst du so etwas? Oder habe ich dich falsch verstanden?
/Edit: das weißt du ja bereits
|
|
LittleBen
Beiträge: 258
Erhaltene Danke: 4
Win 7, Mac OS
Delphi 7
|
Verfasst: Mi 07.11.12 22:32
Jup, das kenn ich schon
|
|
elundril
Beiträge: 3747
Erhaltene Danke: 123
Windows Vista, Ubuntu
Delphi 7 PE "Codename: Aurora", Eclipse Ganymede
|
Verfasst: Do 08.11.12 02:22
Soweit ich herausgefunden habe laufen Prozesse die mit UAC gestartet wurden im Integrity-Mode "High". Demnach könntest du einfach den Integrity-Mode eines Prozesses herausfinden und nachsehen ob dieser auf High gesetzt ist. Wie man das macht findest du auf dieser MSDN-Seite
lg elundril
_________________ This Signature-Space is intentionally left blank.
Bei Beschwerden, bitte den Beschwerdebutton (gekennzeichnet mit PN) verwenden.
|
|
LittleBen
Beiträge: 258
Erhaltene Danke: 4
Win 7, Mac OS
Delphi 7
|
Verfasst: Do 08.11.12 16:24
Vielen Dank! Das ist das, was ich gesucht habe. Nur habe ich noch ein kleines verständnis Problem.
GetCurrentProcess gibt laut MSDN nur ein pseudo Handle zurück und um die Rechte eines anderen Prozesses herauszubekommen, muss ich ja dessen pseudo Handle herausfinden. Nur wie?
Zitat: | A pseudo handle is a special constant, currently (HANDLE)-1, that is interpreted as the current process handle. For compatibility with future operating systems, it is best to call GetCurrentProcess instead of hard-coding this constant value. The calling process can use a pseudo handle to specify its own process whenever a process handle is required. Pseudo handles are not inherited by child processes. |
msdn.microsoft.com/e...79%28v=vs.85%29.aspx
|
|
jaenicke
Beiträge: 19285
Erhaltene Danke: 1743
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: Do 08.11.12 16:34
Du kannst auch den Prozess mit OpenProcess öffnen, dann hast du ein "richtiges" Handle.
|
|
LittleBen
Beiträge: 258
Erhaltene Danke: 4
Win 7, Mac OS
Delphi 7
|
Verfasst: Do 08.11.12 21:02
Aber dieses "richtige" Handle kann ja an der stelle OpenProcessToken gar nicht gebrauchen
Hier der gefundene Code:
www.plugins-soft.com.../integritylevel.html
|
|
jaenicke
Beiträge: 19285
Erhaltene Danke: 1743
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: Do 08.11.12 23:09
|
|
LittleBen
Beiträge: 258
Erhaltene Danke: 4
Win 7, Mac OS
Delphi 7
|
Verfasst: Do 08.11.12 23:15
Nönönö Gibt eine Exception aus (Code kommt morgen, PC schon aus).
|
|
jaenicke
Beiträge: 19285
Erhaltene Danke: 1743
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: Do 08.11.12 23:49
Dann liegt das vielleicht daran: Zitat: | The process must have the PROCESS_QUERY_INFORMATION access permission.
|
Welchen Fehlercode bekommst du denn?
|
|
LittleBen
Beiträge: 258
Erhaltene Danke: 4
Win 7, Mac OS
Delphi 7
|
Verfasst: Fr 09.11.12 23:02
PROCESS_QUERY_INFORMATION habe ich als Argument drin...
Ich bekomme die Fehlermeldung: "Externe Exception C0000008"
|
|
jaenicke
Beiträge: 19285
Erhaltene Danke: 1743
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: Fr 09.11.12 23:19
Mit ansonsten dem geposteten Quelltext?
|
|
LittleBen
Beiträge: 258
Erhaltene Danke: 4
Win 7, Mac OS
Delphi 7
|
Verfasst: Fr 09.11.12 23:42
Entschuldigung, ich nehme alles zurück...
Ich habe per OpenProcess probiert, ein Prozess mit Administratorrechten zu öffnen und danach nicht abgefragt, ob der Wert 0 ist. Und da ich diesen Prozess nicht öffnen darf, war das Handle 0. Kann ich das Handle auch ohne Adminrechte herausfinden?
|
|
Martok
Beiträge: 3661
Erhaltene Danke: 604
Win 8.1, Win 10 x64
Pascal: Lazarus Snapshot, Delphi 7,2007; PHP, JS: WebStorm
|
Verfasst: Sa 10.11.12 00:48
Du kannst das dann ja triangulieren
Wenn du Admin bist, bekommst du ein Handle und davon eine korrekte Antwort.
Wenn du nicht Admin bist, bekommst du entweder Handle&Antwort (die dann "nein" ist) oder kein Handle, was bedeutet dass der Prozess ein höheres Level hat und dann höchstwahrscheinlich entweder Admin oder SystemService ist...
_________________ "The phoenix's price isn't inevitable. It's not part of some deep balance built into the universe. It's just the parts of the game where you haven't figured out yet how to cheat."
|
|
LittleBen
Beiträge: 258
Erhaltene Danke: 4
Win 7, Mac OS
Delphi 7
|
Verfasst: Sa 10.11.12 11:49
Das ist natürlich eine sehr saubere Lösung Werde es nachher mal ausprobieren.
EDIT: Wo wir schon beim Thema sind ist mir eingefallen: Ist es möglich dieses Integrity Level eines Prozesses zu verändern (angenommen man ist Admin)?
|
|
jaenicke
Beiträge: 19285
Erhaltene Danke: 1743
W11 x64 (Chrome, Edge)
Delphi 11 Pro, Oxygene, C# (VS 2022), JS/HTML, Java (NB), PHP, Lazarus
|
Verfasst: Sa 10.11.12 16:33
Man kann nicht nachträglich den Adminstatus ändern, nein. Aus Sicherheitsgründen wird ausschließlich beim Starten eines Prozesses entschieden, ob dieser als Admin läuft oder nicht. Hinterher lässt sich das nicht ändern.
|
|