# !/bin/python
# -*- coding: utf-8 -*-
u"""SecureTea Social Engineering
Project:
    ╔═╗┌─┐┌─┐┬ ┬┬─┐┌─┐╔╦╗┌─┐┌─┐
    ╚═╗├┤ │  │ │├┬┘├┤  ║ ├┤ ├─┤
    ╚═╝└─┘└─┘└─┘┴└─└─┘ ╩ └─┘┴ ┴
    Author: Digvijay Bhosale <digvijayb1729@gmail.com> August 15 2021
    Version: 1.0
    Module: SecureTea
"""

import os
import json
from securetea.lib.malware_analysis.fileAnalysis import FileAnalyser
from securetea.lib.malware_analysis.malwareAnalysis import MalwareAnalysis

i = 0
filename = ''
same_file = 'n'

if __name__ == '__main__':
    while True:
        if i == 1:  # so that this will run after the first loop runs
            try:
                same_file = input('Use same file? (Y/n)') or 'y'  # makes UX better by not making select same file again
            except KeyboardInterrupt:
                print("KeyboardInterrupt Detected. Quitting now ...")

        if same_file.lower() == 'n':  # get new file if user wants new file
            filename = ''
            i = 0
            try:
                pass
                filename = input(
                    "File to check for malware (Enter complete path if file not in directory of script) : ")
            except KeyboardInterrupt:
                print("KeyboardInterrupt Detected. Quitting now ...")
                exit(0)

            if filename.lower().strip() == 'q' or filename.lower() == 'quit' or filename.lower() == 'exit':
                print("Thank you for using SecureTea Malware Analysis Tool")
                exit()

            if os.path.isfile(filename):
                pass
            else:
                print('Given Filename does not exist. ')
                continue

        file = open(filename, 'r')
        action = ''
        try:
            action = input('f/F - Steganographic File Analysis of Suspicious file\n'
                           'm/M - Malware Analysis of Suspicious file\n'
                           'a/A - Steg and Malware analysis\n'
                           'q/Q - Quit\n'
                           '\t:')
        except KeyboardInterrupt:
            print("KeyboardInterrupt Detected. Quitting now ...")
            exit(0)

        if action.lower() == 'f':
            f_analysis = FileAnalyser(file)
            f_analysis.start_analysis()
        elif action.lower() == 'm':
            m_analysis = MalwareAnalysis(file, filename)
            m_analysis.runner()
        elif action.lower() == 'a':
            f_analysis = FileAnalyser(file)
            f_analysis.start_analysis()
            m_analysis = MalwareAnalysis(file, filename)
            m_analysis.runner()
        elif action.lower() == 'q':
            print("Thank you for using SecureTea Malware Analysis Tool")
            exit()
        else:
            print('Incorrect Option selected')

        i = 1  # after first loop, i =1
