#!/bin/sh #Created by Budh & TheX1le #With a few code segments from Jabra and Muts #BackTrack 2 Installer ########################################################### # Values # ########################################################### VERSION=0.0.3 BOOTP= SWAPP= #ROOTP= #not implimented yet SOURCE= ROOT= BOOT= INPUT=$* PROG=`basename $0` ########################################################### # Displays version # ########################################################### pversion() { echo "version $VERSION" read exit } ########################################################### # display proper usage # ########################################################### usage() { clear echo " usage: $PROG [options]" echo " " echo " -f --format Format Disk" #echo " -h --help Show the help message" echo " -i --interactive Interactive step by step install mode" echo " -s --source Install Source" echo " -b --boot Boot Directory Destination" echo " -r --root Root Directory Destination" echo " -v --version Show the version" echo " " exit 0 } ########################################################### #hanels comandline arugments # ########################################################### script_arg() { case "$SCRIPT_ARG" in -f|--format) buhd_fdisk ;; -i|--interactive) usr_input ;; -s|--source) echo "null" ;; -b|--boot) echo "null" ;; -r|--root) echo "null" ;; -v|--version) pversion ;; *) ;; esac } ########################################################### # Budh's Fdisk # ########################################################### budh_fdisk() { #Simple shell script that creates the partition for Backtrack HD Install using Parallels #Author: Budh, budh -at- nagologic -dot- com echo "Welcome, this will set up your hard drives to install Backtrack2" echo "First we need to know what sizes you want your partitions to be" echo -n "Boot Partition size in MB ie 1GB = 1024MB (default 50): "; read BOOTP echo -n "Swap Partition size in MB ie 1GB = 1024MB (default 512)"; read SWAPP #echo -n "ROOT Partition size in MB ie 1GB = 1024MB"; read ROOTP #Warns the user that formatting procedure is taking place. clear echo "WARNING!!" echo "This procedure will wipe the content of the current hard drive." echo -n "Are you sure you want to continue. (y/n): "; read sAnswer if [ $sAnswer = "n" ] ; then echo "Leaving..." exit 0 fi echo "Creating the partitions..." ERRMSG=$(echo -e "\033[31m Partition creation failed on") SUCMSG=$(echo "Partition creation was successfull") fdisk /dev/hda <<< $'n\np\n1\n\n+'"$BOOTP"$'M\nn\np\n2\n\n+'"$SWAPP"$'M\n\nn\np\n3\n\n\n\na\n1\nt\n2\n82\nw\nq\n' >/dev/null errcsk fdisk /dev/hda <<< $'p\nq\n' echo "Formating the drives..." ERRMSG=$(echo -e "\033[31m mkfs.ext3 failed") SUCMSG=$() mkfs.ext3 /dev/hda1 >/dev/null errcsk ERRMSG=$(echo -e "\033[31m mkfs.ext3 failed") SUCMSG=$() mkfs.ext3 /dev/hda3 >/dev/null errcsk mkswap /dev/hda2 swapon /dev/hda2 echo "Mounting partition..." mkdir /tmp/boot mkdir /tmp/BT2f mount /dev/hda1 /tmp/boot mount /dev/hda3 /tmp/BT2f echo "Script is completed..." exit 0 } ########################################################### # Error checking Function, based on ouput codes ie # # 0=success any thing is is failure # ########################################################### errcsk() { if [ "$?" -na 0 ]; then echo $ERRMSG exit else echo $SUCMSG fi } ########################################################### # Input Section # ########################################################### usr_input() { clear echo "This simple script is just for installing bt2, it assumes you have created and formatted your partitions all ready. Version BETA 2" #Handles input of boot and root partitions echo "Your Source for BT files EX. /" read SOURCE echo "Your boot partition EX. hda1" read BOOT echo "Your root partition EX. hda3" read ROOT clear } ########################################################### # Input Validation Chk # ########################################################### input_val() { if [ -z "$SOURCE" ]; then echo "Please set a source" exit else if [ -z "$BOOT" ]; then echo "Please set a boot Destination" exit else if [ -z "$ROOT" ]; then echo "Please set a root Destination" exit fi fi fi } ########################################################### # Mounts Partitons and checks that they exist" # ########################################################### mount_an_chk() { if [ "$BOOT" == "$ROOT" ]; then echo -e "This is not the best recomended install method. Continue? [y/n]" read YES if [ "y" != "$YES" ]; then exit fi echo "Mounting Drive" ERRMSG=$(echo -e "\033[31m Mounting failed check your partitions") SUCMSG=$(echo "Drive mounted sucessfully") mount /dev/$ROOT /tmp/backtrack errcsk else echo "Mounting Drives" mount /dev/$BOOT /tmp/backtrack/boot mount /dev/$ROOT /tmp/backtrack ERRMSG=$(echo -e "\033[31m Mounting failed check your partitions") SUCMSG=$(echo "Drives mounted sucessfully") mount /dev/$ROOT /tmp/backtrack errcsk fi } ########################################################### # Creats new install / with files and folder # ########################################################### cp_root() { mkdir -p /tmp/backtrack/boot cp --preserve -R -v $SOURCE/{bin,dev,home,pentest,root,usr,etc,lib,opt,sbin,var} /tmp/backtrack ERRMSG=$(echo -e "\033[31m Files did not copy correctly there were some errors") SUCMSG=$(echo "Backtrack files copied sucessfully") errcsk mkdir /tmp/backtrack/{mnt,proc,sys,tmp} ERRMSG=$(echo -e "\033[31m mnt,proc,sys,tmp failed to be made there was an error") SUCMSG=$(echo "mnt,proc,sys,tmp created sucessfully") errcsk cp "$SOURCE"/boot/vmlinuz /tmp/backtrack/boot ERRMSG=$(echo -e "\033[31m Kernel did not copy correctly there was an error") SUCMSG=$(echo "Kernel copied sucessfully") errcsk read -p "Backtrack copied to hard drive successfully press the ANY KEY to continue" clear echo "mounting dev and proc" mount --bind /dev/ /tmp/backtrack/dev/ mount -t proc proc /tmp/backtrack/proc/ ERRMSG=$(echo -e "\033[31m dev or proc failed to mount there was an error") SUCMSG=$(echo "dev and proc mounted sucessfully") errcsk } ########################################################### # Chroot Function # ########################################################### chrooted() { echo "your next step is to chroot into your new install IE [chroot /tmp/backtrack/ /bin/bash], then edit /etc/lilo.conf and run lilo -v . Thats it your installed" } ########################################################### ##### ############## Main ############### ##### ########################################################### usage #usr_input #input_val #mount_an_chk #cp_root #chrooted