Outils pour utilisateurs

Outils du site


misc:suid_running_proc

~~NOTOC~~ ==== Changer l'UID et le GID d'un processus actif ==== Par exemple vous lancez un daemon en root pour ouvrir un port <1024, il a donc l'UID=0 et le GID=0.\\ On veut lui donner l'UID=1000 et le GID=1000 d'un utilisateur((la command //id// affiche l'UID et le GID de l'utilisateur courant)) par mesure de sécurité. On a notre daemon lancé et on connait son PID, 15045 par exemple. On lance GDB et on lui demande de s'attacher à ce PID pour débugger le programme, puis on utilise l'instruction //call// pour exécuter setgid et setuid: <code> root@localhost:~# gdb GNU gdb (GDB) 7.0.1-debian Copyright (C) 2009 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html> This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. Type "show copying" and "show warranty" for details. This GDB was configured as "x86_64-linux-gnu". For bug reporting instructions, please see: <http://www.gnu.org/software/gdb/bugs/>. (gdb) attach 15045 Attaching to process 15421 Reading symbols from /usr/bin/daemon...(no debugging symbols found)...done. Current language: auto The current source language is "auto; currently asm". (gdb) call setgid(1000) $1 = 0 (gdb) call setuid(1000) $2 = 0 (gdb) detach Detaching from program: /usr/bin/daemon, process 15045 (gdb) quit </code> Maintenant notre programme 15045 est exécuté par l'utilisateur 1000:1000.

misc/suid_running_proc.txt · Dernière modification: 2013/08/31 01:23 par mrhide