Skip to content

Instantly share code, notes, and snippets.

@ab
Created August 30, 2012 00:45
Show Gist options
  • Save ab/3521125 to your computer and use it in GitHub Desktop.
Save ab/3521125 to your computer and use it in GitHub Desktop.
Changing user passwords inside a disk image
$ sudo kpartx -v -a stripe-ctf-server-ubuntu-10.04-lucid-amd64-20120427-0108.img
add map loop0p1 (253:7): 0 8386560 linear /dev/loop0 2048
$ mkdir /tmp/mnt
$ sudo mount /dev/mapper/loop0p1 /tmp/mnt
$ sudo chroot /tmp/mnt
# getent passwd
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
bin:x:2:2:bin:/bin:/bin/sh
sys:x:3:3:sys:/dev:/bin/sh
sync:x:4:65534:sync:/bin:/bin/sync
games:x:5:60:games:/usr/games:/bin/sh
man:x:6:12:man:/var/cache/man:/bin/sh
lp:x:7:7:lp:/var/spool/lpd:/bin/sh
mail:x:8:8:mail:/var/mail:/bin/sh
news:x:9:9:news:/var/spool/news:/bin/sh
uucp:x:10:10:uucp:/var/spool/uucp:/bin/sh
proxy:x:13:13:proxy:/bin:/bin/sh
www-data:x:33:33:www-data:/var/www:/bin/sh
backup:x:34:34:backup:/var/backups:/bin/sh
list:x:38:38:Mailing List Manager:/var/list:/bin/sh
irc:x:39:39:ircd:/var/run/ircd:/bin/sh
gnats:x:41:41:Gnats Bug-Reporting System (admin):/var/lib/gnats:/bin/sh
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
libuuid:x:100:101::/var/lib/libuuid:/bin/sh
syslog:x:101:103::/home/syslog:/bin/false
messagebus:x:102:107::/var/run/dbus:/bin/false
sshd:x:104:65534::/var/run/sshd:/usr/sbin/nologin
postfix:x:106:113::/var/spool/postfix:/bin/false
ctf:x:500:500:Charles Theodore Frog,,,:/home/ctf:/bin/bash
level01:x:1000:1000:level01,,,:/home/level01:/bin/bash
level02:x:1001:1001:level02,,,:/home/level02:/bin/bash
level03:x:1002:1002:level03,,,:/home/level03:/bin/bash
level04:x:1003:1003:level04,,,:/home/level04:/bin/bash
level05:x:1004:1004:level05,,,:/home/level05:/bin/bash
level06:x:1005:1005:level06,,,:/home/level06:/bin/bash
the-flag:x:1006:1006:the-flag,,,:/home/the-flag:/bin/bash
# passwd ctf
...
# exit
$ sudo umount /tmp/mnt/
$ sudo kpartx -v -d stripe-ctf-server-ubuntu-10.04-lucid-amd64-20120427-0108.img
del devmap : loop0p1
loop deleted : /dev/loop0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment