cloudflare / flan

A pretty sweet vulnerability scanner
BSD 3-Clause "New" or "Revised" License
4.07k stars 289 forks source link

Error on first run #40

Open dellarte opened 4 years ago

dellarte commented 4 years ago

Hi,

I ran make build withour any error. Then i tested make start and got this error :

docker run --name flan_1574936755 -v /tmp/flan/shared:/shared flan_scan
mkdir: can't create directory '/shared/xml_files/2019.11.28-10.25': No such file or directory
/run.sh: line 34: can't open /shared/ips.txt: no such file
Traceback (most recent call last):
  File "/output_report.py", line 238, in <module>
    main()
  File "/output_report.py", line 224, in main
    for i, filename in enumerate(os.listdir(dirname)):
FileNotFoundError: [Errno 2] No such file or directory: '/shared/xml_files/2019.11.28-10.25'
sed: /shared/reports/report_2019.11.28-10.25.tex: No such file or directory
sed: /shared/reports/report_2019.11.28-10.25.tex: No such file or directory
sed: /shared/reports/report_2019.11.28-10.25.tex: No such file or directory
sed: /shared/reports/report_2019.11.28-10.25.tex: No such file or directory
root360-AndreasUlm commented 4 years ago

Did you use the folder structure provided by 'shared'-folder in the git to initialize your '/tmp/flan/shared'?

If not than that's the reason because the run logic currently expects that the shared folder has the following content:

dellarte commented 4 years ago

I scrupulously followed all the steps :

I'm on Windows, using WSL My docker version is Docker version 19.03.2, build 6a30dfc

adi928 commented 4 years ago

As @root360-AndreasUlm mentioned, you may have to create the folders 'xm_files' and 'reports' beforehand in your shared folder.

Zebradil commented 4 years ago

I have the same error. I'll go check the Makefile to see how to fix it and it's not a big deal, probably. What I'm concerned about is the instructions in README. There is nothing said about directory creation or something like this:

image

Zebradil commented 4 years ago

Hmm, it seems like the issue is not the same. The output is slightly different:

Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Mon Dec  9 16:26:01 2019 -- 256 IP addresses (6 hosts up) scanned in 5472.80 seconds
Traceback (most recent call last):
  File "/output_report.py", line 238, in <module>
    main()
  File "/output_report.py", line 229, in main
    parse_results(data)
  File "/output_report.py", line 113, in parse_results
    parse_host(h)
  File "/output_report.py", line 102, in parse_host
    parse_port(ip_addr, p)
  File "/output_report.py", line 86, in parse_port
    parse_script(ip_addr, port_num, app_name, scripts)
  File "/output_report.py", line 36, in parse_script
    script_table = script['table']['table']
TypeError: list indices must be integers or slices, not str
sed: /shared/reports/report_2019.12.09-14.54.tex: No such file or directory
sed: /shared/reports/report_2019.12.09-14.54.tex: No such file or directory
sed: /shared/reports/report_2019.12.09-14.54.tex: No such file or directory
sed: /shared/reports/report_2019.12.09-14.54.tex: No such file or directory
dellarte commented 4 years ago

There is no directory to create since they are present when this repo is cloned. The issue is still here :

root@mylaptop:/tmp/flan# ls -l
total 28
-rw-r--r-- 1 root root  411 Jan  2 10:36 Dockerfile
-rw-r--r-- 1 root root 1518 Jan  2 10:36 LICENSE
-rw-r--r-- 1 root root  172 Jan  2 10:36 Makefile
-rw-r--r-- 1 root root 5262 Jan  2 10:36 README.md
-rw-r--r-- 1 root root  287 Jan  2 10:36 aws_push.py
-rw-r--r-- 1 root root  214 Jan  2 10:36 gcp_push.py
drwxr-xr-x 1 root root 4096 Jan  2 10:36 kubernetes_templates
-rw-r--r-- 1 root root  397 Jan  2 10:36 latex_header.tex
-rw-r--r-- 1 root root 8488 Jan  2 10:36 output_report.py
-rwxr-xr-x 1 root root 1046 Jan  2 10:36 run.sh
drwxr-xr-x 1 root root 4096 Jan  2 10:40 shared
root@mylaptop:/tmp/flan# ls -l shared/
total 0
-rw-r--r-- 1 root root   15 Jan  2 10:37 ips.txt
drwxr-xr-x 1 root root 4096 Jan  2 10:36 reports
drwxr-xr-x 1 root root 4096 Jan  2 10:36 xml_files
dellarte commented 4 years ago

There is no directory to create since they are present when this repo is cloned. The issue is still here :

root@mylaptop:/tmp/flan# ls -l
total 28
-rw-r--r-- 1 root root  411 Jan  2 10:36 Dockerfile
-rw-r--r-- 1 root root 1518 Jan  2 10:36 LICENSE
-rw-r--r-- 1 root root  172 Jan  2 10:36 Makefile
-rw-r--r-- 1 root root 5262 Jan  2 10:36 README.md
-rw-r--r-- 1 root root  287 Jan  2 10:36 aws_push.py
-rw-r--r-- 1 root root  214 Jan  2 10:36 gcp_push.py
drwxr-xr-x 1 root root 4096 Jan  2 10:36 kubernetes_templates
-rw-r--r-- 1 root root  397 Jan  2 10:36 latex_header.tex
-rw-r--r-- 1 root root 8488 Jan  2 10:36 output_report.py
-rwxr-xr-x 1 root root 1046 Jan  2 10:36 run.sh
drwxr-xr-x 1 root root 4096 Jan  2 10:40 shared
root@mylaptop:/tmp/flan# ls -l shared/
total 0
-rw-r--r-- 1 root root   15 Jan  2 10:37 ips.txt
drwxr-xr-x 1 root root 4096 Jan  2 10:36 reports
drwxr-xr-x 1 root root 4096 Jan  2 10:36 xml_files

