@@ -57,6 +57,10 @@ type MalwareBazarQueryData struct {
5757 File_name string `json:"file_name"`
5858}
5959
60+ type MalwareBazaarQueryStatus struct {
61+ Status string `json:"query_status"`
62+ }
63+
6064type AssemblyLineQuery struct {
6165 Error_message string `json:"api_error_message"`
6266 Response * AssemblyLineQueryResponse `json:"api_response"`
@@ -958,33 +962,43 @@ func malwareBazaarDownload(uri string, api string, hash Hash, doNotExtract bool,
958962 fmt .Printf (" [!] Normally the response code: %s means that the provided URL %s needs a trailing slash (to avoid the redirect), but this already has a trailing slash.\n Please file a bug report at https://github.com/xorhex/mlget/issues\n " , response .Status , uri )
959963 }
960964 } else {
961- fmt .Printf (" [!] %s\n " , response .Status )
962- }
963- }
965+ byteValue , _ := io .ReadAll (response .Body )
964966
965- err = writeToFile (response .Body , hash .Hash + ".zip" )
966- if err != nil {
967- fmt .Println (err )
968- return false , ""
969- }
967+ var data = MalwareBazaarQueryStatus {}
968+ error = json .Unmarshal (byteValue , & data )
970969
971- fmt .Printf (" [+] Downloaded %s\n " , hash .Hash + ".zip" )
972- if doNotExtract {
973- return true , hash .Hash + ".zip"
974- } else {
975- fmt .Println (" [-] Extracting..." )
976- files , err := extractPwdZip (hash .Hash + ".zip" , password , true , hash )
977- if err != nil {
978- fmt .Println (err )
979- return false , ""
980- } else {
981- for _ , f := range files {
982- fmt .Printf (" [-] Extracted %s\n " , f .Name )
970+ if error == nil {
971+ if data .Status == "file_not_found" {
972+ return false , ""
973+ }
974+ } else {
975+ err = writeToFile (io .NopCloser (bytes .NewReader (byteValue )), hash .Hash + ".zip" )
976+ if err != nil {
977+ fmt .Println (err )
978+ return false , ""
979+ }
980+
981+ fmt .Printf (" [+] Downloaded %s\n " , hash .Hash + ".zip" )
982+ if doNotExtract {
983+ return true , hash .Hash + ".zip"
984+ } else {
985+ fmt .Println (" [-] Extracting..." )
986+ files , err := extractPwdZip (hash .Hash + ".zip" , password , true , hash )
987+ if err != nil {
988+ fmt .Println (err )
989+ return false , ""
990+ } else {
991+ for _ , f := range files {
992+ fmt .Printf (" [-] Extracted %s\n " , f .Name )
993+ }
994+ }
995+ os .Remove (hash .Hash + ".zip" )
996+ return true , hash .Hash
997+ }
983998 }
984999 }
985- os .Remove (hash .Hash + ".zip" )
986- return true , hash .Hash
9871000 }
1001+ return false , ""
9881002}
9891003
9901004func filescanio (uri string , api string , hash Hash , doNotExtract bool , password string ) (bool , string ) {
0 commit comments