Advertisement
metalx1000

Create Chroot with Busybox nmap arp-scan

Jul 17th, 2015
984
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.52 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. start=$PWD
  4. fs=${start}/fs
  5. ARCH="x86_64"
  6. ARCH2="x86"
  7.  
  8. mkdir $fs
  9. cd $fs
  10. mkdir -pv bin lib dev etc mnt/root proc root sbin sys usr/bin lib/x86_64-linux-gnu
  11. mknod -m 666 dev/null c 1 3
  12. mknod -m 666 dev/tty c 5 0
  13. mknod -m 666 dev/zero c 1 5
  14. mknod -m 666 dev/random c 1 8
  15.  
  16. echo "nameserver 8.8.8.8" > etc/resolv.conf
  17. echo "search 8.8.8.8" >> etc/resolv.conf
  18.  
  19. cd bin
  20. wget -c "http://www.busybox.net/downloads/binaries/latest/busybox-$ARCH" -O busybox
  21. chmod +x busybox
  22.  
  23. ./busybox  --help | \
  24. sed -e '1,/^Currently defined functions:/d' \
  25.     -e 's/[ \t]//g' -e 's/,$//' -e 's/,/\n/g' | \
  26. while read app ; do
  27.   if [ "$app" != "" ]; then
  28.     echo "linking ${app}..."
  29.     ln -sf "./busybox" "$app"
  30.     ls -ld "$app"
  31.   fi
  32. done
  33.  
  34. cd $fs
  35.  
  36. progDir="/usr/bin/"
  37. progs=("nmap" "arp-scan")
  38.  
  39. for i in "${progs[@]}"
  40. do
  41.   ldd ${progDir}$i |cut -d\> -f2|awk '{print $1}'|\
  42.     while read lib
  43.     do
  44.       cp ${progDir}$i usr/bin/
  45.       lib2="$(echo "$lib"|sed s'/\///')"
  46.       lib2="$(dirname "$lib2")"
  47.       mkdir -pv $lib2
  48.       cp -v "$lib" "$lib2"
  49.     done
  50. done
  51.  
  52. #extra files for nmap
  53. mkdir usr/share/nmap
  54. cp -v /etc/services etc/
  55. cp -v /usr/share/nmap/nmap-services usr/share/nmap/
  56.  
  57. #extra file for arp-scan
  58. mkdir -p usr/share/arp-scan/
  59. cp -v /usr/share/arp-scan/* usr/share/arp-scan/
  60.  
  61. clear
  62. echo "useage:"
  63. echo "nmap --unprivileged -T4 -v 192.168.1.1-255|grep -v 'host down'"
  64. echo "arp-scan -l -I eth0"
  65. echo "===================================="
  66. echo "WELCOME TO YOUR CHROOT"
  67. chroot $fs sh
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement