Paste: nmap
Author: | Sonderblade |
Mode: | factor |
Date: | Fri, 13 Dec 2013 18:01:15 |
Plain Text |
USING:
arrays
assocs
io.encodings.utf8 io.files
kernel
pcre
sequences
shuffle ;
IN: nmap-parser
: parse-line ( port-data current-ip line -- port-data' current-ip' )
dup "\\((\\d+.\\d+.\\d+.\\d+)\\)" findall
[
"(\\d+)/tcp (open|filtered)" findall
[
first second second
spin [ push-at ] 2keep swap
] unless-empty
]
[ nip first second second nip ] if-empty ;
: parse-output ( filename -- port-data )
utf8 file-lines { H{ } f }
[
[ first2 ] dip parse-line 2array
] reduce first ;
New Annotation