Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@freb
freb / .zshrc
Last active March 22, 2022 05:19
Bash functions for pentest tool output
nmap-uphosts() {
FILE=`realpath $1`
echo "
from lxml import etree
t = etree.parse('$FILE')
if \"-Pn\" in t.xpath(\"string(@args)\"): # port scan
hosts = t.xpath(\"/*/host[ports/port/state[@state='open']]/address[@addrtype='ipv4']/@addr\")
else: # ping scan
hosts = t.xpath(\"/*/host[status[@state='up']]/address[@addrtype='ipv4']/@addr\")
print(' '.join(hosts))
#
# use none for unchanged color
# match groups appear to match in reverse order
#
# https://github.com/pengwynn/grc/blob/master/grcat
#
# ip address
regexp=\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}
colours=bold yellow
======