Skip to content

Commit

Permalink
fix for nmap file parser (not properly assigned ip variable)
Browse files Browse the repository at this point in the history
  • Loading branch information
drwetter committed Jun 14, 2017
1 parent 7094c44 commit 4c73afe
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions testssl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12370,7 +12370,7 @@ nmap_to_plain_file() {
if [[ "$(head -1 "$FNAME")" =~ ( -oG )(.*) ]]; then
# yes, greppable
if [[ $(grep -c Status "$FNAME") -ge 1 ]]; then
[[ $(grep -c '\/open\/' $FNAME) -eq 0 ]] && \
[[ $(grep -c '\/open\/' "$FNAME") -eq 0 ]] && \
fatal "Nmap file $FNAME should contain at least one open port" -1
else
fatal "strange, nmap grepable misses \"Status\"" -1
Expand All @@ -12396,6 +12396,7 @@ nmap_to_plain_file() {
while read -r hosttxt ip round_brackets tmp ports_specs; do
grep -q "Status: " <<< "$ports_specs" && continue # we don't need this
grep -q '\/open\/tcp\/' <<< "$ports_specs" || continue # no open tcp at all for this IP --> move on
host_spec="$ip"
fqdn="${round_brackets/\(/}"
fqdn="${fqdn/\)/}"
if [[ -n "$fqdn" ]]; then
Expand All @@ -12404,10 +12405,8 @@ nmap_to_plain_file() {
if [[ "$tmp" == "$ip" ]]; then
host_spec="$fqdn"
fi
else
host_spec="$ip"
fi
while read oneline; do
while read -r oneline; do
# 25/open/tcp//smtp//<banner>/,
grep -q '\/open\/tcp\/' <<< "$oneline" || continue # no open tcp for this port on this IP --> move on
IFS=/ read -r port dontcare protocol dontcare1 <<< "$oneline"
Expand Down

0 comments on commit 4c73afe

Please sign in to comment.