Skip to content

Instantly share code, notes, and snippets.

@akhil-reni
Last active May 23, 2020 13:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akhil-reni/99e29f06fc58dfd8f4faaa6c272b541c to your computer and use it in GitHub Desktop.
Save akhil-reni/99e29f06fc58dfd8f4faaa6c272b541c to your computer and use it in GitHub Desktop.
An example how to normalise scan outputs and send to ES

Index per scan

elasticdump \
    --input="./output.json" \
    --output="http://127.0.0.1:9200" \
    --output-index="subfinder" \
    --limit=10000 \
    --type=data \
    --transform="doc._source=Object.assign({},doc)"

find_and_send_to_es.py

import os
import json

# run subfinder

cmd = "subfinder -d {} -oJ -silent -o {}".format("test.com", "output.json")

os.system(cmd)

with open("output.json", "r+") as f:
    data = json.load(f)

final_data = {}
final_data["subdomains"] = data
with open("mod_output.json", "w+") as f:
    json.dump(final_data, f)


cmd = "elasticdump  --input \"{}\"  --output=http://127.0.0.1:9200/ --output-index={} --type=data --transform=\"doc._source=Object.assign({},doc)\"".format("mod_output.json", "subfinder")
os.system(cmd)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment