Shell improvements in GreyNoise-Canary script#5
Open
szepeviktor wants to merge 1 commit intothinkst:masterfrom
Open
Shell improvements in GreyNoise-Canary script#5szepeviktor wants to merge 1 commit intothinkst:masterfrom
szepeviktor wants to merge 1 commit intothinkst:masterfrom
Conversation
szepeviktor
commented
Aug 25, 2021
|
|
||
| # Replace these placeholder values with your own | ||
| export CANARY_HASH="abcd1234" | ||
| export CANARY_TOKEN="11a2222bb3333c444d555e6f777ggg88" |
Author
There was a problem hiding this comment.
No need for EXPORT, we use these variables inside the script
szepeviktor
commented
Aug 25, 2021
| export CANARY_TOKEN="11a2222bb3333c444d555e6f777ggg88" | ||
| CANARY_HASH="abcd1234" | ||
| CANARY_TOKEN="11a2222bb3333c444d555e6f777ggg88" | ||
| CANARY_IP_LIST="canary-ips-$(date +%Y-%m-%d).txt" |
Author
There was a problem hiding this comment.
Date changes every midnight - putting it into a variable
szepeviktor
commented
Aug 25, 2021
| # 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}" |
Author
There was a problem hiding this comment.
--raw-output avoids double quotes - remove useless cat
szepeviktor
commented
Aug 25, 2021
| 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" |
Author
There was a problem hiding this comment.
This is how one reads lines from a file - Please consider using https://github.com/koalaman/shellcheck
Contributor
|
LGTM, thanks for the contribution @szepeviktor ! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is an inspirational PR.