Skip to content

Commit

Permalink
Android Analytics basically activated & e-mail information update
Browse files Browse the repository at this point in the history
  • Loading branch information
MehmetYukselSekeroglu committed Mar 4, 2024
1 parent bc315e7 commit 42442f3
Show file tree
Hide file tree
Showing 13 changed files with 204 additions and 102 deletions.
11 changes: 6 additions & 5 deletions guilib/AndroidAnlysisScreen.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ def setupUi(self, AndroidAnlysisWidget):
self.tab.setObjectName("tab")
self.gridLayout_2 = QtWidgets.QGridLayout(self.tab)
self.gridLayout_2.setObjectName("gridLayout_2")
self.label = QtWidgets.QLabel(self.tab)
self.label.setMaximumSize(QtCore.QSize(16777215, 21))
self.label.setObjectName("label")
self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1)
self.widget_2 = QtWidgets.QWidget(self.tab)
self.widget_2.setObjectName("widget_2")
self.gridLayout_3 = QtWidgets.QGridLayout(self.widget_2)
Expand All @@ -44,6 +40,7 @@ def setupUi(self, AndroidAnlysisWidget):
self.pushButton_selectFile.setObjectName("pushButton_selectFile")
self.gridLayout_3.addWidget(self.pushButton_selectFile, 2, 1, 1, 1)
self.textBrowser_logConsole = QtWidgets.QTextBrowser(self.widget_2)
self.textBrowser_logConsole.setStyleSheet("font: 12pt \"Hack\";")
self.textBrowser_logConsole.setObjectName("textBrowser_logConsole")
self.gridLayout_3.addWidget(self.textBrowser_logConsole, 5, 0, 1, 7)
self.line_2 = QtWidgets.QFrame(self.widget_2)
Expand All @@ -68,6 +65,10 @@ def setupUi(self, AndroidAnlysisWidget):
self.label_2.setObjectName("label_2")
self.gridLayout_3.addWidget(self.label_2, 0, 1, 1, 2)
self.gridLayout_2.addWidget(self.widget_2, 1, 0, 1, 1)
self.label = QtWidgets.QLabel(self.tab)
self.label.setMaximumSize(QtCore.QSize(16777215, 21))
self.label.setObjectName("label")
self.gridLayout_2.addWidget(self.label, 0, 0, 1, 1)
self.tabWidget.addTab(self.tab, "")
self.tab_2 = QtWidgets.QWidget()
self.tab_2.setObjectName("tab_2")
Expand All @@ -81,14 +82,14 @@ def setupUi(self, AndroidAnlysisWidget):
def retranslateUi(self, AndroidAnlysisWidget):
_translate = QtCore.QCoreApplication.translate
AndroidAnlysisWidget.setWindowTitle(_translate("AndroidAnlysisWidget", "Form"))
self.label.setText(_translate("AndroidAnlysisWidget", "<html><head/><body><p align=\"center\">Android Anlysis Toolkit</p></body></html>"))
self.checkBox_sendVT.setText(_translate("AndroidAnlysisWidget", "Send to VirusTotal"))
self.pushButton_saveReport.setText(_translate("AndroidAnlysisWidget", "Save Report"))
self.pushButton_startAnlysis.setText(_translate("AndroidAnlysisWidget", "Start Anlysis"))
self.pushButton_selectFile.setText(_translate("AndroidAnlysisWidget", "Select File"))
self.label_3.setText(_translate("AndroidAnlysisWidget", "Result & Log Console:"))
self.pushButton_stopAnlysis.setText(_translate("AndroidAnlysisWidget", "Stop Anlysis"))
self.label_2.setText(_translate("AndroidAnlysisWidget", "Target File:"))
self.label.setText(_translate("AndroidAnlysisWidget", "<html><head/><body><p align=\"center\">Android Anlysis Toolkit</p></body></html>"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), _translate("AndroidAnlysisWidget", "Anlysis Page"))
self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_2), _translate("AndroidAnlysisWidget", "Tech Information"))

Expand Down
125 changes: 57 additions & 68 deletions guilib/AndroidAnlysis_controller.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from guilib.AndroidAnlysisScreen import Ui_AndroidAnlysisWidget
from guilib.html_text_generator import html_draft

from hivelibrary.AndroidTools import androguard_tools
from hivelibrary.hash_tools import all_hash

from hivelibrary.database_tools import check_exists_systemTable,connection_function
from hivelibrary.psqlConfig import POSTGRESQL_CONFIG
from hivelibrary.env import VIRUSTOTAL_API_KEY
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
import os

DEFAULT_SPACE:int="30"

"""
*** ANDROID ANALIZ ARAC SETI ***
Expand All @@ -28,28 +28,16 @@

class backendWorker(QThread):
threadSignal = pyqtSignal(dict)


def __init__(self, targetApkPath:str):
super().__init__()

self.targetApkFile = targetApkPath


def __runningReturner(self, message:str):
return self.threadSignal.emit({
"success":None,
"end":False,
"message":message,

})
return self.threadSignal.emit({"success":None,"end":False,"message":message,})

def __finalyReturner(self, success:bool=False, end:bool=True, message:str=None):
return self.threadSignal.emit({
"success":success,
"end":end,
"message":message
})
return self.threadSignal.emit({"success":success,"end":end,"message":message})

def run(self):
general_iformation = androguard_tools.get_information_standard(apk_path=self.targetApkFile)
Expand All @@ -59,9 +47,7 @@ def run(self):
self.__finalyReturner(success=False, end=True, message=html_draft.gen_error_text(general_iformation[1]))
return


apk_info = general_iformation[1]

apk_name = apk_info[0]
packet_anem = apk_info[1]
apk_target_sdk = apk_info[2]
Expand All @@ -78,69 +64,57 @@ def run(self):
included_files_list = apk_info[13]


RETURN_TEXT = """"""
RETURN_TEXT += f"""<B>FILE PATH: </B>{self.targetApkFile}\n\n"""
RETURN_TEXT += f"""<B>APK SHA-1 HASH: </B>{hash_information["sha1"]}\n"""
RETURN_TEXT += f"""<B>APK SHA-256 HASH: </B>{hash_information["sha256"]}\n"""
RETURN_TEXT += f"""<B>APK MD-5 HASH: </B>{hash_information["md5"]}\n\n"""
RETURN_TEXT += f"""<B>APK NAME: </B>{apk_name}\n"""
RETURN_TEXT += f"""<B>PACKAGE NAME: </B>{packet_anem}\n"""
RETURN_TEXT += f"""<B>TARGET SDK: </B>{apk_target_sdk}\n"""
RETURN_TEXT += f"""<B>MIN SDK: </B>{apk_min_sdk} \n"""
RETURN_TEXT += f"""<B>MAX SDK: </B>{apk_max_sdk} \n"""
RETURN_TEXT += f"""<B>INTERNAL VERSION: </B>{apk_internalVersion} \n"""
RETURN_TEXT += f"""<B>DISPLAYED VERSION: </B>{apk_displayedVersion} \n"""
RETURN_TEXT += f"""<B>SIGNATURE V1 ISSIGNED: </B>{apk_v1_issigned} \n"""
RETURN_TEXT += f"""<B>SIGNATURE V2 ISSIGNED: </B>{apk_v2_issigned}\n"""
RETURN_TEXT += f"""<B>SIGNATURE V3 ISSIGNED: </B>{apk_v3_issigned} \n\n"""


RETURN_TEXT = f"""
[ INFO ] FILE PATH:{self.targetApkFile}<br>
[ INFO ] DATE:None<br>
<br>
[ INFO ] HASHES:<br>
MD-5: {hash_information["md5"]}<br>
SHA-1: {hash_information["sha1"]}<br>
SHA-256: {hash_information["sha256"]}<br>
<br>
[ INFP ] PACKAGE INFORMATION:<br>
<br>
Apk Name: {apk_name}<br>
Package Name: {packet_anem}<br>
Displayed Version: {apk_displayedVersion}<br>
Internal Version: {apk_internalVersion}<br>
Target SDK: {apk_target_sdk}<br>
Minimum SDK: {apk_min_sdk}<br>
Maximum SDK: {apk_max_sdk}<br>
V1 Signature: {apk_v1_issigned}<br>
V2 Signature: {apk_v2_issigned}<br>
V3 Signature: {apk_v3_issigned}<br><br>"""



if len(apk_services_list) > 0:
RETURN_TEXT += """[ INFO ] SERVICES:<br><br>"""

RETURN_TEXT += """<B>[ SERVICES ]</B>\n"""
for file in apk_services_list:
RETURN_TEXT += f"""{file}<br>"""

RETURN_TEXT += "<br><br>"
RETURN_TEXT += f"""{file}\n"""
RETURN_TEXT += """\n\n"""
else:
RETURN_TEXT += """[ INFO ] NO SERVICES<br><br>"""
RETURN_TEXT += """<B>[ SERVICES ]: No service detected.</B>\n"""

if len(apk_permissions_list) > 0:
RETURN_TEXT += """[ INFO ] PERMISSIONS:<br><br>"""

RETURN_TEXT += """<B>[ PERMISSIONS ]</B>\n"""
for file in apk_permissions_list:
RETURN_TEXT += f"""{file}<br>"""

RETURN_TEXT += "<br><br>"
RETURN_TEXT += f"""{file}\n"""
RETURN_TEXT += """\n\n"""
else:
RETURN_TEXT += """[ INFO ] NO PERMISSIONS<br><br>"""



RETURN_TEXT += """<B>[ PERMISSIONS ]: No permissions detected.</B>\n"""

if len(included_librarys_list) > 0:
RETURN_TEXT += """[ INFO ] INCLUDED LIBRARY:<br><br>"""

RETURN_TEXT += """<B>[ INCLUDED LIBRARYS ]</B>\n"""
for file in included_librarys_list:
RETURN_TEXT += f"""{file}<br>"""

RETURN_TEXT += "<br><br>"
RETURN_TEXT += f"""{file}\n"""
RETURN_TEXT += """\n\n"""
else:
RETURN_TEXT += """[ INFO ] NO INCLIDED LIBRARY<br><br>"""



RETURN_TEXT += """<B>[ INCLUDED LIBRARYS ]: No included library detected.</B>\n"""

if len(included_files_list) > 0:
RETURN_TEXT += """<B>[ INCLUDED FILES ]</B>\n"""
for file in included_files_list:
RETURN_TEXT += f"""{file}\n"""
RETURN_TEXT += """\n\n"""
else:
RETURN_TEXT += """<B>[ INCLUDED FILES ]: No included library detected.</B>\n"""


RETURN_TEXT = RETURN_TEXT.replace("\n","<br>")
self.__runningReturner(message=RETURN_TEXT)


Expand All @@ -155,17 +129,33 @@ def __init__(self):
self.setWindowTitle("Android Anlysis")
self.AndroidPage.lineEdit_showTargetPath.setDisabled(True)

self.databaseCnn, self.databaseCursor = connection_function(db_config_dict=POSTGRESQL_CONFIG)

# buton sinyalleri slolata bağlandı
self.AndroidPage.pushButton_selectFile.clicked.connect(self.selectTargetFile)
self.AndroidPage.pushButton_startAnlysis.clicked.connect(self.startAnlysis)
self.AndroidPage.pushButton_stopAnlysis.clicked.connect(self.stopAnlysis)
self.AndroidPage.pushButton_saveReport.clicked.connect(self.saveReport)
self.AndroidPage.checkBox_sendVT.stateChanged.connect(self.handleVirusTotal)

# global değişkenler tanımlandı
self.BackendWorkerThread = QThread()
self.SelectedTargetFile = None
self.sendVT = False

def handleVirusTotal(self):
if not self.AndroidPage.checkBox_sendVT.isChecked():
return

vt_api_key_status = check_exists_systemTable(db_curosr=self.databaseCursor,sql_key=VIRUSTOTAL_API_KEY)
if not vt_api_key_status[0]:
get_user_answer = QMessageBox.question(self,"VirusTotal Api Key Not Found",
"""Do you want to configure the VirusTotal API now?""",
QMessageBox.StandardButton.Yes | QMessageBox.StandardButton.No, QMessageBox.StandardButton.No)

if get_user_answer != QMessageBox.StandardButton.Yes:
self.sendVT = False
self.AndroidPage.checkBox_sendVT.setChecked(False)


def selectTargetFile(self) -> None:
Expand All @@ -186,7 +176,6 @@ def selectTargetFile(self) -> None:
self.AndroidPage.lineEdit_showTargetPath.setText("Ivalid file selections, proccess stopped")
self.SelectedTargetFile = None
return

# seçim doğru yapıldıysa değişkene atandı
self.AndroidPage.lineEdit_showTargetPath.setText(self.SelectedTargetFile)

Expand Down
8 changes: 8 additions & 0 deletions guilib/TheHive_mainWindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def setupUi(self, TheHve_MainWindow):
self.menuTurkey_Only.setObjectName("menuTurkey_Only")
self.menuExternel_Madules = QtWidgets.QMenu(self.menubar_menuController)
self.menuExternel_Madules.setObjectName("menuExternel_Madules")
self.menuAnalysis = QtWidgets.QMenu(self.menubar_menuController)
self.menuAnalysis.setObjectName("menuAnalysis")
TheHve_MainWindow.setMenuBar(self.menubar_menuController)
self.statusbar = QtWidgets.QStatusBar(TheHve_MainWindow)
self.statusbar.setObjectName("statusbar")
Expand Down Expand Up @@ -99,6 +101,8 @@ def setupUi(self, TheHve_MainWindow):
self.actionimport_module.setObjectName("actionimport_module")
self.actionBin_Lookup = QtWidgets.QAction(TheHve_MainWindow)
self.actionBin_Lookup.setObjectName("actionBin_Lookup")
self.actionAndroid_Static_Analysis = QtWidgets.QAction(TheHve_MainWindow)
self.actionAndroid_Static_Analysis.setObjectName("actionAndroid_Static_Analysis")
self.menuSecurity.addAction(self.actionChange_Login_Password)
self.menuOsintTools.addAction(self.actioniban_Parser)
self.menuOsintTools.addAction(self.actionreverse_ip_lookup)
Expand All @@ -115,12 +119,14 @@ def setupUi(self, TheHve_MainWindow):
self.menuTurkey_Only.addAction(self.actionTC_Calculator)
self.menuRegion_specific_only.addAction(self.menuTurkey_Only.menuAction())
self.menuExternel_Madules.addAction(self.actionimport_module)
self.menuAnalysis.addAction(self.actionAndroid_Static_Analysis)
self.menubar_menuController.addAction(self.menuSecurity.menuAction())
self.menubar_menuController.addAction(self.menuOsintTools.menuAction())
self.menubar_menuController.addAction(self.menuFile_operations.menuAction())
self.menubar_menuController.addAction(self.menuIdentify_Tools.menuAction())
self.menubar_menuController.addAction(self.menuRegion_specific_only.menuAction())
self.menubar_menuController.addAction(self.menuExternel_Madules.menuAction())
self.menubar_menuController.addAction(self.menuAnalysis.menuAction())

self.retranslateUi(TheHve_MainWindow)
self.tabWidget.setCurrentIndex(0)
Expand All @@ -139,6 +145,7 @@ def retranslateUi(self, TheHve_MainWindow):
self.menuRegion_specific_only.setTitle(_translate("TheHve_MainWindow", "Region specific only"))
self.menuTurkey_Only.setTitle(_translate("TheHve_MainWindow", "Türkey Only"))
self.menuExternel_Madules.setTitle(_translate("TheHve_MainWindow", "Externel Madules"))
self.menuAnalysis.setTitle(_translate("TheHve_MainWindow", "Analysis"))
self.actionChange_Login_Password.setText(_translate("TheHve_MainWindow", "Change Login Password"))
self.actioniban_Parser.setText(_translate("TheHve_MainWindow", "Iban parser"))
self.actionreverse_ip_lookup.setText(_translate("TheHve_MainWindow", "Reverse ip lookup"))
Expand All @@ -153,6 +160,7 @@ def retranslateUi(self, TheHve_MainWindow):
self.actionTC_Calculator.setText(_translate("TheHve_MainWindow", "TC Calculator"))
self.actionimport_module.setText(_translate("TheHve_MainWindow", "import module"))
self.actionBin_Lookup.setText(_translate("TheHve_MainWindow", "Bin lookup"))
self.actionAndroid_Static_Analysis.setText(_translate("TheHve_MainWindow", "Android Static Analysis"))
import main_icon_files_rc


Expand Down
76 changes: 76 additions & 0 deletions guilib/VirusTotalApiKeyConfigurationScreen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'raw_ui_files/ApiKeyConfigurationOnlyKeyScreen.ui'
#
# Created by: PyQt5 UI code generator 5.15.10
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again. Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_ApiKeyConfScreen(object):
def setupUi(self, ApiKeyConfScreen):
ApiKeyConfScreen.setObjectName("ApiKeyConfScreen")
ApiKeyConfScreen.resize(534, 142)
self.gridLayout = QtWidgets.QGridLayout(ApiKeyConfScreen)
self.gridLayout.setObjectName("gridLayout")
self.label_2 = QtWidgets.QLabel(ApiKeyConfScreen)
self.label_2.setStyleSheet("font: 11pt \"Hack\";")
self.label_2.setObjectName("label_2")
self.gridLayout.addWidget(self.label_2, 2, 0, 1, 1)
self.pushButton_startConfiguration = QtWidgets.QPushButton(ApiKeyConfScreen)
self.pushButton_startConfiguration.setStyleSheet("font: 11pt \"Hack\";")
self.pushButton_startConfiguration.setObjectName("pushButton_startConfiguration")
self.gridLayout.addWidget(self.pushButton_startConfiguration, 4, 0, 1, 1)
self.lineEdit_apiKeyInput = QtWidgets.QLineEdit(ApiKeyConfScreen)
self.lineEdit_apiKeyInput.setMinimumSize(QtCore.QSize(330, 31))
self.lineEdit_apiKeyInput.setStyleSheet("font: 11pt \"Hack\";")
self.lineEdit_apiKeyInput.setObjectName("lineEdit_apiKeyInput")
self.gridLayout.addWidget(self.lineEdit_apiKeyInput, 2, 1, 1, 3)
self.pushButton_exitScreen = QtWidgets.QPushButton(ApiKeyConfScreen)
self.pushButton_exitScreen.setStyleSheet("font: 11pt \"Hack\";")
self.pushButton_exitScreen.setObjectName("pushButton_exitScreen")
self.gridLayout.addWidget(self.pushButton_exitScreen, 4, 1, 1, 1)
self.label_apiServiceInfoMessage = QtWidgets.QLabel(ApiKeyConfScreen)
self.label_apiServiceInfoMessage.setMinimumSize(QtCore.QSize(0, 0))
self.label_apiServiceInfoMessage.setMaximumSize(QtCore.QSize(0, 0))
self.label_apiServiceInfoMessage.setStyleSheet("font: 12pt \"Hack\";")
self.label_apiServiceInfoMessage.setText("")
self.label_apiServiceInfoMessage.setObjectName("label_apiServiceInfoMessage")
self.gridLayout.addWidget(self.label_apiServiceInfoMessage, 1, 0, 1, 4)
self.label_3 = QtWidgets.QLabel(ApiKeyConfScreen)
self.label_3.setMinimumSize(QtCore.QSize(0, 0))
self.label_3.setStyleSheet("font: 11pt \"Hack\";")
self.label_3.setObjectName("label_3")
self.gridLayout.addWidget(self.label_3, 3, 0, 1, 2)
self.label = QtWidgets.QLabel(ApiKeyConfScreen)
self.label.setStyleSheet("font: 11pt \"Hack\";")
self.label.setObjectName("label")
self.gridLayout.addWidget(self.label, 0, 0, 1, 4)
spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem, 5, 1, 1, 1)

self.retranslateUi(ApiKeyConfScreen)
QtCore.QMetaObject.connectSlotsByName(ApiKeyConfScreen)

def retranslateUi(self, ApiKeyConfScreen):
_translate = QtCore.QCoreApplication.translate
ApiKeyConfScreen.setWindowTitle(_translate("ApiKeyConfScreen", "Form"))
self.label_2.setText(_translate("ApiKeyConfScreen", "Api Key:"))
self.pushButton_startConfiguration.setText(_translate("ApiKeyConfScreen", "Start Configuration"))
self.pushButton_exitScreen.setText(_translate("ApiKeyConfScreen", "Exit"))
self.label_3.setText(_translate("ApiKeyConfScreen", "Status:"))
self.label.setText(_translate("ApiKeyConfScreen", "<html><head/><body><p align=\"center\"><span style=\" font-weight:600;\">Configure Api Key</span></p></body></html>"))


if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
ApiKeyConfScreen = QtWidgets.QWidget()
ui = Ui_ApiKeyConfScreen()
ui.setupUi(ApiKeyConfScreen)
ApiKeyConfScreen.show()
sys.exit(app.exec_())
Empty file.
Loading

0 comments on commit 42442f3

Please sign in to comment.