malwaredllc / byob

An open-source post-exploitation framework for students, researchers and developers.
https://byob.dev
GNU General Public License v3.0
8.84k stars 2.1k forks source link

No module named 'flask' #713

Open audiofolks opened 1 month ago

audiofolks commented 1 month ago

is there a solution ??

Traceback (most recent call last): File "/home/onion/tools/byob/web-gui/run . py", line 1, in from buildyourownbotnet import create_app File "/home/onion/tools/byob/web-gui/buildyourownbotnet/init.py", line 2, in from flask import Flask ModuleNotFoundError: No module named 'flask'

audiofolks commented 1 month ago

note: This error originates from a subprocess, and is likely not a problem wit h pip. subprocess-exited-with-error error: pip subprocess to install build dependencies did not run successfully. exit code: 1 See above for output.

audiofolks commented 1 month ago

on my python versions(3.11.2): flask==2.1.3, numpy==1.24.2, opencv-python==4.8.1.78 and it worked

DuckyPolice commented 3 weeks ago

then import flask: pip install flask

Pixel-Aspect commented 1 week ago

Hello world! I'm new to this area of study, but I have been working on this issue by myself for 2-3 weeks. I recently came through to see if I could find a fix here, but instead, I found a lot of people with the same issue and no real solutions.

I was able to get the site up and running. (able to open the site at 127.0.0.1:5000) I wanted to double back and drop in what I did, in hope that it helps others. If it does not, please share as well!!

I will go through the process that I used, and try to explain as best I can.

In terminal: (as root)

First we need to try and fix the disconnect between APT and PIP, by removing EXTERNALLY-MANAGED from our python3 install change directory into /usr/bin/python3.11:

cd /usr/bin/python3.11

Next, when in the specified directory:

sudo rm EXTERNALLY-MANAGED

(This i believe is what fixed the main issue for me of APT and PIP fighting about which service is managing these downloads, and how they get saved etc..)

So now, when you are in your "byob/web-gui" directory and attempt to run: "python3 run.py", you get an error message. Something to the effect of:

root@parrot]─[/home/user/byob/web-gui] └──╼ #python3 run.py Traceback (most recent call last): File "/home/user/byob/web-gui/run.py", line 1, in from buildyourownbotnet import create_app File "/home/user/byob/web-gui/buildyourownbotnet/init.py", line 8, in from flask_login import LoginManager ModuleNotFoundError: No module named 'flask_login'

or something similar?

so, since you are in root already lets do this:

python3 -m venv venv

source venv/bin/activate

disclaimer (not an expert, barely competent, if at all) My understanding is that this command allows for a virtual environment (venv) to be created so that APT and PIP stop fighting, while you try and install the missing pieces. (if you have a better understanding, and can articulate, please feel free to correct)

Once that is done, try the command again:

python3 run.py

For me it did not run, and gave the same error. This is when I attempted to install the missing pieces with PIP:

sudo pip install flask_login

Now with the virtual environment (venv), and the removal of EXTERNALLY-MANAGED, i was able to install the packages, where before I was not. I would receive an error that defined 3 possible pivots to use, unfortunately none of them alone was what I needed.

So after that was installed I tried to run it again.... back to directory:

cd byob/web-gui

Once there, try to run the command:

python3 run.py

Again i was met with a similar error to the one we had with flask_login, but it was another package and no longer flask_login... this made me think maybe it took..?? So I followed the same process for every other missing package. While in the same directory, using the same command as before:

sudo pip install (insert particular package here)

I was able to install all missing packages.

and that was basically it. After every new install of a package from the requirements list (i.e. flask, Flask_Login, flask_wtf, etc...) i would try and run the command:

python3 run.py

from the byob/web-gui directory. Eventually I had all the packages that were missing and causing these errors.

I know this is a difficult read, but if you made it this far I hope it works for you! I know this is probably the most archaic method to solve this issue and there are probably 99 better ways to do this. This worked for me, let me know if it helps or hinders you!

Also important to note: After the initial connection, I was elated that it worked, but also at the end of my work day and week. I needed to pack up and leave for the day. When I returned Monday, I couldn't get back in and was getting the same messages... because I forgot to start the virtual environment.... repeat the steps above that we used to get the (venv) running:

python3 -m venv venv

source venv/bin/activate

After that, you should be able to log in again without issue. All the best!