Skip to content

Update main.py #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ RUN pip3 install -r requirements.txt

COPY . .

CMD ["python3", "./main.py"]
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"]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
75 changes: 29 additions & 46 deletions main.py
Original file line number Diff line number Diff line change
@@ -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()

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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