Skip to content

Instantly share code, notes, and snippets.

@goncalor
Last active November 30, 2021 21:48
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goncalor/bcf0c58d385c9ec9fcef302716fb0a03 to your computer and use it in GitHub Desktop.
Save goncalor/bcf0c58d385c9ec9fcef302716fb0a03 to your computer and use it in GitHub Desktop.
#!/bin/sh
#
# Converts `masscan`'s JSON output to JSON lines that can be
# parsed by `jq` or `python -m json.tool --json-lines`.
# masscan (1.0.4) outputs an array with a trailing comma, which is invalid.
# This basically breaks the array into its elements, one per line.
#
# Example:
# [
# {...},
# {...},
# ]
#
# to
#
# {...}
# {...}
#
# Usage example:
# cat masscan_output.json | ./masscan-json2json | jq -r .ip
cat - | sed -e '/^\[/d' -e '/^\]/d' -e 's/,$//'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment