1
0
mirror of https://github.com/byReqz/blackmate.git synced 2024-11-23 11:44:56 +00:00

Minor bug fixed + clean of the script

Tested as this day on a fresh xface4 install, works as expected whatever the theme in use.

A small bug occur on my env, the icons of the categorie Audit and Windows won't display, thanks for any feedback about this script in your env
This commit is contained in:
Anyon3 2016-09-25 19:13:53 +08:00 committed by GitHub
parent 9551a8b660
commit bd594e4060

View File

@ -1,6 +1,6 @@
#!/bin/bash #!/bin/bash
# #
# Blackmate v0.4 # Blackmate v0.41
# #
# Description : BlackMate is a menu generator for the BlackArch Linux os tools, made for the wm xfce4. # Description : BlackMate is a menu generator for the BlackArch Linux os tools, made for the wm xfce4.
# It will fetch the latest database of BlackArch and create an entry for each of them in the menu. # It will fetch the latest database of BlackArch and create an entry for each of them in the menu.
@ -14,8 +14,8 @@
#Check if the script have the root permission #Check if the script have the root permission
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
echo "Blackmate must run with root permission (use sudo or the script will fail)" printf 'Blackmate must run with root permission (use sudo or the script will fail)';
exit 1 exit 1;
fi fi
printf "[*] Creating the new menu entry\n"; printf "[*] Creating the new menu entry\n";
@ -33,18 +33,24 @@ fi
#Generate the new categorie entry menu #Generate the new categorie entry menu
for u in $( ls --color=auto /usr/share/blackmate/menu-i/ | sort ); do for u in $( ls --color=auto /usr/share/blackmate/menu-i/ | sort ); do
c=`echo $u | sed 's/BlackArch-//' | sed 's/\.png//'`; c=`echo $u | sed 's/BlackArch-//' | sed 's/\.png//'`;
cat /usr/share/blackmate/dfdir | sed 's/^Name=.*/Name='$c'/' |
cat /usr/share/blackmate/dfdir | sed 's/^Name=.*/Name='$c'/' | sed 's/^Icon=.*/Icon=BlackArch-'$c'/' > /usr/share/desktop-directories/BlackArch-$c.directory
sed 's/^Icon=.*/Icon=BlackArch-'$c'/' > /usr/share/desktop-directories/BlackArch-$c.directory
done done
#Fetch the current icons theme in use
printf "[*] Update the icons theme in use\n"; printf "[*] Update the icons theme in use\n";
#Fetch the current icons theme in use if [[ -f /home/$SUDO_USER/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml ]]; then
thic=`cat /home/$SUDO_USER/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml | grep IconThemeName |
sed 's/<property name="IconThemeName" type="string" value\="//' | tr -d '"/>' | tr -d ' '`; thic=`cat /home/$SUDO_USER/.config/xfce4/xfconf/xfce-perchannel-xml/xsettings.xml | grep IconThemeName |
sed 's/<property name="IconThemeName" type="string" value\="//' | tr -d '"/>' | tr -d ' '`;
#If the file do not exist, we assume the current theme is the default one (gnome)
else
thic=`echo gnome`;
fi
#Copy the extra icons into the icons theme #Copy the extra icons into the icons theme
cp /usr/share/blackmate/menu-i/* /usr/share/icons/$thic/32x32/apps/ 2> /dev/null || true cp /usr/share/blackmate/menu-i/* /usr/share/icons/$thic/32x32/apps/ 2> /dev/null || true
@ -53,11 +59,11 @@ fi
chown $SUDO_USER:$SUDO_USER /usr/share/icons/$thic/32x32/apps/ -R 2> /dev/null || true chown $SUDO_USER:$SUDO_USER /usr/share/icons/$thic/32x32/apps/ -R 2> /dev/null || true
chmod 755 /usr/share/icons/$thic/32x32/apps/ -R 2> /dev/null || true chmod 755 /usr/share/icons/$thic/32x32/apps/ -R 2> /dev/null || true
printf "[*] Download the tools list\n";
#Download and generate the latest tools list #Download and generate the latest tools list
printf "[*] Download the tools list, please wait...\n";
mkdir /usr/share/blackmate/tmp mkdir /usr/share/blackmate/tmp
wget -P /usr/share/blackmate/ https://mirror.yandex.ru/mirrors/blackarch/blackarch/os/x86_64/blackarch.db.tar.gz wget -q -P /usr/share/blackmate/ https://mirror.yandex.ru/mirrors/blackarch/blackarch/os/x86_64/blackarch.db.tar.gz
tar -zxf /usr/share/blackmate/blackarch.db.tar.gz -C /usr/share/blackmate/tmp tar -zxf /usr/share/blackmate/blackarch.db.tar.gz -C /usr/share/blackmate/tmp
#Terminal to use for the blackarch entry #Terminal to use for the blackarch entry
@ -68,133 +74,133 @@ fi
#Start to loop each tools, set $subc as subcategorie and $tname as name of the tool #Start to loop each tools, set $subc as subcategorie and $tname as name of the tool
for u in $( ls --color=auto /usr/share/blackmate/tmp/ | sort ); do for u in $( ls --color=auto /usr/share/blackmate/tmp/ | sort ); do
#Subcategorie #Subcategorie
subc=`cat /usr/share/blackmate/tmp/$u/desc | sed 's/blackarch//' | subc=`cat /usr/share/blackmate/tmp/$u/desc | sed 's/blackarch//' |
sed '/^\s*$/d' | sed -n '/%GROUPS%/{n;p}' | sed 's/-//'`; sed '/^\s*$/d' | sed -n '/%GROUPS%/{n;p}' | sed 's/-//'`;
#Check the group of the current tool, if empty, go to the next iteration #Check the group of the current tool, if empty, go to the next iteration
if [[ -z "$subc" ]]; then if [[ -z "$subc" ]]; then
continue 1; continue 1;
fi fi
#Name of the tool #Name of the tool
tname=`cat /usr/share/blackmate/tmp/$u/desc | sed 's/blackarch//' | tname=`cat /usr/share/blackmate/tmp/$u/desc | sed 's/blackarch//' |
sed '/^\s*$/d' | sed -n '/%NAME%/{n;p}' | cut -d "-" -f 2`; sed '/^\s*$/d' | sed -n '/%NAME%/{n;p}' | cut -d "-" -f 2`;
#Set categorie of the subcategorie tool branche #Set categorie of the subcategorie tool branche
if [[ $subc == "code-audit" ]] || [[ $subc == 'decompiler' ]] || if [[ $subc == "code-audit" ]] || [[ $subc == 'decompiler' ]] ||
[[ $subc == 'disassembler' ]] || [[ $subc == 'reversing' ]]; then [[ $subc == 'disassembler' ]] || [[ $subc == 'reversing' ]]; then
namecat=`echo X-BlackArch-Audit;`; namecat=`echo X-BlackArch-Audit;`;
elif [[ $subc == 'automation' ]]; then elif [[ $subc == 'automation' ]]; then
namecat=`echo X-BlackArch-Automation;`; namecat=`echo X-BlackArch-Automation;`;
elif [[ $subc == 'backdoor' ]] || [[ $subc == 'keylogger' ]] || elif [[ $subc == 'backdoor' ]] || [[ $subc == 'keylogger' ]] ||
[[ $subc == 'malware' ]]; then [[ $subc == 'malware' ]]; then
namecat=`echo X-BlackArch-Backdoor;`; namecat=`echo X-BlackArch-Backdoor;`;
elif [[ $subc == 'binary' ]]; then elif [[ $subc == 'binary' ]]; then
namecat=`echo X-BlackArch-Binary;`; namecat=`echo X-BlackArch-Binary;`;
elif [[ $subc == 'bluetooth' ]]; then elif [[ $subc == 'bluetooth' ]]; then
namecat=`echo X-BlackArch-Bluetooth;`; namecat=`echo X-BlackArch-Bluetooth;`;
elif [[ $subc == 'cracker' ]]; then elif [[ $subc == 'cracker' ]]; then
namecat=`echo X-BlackArch-Cracker;`; namecat=`echo X-BlackArch-Cracker;`;
elif [[ $subc == 'crypto' ]]; then elif [[ $subc == 'crypto' ]]; then
namecat=`echo X-BlackArch-Crypto;`; namecat=`echo X-BlackArch-Crypto;`;
elif [[ $subc == 'defensive' ]]; then elif [[ $subc == 'defensive' ]]; then
namecat=`echo X-BlackArch-Defensive;`; namecat=`echo X-BlackArch-Defensive;`;
elif [[ $subc == 'dos' ]]; then elif [[ $subc == 'dos' ]]; then
namecat=`echo X-BlackArch-Dos;`; namecat=`echo X-BlackArch-Dos;`;
elif [[ $subc == 'exploitation' ]] || [[ $subc == 'social' ]] || elif [[ $subc == 'exploitation' ]] || [[ $subc == 'social' ]] ||
[[ $subc == 'spoof' ]] || [[ $subc == 'fuzzer' ]]; then [[ $subc == 'spoof' ]] || [[ $subc == 'fuzzer' ]]; then
namecat=`echo X-BlackArch-Exploitation;`; namecat=`echo X-BlackArch-Exploitation;`;
elif [[ $subc == 'forensic' ]] || [[ $subc == "anti-forensic" ]]; then elif [[ $subc == 'forensic' ]] || [[ $subc == "anti-forensic" ]]; then
namecat=`echo X-BlackArch-Forensic;`; namecat=`echo X-BlackArch-Forensic;`;
elif [[ $subc == 'honeypot' ]]; then elif [[ $subc == 'honeypot' ]]; then
namecat=`echo X-BlackArch-Honeypot;`; namecat=`echo X-BlackArch-Honeypot;`;
elif [[ $subc == 'mobile' ]]; then elif [[ $subc == 'mobile' ]]; then
namecat=`echo X-BlackArch-Mobile;`; namecat=`echo X-BlackArch-Mobile;`;
elif [[ $subc == 'networking' ]] || [[ $subc == 'fingerprint' ]] ||
[[ $subc == 'firmware' ]] || [[ $subc == 'tunnel' ]] ; then
namecat=`echo X-BlackArch-Networking;`;
elif [[ $subc == 'scanner' ]] || [[ $subc == 'recon' ]] ; then
namecat=`echo X-BlackArch-Scanning;`;
elif [[ $subc == 'sniffer' ]]; then
namecat=`echo X-BlackArch-Sniffer;`;
elif [[ $subc == 'voip' ]]; then
elif [[ $subc == 'networking' ]] || [[ $subc == 'fingerprint' ]] || namecat=`echo X-BlackArch-Voip;`;
[[ $subc == 'firmware' ]] || [[ $subc == 'tunnel' ]] ; then
namecat=`echo X-BlackArch-Networking;`;
elif [[ $subc == 'scanner' ]] || [[ $subc == 'recon' ]] ; then
namecat=`echo X-BlackArch-Scanning;`;
elif [[ $subc == 'sniffer' ]]; then
namecat=`echo X-BlackArch-Sniffer;`;
elif [[ $subc == 'voip' ]]; then
namecat=`echo X-BlackArch-Voip;`;
elif [[ $subc == 'webapp' ]]; then
namecat=`echo X-BlackArch-Webapp;`;
elif [[ $subc == 'windows' ]]; then
namecat=`echo X-BlackArch-Windows;`;
elif [[ $subc == 'wireless' ]]; then
namecat=`echo X-BlackArch-Wireless;`;
else
namecat=`echo X-BlackArch-Misc;`;
fi
#For each tools of the target categorie
for i in $tname; do
#Parse the default launcher and set his name
cat /usr/share/blackmate/dfdesk | sed 's/^Name=.*/Name='$i'/' |
#Set the bash command to execute
sed 's/^Exec=.*/Exec='$terminal' -e "bash -ic \\"\/usr\/bin\/'$i'; exec bash"\\"/' |
#Set the categorie to the launcher && Set the name file to ba-`toolsname`.desktop
sed 's/Categories=.*/Categories='$namecat';/' > /usr/share/blackmate/ba-$i.desktop
#End of the current tool elif [[ $subc == 'webapp' ]]; then
namecat=`echo X-BlackArch-Webapp;`;
elif [[ $subc == 'windows' ]]; then
namecat=`echo X-BlackArch-Windows;`;
elif [[ $subc == 'wireless' ]]; then
namecat=`echo X-BlackArch-Wireless;`;
else
namecat=`echo X-BlackArch-Misc;`;
fi
#For each tools of the target categorie
for i in $tname; do
#Parse the default launcher and set his name
cat /usr/share/blackmate/dfdesk | sed 's/^Name=.*/Name='$i'/' |
#Set the bash command to execute
sed 's/^Exec=.*/Exec='$terminal' -e "bash -ic \\"\/usr\/bin\/'$i'; exec bash"\\"/' |
#Set the categorie to the launcher && Set the name file to ba-`toolsname`.desktop
sed 's/Categories=.*/Categories='$namecat';/' > /usr/share/blackmate/ba-$i.desktop
#End of the current tool
done
#End of the current categorie
done done
#End of the current categorie printf "[*] Cleanup...\n";
done
printf "[*] Cleanup...\n"; #Move the .desktop to the right directory
mv /usr/share/blackmate/ba-*.desktop /usr/share/applications
#Move the .desktop to the right directory #Delete tmp directory
mv /usr/share/blackmate/ba-*.desktop /usr/share/applications rm -rf /usr/share/blackmate/tmp/
rm /usr/share/blackmate/blackarch.db.tar.gz
#Delete tmp directory echo "[*] Done, in order to have a correct display of the new menu, you may need to restart xfce4";
rm -rf /usr/share/blackmate/tmp/
rm /usr/share/blackmate/blackarch.db.tar.gz
echo "[*] Done";