-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RSA toolkit added and VirusTotal url scanner added
- Loading branch information
1 parent
5d374bb
commit 5c1472b
Showing
5 changed files
with
197 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import androguard | ||
from androguard.core.apk import * | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
from guilib.IPtracerBasic_controller import BasicIPtracerWidget | ||
import androguard | ||
|
||
|
||
from PyQt5.QtWidgets import * | ||
|
||
|
||
|
||
app = QApplication([]) | ||
win = BasicIPtracerWidget() | ||
win.show() | ||
app.exec_() |