@@ 1,13 1,15 @@
#!/bin/bash
file_hash="$1"
-file_name="$2.json"
+file_name="$2"
+
+json_v="$file_name.json"
touch $file_name
curl --request GET \
--url https://www.virustotal.com/api/v3/files/$file_hash \
- --header 'x-apikey: <API KEY>' >> $file_name
+ --header 'x-apikey: <API KEY>' >> $json_v
oname="readable_$file_name"
touch $oname
@@ 19,7 21,7 @@ curl --request GET \
# Getting it parsing the raw json with jq and cleaning
# the result so it's only the label name
-raw_label=$(jq .data.attributes.popular_threat_classification.suggested_threat_label $file_name)
+raw_label=$(jq .data.attributes.popular_threat_classification.suggested_threat_label $json_v)
clean_label=${raw_label//\"}
clean_label=${clean_label//.}
@@ 34,7 36,7 @@ echo -e "\n" >> $oname
# Getting it parsing the raw json with jq and cleaning
# the result so it's only the label name
-raw_tags=$(jq .data.attributes.type_tags $file_name)
+raw_tags=$(jq .data.attributes.type_tags $json_v)
cl1_tags=$(echo $raw_tags | tr \[ \( | tr \] \))
declare -a arr=$cl1_tags
@@ 49,7 51,7 @@ echo -e "\n" >> $oname
# Meaningful name
-raw_name=$(jq .data.attributes.meaningful_name $file_name)
+raw_name=$(jq .data.attributes.meaningful_name $json_v)
clean_name=${raw_name//\"}
clean_label=${clean_name//.}
@@ 60,7 62,7 @@ echo -e "\n" >> $oname
# Imports
-raw_imports=$(jq .data.attributes.pe_info.import_list[].library_name $file_name)
+raw_imports=$(jq .data.attributes.pe_info.import_list[].library_name $json_v)
cl1_imports=$(echo $raw_imports | tr \[ \( | tr \] \))
declare -a arr2=$cl1_imports