-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathchrooty
More file actions
34 lines (28 loc) · 705 Bytes
/
chrooty
File metadata and controls
34 lines (28 loc) · 705 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
clear
rootdir=$(echo $PWD | sed 's/.*\///g')
if [ "$(whoami)" == "root" ]; then
# mount --bind ../$rootdir ../$rootdir
mount --bind /proc proc
mount --bind /dev dev
mount --bind /sys sys
mount --bind /tmp tmp
chroot ../$rootdir /bin/sh
umount tmp
umount proc
umount dev
umount sys
# umount ../$rootdir
else
# sudo mount --bind ../$rootdir ../$rootdir
sudo mount --bind /proc proc
sudo mount --bind /dev dev
sudo mount --bind /sys sys
sudo mount --bind /tmp tmp
sudo chroot ../$rootdir /bin/sh
sudo umount tmp
sudo umount proc
sudo umount dev
sudo umount sys
# sudo umount ../$rootdir
fi