From 0d5cb1161c143097599616f519a5350c118d6c14 Mon Sep 17 00:00:00 2001 From: Arhan002 <129582801+Arhan002@users.noreply.github.com> Date: Sat, 1 Feb 2025 13:06:37 +0530 Subject: [PATCH 1/4] Update main.py --- main.py | 75 ++++++++++++++++++++++----------------------------------- 1 file changed, 29 insertions(+), 46 deletions(-) diff --git a/main.py b/main.py index b82befc..887c422 100644 --- a/main.py +++ b/main.py @@ -1,61 +1,44 @@ import os import time import pyfiglet +import streamlit as st -def run_PE(): - file = input("Enter the path and name of the file : ") - os.system("python3 Extract/PE_main.py {}".format(file)) +def run_PE(file): + os.system(f"python3 Extract/PE_main.py {file}") def run_URL(): os.system('python3 Extract/url_main.py') -def exit(): - os.system('exit') +def main(): + st.title(pyfiglet.figlet_format("Malware Detector")) + st.subheader("Welcome to antimalware detector") -def start(): - print(pyfiglet.figlet_format("Malware Detector")) - print(" Welcome to antimalware detector \n") - print(" 1. PE scanner") - print(" 2. URL scanner") - print(" 3. Exit\n") + menu = ["PE Scanner", "URL Scanner", "Exit"] + choice = st.sidebar.selectbox("Select option", menu) - select = int(input("Enter your choice : ")) - - if (select in [1,2,3]): - - if(select == 1): - run_PE() - choice = input("Do you want to search again? (y/n)") - if(choice not in ['Y','N','n','y']): - print("Bad input\nExiting...") - time.sleep(3) - exit() + if choice == "PE Scanner": + file = st.text_input("Enter the path and name of the file:") + if file: + run_PE(file) + again = st.radio("Do you want to search again?", ('Yes', 'No')) + if again == 'Yes': + main() # Restart the main function else: - if(choice == 'Y' or 'y'): - start() - elif(choice == 'N' or 'n'): - exit() - + st.stop() # Exit the app - elif(select == 2): + elif choice == "URL Scanner": + if st.button('Run URL Scanner'): run_URL() - choice = input("Do you want to search again? (y/n)") - if(choice not in ['Y','N','n','y']): - print("Bad input\nExiting...") - time.sleep(3) - exit() + again = st.radio("Do you want to search again?", ('Yes', 'No')) + if again == 'Yes': + main() # Restart the main function else: - if(choice == 'Y' or 'y'): - start() - else: - exit() - - else: - exit() - else: - print("Bad input\nExiting...") - time.sleep(3) - exit() - -start() + st.stop() # Exit the app + + elif choice == "Exit": + st.write("Exiting...") + st.stop() # Stop the Streamlit app + +if __name__ == "__main__": + main() From 61a154976dcf9810d0e77182188cb139aa70f61f Mon Sep 17 00:00:00 2001 From: Kabir Dhruw <34811605+Kiinitix@users.noreply.github.com> Date: Sat, 1 Feb 2025 14:26:25 +0530 Subject: [PATCH 2/4] Update Dockerfile --- Dockerfile | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 43ee9b2..5c6781c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,4 +6,8 @@ RUN pip3 install -r requirements.txt COPY . . -CMD ["python3", "./main.py"] \ No newline at end of file +EXPOSE 8501 + +HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health + +ENTRYPOINT ["streamlit", "run", "main.py", "--server.port=8501", "--server.address=0.0.0.0"] From 9962dc5aa733913e96f465f92709b17ca0ddd865 Mon Sep 17 00:00:00 2001 From: Kabir Dhruw <34811605+Kiinitix@users.noreply.github.com> Date: Sat, 1 Feb 2025 14:26:43 +0530 Subject: [PATCH 3/4] Update requirements.txt --- requirements.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/requirements.txt b/requirements.txt index 396c6d2..24efef0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -8,5 +8,6 @@ pytz==2023.3 scikit-learn==0.24.1 scipy==1.10.1 six==1.16.0 +streamlit threadpoolctl==3.1.0 tzdata==2023.3 From 6ed549fb8c9bb5c4fbbbfb9f9f3d66bab931d4df Mon Sep 17 00:00:00 2001 From: Kabir Dhruw <34811605+Kiinitix@users.noreply.github.com> Date: Sat, 1 Feb 2025 14:27:24 +0530 Subject: [PATCH 4/4] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 85c558e..9e4ccd2 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ After pushing the changes you are now good to send the pull request and after ev git clone https://github.com/Kiinitix/Malware-Detection-using-Machine-learning.git cd Malware-Detection-using-Machine-learning docker build -t py-md . -docker run -ti py-md +docker run -p 8501:8501 -ti py-md ``` Thanks for reading!