Automated driver installation (v2.0)
12-30-2021
My theory from the previous post put into action. The system didn't like simply echoing into the file, but the tee command worked just fine! What's better is this program does away with the verbose file paths that were in the previous "first script". This project was very illuminating. From a cybersecurity standpoint, I was able to create software that could inject a payload into the system files and set it to automatically execute without any user interaction apart from the prompt to switch to superuser. This could be bypassed by editing the "/etc/sudoers" file, but personally I know the security consequences of that are dire. That said, If I were the one trying to compromise a system I suppose it might be in my best interest as it would allow me the unhindered ability to execute any command.
#!/bin/bash
echo "*******************MOVING SETUP FILE*******************"
#file to inject
fileContents="#!/bin/bash
echo '*******************INSTALLING GIT*******************'
sudo apt-get install git
echo '*******************INSTALLING DKMS*******************'
sudo apt-get install dkms
echo '*******************CLONING REALTEK DRIVER*******************'
cd ~/Documents
git clone https://github.com/aircrack-ng/rtl8812au
cd rtl8812au/
echo '*******************DRIVER INSTALL*******************'
make
sudo make install
echo '*******************DIAGNOSTIC*******************'
lsusb
iwconfig"
#create the file and inject it into the appropriate location
echo "$fileContents" | sudo tee custom-drivers.sh >/dev/null
sudo mv custom-drivers.sh /usr/local/bin/custom-drivers.sh
#set permissions
sudo chmod 755 /usr/local/bin/custom-drivers.sh
#confirm
#ls -l /usr/local/bin | grep 'custom-drivers'
#cat /usr/local/bin/custom-drivers.sh
echo "*******************SETTING CRONTAB*******************"
(crontab -l 2>/dev/null; echo -e "@reboot /usr/local/bin/custom-drivers.sh") | sudo crontab -u kali -
crontab -l | grep 'custom-drivers.sh'
echo "*******************APT UPDATE*******************"
sudo apt update
echo "*******************UPDATING KALI*******************"
sudo apt upgrade -y
sudo apt dist-upgrde -y
sudo reboot now