def submit_file(self, file: File): self.api_subf.data = self.get_apikey() self.api_subf.file = {"file": (file.name, file.fd())} data, _ = request(self.api_subf) data = frmt.jsontree(data) # web.openurl(data["permalink"]) data = frmt.jsonvert(data) # return out.pformat(data) return data
def report_url(self, url: str): self.api_repu.data = { "url": quoteurl(url), "format": "json", **self.get_apikey() } data, _ = request(self.api_repu) data = frmt.jsontree(data) return out.pformat(data)
def report_file(self, hash: Hash): self.api_repf.param = { **self.get_apikey(), "allinfo": "true", "resource": hash.hash } data, _ = request(self.api_repf) data = frmt.jsontree(data, depth=1) # data = frmt.jsonvert(data["scans"]) # openurl(data["permalink"]) return out.pformat(data)
def search(self, srch: str): from re import escape srch = escape(srch) self.api_srch.param = {**self.get_apikey(), "limit": self.limit, "value__regexp": f".*{srch}.*"} # self.api_srch.param = {**self.get_apikey(), "value": srch} data, _ = request(self.api_srch) data = frmt.jsontree(data) return out.pformat(data)
def report_file(self, hash: Hash): if hash.alg == HASH_MD5 or hash.alg == HASH_SHA1: self.api_repf.param = {**self.get_apikey(), "type": "md5", # MD5 or SHA-1 "value": hash.hash, "limit": self.limit} data, _ = request(self.api_repf) data = frmt.jsontree(data) return out.pformat(data) else: return f"{hash.alg} is not MD5 or SHA1"
def submit_file(self, file: File): self.api_subf.data = self.get_apikey() self.api_subf.file = {"file": (file.name, file.fd())} if file.len > 32 * 1024 * 1024: api_subfl = APISpec("GET", "https://www.virustotal.com", "/vtapi/v2/file/scan/upload_url") api_subfl.param = {**self.get_apikey()} data, _ = request(api_subfl) data = frmt.jsontree(data) self.api_subf.fulluri = data["upload_url"] self.api_subf.data = None else: self.api_subf.default() data, _ = request(self.api_subf) data = frmt.jsontree(data) # web.openurl(data["permalink"]) data = frmt.jsonvert(data) # return out.pformat(data) return data
def search(self, srch: str): from requests.exceptions import HTTPError self.api_srch.fulluri = self.api_srch.fullurl % \ ("breachedaccount", srch) try: data, _ = request(self.api_srch) except HTTPError as e: if e.response.status_code == 404: return f"account \"{srch}\" not found" raise HTTPError(e) data = frmt.jsontree(data) return out.pformat(data)
def report_url(self, url: str): self.api_repu.param = self.get_apikey() self.api_repu.header = {'Content-Type': 'application/json'} self.api_repu.json = { "client": { "clientId": MALSUB_NAME, "clientVersion": MALSUB_VERSION }, "threatInfo": { # "POTENTIALLY_HARMFUL_APPLICATION" # "THREAT_TYPE_UNSPECIFIED" # "UNWANTED_SOFTWARE" "threatTypes": ["MALWARE", "SOCIAL_ENGINEERING"], "platformTypes": ["ALL_PLATFORMS"], "threatEntryTypes": ["URL"], "threatEntries": [{ "url": url }] } } data, _ = request(self.api_repu) data = frmt.jsontree(data) return out.pformat(data)
def report_file(self, hash: Hash): self.api_repf.data = {**self.get_apikey(), "query": hash.hash} data, _ = request(self.api_repf) data = frmt.jsontree(data) return out.pformat(data)
def search(self, srch: str): self.api_srch.param = {**self.get_apikey(), "query": srch} data, _ = request(self.api_srch) data = frmt.jsontree(data) return out.pformat(data)
def report_file(self, hash: Hash): self.api_repf.data = {"type": "json", hash.alg: hash.hash} data, _ = request(self.api_repf) data = frmt.jsontree(data) return out.pformat(data)
def report_ip(self, ip: str): self.api_repi.param = {"ip": ip} data, _ = request(self.api_repi) data = frmt.jsontree(data) return out.pformat(data)
def submit_file(self, file: File): self.api_subf.header = self.get_apikey() self.api_subf.file = {"file": file.fd()} data, _ = request(self.api_subf) data = frmt.jsontree(data) return out.pformat(data)
def report_file(self, hash: Hash): self.api_repf.fulluri = self.api_repf.fullurl + hash.hash self.api_repf.param = self.get_apikey() data, _ = request(self.api_repf) data = frmt.jsontree(data) return out.pformat(data)
def quota(self): self.api_quot.cookie = self.get_apikey() res, _ = request(self.api_quot) res = frmt.jsontree(res) return out.pformat(res)
def search(self, srch: str): self.api_srch.param = self.get_apikey() self.api_srch.header = {'Content-Type': 'application/json'} data, _ = request(self.api_srch) data = frmt.jsontree(data) return out.pformat(data)
def report_url(self, url: str): self.api_repu.data = {**self.get_apikey(), "resource": url} data, _ = request(self.api_repu) data = frmt.jsontree(data) # web.openurl(data["permalink"]) return out.pformat(data)
def report_dom(self, dom: str): self.api_repd.param = {"domain": dom} data, _ = request(self.api_repd) data = frmt.jsontree(data) return out.pformat(data)
def submit_url(self, url: str): self.api_subu.data = {**self.get_apikey(), "url": url} data, _ = request(self.api_subu) data = frmt.jsontree(data) # web.openurl(data["permalink"]) return out.pformat(data)
def search(self, srch: str): self.api_srch.param = {"antivirus": srch} data, _ = request(self.api_srch) data = frmt.jsontree(data) return out.pformat(data)
def search(self, srch: str): self.api_srch.fulluri = self.api_srch.fullurl % (self.get_apikey( key=True), srch) data, _ = request(self.api_srch) data = frmt.jsontree(data) return data