All pastes #395274 Raw Edit

Anonymous

public shellscript v1 · immutable
·published 2007-03-14 22:19 UTC
rendered paste body
#!/bin/sht66y#Created by Budh & TheX1le#With a few code segments from Jabra and Muts#BackTrack 2 Installer#Alpha 3.0#######################################################################################                                         Configs                                    #######################################################################################BOOTP=SWAPP=#ROOTP=                 #not implimented yetSOURCE=ROOT=BOOT=PROG=`basename $0`#######################################################################################                           display proper usage                                     ########################################################################################stone from jabras script liked it so will edit and work into mineusage() {	echo " usage: $PROG [options]"	echo " "	echo "  -f   --file FILE        Config file to be used"	echo "  -h   --help             Show the help message"	echo "  -i   --interactive      Interactive mode"	echo "  -s   --scan             Scan for wireless networks"	echo "  -v   --version          Show the version"	echo " "	exit 0}#######################################################################################                                  Budh's Fdisk                                       #######################################################################################function 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 #######################################################################################function errcsk {if [ "$?" != "0" ]; then	echo $ERRMSG	exitelse	echo $SUCMSGfi}#######################################################################################                             User Input Section                                     #######################################################################################function usr_input {clearecho "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 partitionsecho "Your Source for BT files EX. /"read SOURCEecho "Your boot partition EX. hda1" read BOOTecho "Your root partition EX. hda3"read ROOTclear}#######################################################################################                            Input Validation Chk                                    #######################################################################################function input_val {if [ -z "$SOURCE" ]; then	echo "Please set a source"	exitelse	if [ -z "$BOOT" ]; then		echo "Please set a boot Destination"		exit	else		if [ -z "$ROOT" ]; then			echo "Please set a root Destination"			exit		fi	fifi}#######################################################################################                    Mounts Partitons and checks that they exist"                    #######################################################################################function 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 folders                    #######################################################################################function cp_root {mkdir -p /tmp/backtrack/bootcp --preserve -R -v $SOURCE/{bin,dev,home,pentest,root,usr,etc,lib,opt,sbin,var} /tmp/backtrackERRMSG=$(echo -e "\033[31m Files did not copy correctly there were some errors")SUCMSG=$(echo "Backtrack files copied sucessfully")errcskmkdir /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")errcskcp "$SOURCE"/boot/vmlinuz /tmp/backtrack/bootERRMSG=$(echo -e "\033[31m Kernel did not copy correctly there was an error")SUCMSG=$(echo "Kernel copied sucessfully")errcskread -p "Backtrack copied to hard drive successfully press the ANY KEY to continue"clearecho "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                                 #######################################################################################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