You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

runme.sh 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #!/bin/bash
  2. function pause(){
  3. read -p "$*"
  4. }
  5. #Root check!
  6. if [ "$EUID" -ne 0 ]
  7. then
  8. whiptail --backtitle "Pentest Build Script" --title "NOT ROOT" --msgbox "YOU ARE NOT ROOT. PLEASE RUN THIS SCRIPT AS ROOT." 10 55
  9. exit 1
  10. fi
  11. #Arguments
  12. DISTRO=$(lsb_release -i -s)
  13. while getopts ul:d:r: option
  14. do
  15. case "${option}" in
  16. u) UNATTEND="true" && echo "UNATTEND";;
  17. l) DISTRO=${OPTARG} && echo $DISTRO;;
  18. d) DESKTOP=${OPTARG} && echo $DESKTOP;;
  19. r) REPO=${OPTARG} && echo $REPO;;
  20. esac
  21. done
  22. if [[ $UNATTEND != "true" ]];
  23. then
  24. whiptail --backtitle "Pentest Build Script" --title "Welcome" --msgbox "This script will help you build a custom pentesting distribution." 7 70
  25. DESKTOP=$(whiptail --backtitle "Pentest Build Script" --title "Desktop Environment" --menu "Choose a desktop:" 15 50 6 \
  26. "gnome" "GNOME Desktop Environment" \
  27. "mate" "MATE Advanced Traditional Environment" \
  28. "cinnamon" "Cinnamon Desktop Environment" \
  29. "kde" "K Desktop Environment" \
  30. "xfce" "Xfce Desktop Environment" \
  31. "lxde" "Lightweight X11 Desktop Environment" 3>&1 1>&2 2>&3)
  32. REPO=$(whiptail --backtitle "Pentest Build Script" --title "Repository" --menu "Which repository are you going to use?" 10 60 2 \
  33. "default" "The distribution's default repository" \
  34. "local" "A repository hosted on your local network" 3>&1 1>&2 2>&3)
  35. if [ $REPO == "local" ];
  36. then
  37. REPO=$(whiptail --backtitle "Pentest Build Script" --title "Local Repository" --inputbox "What is the IP address of your local repository?" \
  38. 10 60 3>&1 1>&2 2>&3)
  39. fi
  40. if (whiptail --backtitle "Pentest Build Script" --title "Confirmation" --yesno "We're going to build:
  41. Distribution: $DISTRO
  42. Desktop Environment: $DESKTOP
  43. Repository: $REPO
  44. Shall we proceed?" 10 50)
  45. then
  46. whiptail --backtitle "Pentest Build Script" --title "Build Time!" --msgbox "This will take a while. Press OK to proceed." 8 30
  47. else
  48. whiptail --backtitle "Pentest Build Script" --title "OK" --msgbox "This script will now terminate." 8 35
  49. exit 1
  50. fi
  51. fi
  52. #This is the stuff that's common to both distros
  53. rm -rf build
  54. mkdir build
  55. apt install git build-essential cdebootstrap live-build debian-cd curl wget -y
  56. cd ./debs
  57. bash get-debs.sh
  58. dpkg-name *.deb
  59. cd ..
  60. case $DISTRO in
  61. Kali)
  62. IMAGENAME=kali-rolling-$DESKTOP-$(date -I)-$(date +%H%M)
  63. cp -rv ./modules/live-build-config ./build/
  64. mkdir ./build/live-build-config/kali-config/variant-$DESKTOP/packages.chroot
  65. cp ./debs/*.deb build/live-build-config/kali-config/variant-$DESKTOP/packages.chroot/
  66. cp ./build/*.deb build/live-build-config/kali-config/variant-$DESKTOP/packages.chroot/
  67. cp -rv filesystem/* ./build/live-build-config/kali-config/common/includes.chroot/
  68. cp config/software.list.chroot ./build/live-build-config/kali-config/variant-$DESKTOP/package-lists/
  69. cp config/pentest-distro-builder.chroot ./build/live-build-config/kali-config/common/hooks/live/
  70. if [ $REPO != "default" ];
  71. then
  72. sed -i "s|archive.kali.org|$REPO|g" ./build/live-build-config/auto/config
  73. fi
  74. cd build/live-build-config
  75. ./build.sh --distribution kali-rolling --variant $DESKTOP --verbose | tee ../../logs/$IMAGENAME.log
  76. cp images/*.iso ../../images/$IMAGENAME.iso
  77. ;;
  78. Parrot)
  79. IMAGENAME=parrotsec-$DESKTOP-$(date -I)-$(date +%H%M)
  80. cp -rv ./modules/parrot-build ./build/
  81. mkdir ./build/parrot-build/templates/parrot-variant-$DESKTOP/packages.chroot
  82. cp ./debs/*.deb build/parrot-build/templates/parrot-variant-$DESKTOP/packages.chroot/
  83. cp ./build/*.deb build/parrot-build/templates/parrot-variant-$DESKTOP/packages.chroot/
  84. cp -rv filesystem/* ./build/parrot-build/templates/common/includes.chroot/
  85. cp config/software.list.chroot ./build/parrot-build/templates/parrot-variant-$DESKTOP/package-lists/
  86. cp config/pentest-distro-builder.chroot ./build/parrot-build/templates/common/hooks/normal/
  87. if [ $REPO != "default" ];
  88. then
  89. sed -i "s|archive.parrotsec.org|$REPO|g" ./build/parrot-build/auto/config
  90. sed -i "s|deb.parrotsec.org|$REPO|g" ./build/parrot-build/templates/common/archives/parrot.list
  91. fi
  92. cd build/parrot-build
  93. ./build.sh build variant-$DESKTOP amd64 | tee ../../logs/$IMAGENAME.log
  94. cp ../*.iso ../../images/$IMAGENAME.iso
  95. ;;
  96. esac
  97. if [[ $UNATTEND != "true" ]];
  98. then
  99. if [ -f ../../images/$IMAGENAME.iso ];
  100. then
  101. whiptail --backtitle "Pentest Build Script" --title "Finished" \
  102. --msgbox "Fingers crossed there were no errors... Your image should be done!" 7 70
  103. else
  104. whiptail --backtitle "Pentest Build Script" --title "OH NO" \
  105. --msgbox "Something went wrong and no .iso file was created... Check the log file for details! :-(" 7 92
  106. fi
  107. fi
  108. exit 0