2016-07-11 03:40:40 +00:00
#!/bin/bash
#
2017-06-15 15:42:24 +00:00
# Blackmate v0.43.1
2016-07-11 03:40:40 +00:00
#
2020-04-27 18:07:47 +00:00
# Description : BlackMate is a menu generator for the BlackArch Linux os tools, unified for all Desktops.
2016-09-24 18:59:58 +00:00
# It will fetch the latest database of BlackArch and create an entry for each of them in the menu.
2020-04-27 18:07:47 +00:00
# You may run the script as often as new tools are available.
2016-09-23 18:57:21 +00:00
#
2016-07-11 03:40:40 +00:00
#
2020-04-26 20:29:01 +00:00
# Author : Dimitri Mader -> dimitri@linux.com / byReqz -> https://byreqz.de/contact
# Url : https://github.com/byReqz/blackmate
2017-03-07 16:42:00 +00:00
# Gnu / GPL v3
2016-07-11 03:40:40 +00:00
2016-09-25 11:19:22 +00:00
#Check if the script have the root permission
if [ [ $EUID -ne 0 ] ] ; then
2017-03-07 16:42:00 +00:00
echo -e "\033[31m[ERROR]\e[0m Blackmate must run with root permission (use sudo or the script will fail)" ;
2016-09-25 11:19:22 +00:00
exit 1;
fi
2016-07-11 03:40:40 +00:00
2017-03-07 16:42:00 +00:00
#Check if gtk-murrine engine is installed, if not, purpose to install it
if [ [ ! -f /usr/share/gtk-engines/murrine.xml ] ] ; then
echo -e "\033[31m[Warning]\e[0m gtk murrine engine is not installed, it is highly recommanded to install it in order to have a proper display of the categories icons, do you want to install it now ?" ;
select yn in "Yes" "No" ; do
case $yn in
Yes ) pacman -S --noconfirm gtk-engine-murrine; break; ;
No ) break; ;
esac
done
2017-06-15 05:02:23 +00:00
2017-03-07 16:42:00 +00:00
fi
echo -e "\033[32m[*]\e[0m Creating the new menu entry" ;
2016-07-11 03:40:40 +00:00
2016-07-25 09:15:16 +00:00
#Clean any previous application entry and categorie entry
rm /usr/share/applications/ba-*.desktop 2> /dev/null || true
rm /usr/share/desktop-directories/BlackArch*.directory 2> /dev/null || true
2016-07-11 03:40:40 +00:00
2016-07-25 09:15:16 +00:00
#Update X.BlackArch.menu
cp /usr/share/blackmate/X-BlackArch.menu /etc/xdg/menus/applications-merged/X-BlackArch.menu
2016-07-11 03:40:40 +00:00
2016-07-25 09:15:16 +00:00
#Copy the directory file BlackArch (Blackarch -> categorie -> tools...)
cp /usr/share/blackmate/BlackArch.directory /usr/share/desktop-directories/
#Generate the new categorie entry menu
2016-09-25 11:19:22 +00:00
for u in $( ls --color= auto /usr/share/blackmate/menu-i/ | sort ) ; do
2016-09-25 11:13:53 +00:00
c = ` echo $u | sed 's/BlackArch-//' | sed 's/\.png//' ` ;
cat /usr/share/blackmate/dfdir | sed 's/^Name=.*/Name=' $c '/' |
2016-09-25 11:19:22 +00:00
sed 's/^Icon=.*/Icon=BlackArch-' $c '/' > /usr/share/desktop-directories/BlackArch-$c .directory
2016-07-25 09:15:16 +00:00
done
2017-06-15 15:42:24 +00:00
2020-04-27 16:55:52 +00:00
# NEEDS FIXING
2017-06-15 15:42:24 +00:00
#Delete any cache icons of the current theme
2020-04-27 16:55:52 +00:00
# rm /usr/share/icons/$thic/icon-theme.cache 2> /dev/null || true
2017-06-15 15:42:24 +00:00
2016-09-23 18:57:21 +00:00
#Copy the extra icons into the icons theme
2020-04-27 16:55:52 +00:00
# cp /usr/share/blackmate/menu-i/* /usr/share/icons/$thic/32x32/apps/ 2> /dev/null || true
2016-09-23 18:57:21 +00:00
2017-06-15 05:02:23 +00:00
#Set the correct chmod
2020-04-27 16:55:52 +00:00
# chmod 755 /usr/share/icons/$thic/32x32/apps/ -R 2> /dev/null || true
2016-09-23 18:57:21 +00:00
2016-07-25 09:15:16 +00:00
#Download and generate the latest tools list
2017-03-07 16:42:00 +00:00
echo -e "\033[32m[*]\e[0m Download the tools list, please wait..." ;
#Check if the directory exist, if true, delete it (Fix any previous abort before the end...)
if [ [ -d "/usr/share/blackmate/tmp" ] ] ; then
rm -rf /usr/share/blackmate/tmp 2> /dev/null || true
fi
#Create temporary directory to store the tools list
mkdir /usr/share/blackmate/tmp 2> /dev/null || true
2016-09-25 11:13:53 +00:00
wget -q -P /usr/share/blackmate/ https://mirror.yandex.ru/mirrors/blackarch/blackarch/os/x86_64/blackarch.db.tar.gz
2016-07-25 09:15:16 +00:00
tar -zxf /usr/share/blackmate/blackarch.db.tar.gz -C /usr/share/blackmate/tmp
2016-07-11 03:40:40 +00:00
2016-09-23 18:57:21 +00:00
#Terminal to use for the blackarch entry
2020-04-26 20:29:01 +00:00
terminal = ` echo konsole` ;
2016-09-23 18:57:21 +00:00
2017-03-07 16:42:00 +00:00
echo -e "\033[32m[*]\e[0m Generating the menu, please wait..." ;
2016-07-11 03:40:40 +00:00
2016-09-23 18:57:21 +00:00
#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
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
#Subcategorie
subc = ` cat /usr/share/blackmate/tmp/$u /desc | sed 's/blackarch//' |
2016-09-25 11:19:22 +00:00
sed '/^\s*$/d' | sed -n '/%GROUPS%/{n;p}' | sed 's/-//' ` ;
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
#Check the group of the current tool, if empty, go to the next iteration
if [ [ -z " $subc " ] ] ; then
2017-06-15 05:02:23 +00:00
continue ;
2016-09-25 11:13:53 +00:00
fi
#Name of the tool
tname = ` cat /usr/share/blackmate/tmp/$u /desc | sed 's/blackarch//' |
2017-06-15 05:02:23 +00:00
sed '/^\s*$/d' | sed -n '/%NAME%/{n;p}' ` ;
#Check if the tool is installed on the system, otherwise skip to the next
command -v $tname >/dev/null 2>& 1 || { continue ; }
2016-07-25 09:15:16 +00:00
2016-09-25 11:13:53 +00:00
#Set categorie of the subcategorie tool branche
if [ [ $subc = = "code-audit" ] ] || [ [ $subc = = 'decompiler' ] ] ||
2016-09-25 11:19:22 +00:00
[ [ $subc = = 'disassembler' ] ] || [ [ $subc = = 'reversing' ] ] ; then
2016-07-25 09:15:16 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Audit; ` ;
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'automation' ] ] ; then
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Automation; ` ;
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'backdoor' ] ] || [ [ $subc = = 'keylogger' ] ] ||
2016-09-25 11:19:22 +00:00
[ [ $subc = = 'malware' ] ] ; then
2016-07-11 03:40:40 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Backdoor; ` ;
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'binary' ] ] ; then
2016-07-11 03:40:40 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Binary; ` ;
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'bluetooth' ] ] ; then
2016-07-11 03:40:40 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Bluetooth; ` ;
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'cracker' ] ] ; then
2016-07-11 03:40:40 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Cracker; ` ;
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'crypto' ] ] ; then
2016-07-11 03:40:40 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Crypto; ` ;
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'defensive' ] ] ; then
2016-07-11 03:40:40 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Defensive; ` ;
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'dos' ] ] ; then
2016-07-11 03:40:40 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Dos; ` ;
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'exploitation' ] ] || [ [ $subc = = 'social' ] ] ||
2016-09-25 11:19:22 +00:00
[ [ $subc = = 'spoof' ] ] || [ [ $subc = = 'fuzzer' ] ] ; then
2016-07-25 09:15:16 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Exploitation; ` ;
2016-07-25 09:15:16 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'forensic' ] ] || [ [ $subc = = "anti-forensic" ] ] ; then
2016-07-25 09:15:16 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Forensic; ` ;
2016-07-25 09:15:16 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'honeypot' ] ] ; then
2016-07-25 09:15:16 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Honeypot; ` ;
2016-07-25 09:15:16 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'mobile' ] ] ; then
2016-07-25 09:15:16 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Mobile; ` ;
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'networking' ] ] || [ [ $subc = = 'fingerprint' ] ] ||
2016-09-25 11:19:22 +00:00
[ [ $subc = = 'firmware' ] ] || [ [ $subc = = 'tunnel' ] ] ; then
2016-07-25 09:15:16 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Networking; ` ;
2016-07-25 09:15:16 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'scanner' ] ] || [ [ $subc = = 'recon' ] ] ; then
2016-07-11 03:40:40 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Scanning; ` ;
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'sniffer' ] ] ; then
2016-07-25 09:15:16 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Sniffer; ` ;
2016-07-25 09:15:16 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'voip' ] ] ; then
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Voip; ` ;
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'webapp' ] ] ; then
2016-07-25 09:15:16 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Webapp; ` ;
2016-07-25 09:15:16 +00:00
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'windows' ] ] ; then
2016-07-25 09:15:16 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Windows; ` ;
2016-09-25 11:13:53 +00:00
elif [ [ $subc = = 'wireless' ] ] ; then
2016-07-25 09:15:16 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Wireless; ` ;
2016-07-25 09:15:16 +00:00
2016-09-25 11:13:53 +00:00
else
2016-07-25 09:15:16 +00:00
2016-09-25 11:19:22 +00:00
namecat = ` echo X-BlackArch-Misc; ` ;
2016-07-25 09:15:16 +00:00
2016-09-25 11:13:53 +00:00
fi
2016-07-25 09:15:16 +00:00
2020-04-27 16:55:52 +00:00
#For each tools of the target category
2016-09-25 11:13:53 +00:00
for i in $tname ; do
2016-07-25 09:15:16 +00:00
2016-09-25 11:13:53 +00:00
#Parse the default launcher and set his name
cat /usr/share/blackmate/dfdesk | sed 's/^Name=.*/Name=' $i '/' |
#Set the bash command to execute
2020-04-27 16:55:52 +00:00
sed 's/^Exec=.*/Exec=' bash' -c "\/usr\/bin\/' $i '; exec bash"/' |
#Set the category to the launcher && Set the name file to ba-`toolsname`.desktop
2016-09-25 11:13:53 +00:00
sed 's/Categories=.*/Categories=' $namecat ';/' > /usr/share/blackmate/ba-$i .desktop
#End of the current tool
done
2016-07-11 03:40:40 +00:00
2020-04-27 16:55:52 +00:00
#End of the current category
2016-07-11 03:40:40 +00:00
done
2017-03-07 16:42:00 +00:00
echo -e "\033[32m[*]\e[0m Cleanup..." ;
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
#Move the .desktop to the right directory
2017-06-15 05:02:23 +00:00
mv /usr/share/blackmate/ba-*.desktop /usr/share/applications 2> /dev/null || true
2016-07-11 03:40:40 +00:00
2016-09-25 11:13:53 +00:00
#Delete tmp directory
2017-06-15 05:02:23 +00:00
rm -rf /usr/share/blackmate/tmp/ 2> /dev/null || true
rm /usr/share/blackmate/blackarch.db.tar.gz 2> /dev/null || true
2016-07-11 03:40:40 +00:00
2020-04-27 16:55:52 +00:00
echo -e "\033[32m[*]\e[0m Done, in order to have a correct display of the new menu, you may need to restart your Desktop Environment" ;