Skip to content

Instantly share code, notes, and snippets.

@kyouheicf
Last active July 25, 2024 04:35
Show Gist options
  • Select an option

  • Save kyouheicf/60ae48fafd4f61f7c8dcbeb966299cf3 to your computer and use it in GitHub Desktop.

Select an option

Save kyouheicf/60ae48fafd4f61f7c8dcbeb966299cf3 to your computer and use it in GitHub Desktop.

Revisions

  1. kyouheicf revised this gist Jul 25, 2024. 1 changed file with 5 additions and 1 deletion.
    6 changes: 5 additions & 1 deletion getPassiveDnsCategories.sh
    Original file line number Diff line number Diff line change
    @@ -16,5 +16,9 @@ export CATEGORY=$(curl -sX GET "https://api.cloudflare.com/client/v4/accounts/$A
    -H "X-Auth-Email: $EMAIL" \
    -H "X-Auth-Key: $APIKEY" \
    -H "Content-Type: application/json" | jq -r -c '.result.content_categories[]' | tr '\n' ',')
    cat reverse_records.json | jq '.['"${i}"'] |= .+ {"content_categories": ['"${CATEGORY%,}"']} | .['"${i}"']'
    export RISK=$(curl -sX GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/intel/domain?domain=$DOMAIN" \
    -H "X-Auth-Email: $EMAIL" \
    -H "X-Auth-Key: $APIKEY" \
    -H "Content-Type: application/json" | jq -r -c '.result.risk_type[]' | tr '\n' ',')
    cat reverse_records.json | jq '.['"${i}"'] |= .+ {"content_categories": ['"${CATEGORY%,}"'],"risk_type": ['"${RISK%,}"']} | .['"${i}"']'
    done
  2. kyouheicf created this gist Jul 25, 2024.
    20 changes: 20 additions & 0 deletions getPassiveDnsCategories.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    export EMAIL='YOUR_EMAIL'
    export APIKEY='YOUR_APIKEY'
    export ZONE_ID='YOUR_ACCOUNT_ID'

    curl -sX GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/intel/dns?ipv4=43.153.133.9&start=2024-07-23&end=2024-07-26&per_page=200" \
    -H "X-Auth-Email: $EMAIL" \
    -H "X-Auth-Key: $APIKEY" \
    -H "Content-Type: application/json" | jq -r .result.reverse_records > reverse_records.json

    for i in {0..$(cat reverse_records.json | jq 'length')}
    do
    echo "${i}"
    export HOSTNAME=$(cat reverse_records.json | jq -r '.['"${i}"'].hostname')
    export DOMAIN=$(echo $HOSTNAME |awk -F'[./]' -v 'OFS=.' '{print $(NF-1),$NF}')
    export CATEGORY=$(curl -sX GET "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/intel/domain?domain=$DOMAIN" \
    -H "X-Auth-Email: $EMAIL" \
    -H "X-Auth-Key: $APIKEY" \
    -H "Content-Type: application/json" | jq -r -c '.result.content_categories[]' | tr '\n' ',')
    cat reverse_records.json | jq '.['"${i}"'] |= .+ {"content_categories": ['"${CATEGORY%,}"']} | .['"${i}"']'
    done