PDA

View Full Version : Bash scripting for the lazy



R1g1L
2015-03-29, 19:44
Hey Guys im new to the kali forum, and though id ask you guys for some ideas. Im working on a bash script that will automatically change settings , Backgrounds, update and install various programs. i was hoping a more expierenced kali user could help me get ideas for things to add or problems they see that neeed to be fixed. Thanks for feedback

#!/bin/bash
#oh f**k gotta start from scratch
# remember chmod +x aintthatabitch.sh

#Mr. Red
RED=$(tput setaf 1 && tput bold)
#Mr.BLUE
BLUE=$(tput setaf 6 && tput bold)
GREEN=$(tput setaf 2 && tput bold)
hwclock --systohc
echo -e $BLUE" GoTtA StArT FrOm ScRaTcH"
sleep 2
echo $RED"!"$GREEN"+++++"$RED"***"$GREEN"++"$RED"***"$GREEN"+++++++"$RED"****"$GREEN"+++++++"$RED"!"
echo $RED"!"$GREEN"+++++"$RED"***"$GREEN"++"$RED"***"$GREEN"++++++"$RED"******"$GREEN"++++++"$RED"!"
echo $RED"!"$GREEN"+++++"$RED"***"$GREEN"++"$RED"***"$GREEN"+++++"$RED"********"$GREEN"+++++"$RED"!"
echo $RED"!"$GREEN"+++++"$RED"********"$GREEN"++++"$RED"***"$GREEN"+++"$RED"****"$GREEN"++++"$RED"!"
echo $RED"!"$GREEN"+++++"$RED"********"$GREEN"++++"$RED"****"$GREEN"+"$RED"*****"$GREEN"++++"$RED"!"
echo $RED"!"$GREEN"+++++"$RED"***"$GREEN"++"$RED"***"$GREEN"+++"$RED"************"$GREEN"+++"$RED"!"
echo $RED"!"$GREEN"+++++"$RED"***"$GREEN"++"$RED"***"$GREEN"+++"$RED"****"$GREEN"++++"$RED"****"$GREEN"+++"$RED"!"
echo $BLUE"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
sleep 2
clear
sleep 1
echo
echo
echo -e
echo -e $BLUE" ThAtS A SaD StOrY...."
echo -e $BLUE" press enter to continue "
read

echo
echo
echo
echo
echo -e $BLUE " FoR ThIs YoUr GoNnA NeEd "$RED"POWER!!!"
sleep 2
cp /media/$usbname/Rboot/linux-wifi-connect-bash-script.sh /Desktop/
chmod +x /Desktop/linux-wifi-connect-bash-script.sh
./linux-wifi-connect-bash-script.sh
rm Desktop/list.temp
clear
echo -e $RED " FiRsT LeTs GeT ThOsE SoUrCeS FiXeD"
sleep 5
rm /etc/apt/sources.list
cp /media/"Kali Live"/Rboot/sources.list /etc/apt/
echo -e $RED " ChAnGiNg BaCkGrOuNdS"
sleep 5
mv /usr/share/images/desktop-base/login-background.png /usr/share/images/desktop-base/login-background-orig.png
cp $loginbackground /usr/share/images/desktop-base/
mv /usr/share/images/desktop-base/desktop-grub.png /usr/share/images/desktop-base/desktop-grub.orig.png
cp $Background /usr/share/images/desktop-base/
mv /usr/share/images/desktop-base/kali-grub.png /usr/share/images/desktop-base/kali-grub.org.png
cp $bootsplash /usr/share/images/desktop-base/
GRUB_BACKGROUND="/usr/share/images/desktop-base/login-background.png"
update-grub
echo -e $BLUE " FeW...ThAt LoOkS A LiTtLe BeTtEr"
sleep 2
echo -e $RED " UpDaTiNg!"
while true;do echo -n .;sleep 5;done &
apt-get -qq update && apt-get -qq -y upgrade && apt-get -qq -y dist-upgrade
kill $!; trap 'kill $!' SIGTERM
echo -e $RED " ClEaNiNg Up A BiT"
apt-get -q -y autoclean && apt-get -q -y clean
echo -e $RED" InStaLlInG "$BLUE"ViRtUaLbOx"
sleep 2
apt-get -q -y install virtualbox
echo -e $RED " CaNt FoRgEt AbOuT" $BLUE" HtTrAcK!"
sleep 2
apt-get -y -q install httrack
echo -e $RED "ThOsE **** ViRtUaL PrIvAtE NeTwOrKs!!"
aptitude -q -r -y install network-manager-openvpn-gnome network-manager-pptp network-manager-pptp-gnome network-manager-strongswan network-manager-vpnc network-manager-vpnc-gnome
aptitude -q -y install git-core monodevelop
echo -e $RED "GoTtA FiX ThAt PrOxY ChAiNs"
sleep 2
ln -s /usr/lib/proxychains3/proxyresolv /usr/bin/
shee echo -e $RED" InStAlLiNg "$BLUE"DeLuGe"
apt-get -q -y install deluge
echo -e $RED "InStAlLiNg "$BLUE"BaNsHeE"
sleep 2
apt-get -q -y install banshee
echo -e $RED" InStAlLiNg "$BLUE"BlEaChBiT"
apt-get -q -y install bleachbit
echo -e $RED" InStAlIng "$BLUE"ScRiPtS"
sleep 2
cp /media/"Kali Live"/scripts/updater.sh /usr/bin/
chmod +x /usr/bin/updater.sh
echo $RED" UpDaTeR InStAlLeD"
cp /media/"Kali Live"/scripts/Backitup_illtakeit.sh /usr/bin/
chmod +x /usr/bin/Backitup_illtakeit.sh
echo -e $BLUE "BaCkItUp_IlLtAkEiT InStAlLeD"
sleep 3
#
#
#JUST SPARE SPACE TO REMEMBER WHERE TO PUT MORE SCRIPTS
#
#AND A QUICK MENU WETHER TO REBOOT OR JUST EXIT
echo -e $RED "BrOwSeR TiMe"
sleep 5
cp /media/"Kali Live"/Rboot/.mozilla /home/
echo -e $BLUE "AnD MuSiC "
sleep 5
cp /media/"Kali Live"/Music /home/
echo -e $RED "PuTtInG Vm'S BaCk"
sleep 5
cp /media/"Kali Live"/"Virtual Machines" /home/
echo -e $RED" InStAlIng "$BLUE"ScRiPtS"
sleep 2
echo -e $RED" CrEaTiNg YoU"
sleep 5
echo -e $BLUE "Ok We'Ve MaDe It baCk FrOm ThE BrInK"
clear
echo -e v$BLUE "YoU NeEd To ReBoOt !?i?!?i?!?i?!?i?!"
echo
echo $RED"1."$BLUE" ReBoOt"
echo $RED"2."$BLUE"Dont TeLl Me WhAT To Do!"
read menuoption
if [$menuoption = "1"]
shutdown now
if [$menuoption = "2"]
exit

g0tmi1k
2015-03-30, 07:16
If your looking for more ideas/features, you can find my personal copy at the following address: https://github.com/g0tmi1k/os-scripts/blob/master/kali.sh

soluck9x
2015-04-04, 00:28
Hey R1g1L , Good idea ,keep it up :)

R1g1L
2015-04-10, 05:33
Ok Guys i Finished this script to fit my needs, and have decided to move on to a new script project,
[code]
#!/bin/bash/
#

#My idea for this script was to make a super customizable
#script to automaticaly update a fresh kali install of
#you are free to do as you wish with this script just please leave the comments intact,
#so others customize there own version!!!
############################################
## Writen by R1g1L ##
## Contact R1g1L@inbox.com ##
############################################
#choice program selection just change the name of the program you wish to install my choices are defaults
A=bleachbit
B=virtualbox
C=conky
D=gnome-tweak-tool
E=banshee
F=deluge
G=figlet
figlettext= R . 1 . g . 1 . L .
#these are the names of the folders/files on your usb you want moved to /home/
DIR1=music
DIR2=tutorials
DIR3=virtualmachines
DIR4=pentest
DIR5=.mozilla
DIR6=.scripts
DIR7=.conkyrc
#this next variable is the name of your usb backup device mine was named "Kali Live"
#yours will probably be somethings like usb0 or usb1 something like that
usb="Kali Live"

#remember if you dont want to use my settings changes you can always comment them out
#script start



echo "================================================== =";
echo "=== === ==== == == ==== = = =";
echo "== == == ==== = ==== = ==== == ===== ====";
echo "= ==== = ==== = ==== = ==== == ===== ====";
echo "= ==== = ==== == ====== ==== == ===== ====";
echo "= ==== = ==== ==== == ===== ====";
echo "= ==== = ==== ====== == ==== == ===== ====";
echo "= ==== = ==== = ==== = ==== == ===== ====";
echo "== == == ==== = ==== = ==== == ===== ====";
echo "=== === ==== == == ==== = ==== ====";
echo "================================================== =";

sleep 3
clear
echo " gotta start from scratch?"
sleep 2
echo " Thats a sad story..."
sleep 2
echo " Shall we continue? "
read
clear
echo " fixing sources.list"
rm /etc/apt/sources.list
cp /media/$usb/Rboot/sources.list /etc/apt/
echo done
clear
echo" changing desktop backgrounds"
rm /usr/share/images/desktop-base/login-background.png
rm /usr/share/images/desktop-base/desktop-grub.png
rm /usr/share/images/desktop-base/kali-grub.png
cp /media/$usb/login-background.png /usr/share/images/desktop-base/
cp /media/$usb/desktop-grub.png /usr/share/images/desktop-base/
cp /media/$usb/kali-grub.png /usr/share/images/desktop-base/
echo done
#time to change some common settings
echo unique hostname everyboot?..of_course
grep -q "hostname" /etc/rc.local hostname || sed -i 's#^exit 0#hostname $(cat /dev/urandom | tr -dc "A-Za-z" | head -c8)\nexit 0#' /etc/rc.local
echo " enabling real_transparency
gsettings set org.gnome.metacity compositing-manager true
echo" done"
echo " Hiding computer icon"
dconf write /org/gnome/nautilus/desktop/computer-icon-visible false
echo done
echo" showing hidden files "
dconf write /org/gnome/nautilus/preferences/show-hidden-files true
echo " panal auto-hide "
dconf write /org/gnome/gnome-panel/layout/toplevels/top-panel/auto-hide true
echo " Fixing proxychains link "
ln -s /usr/lib/proxychains3/proxyresolv /usr/bin/

clear
echo performing upgrade/update process
apt-get -y update && apt-get -y upgrade && apt-get -y dist-upgrade
echo done
sleep 2
clear
echo" fixing that header problem you probably dont understand"
apt-get install build-essential linux-headers-$(uname -r)
echo done
clear
echo installing Choice tool
sleep 2
clear
echo" installing $A "
apt-get -y install $A
echo done
clear
echo" installing $B "
apt-get -y install $B
echo done
echo" installing $C "
apt-get -y install $C
echo done
echo" installing $D "
apt-get -y install $D
echo done
echo" installing $E "
apt-get -y install $E
echo done
echo" installing $F "
apt-get -y install $F
echo" installing $E "
apt-get -y -q $E
echo " $figlettext ">> .bashrc
echo " Installing VPN'S"
aptitude -q -r -y install network-manager-openvpn-gnome network-manager-pptp network-manager-pptp-gnome network-manager-strongswan network-manager-vpnc network-manager-vpnc-gnome
clear
echo done
clear
echo" moving home backup file's"
cp /media/$usb/$dir1 /home/
cp /media/$usb/$dir2 /home/
cp /media/$usb/$dir3 /home/
cp /media/$usb/$dir4 /home/
cp /media/$usb/$dir5 /home/
cp /media/$usb/$dir6 /home/
Echo " Few Thats a Little better "
clear
echo -e $BLUE "Ok We'Ve MaDe It baCk FrOm ThE BrInK"
clear
echo -e v$BLUE "YoU NeEd To ReBoOt !?i?!?i?!?i?!?i?!"
echo
echo $RED"1."$BLUE" ReBoOt"
echo $RED"2."$BLUE"Dont TeLl Me WhAT To Do!"
read menuoption
if [$menuoption = "1"]
shutdown now
if [$menuoption = "2"]
exit
[code]


I Hope some other members will help me add to this script in the future and maybe we could make a perfect post install script
for all kali users to update there fresh installs to there needs, but that task is to daunthing for me to take on by myself. If any of you would be willing to help with this challange pm or email me and ill get back at it. I know with a little help we could make a truely great and useful script for all users to enjoy.
as always i appreciate any input or advice at all
R1g1L

crypts3c
2015-12-08, 23:06
Cool.. I like that... Will use it as a template!

mmusket33
2015-12-12, 03:32
Keep innovating we like your work

MTeams

liverpoolkak1234
2016-02-18, 01:28
thank you sir :)