It seems it's a docker issue on windows. Volumes are not mount.. Working on it.

Powelljl commented 4 years ago

I'm having the same issue on my Ubuntu VM,

docker run --name flan_1583706873 -v "/shared:/shared:Z" flan_scan mkdir: can't create directory '/shared/xml_files/2020.03.08-22.34': No such file or directory /run.sh: line 34: can't open /shared/ips.txt: no such file Traceback (most recent call last): File "/output_report.py", line 72, in <module> main(*sys.argv[1:4], report_type='latex') File "/output_report.py", line 59, in main for entry in os.scandir(dirname): # type: os.DirEntry FileNotFoundError: [Errno 2] No such file or directory: '/shared/xml_files/2020.03.08-22.34' sed: /shared/reports/report_2020.03.08-22.34.tex: No such file or directory sed: /shared/reports/report_2020.03.08-22.34.tex: No such file or directory sed: /shared/reports/report_2020.03.08-22.34.tex: No such file or directory sed: /shared/reports/report_2020.03.08-22.34.tex: No such file or directory

It seems to output fine for me with docker build and docker run flan_scan, but don't get the output reports.

ghost commented 4 years ago

Can confirm the same issue exists on a vanilla debian 10 installation. Error on first attempt of make start. All dirs exist like they should.

root@flan:/home/jb/flan/shared# ls -lart total 36 drwxr-xr-x 2 jb jb 4096 Mar 9 11:54 xml_files drwxr-xr-x 2 jb jb 4096 Mar 9 11:54 reports drwxr-xr-x 6 jb jb 4096 Mar 9 11:54 .. -rw-r--r-- 1 jb jb 18149 Mar 9 12:01 ips.txt drwxr-xr-x 4 jb jb 4096 Mar 9 12:01 .

root@flan:/home/jb/flan# make start docker run --name flan_1583755701 -v "/shared:/shared:Z" flan_scan mkdir: can't create directory '/shared/xml_files/2020.03.09-12.08': No such file or directory /run.sh: line 34: can't open /shared/ips.txt: no such file Traceback (most recent call last): File "/output_report.py", line 72, in <module> main(*sys.argv[1:4], report_type='latex') File "/output_report.py", line 59, in main for entry in os.scandir(dirname): # type: os.DirEntry FileNotFoundError: [Errno 2] No such file or directory: '/shared/xml_files/2020.03.09-12.08' sed: /shared/reports/report_2020.03.09-12.08.tex: No such file or directory sed: /shared/reports/report_2020.03.09-12.08.tex: No such file or directory sed: /shared/reports/report_2020.03.09-12.08.tex: No such file or directory sed: /shared/reports/report_2020.03.09-12.08.tex: No such file or directory

nadinelyab commented 4 years ago

Hey @jboger and @Powelljl, I just merged a PR that might fix this. Can you try again?

Powelljl commented 4 years ago

Hey @nadinelyab

Sorry for the delay, yep all working now :).

ILPlais commented 3 years ago

Hello, I just clone the last repository (5b9276617ab3b9cd477cae27dc4b9e3559f7867d), so with the #54 merge from @nadinelyab. But I still have the directories' error.

lionel@lionel-X202E:~/Git/flan$ make start
docker run --rm --cap-drop=all --cap-add=NET_RAW --name flan_1620928724 -v "/home/lionel/Git/flan/shared:/shared:Z" flan_scan
mkdir: can't create directory '/shared/xml_files/2021.05.13-17.58': Permission denied
Failed to open XML output file /shared/xml_files/2021.05.13-17.58/1.1.1.1.xml for writing
QUITTING!
[…]
Traceback (most recent call last):
  File "/output_report.py", line 81, in <module>
    main(*sys.argv[1:4], report_type=report_format)
  File "/output_report.py", line 67, in main
    for entry in os.scandir(dirname):  # type: os.DirEntry
FileNotFoundError: [Errno 2] No such file or directory: '/shared/xml_files/2021.05.13-17.58'
sed: /shared/reports/report_2021.05.13-17.58.tex: No such file or directory
sed: /shared/reports/report_2021.05.13-17.58.tex: No such file or directory
sed: /shared/reports/report_2021.05.13-17.58.tex: No such file or directory
sed: /shared/reports/report_2021.05.13-17.58.tex: No such file or directory

For information, I have two warnings with make build:

WARNING: Running pip as root will break packages and permissions. You should install packages reliably by using venv: https://pip.pypa.io/warnings/venv
Cloning into '/usr/share/nmap/scripts/vulners'...

And

WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/main: No such file or directory
WARNING: Ignoring https://dl-cdn.alpinelinux.org/alpine/v3.13/community: No such file or directory

Someone has the same issue and how to fix it? Thanks.

g33k247 commented 3 years ago

I discovered that the xml_files folder had incorrect perms for "others". Once I corrected that issue, flan works great!

sebelk commented 3 years ago

I've found that chmoding with 777 and directories under shared it works, is that the expected behaviour?

AlanKK commented 3 years ago

I just had the same issue and chmoding with 777 fixed it for me too.

NouvelleEcosse commented 2 years ago

Following all instructions, I had similar permissions errors as those mentioned in this thread. I tried doing a chmod -R 777 on the shared directory and that fixed it for me.