From 8c6caf9c6076ba8443f8e629c57a178d7b219116 Mon Sep 17 00:00:00 2001 From: AkaliRep Date: Tue, 31 Aug 2021 18:14:31 +0200 Subject: [PATCH 1/2] Agregado soporte para arch y mejores errores --- htbExplorer | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/htbExplorer b/htbExplorer index 3b831fc..176425b 100755 --- a/htbExplorer +++ b/htbExplorer @@ -34,6 +34,14 @@ if [ ! "$API_TOKEN" ]; then exit 1 fi +# Check if user has connection +ping -c 1 hackthebox.eu &>/dev/null +if [[ $? -ne 0 ]]; then + echo -ne "${redColour}[!] You have no connectivity with HackTheBox API...${endColour}\n" + exit 1 +fi + + function banner(){ echo -e "${greenColour} . @@ -152,12 +160,18 @@ function trimString(){ } function generateFiles(){ - echo '' > $tmp_file - while [ "$(cat $tmp_file | wc -l)" != "0" ]; do curl -s -H "$USER_AGENT" "$url_machines_get_all?api_token=$API_TOKEN" -X GET -L | tr "'" '"' | sed 's/None/\"None\"/g' | sed 's/True/\"True\"/g' | sed 's/False/\"False\"/g' > $tmp_file done + + # Check if document has parsed correctly + grep -E "\" $tmp_file &>/dev/null + if [[ $? -eq 0 ]]; then + echo -ne "${redColour}[!] Document couldn't be parsed correctly, please verify if your API TOKEN is valid!${endColour}\n" + tput cnorm + exit 1 + fi } getAllMachines(){ @@ -941,8 +955,11 @@ function dependencies(){ if [ ! "$(command -v $program)" ]; then echo -e "${redColour}[X]${endColour}${grayColour} $program${endColour}${yellowColour} is not installed${endColour}"; sleep 1 echo -e "\n${yellowColour}[i]${endColour}${grayColour} Installing...${endColour}"; sleep 1 - - apt install $program -y > /dev/null 2>&1 + if [ $OS_RELEASE == "Arch Linux" ]; then + pacman -S $program --noconfirm > /dev/null 2>&1 + else + apt install $program -y > /dev/null 2>&1 + fi echo -e "\n${greenColour}[V]${endColour}${grayColour} $program${endColour}${yellowColour} installed${endColour}\n"; sleep 2 fi From 0a4798d9a51b36e75af475bed0127b4894da3502 Mon Sep 17 00:00:00 2001 From: AkaliRep Date: Tue, 31 Aug 2021 18:24:22 +0200 Subject: [PATCH 2/2] =?UTF-8?q?Peque=C3=B1as=20correcciones?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- htbExplorer | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htbExplorer b/htbExplorer index 176425b..d6a719b 100755 --- a/htbExplorer +++ b/htbExplorer @@ -37,7 +37,7 @@ fi # Check if user has connection ping -c 1 hackthebox.eu &>/dev/null if [[ $? -ne 0 ]]; then - echo -ne "${redColour}[!] You have no connectivity with HackTheBox API...${endColour}\n" + echo -ne "${redColour}[!] You have no connectivity with HackTheBox...${endColour}\n" exit 1 fi @@ -955,7 +955,7 @@ function dependencies(){ if [ ! "$(command -v $program)" ]; then echo -e "${redColour}[X]${endColour}${grayColour} $program${endColour}${yellowColour} is not installed${endColour}"; sleep 1 echo -e "\n${yellowColour}[i]${endColour}${grayColour} Installing...${endColour}"; sleep 1 - if [ $OS_RELEASE == "Arch Linux" ]; then + if [[ $OS_RELEASE == "Arch Linux" ]]; then pacman -S $program --noconfirm > /dev/null 2>&1 else apt install $program -y > /dev/null 2>&1