Changes to nmap scripts

Jonathan Hodgson 5 years ago
parent b8f4a36858
commit 5638481d1a
  1. 6
      bin/.bin/nmap/nmap-clean
  2. 6
      bin/.bin/nmap/nmap-get
  3. 35
      bin/.bin/nmap/nmap-get-json

@ -0,0 +1,6 @@
#!/usr/bin/env bash
cat | grep -v 'host down' |\
grep -v Increa |\
grep -v Ignoring |\
grep -v '^#'

@ -1,8 +1,4 @@
#!/usr/bin/env bash
cat | grep -v 'host down' |\
grep -v Increa |\
grep -v Ignoring |\
grep -v '^#' |\
awk -v RS="\n\n" -v ORS="\n\n" '{if ($0 ~ "'"$1"'" ) print $0}'
cat | awk -v RS="\n\n" -v ORS="\n" '{gsub("\n","§",$0); print $0}' | grep "$@" | sed 's/$/\n/' | sed 's/§/\n/g'

@ -38,6 +38,37 @@ function print_basic_info(){
#| [select(."@attributes".protocol)]
}
function print_with_match(){
local match=$1
echo $json | # Echo the full json file
jq ' if ( .host | type ) == "object" then [ .host ] else .host end ' | # Get the hosts as an array (even if there is only one
#jq '.[9]'
#jq '[ .[9] | {
# address: .address."@attributes".addr,
# domains: .hostnames.hostname."@attributes".name,
# port: {
# tcp : (try ( [ .ports.port[] | select( ."@attributes".protocol == "tcp" ) | select( .service."@attributes".name | test("'"$match"'; "i") ) | {
# port: ."@attributes".portid,
# service: .service."@attributes",
# } ] ) catch null ),
# udp : (try ( [ .ports.port[] | select( ."@attributes".protocol == "udp" ) | {
# port: ."@attributes".portid,
# service: .service."@attributes",
# } ] ) catch null )
# }
#} ]'
jq '[ .[9] | {
address: .address."@attributes".addr,
domains: .hostnames.hostname."@attributes".name,
port: {
tcp : [ .ports.port | {
port: .,
service: .service."@attributes",
} ],
}
} ]'
}
if [ -n "$1" ] ; then
case "$1" in
-h|--help)
@ -48,5 +79,9 @@ if [ -n "$1" ] ; then
print_basic_info
exit 0
;;
*)
print_with_match "$@"
exit 0
;;
esac
fi

Loading…
Cancel
Save