diff --git a/hivelibrary/AndroidTools/androguard_tools.py b/hivelibrary/AndroidTools/androguard_tools.py new file mode 100644 index 0000000..6074dca --- /dev/null +++ b/hivelibrary/AndroidTools/androguard_tools.py @@ -0,0 +1,6 @@ +import androguard +from androguard.core.apk import * + + + + diff --git a/hivelibrary/VirusTotal/url_scanner.py b/hivelibrary/VirusTotal/url_scanner.py new file mode 100644 index 0000000..b741415 --- /dev/null +++ b/hivelibrary/VirusTotal/url_scanner.py @@ -0,0 +1,75 @@ + +import requests +from urllib.parse import urlparse + + +def virustotal_url_scanner(target_url, vt_api_key) -> list: + target_url = str(target_url) + vt_api_key = str(vt_api_key) + + STATIC_URL_SCAN_API_URL = "https://www.virustotal.com/vtapi/v2/url/scan" + request_parametres = { + "apikey" : vt_api_key, + "url" : target_url + } + + rawReq = requests.post(url=STATIC_URL_SCAN_API_URL, data=request_parametres) + + if rawReq.status_code == 200: + try: + parsed_req = rawReq.json() + if parsed_req["response_code"] == 1: + scan_id_is = parsed_req["scan_id"] + return [ "true", str(scan_id_is) ] + + else: + return [ "false", "API isteği kabul etmedi veya edemedi" ] + except Exception: + return [ "false", "Veri işlenirken hata gerçekleşti" ] + else: + return [ "false", f"İstek geçersiz durum kodu döndürdü kod: {str(rawReq.status_code)}" ] + + + +def virustotal_url_response_handler(vt_api_key, is_response_id) -> list: + vt_api_key = str(vt_api_key) + is_response_id = str(is_response_id) + + # api url + STATIC_REPORT_URL = "https://www.virustotal.com/vtapi/v2/url/report" + + request_prametres = { + "apikey" : vt_api_key, + "resource" : is_response_id + } + + get_results = requests.get(url=STATIC_REPORT_URL, params=request_prametres) + + if get_results.status_code == 200: + try: + results_json = get_results.json() + + # if respons success + if results_json["response_code"] == 1: + target_url = results_json["url"] + vt_sonuc_linki = results_json["permalink"] + toplam_tarayan = results_json["total"] + tespit_edilen = results_json["positives"] + tarama_tarihi = results_json["scan_date"] + + return ["true", [ target_url, toplam_tarayan, tespit_edilen, tarama_tarihi, vt_sonuc_linki ] ] + + else: + return [ "false", "API isteği kabul etmedi veya edemedi" ] + + # error exceptions and feedback + except Exception: + return ["false", f"Veri işlenirken hata gerçekleşti"] + else: + return [ "false", f"İstek geçersiz durum kodu döndürdü kod: {str(get_results.status_code)}" ] + +def is_url(string): + parsed_url = urlparse(string) + if parsed_url.netloc: + return True + return False \ No newline at end of file diff --git a/hivelibrary/hash_tools.py b/hivelibrary/hash_tools.py index bfba350..37180c0 100644 --- a/hivelibrary/hash_tools.py +++ b/hivelibrary/hash_tools.py @@ -59,3 +59,23 @@ def file_hash_sha1(file_path:str) -> str: return sha_1_hasher.hexdigest() + + +def all_hash(file_path:str) -> dict: + with open(file_path, "rb") as targetFile: + raw_data = targetFile.read() + + return { + "sha1": hashlib.sha1(raw_data).hexdigest(), + "sha256":hashlib.sha256(raw_data).hexdigest(), + "md5":hashlib.sha256(raw_data).hexdigest() + } + + + + + + + + + diff --git a/hivelibrary/rsa_tools.py b/hivelibrary/rsa_tools.py new file mode 100644 index 0000000..f9b03b3 --- /dev/null +++ b/hivelibrary/rsa_tools.py @@ -0,0 +1,95 @@ +import rsa +import os +DEFAULT_CHARSET_ENCODINGS = "utf-8" +SUPPORTED_KEY_SIZES = [ + 1024, + 2048, + 4096 +] + +def generateNewKeyAndSave(keysize:int, key_name:str, save_dir:str) -> dict: + + if keysize not in SUPPORTED_KEY_SIZES: + return {"success":False, "message":"Not supported keysize", "private_path":None, "public_path":None, "code":"invalid_ksize"} + + if os.name == "nt": + check_digit = str(save_dir[-2:]) + if not str(os.path.sep) in check_digit: + save_dir = str(save_dir) + str(os.path.sep) + else: + check_digit = str(save_dir[-1]) + if not str(os.path.sep) in check_digit: + save_dir = str(save_dir) + str(os.path.sep) + + + PRIVATE_KEY_PATH = save_dir + key_name + ".priv" + PUBLIC_KEY_PATH = save_dir + key_name + ".pub" + + if os.path.exists(PRIVATE_KEY_PATH) or os.path.exists(PUBLIC_KEY_PATH): + return { "success":False, "message":"Key files alredy exists proccess stopped", "private_path":None, "public_path":None, "code":"keyfiles_exists" } + + + public_key, private_key = rsa.newkeys(keysize) + + with open(PUBLIC_KEY_PATH, "wb") as public_key_file: + public_key_file.write(public_key.save_pkcs1()) + + + with open(PRIVATE_KEY_PATH, "wb") as private_key_file: + private_key_file.write(private_key.save_pkcs1()) + + + return { + "success":True, + "message":"RSA new keys successfully generated", + "private_path": PRIVATE_KEY_PATH, + "public_path": PUBLIC_KEY_PATH, + "code":"success" + + } + + + + +def loadPrivateKey(private_key_file_path:str) -> dict: + if not os.path.exists(private_key_file_path): + return { + "success": "false", + "message": f"{private_key_file_path} not found" + } + + with open(private_key_file_path, "rb") as private_key_file: + key_data = private_key_file.read() + key_data = rsa.PrivateKey.load_pkcs1(key_data) + return { + "success":"true", + "data": key_data + } + + + +def loadPublicKey(public_key_file_path:str) -> dict: + if not os.path.exists(public_key_file_path): + return { + "success" : False, + "message" : f"{public_key_file_path} not found" + } + + with open(public_key_file_path, "rb") as public_key_file: + key_data = public_key_file.read() + key_data = rsa.PublicKey.load_pkcs1(key_data) + return { + "success" : True, + "data": key_data + } + + + + + +def encrypte_string(public_key, target_string:str) -> str: + target_string = str(target_string) + return rsa.encrypt(target_string.encode(DEFAULT_CHARSET_ENCODINGS),pub_key=public_key) + +def decrypte_string(private_key, target_string) -> str: + return rsa.decrypt(target_string,priv_key=private_key).decode(DEFAULT_CHARSET_ENCODINGS) \ No newline at end of file diff --git a/testFile.py b/testFile.py index 6ce97fc..9ece69e 100644 --- a/testFile.py +++ b/testFile.py @@ -1,11 +1,4 @@ -from guilib.IPtracerBasic_controller import BasicIPtracerWidget +import androguard -from PyQt5.QtWidgets import * - - -app = QApplication([]) -win = BasicIPtracerWidget() -win.show() -app.exec_() \ No newline at end of file