blackbird icon indicating copy to clipboard operation
blackbird copied to clipboard

Not responding when running as web server

Open shaxiaozz opened this issue 2 years ago • 16 comments

Hi, here I am again

I'm trying to run blackbird in web mode using the "python blackbird.py --web" directive. The web interface can be opened normally. However, after entering "username" and clicking search, I have been stuck on the "Searching 131 sites for 'username'..." interface and have not returned. As shown below image

I can make sure my network is accessible because I do a command-style search ("python blackbird.py -u just") with success. As shown below image image

shaxiaozz avatar Jul 14 '22 02:07 shaxiaozz

In addition, you can see from F12 that an error occurs when the front-end js code calls the back-end

image

shaxiaozz avatar Jul 14 '22 04:07 shaxiaozz

Hi shaxiaozz!

Can you show me what error the server response gives please?

Thanks in advance!

p1ngul1n0 avatar Jul 19 '22 00:07 p1ngul1n0

Hi p1ngul1n0!Thank you very much for your reply

Check the flask log (debug=true enabled), but no obvious error message is reported.

Look at the source code combined with the F12 console output, it feels like a cross-domain problem, but I see the source code is already cross-domain processing.

I wonder if it's because I run Blackbird with Docker containers.....

Best Regards

shaxiaozz avatar Jul 19 '22 01:07 shaxiaozz

Please verify the HTTP response in network tab in F12.

p1ngul1n0 avatar Jul 19 '22 02:07 p1ngul1n0

Please see the screenshot below. image

You can visit this address: "http://103.210.21.46:5000/"

shaxiaozz avatar Jul 19 '22 02:07 shaxiaozz

Thanks!

For what i understand, this is happening because the FrontEnd was developed to always fetch localhost, so when you use it in a Docker the FrontEnd can't reach it.

p1ngul1n0 avatar Jul 19 '22 02:07 p1ngul1n0

Good.

How can I try to solve it?

shaxiaozz avatar Jul 19 '22 02:07 shaxiaozz

Unfortunately i don't have knowledge on Docker yet, so i can't tell if its possible to fix this error with some Docker container configuration or there is something to be done on FrontEnd.

p1ngul1n0 avatar Jul 19 '22 02:07 p1ngul1n0

I tried to change 127.0.0.1:5000 in FrontEnd to the domain name mode. Add host resolution to the container

shaxiaozz avatar Jul 19 '22 02:07 shaxiaozz

I tried to change 127.0.0.1:5000 in FrontEnd to the domain name mode. Add host resolution to the container

How were you able to change it? And does it help? My Docker is running behind a reverse Proxy on another machine. I request it over a domainname....normally this could be an easy fix...

I found static/js/Config/api.jsin the browser but I am unable to change original code as everything is minified. I got no experience with react, unfortunately. How can I review/change the FrontEnd code?

Pitastic avatar Aug 26 '22 08:08 Pitastic

bump... I'm happy to contribute if you provide js source code and/or build instructions...

Pitastic avatar Sep 12 '22 12:09 Pitastic

I got this same issue. It seems that the container does not work unless you explicitly go to http://127.0.0.1:9797. If you host this container on a network and browse to the page by the host's name, the query never completes.

So there's a workaround but that requires local/direct access to the server that's running the container.

yllekz avatar Sep 13 '22 17:09 yllekz

What workaround could that be? I think it is as simple as that: JS frontend should query the API on domain.tld instead of hardcoded localhost:port. But I am unable to fix already minified code...

Pitastic avatar Sep 13 '22 19:09 Pitastic

Hi!

Thanks for the considerations! So what would be the API domain? We don't have any, we only have the IP from the running machine. If you know about any Docker config that would fix that, please let me know, i didn't found one yet.

Thanks in advance!

p1ngul1n0 avatar Sep 13 '22 19:09 p1ngul1n0

Hi, thanks for answering!

From my understanding this problem cannot be fixed on the server side. So this has nothing to do with any docker settings.

The browser running the javascript fronted code is aware about the domain/ip of the hosting instance. Here we need to change the fixed 127.0.0.1 to a variable with this value.

Could you share the js files in an uncompressed form or give me a hint how to un-minify them? I can see the (false) request to 127.0.0.1 in the browser console but it just lead me to unreadable code...

Pitastic avatar Sep 14 '22 05:09 Pitastic

Hi all,

I have the same issue while not running in Docker but on an AWS machine. Machine is a stock RHEL 7.6 where I have installed blackbird (plus the dependencies obviously). I also believe this is due to the localhost IP address being hardcoded somewhere.

Is there a way to tell the web app to look for resources at another location than 127.0.0.1? image

Thanks! Issam

Issomane avatar Oct 07 '22 08:10 Issomane

Hi everyone!

The FrontEnd is made with React JS, i created a new repo for the FrontEnd code, so any contributors can view and help with this too.

@Pitastic you can visit it here.

p1ngul1n0 avatar Oct 24 '22 23:10 p1ngul1n0

Hi there !

I just had time to come back to this issue. I really just have a little clue of npm but the fix which was needed is very limited.

I made a Pull Request with these changes but was not able to test it with a running backend. However the code compiles in a node.js Docker.

Let me know what you think about it.

Cheers !

Pitastic avatar Jan 23 '23 13:01 Pitastic

Hi @shaxiaozz !

@Pitastic did a a awesome contribution with the FrontEnd code that was the root to this problem, can you please try again and see if the error still persists?

Thanks in advance!

p1ngul1n0 avatar Feb 05 '23 16:02 p1ngul1n0

@p1ngul1n0 Hi,p1ngul1n0 That's great, this issue has been resolved. As shown below。 image

Meanwhile, the following is my Dockerfile

FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir -p /app/blackbird
ADD . /app/blackbird
WORKDIR /app/blackbird
RUN  apt-get install  default-libmysqlclient-dev -y && \
    ln -sf /usr/share/zoneinfo/Asia/Shanghai  /etc/localtime
RUN pip install --upgrade pip  && \
        pip install -r requirements.txt
ENTRYPOINT ["python","blackbird.py","--web"]

shaxiaozz avatar Feb 06 '23 02:02 shaxiaozz