Está en la página 1de 5

Hace un par de meses atrs me hice cargo de una red cuyo router era un equipo Mikr

otik. Lgicamente, necesitaba recuperar la contrasea del mismo sin perder la config
uracin para que todo siguiera funcionando correctamente. Lamentablemente, Mikroti
k no provee un procedimiento oficial para llevarlo a cabo por lo cul decid correr
el riesgo con un procedimiento artesanal que result satisfactorio. En este post t
raduzco el original en ingls, con algunas acotaciones propias de mi experiencia.
Requerimientos
Cable de consola (serie).
Servidor DHCP.
Servidor TFTP.
Minicom.
Netcat.
Herramienta mtbpass.
Compilador g++.
Libreras de openssl.
Kernel OpenWRT.
Kernel para RB411
Kernel para el resto de los RB
Tareas
Bootear el equipo desde la red para cargar el kernel adaptado.
Enviar el archivo con las password a una computadora.
Desencriptar las contraseas en la mquina.
Configuracin de Minicom
En mi caso realic el procedimiento sobre una RB411 con los valores de consola por
defecto y utilizando un cable USB to Serial, con lo cual mi configuracin es la s
iguiente:
A - Serial Device : /dev/ttyUSB0
E - Bps/Par/Bits : 115200 8N1
F - Hardware Flow Control : Yes
G - Software Flow Control : No
Configuracin de DHCP y TFTP
Para la configuracin del DHCP editar el archivo /etc/dhcp3/dhcpd.conf. Notar que
es importante conservar la red 10.0.0.0/24, ya que la misma est hardcodeada en la
s imagenes de los kernel.
default-lease-time 21600;
max-lease-time 43200;
option domain-name-servers 10.0.0.1;
option netbios-name-servers 10.0.0.1;
option netbios-node-type 8;
option www-server 10.0.0.1;
authoritative;
allow booting;
allow bootp;
subnet 10.0.0.0 netmask 255.255.255.0
{
option routers 10.0.0.1;
option subnet-mask 255.255.255.0;
option broadcast-address 10.0.0.255;
filename "/tftpboot/linuxrc";
range 10.0.0.10 10.0.0.100;
}
Para el servidor TFTP editar el archivo /etc/inetd.conf y establecer el director
io del servidor a /tftpboot.
Copiar la imagen del kernel que corresponda a /tftpboot con el nombre linuxrc.
Bootear con el nuevo kernel
Conectar el Mikrotik al puerto de consola.
Conectar el puerto de red principal del Mikrotik al de la computadora.
Asignar la IP 10.0.0.1/24 a la placa de la computadora.
Iniciar los servicios de DHCP y TFTP.
Iniciar minicom sin inicializacin de mdem y prender el Mikrotik.
minicom -o
RouterBOOT booter 1.5
RouterBoard 411
CPU frequency: 300 MHz
Memory size: 32 MB
Press any key within 1 seconds to enter setup
Aqu apretar cualquier tecla rpido, para que muestre el siguiente men
RouterBOOT-1.5
What do you want to configure?
d - boot delay
k - boot key
s - serial console
o - boot device
u - cpu mode
f - try cpu frequency
c - keep cpu frequency
r - reset configuration
g - upgrade firmware
i - board info
p - boot protocol
t - do memory testing
x - exit setup
your choice:
Apretar o
your choice: o - boot device
Select boot device:
e - boot over Ethernet
* n - boot from NAND
c - boot from CF
1 - boot Ethernet once, then NAND
2 - boot Ethernet once, then CF
b - boot chosen device
your choice:
En este paso, si:
El sistema reside en memoria NAND presionar 1.
El sistema bootea desde CF, entonces presionar 2.
RouterBOOT-1.5
What do you want to configure?
d - boot delay
k - boot key
s - serial console
o - boot device
u - cpu mode
f - try cpu frequency
c - keep cpu frequency
r - reset configuration
g - upgrade firmware
i - board info
p - boot protocol
t - do memory testing
x - exit setup
your choice: p - boot protocol
Seleccionar aqu DHCP
Choose which boot protocol to use:
1 - bootp protocol
* 2 - dhcp protocol
your choice: 2 - dhcp protocol
Presionar x para guardar los cambios y reiniciar el equipo.
RouterBOOT-1.5
What do you want to configure?
d - boot delay
k - boot key
s - serial console
o - boot device
u - cpu mode
f - try cpu frequency
c - keep cpu frequency
r - reset configuration
g - upgrade firmware
i - board info
p - boot protocol
t - do memory testing
x - exit setup
your choice: x - exit setup
writing settings to flash... OK
RouterBOOT booter 1.5
RouterBoard 411
CPU frequency: 300 MHz
Memory size: 32 MB
Press any key within 1 seconds to enter setup.
writing settings to flash... OK
trying dhcp protocol... OK
resolved mac address 00:1B:FC:41:BE:43
Gateway: 10.0.0.1
*transfer started ................................ transfer ok, time=1.8s
setting up elf image... OK
jumping to kernel code
[ ... mucha salida propia del kernel ... ]
init started: BusyBox v1.4.2 (2008-01-15 11:43:12 CET) multi-call binary
Please press Enter to activate this console. PPP generic driver version 2.4.2
Presionar Enter y tendremos una consola de OpenWRT en Mikrotik.
BusyBox v1.4.2 (2008-01-15 11:43:12 CET) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
_______ ________ __
| |.-----.-----.-----.| | | |.----.| |_
| - || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
KAMIKAZE (7.09) -----------------------------------
* 10 oz Vodka Shake well with ice and strain
* 10 oz Triple sec mixture into 10 shot glasses.
* 10 oz lime juice Salute!
---------------------------------------------------
root@OpenWrt:/#
Obtener archivo de passwords
Montar la particin NAND en modo slo lectura para obtener el archivo de passwords.
Antes verificar las particiones:
cat /proc/mtd
0x00000000-0x00040000 : "booter" # Para RB411
0x00040000-0x00400000 : "kernel"
0x00400000-0x04000000 : "rootfs"
dev: size erasesize name # Para RB532
mtd0: 00400000 00020000 "RouterBoard NAND Boot"
mtd1: 07c00000 00020000 "RouterBoard NAND Main"
En el caso de la RB411 hay que montar el dispositivo /dev/mtdblock2 y en el de l
a RB532 el /dev/mtdblock1.
mount -t yaffs2 -o ro /dev/mtdblock2 /mnt
Ahora hay que enviar el archivo a la computadora. El mismo debera ubicarse en /mn
t/nova/store/user.dat o en /mnt/rw/store/user.dat. Para hacerlo:
Correr netcat en la PC:
/bin/netcat -l -p 7878 > user.dat
Enviar el archivo desde el Mikrotik:
cat /mnt/nova/store/user.dat|nc 10.0.0.1 7878
Ahora ya es posible desconectar y apagar el Mikrotik.
Desencripcin de passwords
Descomprimir y compilar la herramienta mtpass. Notar que en Debian/Ubuntu es nec
esario tener instalado build-essential y libssl-dev . Luego ejecutar el binario pasndo
le como parmetro el archivo de claves.
./mtpass user.dat
mtpass v0.3 - MikroTik RouterOS password recovery tool, (c) 2008 by manio
Reading file user.dat, 166 bytes long
Rec# | Username | Password | Disable flag | User comment
--------------------------------------------------------------------------------
------------
1 | admin | secretpass | | system default us
er

También podría gustarte