diff --git a/README.md b/README.md index 2b55331..8581556 100644 --- a/README.md +++ b/README.md @@ -39,12 +39,6 @@

İndirme ve ilk kurulum

-Öncelikle Repomuzu GitHub dan çekerek içerisinde girelim sonra diğer adımlara geçebiliriz. - -```shell -git clone https://github.com/MehmetYukselSekeroglu/TheHive.git -cd TheHive -```

Linux Üzerinde TheHive Kurulumu

Windows Üzerinde TheHive Kurulumu

diff --git a/binary/windows/insightface-0.7.3-cp311-cp311-win_amd64.whl b/binary/windows/insightface-0.7.3-cp311-cp311-win_amd64.whl new file mode 100644 index 0000000..7775ec7 Binary files /dev/null and b/binary/windows/insightface-0.7.3-cp311-cp311-win_amd64.whl differ diff --git a/documents/Iban Parser.md b/documents/Iban Parser.md new file mode 100644 index 0000000..698bec2 --- /dev/null +++ b/documents/Iban Parser.md @@ -0,0 +1,20 @@ +# Iban Parser Özelliği Nedir Ne İşe Yarar? + + +IBAN Para transferi için kullanılan küresel bir sistemdir bu nedenle bu sistem içerisinde belirlir tanımlayıcı unsurlar bulunmaktadır. Iban parser modülü de bu tanımlayıcı bilgileri Iban içerisinden çıkartarak insanların anlayabileceği bir formata getirmektedir. + + +IBAN içerisinde gelen bazı bilgiler: + +- Ülke Kodu +- Sepa Desteği +- Hesap Kontrolü Desteği +- Şube Kontrolü +- Banka Kodu +- Hesap Numarası +- Şube Kodu +- Müşteri Numarası +- Hesap Ek Numrası + + +Bu bilgilerden bazıları yetkili makamlar hariç bizim işimize yaramasada banka adı ,şube kodu, Müşteri numarası işimize yarar farklı ibanların aynı müşterinin mi olduğuna, şube kodu ile kişinin yaşadığı tahmini bölge tespit edilebilmektedir. Bu nedenle dolandırıcılık vs gibi olaylarda bu modülden yararlanmak zamandan kazandırır. \ No newline at end of file diff --git a/documents/Ip Tracer.md b/documents/Ip Tracer.md new file mode 100644 index 0000000..29a34d8 --- /dev/null +++ b/documents/Ip Tracer.md @@ -0,0 +1,7 @@ +# IP Tracer Modülü: + + +IP Tracer modülü arka planda `ipinfo.io` api'sinden yararlanmaktadır. Basit bir şekilde IP adresini api üzerinden sorgular ve gelen çıktıyı okunur hale getirir ek olarak coğrafi bir fikir vermesi için verilen IP kordinatlarını haritada işaretler. + + + \ No newline at end of file diff --git a/documents/Linux Kurulumu.md b/documents/Linux Kurulumu.md index 13d6fff..766e939 100644 --- a/documents/Linux Kurulumu.md +++ b/documents/Linux Kurulumu.md @@ -1,4 +1,11 @@ +Öncelikle Repomuzu GitHub dan çekerek içerisinde girelim sonra diğer adımlara geçebiliriz. + +```shell +git clone https://github.com/MehmetYukselSekeroglu/TheHive.git +cd TheHive +``` + ## 1) Config Dosyasını Oluşturma @@ -59,5 +66,4 @@ bash linux.sh --start-hive -
\ No newline at end of file diff --git a/documents/Windows Kurulumu.md b/documents/Windows Kurulumu.md index e69de29..9486ec6 100644 --- a/documents/Windows Kurulumu.md +++ b/documents/Windows Kurulumu.md @@ -0,0 +1,80 @@ + + + + + +Windows için kuruluma başlamadan önce `docker`, `git` ve `python3`paketlerini sisteme kurmamız gerekli. + + +Docker'i indirmek için tıklayın +Python3'ü indirmek için tıklayın +Git'i indirmek için tıklayın + + +Öncelikle Repomuzu GitHub dan çekerek içerisinde girelim sonra diğer adımlara geçebiliriz. + +```shell +git clone https://github.com/MehmetYukselSekeroglu/TheHive.git +cd TheHive +``` + + +## 1) Config Dosyasını Oluşturma + +İlk olarak `config/config.json` yapılandırma dosyamızı oluşturmamız gerekiyor. Bunun için proje klasörü içinde şu komutu çalıştırın. + +```shell +python3 -m hivelibrary.make_config_schema +``` + +Çıktısı aşşağıdaki gibi olmalıdır: + + + + + +## 2) Config Dosyasına Ayarlarımızı Girelim + +NOT: Eğer özel bir PostgreSQL parolası istemiyorsanız bu alanı atlayın. + +Herhangi bir metin editörü ile `config/config.json` dosyamızı açalım. Bu dosyada sadece database config içinde `password` kısmına istediğiniz veritabanı parolasını yazmanız yeterli isterseni olduğu gibi de bırakabilirsiniz. + +Config Dosyasının içeriği aşşağıdaki gibi otomatik oluşturulmuş olacaktır. Gerekli kısma parola yazıp kaydedip çıkabilirsiniz. + + + + +## 3) Kuruluma başlayalım + +TheHive indirme işlemi için otomatik bir kurulum dosyası sağlar. Aşşağıdaki komutu proje klasörü içinde çalıştırırsanız otomatik kurulum başlayacaktır. + +### NOT: Docker'in açık olması gerekli! + +```shell +python windows.py --wizard +``` + +Kurulum tamamlandığı zaman TheHive otomatik olaraç açılacaktır. + + + +## 4) Kurulum sonrası elle başlatma + +İster `main.py` dosyasını çalıştırın isterseniz aşşağıdaki gibi açabilirsiniz. + +```shell +python windows.py --start-hive +``` + + + +# Windows Arayüzünden Örnek Bir Görüntü: + + + + + + + + + diff --git a/guilib/videoFrameExtractor_controller.py b/guilib/videoFrameExtractor_controller.py index 535a610..d01e32a 100644 --- a/guilib/videoFrameExtractor_controller.py +++ b/guilib/videoFrameExtractor_controller.py @@ -104,7 +104,8 @@ def __init__(self): self.targetVideoFile_is_selected = False self.targetOutputDir_is_selected = False - + self.targetVideoFile = "" + def threadSignalHandler(self, result_dict): if result_dict["end"] == True and result_dict["success"] == True: self.video2framePage.textBrowser_logAndResults.append(str(result_dict["text"])) diff --git a/hivelibrary/__pycache__/__init__.cpython-311.pyc b/hivelibrary/__pycache__/__init__.cpython-311.pyc index 8d7b9be..16854bc 100644 Binary files a/hivelibrary/__pycache__/__init__.cpython-311.pyc and b/hivelibrary/__pycache__/__init__.cpython-311.pyc differ diff --git a/hivelibrary/__pycache__/console_tools.cpython-311.pyc b/hivelibrary/__pycache__/console_tools.cpython-311.pyc index a58c6c4..e8fd37b 100644 Binary files a/hivelibrary/__pycache__/console_tools.cpython-311.pyc and b/hivelibrary/__pycache__/console_tools.cpython-311.pyc differ diff --git a/hivelibrary/__pycache__/database_structure.cpython-311.pyc b/hivelibrary/__pycache__/database_structure.cpython-311.pyc index f5b2e26..2ff3452 100644 Binary files a/hivelibrary/__pycache__/database_structure.cpython-311.pyc and b/hivelibrary/__pycache__/database_structure.cpython-311.pyc differ diff --git a/hivelibrary/__pycache__/database_tools.cpython-311.pyc b/hivelibrary/__pycache__/database_tools.cpython-311.pyc index 97ffb60..f43b5db 100644 Binary files a/hivelibrary/__pycache__/database_tools.cpython-311.pyc and b/hivelibrary/__pycache__/database_tools.cpython-311.pyc differ diff --git a/hivelibrary/__pycache__/env.cpython-311.pyc b/hivelibrary/__pycache__/env.cpython-311.pyc index ee96ab6..9a54af0 100644 Binary files a/hivelibrary/__pycache__/env.cpython-311.pyc and b/hivelibrary/__pycache__/env.cpython-311.pyc differ diff --git a/hivelibrary/make_config_schema.py b/hivelibrary/make_config_schema.py index e08b7de..87dde6c 100644 --- a/hivelibrary/make_config_schema.py +++ b/hivelibrary/make_config_schema.py @@ -10,9 +10,11 @@ import sys import os + + + # local library import's from .env import CONFIG_FILE_PATH as __CONFIG_FILE_PATH__ -from .consolePrint import (p_info, p_error) @@ -65,10 +67,10 @@ json.dump(__CONFIG_FILE_DATA__,conf_file,indent=4) except Exception as err: - p_error(f"Failed to crate {__CONFIG_FILE_PATH__}, {err}") + print(f"Failed to crate {__CONFIG_FILE_PATH__}, {err}") sys.exit(-1) - p_info(f"{__CONFIG_FILE_PATH__} successfuly generated.") + print(f"{__CONFIG_FILE_PATH__} successfuly generated.") sys.exit(0) diff --git a/img/temsil2.png b/img/temsil2.png new file mode 100644 index 0000000..71ffd6e Binary files /dev/null and b/img/temsil2.png differ diff --git a/img/windows_installing_1.png b/img/windows_installing_1.png new file mode 100644 index 0000000..2086190 Binary files /dev/null and b/img/windows_installing_1.png differ diff --git a/img/windows_installing_2.png b/img/windows_installing_2.png new file mode 100644 index 0000000..b3ed202 Binary files /dev/null and b/img/windows_installing_2.png differ diff --git a/sql/postgresql_schema.sql b/sql/postgresql_schema.sql index deab057..9ec42b3 100644 --- a/sql/postgresql_schema.sql +++ b/sql/postgresql_schema.sql @@ -24,4 +24,30 @@ CREATE TABLE IF NOT EXISTS "face_recognition_standart" ( face_box BYTEA NOT NULL, face_name TEXT NOT NULL, add_date TIMESTAMP DEFAULT NOW() +======= + "id" SERIAL PRIMARY KEY, + "unique_key" VARCHAR(100) NOT NULL UNIQUE, + "value" VARCHAR(100) NOT NULL +); +CREATE TABLE IF NOT EXISTS "blob_storage" ( + "id" SERIAL PRIMARY KEY, + "unique_blob_key" TEXT NOT NULL UNIQUE, + "key_value" BYTEA NOT NULL, + "data_type" TEXT NOT NULL DEFAULT 'user', + "information_notes" TEXT DEFAULT NULL +); +CREATE TABLE IF NOT EXISTS "authentication" ( + "id" SERIAL PRIMARY KEY, + "username" VARCHAR(128) NOT NULL UNIQUE, + "password" VARCHAR(128) NOT NULL +); +CREATE TABLE IF NOT EXISTS "face_recognition_standart" ( + "id" SERIAL PRIMARY KEY, + "face_picture_blob" BYTEA NOT NULL, + "picture_sha1_hash" TEXT NOT NULL UNIQUE, + "face_embedding_data" BYTEA NOT NULL, + "landmarks_2d" BYTEA NOT NULL, + "face_box" BYTEA NOT NULL, + "face_name" TEXT NOT NULL, + "add_date" TIMESTAMP DEFAULT NOW() ); diff --git a/windows.ps1 b/windows.ps1 deleted file mode 100644 index e69de29..0000000 diff --git a/windows.py b/windows.py new file mode 100644 index 0000000..67b4373 --- /dev/null +++ b/windows.py @@ -0,0 +1,297 @@ +import subprocess +import os +import json +import sys +import time + +# TheHive Wimdows Controller +# + + +# Return Codes +# -1 -> Config File Not Found + + + +CONFIG_PATH = "config" + os.path.sep + "config.json" + + +def p_error(msg): + print(f"[ERROR]: {msg}") + +def p_info(msg): + print(f"[INFO]: {msg}") + +def p_warn(msg): + print(f"[WARNING]: {msg}") + + +def printHelp(): + currentFile = sys.argv[0] + print("\n") + print(f"--- TheHive Windows Controller Help Menu ---\n") + print(f"python {currentFile} --help\t\t\t:open this menu and exit") + print(f"python {currentFile} --generate-container\t:generate new docker container for TheHive") + print(f"python {currentFile} --prepare-psql\t\t:prepare PostgreSQL server") + print(f"python {currentFile} --remove-container\t\t:stop and remove docker container !DANGER!") + print(f"python {currentFile} --start-container\t\t:start the container") + print(f"python {currentFile} --stop-container\t\t:stop the container") + print(f"python {currentFile} --check-commands\t\t:check required command status") + print(f"python {currentFile} --sql-shell:\t\t:start sql shell for container") + print(f"python {currentFile} --install-pip-packaget\t:install required pip packagets") + print(f"python {currentFile} --wizard\t\t\t:otomatik indirme yardımcısı") + + print("\n") + + + + +def executeSelf(param:str): + _commands_is = [str(sys.executable.replace(os.sep, os.path.sep)), "windows.py", param] + + subprocess.run(_commands_is,stdout=sys.stdout,shell=True) + + +def startHive(): + _commands_is = [str(sys.executable.replace(os.sep, os.path.sep)), "main.py"] + subprocess.run(_commands_is,shell=True, stdout=sys.stdout) + + + +def checkCommands(cmd:str) -> None: + + _commands_is = ["powershell","Get-Command", cmd ,"-ErrorAction", "SilentlyContinue"] + _err = "" + _std_out = "" + commandStatus = subprocess.run(_commands_is,capture_output=True,shell=True) + + if commandStatus.returncode != 0: + p_error(f"{cmd} not found, install and add path !") + print(commandStatus.returncode) + sys.exit(1) + else: + p_info(f"{cmd} detected the system, good...") + + + +if not os.path.exists(CONFIG_PATH): + p_error(f"Config file not found: {CONFIG_PATH}") + sys.exit(-1) + + +with open(CONFIG_PATH, "r") as configFile: + JsonData = json.loads(configFile.read()) + + +p_info(f"Reading Config File: {CONFIG_PATH}") + +databaseNmae = JsonData["database_config"]["database"] +databasePassword = JsonData["database_config"]["password"] +databaseUser = JsonData["database_config"]["user"] +databaseHostname = JsonData["database_config"]["host"] +databasePort = JsonData["database_config"]["port"] + +databaseSchemaPath = JsonData["database_schema"] +databaseMaxConnection = 500 +containerPackageName ="postgres" # container package name + +WindowsBinaryPath = "binary" + os.path.sep + "windows" + os.path.sep + +# reference! +# -d -p 5432:$db_port -e POSTGRES_PASSWORD=$db_password $container_package_name -N $postgre_max_connections + + +containerNmae = databaseNmae + "-postresql-container" + + +# reference +# docker exec -t $container_name psql -p $db_port -h $db_hostname -U $db_username -c "CREATE DATABASE \"$db_name\";" + +# reference +# docker exec -t $container_name psql -p $db_port -h $db_hostname -U $db_username -d "$db_name" -f $CONTAINER_SCHEMA_PATH + + + + +def stopContainer(): + _command = [ + "powershell", "docker", "stop", containerNmae + ] + + commandStatus = subprocess.run(_command,capture_output=True,shell=True) + + if commandStatus.returncode != 0: + p_error(f"container durdurma işlemi başarısız oldu!\t{containerNmae}") + print(f"*"*100) + print(commandStatus.stderr.decode("utf-8")) + print(f"*"*100) + sys.exit(2) + else: + p_info(f"Başarıyla duruldu:\t{containerNmae}") + + +def startContainer(): + _command = [ + "powershell", "docker", "start", containerNmae + ] + + commandStatus = subprocess.run(_command,capture_output=True,shell=True) + + if commandStatus.returncode != 0: + p_error(f"container başlatma işlemi başarısız oldu!\t{containerNmae}") + print(f"*"*100) + print(commandStatus.stderr.decode("utf-8")) + print(f"*"*100) + sys.exit(2) + else: + p_info(f"Başarıyla başlatıldı:\t{containerNmae}") + + + +def preparePsql(): + _command = [ + "powershell", "docker", "exec", "-t", str(containerNmae), "psql", "-p" ,str(databasePort), + "-h", str(databaseHostname), "-U", str(databaseUser), f"""--command "CREATE DATABASE {databaseNmae}" """ + ] + p_info(f"Making new database: {databaseNmae}") + commandStatus = subprocess.run(_command,capture_output=True,shell=True) + + if commandStatus.returncode != 0: + p_error("PostgreSQL preparing işleminde hata oldu!") + print(f"*"*100) + print(commandStatus.stderr.decode("utf-8")) + print(commandStatus.stdout.decode("utf-8")) + print(f"*"*100) + sys.exit(2) + + _command = [ + "powershell", "docker", "exec", "-t", str(containerNmae), "psql", "-p", str(databasePort), "-h", str(databaseHostname), + "-d", str(databaseNmae), "-f", databaseSchemaPath + ] + + p_info(f"Executing schema: {_command}") + commandStatus = subprocess.run(_command,capture_output=True,shell=True) + + if commandStatus.returncode != 0: + p_error("PostgreSQL .sql import işleminde hata oldu!") + print(f"*"*100) + print(commandStatus.stderr.decode("utf-8")) + print(f"*"*100) + sys.exit(2) + + p_info("PostgreSQL hazır!") + + + +def installPackage(package:str) -> None: + _command = ["powershell", "python", "-m", "pip", "install", package] + commandStatus = subprocess.run(_command,capture_output=True,shell=True) + + if commandStatus.returncode != 0: + p_error(f"indirme işlemi başarısız oldu!\t{package}") + print(f"*"*100) + print(commandStatus.stderr.decode("utf-8")) + print(f"*"*100) + sys.exit(2) + else: + p_info(f"Başarıyla indirildi:\t{package}") + +def installPipPackaget(): + + + + + with open("requirements.txt", "r",encoding="utf-8") as pipFile: + p_info("pip paketleri kuruluyor...") + for line in pipFile: + line = line.strip() + + if line == "insightface": + p_warn(f"Daha sonra indirilecek:\t{line}") + continue + + installPackage(line) + + + + p_info("Gereksiz kaynak harcanmasın diye önceden derlenmiş paketlere geçildi...") + + for packaget in os.listdir(WindowsBinaryPath): + if packaget.endswith(".whl"): + installPackage(package=str(WindowsBinaryPath+packaget)) + + p_info("işlem tamamlandı") + + +def generateDocker(): + + _command = ["powershell", "docker", "run", "--name", containerNmae, "-d", "-p", f"5432:{databasePort}", + "-e",f"POSTGRES_PASSWORD={databasePassword}", str(containerPackageName), "-N" ,str(databaseMaxConnection) ] + + commandStatus = subprocess.run(_command,capture_output=True,shell=True) + + if commandStatus.returncode != 0: + p_error("Yeni docker container oluşturma işleminde hata oldu!") + print(f"*"*100) + print(commandStatus.stderr.decode("utf-8")) + print(f"*"*100) + sys.exit(2) + return + else: + p_info("Yeni docker container başarıyla oluşturuldu!") + return + + + +if len(sys.argv) < 2: + printHelp() + sys.exit(1) + + +currentParam = sys.argv[1] + + + +if currentParam.lower() == "--help": + printHelp() + sys.exit(0) + + +elif currentParam == "--generate-container": + generateDocker() + +elif currentParam == "--prepare-psql": + preparePsql() + +elif currentParam == "--install-pip-packaget": + installPipPackaget() + +elif currentParam == "--start-container": + startContainer() + +elif currentParam == "--stop-container": + stopContainer() + +elif currentParam == "--start-hive": + startHive() + +elif currentParam == "--wizard": + p_info("Otomatik indirme başlatılıyor...") + + executeSelf("--check-commands") + executeSelf("--install-pip-packaget") + executeSelf("--generate-container") + p_info("container ın stabil olması için 10 saniye uyku moduna girildi...") + time.sleep(10) + executeSelf("--prepare-psql") + executeSelf("--start-hive") + + +elif currentParam == "--check-commands": + p_info("Checking Required Commands ...") + checkCommands("docker") + checkCommands("pip") + sys.exit(0) + + +