Skip to content
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

shared/ips.txt - last IP requires a endline character inorder to be scanned 🇺🇦 #21

Open
vincentclee opened this issue Nov 22, 2019 · 2 comments

Comments

@vincentclee
Copy link

Scenario 1: File with endline character
shared/ips.txt

$ hexdump -C shared/ips.txt
00000000  31 2e 31 2e 31 2e 31 0a  38 2e 38 2e 38 2e 38 0a  |1.1.1.1.8.8.8.8.|
00000010

Scenario 2: File without endline character
shared/ips.txt

$ hexdump -C shared/ips.txt
00000000  31 2e 31 2e 31 2e 31 0a  38 2e 38 2e 38 2e 38     |1.1.1.1.8.8.8.8|
0000000f

run

$ make start
docker run --name flan_1574459039 -v /Users/vincentclee/git/flan/shared:/shared flan_scan
# Nmap 7.70 scan initiated Fri Nov 22 21:44:00 2019 as: nmap -sV -oX /shared/xml_files/2019.11.22-21.44/1.1.1.1.xml -oN - -v1 --script=vulners/vulners.nse 1.1.1.1
Nmap scan report for one.one.one.one (1.1.1.1)
Host is up (0.00042s latency).
All 1000 scanned ports on one.one.one.one (1.1.1.1) are filtered

Read data files from: /usr/bin/../share/nmap
Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
# Nmap done at Fri Nov 22 21:44:12 2019 -- 1 IP address (1 host up) scanned in 11.93 seconds
@ghost
Copy link

ghost commented Nov 24, 2019

This problem also occurs with python 2.7 on the latest version of Raspbian

@root360-AndreasUlm
Copy link

The problem is not in python but in the run.sh logic:

$ echo -ne "a\nb" > shared/ips.txt
$ (while IFS='' read -r line;do echo "$line";done < shared/ips.txt)
a
$ cat -A shared/ips.txt
a$
b

Because 'read' by default uses newline as delimiter it only reads lines that have a newline at the end of the line.
A possible solution is to use a command that adds a newline to every printed line, e.g.
$ while read -r line;do echo "$line";done < <(grep "" shared/ips.txt) (source: https://stackoverflow.com/a/31397871/7888054)

If this solution is ok for @cloudflare I could create a PR.

@vincentclee vincentclee changed the title shared/ips.txt - last IP requires a endline character inorder to be scanned shared/ips.txt - last IP requires a endline character inorder to be scanned 🇺🇦 Jan 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants