Exemple #1
0
 def download_file(self, hash: Hash):
     self.api_dowf.data = {hash.alg: hash.hash, **self.get_apikey()}
     data, filename = request(self.api_dowf, bin=True)
     # out.debug(util.hexdump(data))
     if filename:
         rw.writef(filename, data)
         return f"downloaded \"{filename}\""
     else:
         return "unsuccess"
Exemple #2
0
 def download_file(self, hash: Hash):
     self.api_dowf.fulluri = self.api_dowf.fullurl % self.get_apikey(
         key=True)
     data, filename = request(self.api_dowf, bin=True)
     if filename:
         rw.writef("phishtank-" + filename, data)
         return f"downloaded \"phishtank-{filename}\""
     else:
         return "unsuccess"
Exemple #3
0
 def download_file(self, hash: Hash):
     self.api_dowf.fulluri = self.api_dowf.fullurl % hash.hash
     self.api_dowf.cookie = self.get_apikey()
     data, filename = request(self.api_dowf, bin=True)
     # out.debug(util.hexdump(data))
     if filename:
         rw.writef(filename, data)
         return f"downloaded \"{filename}\""
     else:
         return "unsuccess"
Exemple #4
0
 def download_file(self, hash: Hash):
     self.api_dowf.param = {**self.get_apikey(), "action": "getfile",
                            "hash": hash.hash}
     data, filename = request(self.api_dowf, bin=True)
     # out.debug(util.hexdump(data))
     if data.startswith(b"Sample not found by hash"):
         return f"sample \"{hash}\" not found"
     if not filename:
         filename = hash.hash
     rw.writef(filename, data)
     return f"downloaded \"{filename}\""
Exemple #5
0
 def download_file(self, hash: Hash):
     self.api_dowf.fulluri = self.api_dowf.fullurl + hash.hash
     self.api_dowf.param = self.get_apikey()
     try:
         data, filename = request(self.api_dowf, bin=True)
         # out.debug(util.hexdump(data))
         if not filename:
             filename = hash.hash
         rw.writef(filename, data)
         return f"downloaded \"{filename}\""
     except Exception as e:
         return f"sample not found: {e}"
Exemple #6
0
 def download_file(self, hash: Hash):
     from requests.exceptions import HTTPError
     self.api_dowf.param = {**self.get_apikey(), "hash": hash.hash}
     try:
         data, filename = request(self.api_dowf, bin=True)
     except HTTPError as e:
         if e.response.status_code == 404:
             return f"sample \"{hash}\" not found"
         raise HTTPError(e)
     if not filename:
         filename = hash.hash
     rw.writef(filename, data)
     return f"downloaded \"{filename}\""
Exemple #7
0
 def download_file(self, hash: Hash):
     if hash.alg == HASH_SHA256:
         data, flag = self.state(hash)
         if flag:
             self.api_dowf.fulluri = self.api_dowf.fullurl % hash.hash
             self.api_dowf.param = {
                 "environmentId": 100,
                 "type": "bin",
                 **self.get_apikey()
             }
             filename = hash.hash + ".gz"
             data, _ = request(self.api_dowf, bin=True)
             rw.writef(filename, data)
             return f"downloaded \"{filename}\""
         else:
             return f"sample \"{hash}\" private or not found"
     else:
         return f"{hash.alg} is not SHA-256"
Exemple #8
0
 def download_file(self, hash: Hash):
     # self.api_dowf.fulluri = self.api_dowf.url + "/feed.txt"
     data, filename = request(self.api_dowf)
     rw.writef("openphish-community.txt", data)
     return "downloaded \"openphish-community.txt\""