From 4f79a59b64779077efbb1fd0a1b9dc51bdd2c2b4 Mon Sep 17 00:00:00 2001 From: itdominator <1itdominator@gmail.com> Date: Mon, 24 Oct 2022 20:06:19 -0500 Subject: [PATCH] added notes and nase dir chroot reference script --- ... Linux File System with NMAP for Chroot.sh | 59 +++++++++++++++++++ src/NOTES/Notes.txt | 2 + 2 files changed, 61 insertions(+) create mode 100644 src/NOTES/Create Minimal Linux File System with NMAP for Chroot.sh create mode 100644 src/NOTES/Notes.txt diff --git a/src/NOTES/Create Minimal Linux File System with NMAP for Chroot.sh b/src/NOTES/Create Minimal Linux File System with NMAP for Chroot.sh new file mode 100644 index 0000000..b388f2f --- /dev/null +++ b/src/NOTES/Create Minimal Linux File System with NMAP for Chroot.sh @@ -0,0 +1,59 @@ +#!/bin/bash +#more info here http://www.cyberciti.biz/faq/debian-ubuntu-restricting-ssh-user-session-to-a-directory-chrooted-jail/ + +fs="$PWD/jail" +echo "Creating ${fs}..." +mkdir -p ${fs}/{etc,usr/{bin,lib},bin,lib}/ + +mkdir -p $fs/dev/ +mknod -m 666 $fs/dev/null c 1 3 +mknod -m 666 $fs/dev/tty c 5 0 +mknod -m 666 $fs/dev/zero c 1 5 +mknod -m 666 $fs/dev/random c 1 8 + +cp -v /lib/ld-linux.so.2 $fs/lib/ + +chown root:root $fs +chmod 0755 $fs + +wget "http://www.busybox.net/downloads/binaries/latest/busybox-i686" -O ${fs}/bin/busybox +chmod +x ${fs}/bin/busybox + +cd ${fs}/bin +./busybox --help | \ +sed -e '1,/^Currently defined functions:/d' \ + -e 's/[ \t]//g' -e 's/,$//' -e 's/,/\n/g' | \ +while read app ; do + if [ "$app" != "" ]; then + printf "linking %-12s ...\n" "$app" + ln -sf "./busybox" "$app" + ls -ld "$app" + fi +done + +echo "nameserver 8.8.8.8" > $fs/etc/resolv.conf +echo "search 8.8.8.8" >> $fs/etc/resolv.conf + +#add nmap +cp -v /usr/bin/nmap $fs/usr/bin/nmap_real +#create unprivileged nmap script +cat << EOF > $fs/usr/bin/nmap +#!/bin/sh +nmap_real --unprivileged \$* +EOF +chmod +x $fs/usr/bin/nmap + +mkdir -p $fs/{usr/share/nmap/,etc/services} +#cp -vr /usr/share/nmap $fs/usr/share/nmap/ +ldd /usr/bin/nmap|while read line; +do + echo "$line"|\ + awk '{print $3}' +done|grep lib|while read line; +do + cp -v "$line" $fs/usr/lib/; +done + +clear +echo "welcome to your chroot!" +chroot $fs sh \ No newline at end of file diff --git a/src/NOTES/Notes.txt b/src/NOTES/Notes.txt new file mode 100644 index 0000000..eab810d --- /dev/null +++ b/src/NOTES/Notes.txt @@ -0,0 +1,2 @@ +# Note: Very good breakdown of an LFS setup. His directory script is interesting too. Just a good source all around. +https://www.youtube.com/watch?v=IXA0GNTLf_Q&list=PLHh55M_Kq4OAPznDEcgnkQsbjgvG-QFBR