Skip to content

Conversation

@szepeviktor
Copy link

This is an inspirational PR.


# Replace these placeholder values with your own
export CANARY_HASH="abcd1234"
export CANARY_TOKEN="11a2222bb3333c444d555e6f777ggg88"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for EXPORT, we use these variables inside the script

export CANARY_TOKEN="11a2222bb3333c444d555e6f777ggg88"
CANARY_HASH="abcd1234"
CANARY_TOKEN="11a2222bb3333c444d555e6f777ggg88"
CANARY_IP_LIST="canary-ips-$(date +%Y-%m-%d).txt"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Date changes every midnight - putting it into a variable

# Query Canary API for all events, extract IPs, remove double quotes, and write to a text file for GreyNoise
curl https://$CANARY_HASH.canary.tools/api/v1/incidents/outside_bird/search -d auth_token=$CANARY_TOKEN -d node_ids="INSERT_NODE_IDS" -G | jq '.src_ips[] | .ip_address' | sed 's/\"//g' | cat > canary-ips-$(date +%Y-%m-%d).txt
curl "https://${CANARY_HASH}.canary.tools/api/v1/incidents/outside_bird/search -d auth_token=${CANARY_TOKEN}" -d node_ids="INSERT_NODE_IDS" -G \
| jq --raw-output '.src_ips[] | .ip_address' > "${CANARY_IP_LIST}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--raw-output avoids double quotes - remove useless cat

done

curl "https://api.greynoise.io/v3/community/${ip_address}" | jq '.'
done < "${CANARY_IP_LIST}" > "GreyNoise-Canary-Threat-Intel-Report-$(date +%Y-%m-%d).json"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is how one reads lines from a file - Please consider using https://github.com/koalaman/shellcheck

@justin-varner
Copy link
Contributor

LGTM, thanks for the contribution @szepeviktor !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants