PDA

Ver la versión completa : Gran macana Gran /etc/sudoers



Cypress
12-07-2008, 06:31
Jé.. holis, cortita y al pie
estuve editando el /etc/sudoers
para agregar un usuario, pero lo escribi mal,

puse cypress ALL=PASSWD:ALL

y sería cypress ALL = PASSWD:ALL

el asunto es que no puedo usar sudo ahora

sudoers file: syntax error, line 16
Y necesito editar sudoer para corregir esto. Otro problema, es que no tengo el root.

pregunta: el archivo sudoers puede afectar el root ? es decir, que cambie el pass del root ? No, no ? es que el root que me dieron no funciona :S

y la otra pregunta es, cómo puedo arreglar esto ? :-/
Sin usar LiveCD, estoy conectado a travez de ssh.. y estoy fucked up after that :(
alguna idea brillante ?
tengo solo dos usuarios creados en esta maquina, alguna idea ? :(

Saludoss :(

gondar_f
12-07-2008, 12:03
Yo te iva a decir con un LiveCD, pero si no se puede...

Sinceramente no se que decirte, lo único que se me ocurre en este moment son ideas poco prácticas y van desde usar un exploit para escalar privilegios, pasando por si está activo un apache por ejemplo usar un script cgi (no funciona si está bien montado) y usando lynx u similar hacer la llamada y que sea el script quien haga el cambio... todas así...

Espero que j8, hystd... u otro pueda darte una respuesta

Un Saludo

j8k6f4v9j
12-07-2008, 16:47
Está muy jodido. Te encuentras en la misma situación que cualquier que hubiese conseguido acceso no privilagiado a tu máquina. Y supongo que tu deseo es que esa supuesta persona no puediera conseguir lo que tú te propones hacer ... :rolleyes:

No tengo solución para tu problema por tanto. Con acceso físico todo cambia.

Te dejo el fruto de mis propias indagaciones al respecto:



16:31 < o2T7> Hi, how to repair sudoers.conf --without root perms-- when getting "sudoers file: syntax error" ???
16:31 < o2T7> Remotely
16:32 < Bushmills> o2T7: just su, then fix it
16:32 < inigo> o2T7, do you have a backup system ?
16:32 < doublehp_> o2T7: user cant get root ?
16:32 < o2T7> Bushmills: I'm afraid that there are no root privileges at all
16:33 < doublehp_> o2T7: ssh -l root :)
16:33 < o2T7> doublehp_: neither root pass for ssh :S
16:33 < jelly-home> o2T7: first, su to root. second, it's "/etc/sudoers", not "sudoers.conf". third, fix it
16:33 < doublehp_> o2T7: if you REALLY cant get root at all, i got a trick, 2mn
16:33 < RoyK> o2T7: type 'visudo'
16:33 < Bushmills> o2T7: fire the person who broke sudo without providing an alternative way to become root
16:34 < o2T7> Bushmills: heh, that's probably the best solution xD
16:34 < o2T7> RoyK: Visudo needs root privs too
16:34 < jelly-home> !tell o2T7 -about forgot root password
16:34 < doublehp_> n-iCe: I asked twice mplayer's logs !
16:35 < doublehp_> o2T7: reboot, and pass this to kernel arguments: init=/bin/bash
16:35 < RoyK> o2T7: if course...
16:35 < doublehp_> o2T7: after boot, run : mount -o remount,rw /dev/hda1 / (or whatever your / is )
16:35 < o2T7> doublehp_: It must be done remotely
16:35 < doublehp_> o2T7: then, you have full access to system: run passwd to change root pass, edit any file
16:35 < RoyK> o2T7: that's the whole point - if you can't get root, missing the root password, boot on a cd and
change the root password
16:36 < doublehp_> o2T7: when done: mount -o remount,ro /dev/hda1 / ; sync
16:36 < jelly-home> o2T7: is there a reason you can't use "su"?
16:36 < doublehp_> o2T7: then you can reboot
16:36 < o2T7> jelly-home: Yes, no root pass
16:36 < jelly-home> o2T7: who set up that Debian system?
16:36 < doublehp_> o2T7: there are things that cant be done "for good security reasons"
16:37 < o2T7> I see it just lilke a privileges scalation, since there is no root privs at all and no phisical
access by now to the server.
16:37 < o2T7> doublehp_: Yes, and I thanks it ;)
16:37 < jelly-home> o2T7: sucks to be you. :-)
16:37 < RoyK> o2T7: boot on a debian install cd, mount the root fs from the disk somewhere, chroot into it,
passwd ... and you're done
16:37 < o2T7> RoyK: Nop, that needs phisical access too
16:38 < RoyK> o2T7: well, then you're probably fscked :P
16:38 < jelly-home> o2T7: if you often have to admin servers with no physical access, I recommend hardware with
remote console access, like most brand-name servers have.
16:38 < o2T7> heh, sure xD
16:39 < o2T7> jelly-home: Well, I'll do your recommendation ;)
16:39 < Bushmills> o2T7: no rescue system? net boot which you can select by web interface?
16:39 < jelly-home> o2T7: eg. HP has remote console, power/reset buttons, virtual serial and cdrom capabilities
(can mount and boot from remote iso images)
16:39 < o2T7> Bushmills: I don't know that
16:39 < RoyK> o2T7: with no root password and no sudo access, you won't get in...
16:39 < Bushmills> o2T7: find out
16:39 < o2T7> jelly-home: Yes, I translated some good stuff about that not long ago. Good tools indeed.
16:40 < jelly-home> o2T7: other vendors have similar stuff (dell, sun, ibm...)
16:41 < o2T7> jelly-home: Yes, the pity is that they're not standarized. Something a bit weird, being such a
vital issue.
16:42 < jelly-home> o2T7: I think some bits are standardized, but not much. google "IPMI"
16:42 < o2T7> Yes
16:43 < o2T7> I know, although didn't experiment with it directly


Por otro lado, el procedimiento recomendado ante la pérdida de root en nuestro sistema:

16:34 <dpkg> methinks ifrp is 1) press 'e' to edit the kernel setting in the grub
command line (add 'init=/bin/sh' to the end of it) 2) 'fsck' your root file system, 3) 'mount -o
remount,rw /', 4) 'passwd root' 5) 'mount -o remount,ro /' 6) 'reboot -d -f' (exec /sbin/init should
work); For LILO (e.g. pre-sarge): 1) 'linux init=/bin/sh' at a lilo boot prompt (hold Shift while
booting), steps 2-6 are the same; yaboot: 1) 'Linux init=/bin/sh' at y




Por cierto, para la próxima, para editar /etc/sudoers usa visudo !!
Salu2



http://img359.imageshack.us/img359/6631/celliigy4.pngKeep on Rollin' :mad:

Cypress
12-07-2008, 17:12
jó, si use visudo, pero hay cosas que me suele pasar con vi que no me gustan, que no entiendo y que por eso siempre termino usando nano.

con vi, a veces pasa que corro el cursor y escribe otras cosas, aprece texto por donde no tendría y cosas así.
y visudo me hacia lo mismo :( entonces sudo nano /etc/sudoers

Voy a ver que onda desde ssh :( - me quiero matar, por suerte no me han dicho nada todavía -

odio que los americanos digan: it sucks to be u, a mi ya me lo han dicho, y me dan ganas de matarlos cada vez que me dicen algo así.
Pero bueno, ya les cuento, no creo que pueda ver el grub desde ssh, pero ahí voyyyy

Saludos

p.s: el archivo soudoers, no afecta el pass del root, no ? porque vi el .bash_history y hay un passwd, pero no funciona, es el mismo que me han dicho que use, pero no sé, sudoers, no afecta en nada, no ? :-/

j8k6f4v9j
12-07-2008, 17:40
No, sudoers no afecta al pass de root.

visudo != vi


DESCRIPTION
visudo edits the sudoers file in a safe fashion, analogous to vipw(8).
visudo locks the sudoers file against multiple simultaneous edits, pro‐
vides basic sanity checks, and checks for parse errors

Estás despedido! xD

PD: A mí me encanta vi. Pero tienes que tener en cuenta que cada tecla es un comando si no estás en modo INSERTAR

PD2: Eso me lo dijo porque me preguntó que quién había instalado el sistema. Es como decir: "asumo que fuiste tú", aunque se equivocó.

Salu2


http://img359.imageshack.us/img359/6631/celliigy4.pngKeep on Rollin' :mad:

Cypress
13-07-2008, 17:49
fa, que jodido que estoy :(
ni siquiera tiene gcc instalado como para que pueda compilar esos viejos exploits de linux.
me acorde que shutdown necesita sudo para arrancar, así que super jodido estoy :(

dem.. at this time, it sucks to be me xD

j8k6f4v9j
14-07-2008, 10:01
dem.. at this time, it sucks to be me xD

Sure xD

¿No cuentas con nadie que tenga acceso físico?

Salu2



http://img359.imageshack.us/img359/6631/celliigy4.pngKeep on Rollin' :mad:

Cypress
14-07-2008, 15:45
Sí, hoy sí, el problema es el fin de semana, :-/
ahora espero a que se conecte, y veremos, le he dicho que desde el liveCD que haga un sudo passwd
y que luego cp /etc/shadow /media/hda/etc/shadow

por lo menos así tendremos el root

j8k6f4v9j
14-07-2008, 15:58
le he dicho que desde el liveCD que haga un sudo passwd
y que luego cp /etc/shadow /media/hda/etc/shadow

¿Y por qué no ...?



chroot /media/hda
sudo passwd
visudo


;)

Salu2



http://img359.imageshack.us/img359/6631/celliigy4.pngKeep on Rollin' :mad:

Cypress
17-07-2008, 15:53
ya está arreglado, Los LiveCD son como dicen ustedes " la ostia " jajaja
es más, editamos el shadow, y le puse el pass que queriamos. y luego editamos el sudoers..

y otra vez un millon de gracias j8, creo que estás cansado de que te lo diga, pero u rocks !
y me acabo de sumar un comando que ahora estoy leyendo el man, chroot.
ese no lo tenia :)
Graciasssssss :) por todo, siempre :)

j8k6f4v9j
17-07-2008, 18:24
De nada :)

Salu2



http://img359.imageshack.us/img359/6631/celliigy4.pngKeep on Rollin' :mad: