Skip to content

Commit

Permalink
Merge pull request #31 from aasicq/master
Browse files Browse the repository at this point in the history
Discord Webhook url added for notifications
hisxo authored Oct 13, 2020
2 parents 98dfd0c + f2aa97f commit 77672d0
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -47,6 +47,7 @@ optional arguments:
-k KEYWORDSFILE, --keyword KEYWORDSFILE Specify a keywords file (-k keywordsfile.txt)
-q QUERY, --query QUERY Specify your github query (-q "apikey")
-m, --monitor Enable monitoring of your search query by creating cron job [Every 30 mins]
-d, --discord Enable discord notifications
-s, --slack Enable slack notifications
-tg, --telegram Enable telegram notifications
-w WORDLIST, --wordlist WORDLIST Create a wordlist that fills dynamically with discovered filenames on GitHub
@@ -87,6 +88,7 @@ gitGraber needs some dependencies, to install them on your environment:
Before to start **gitGraber** you need to modify the configuration file ``config.py`` :

- Add your own Github tokens (_Personal access tokens_) : ``GITHUB_TOKENS = ['yourToken1Here','yourToken2Here']``
- Add your own Discord Webhook : ``DISCORD_WEBHOOKURL = 'https://discordapp.com/api/webhooks/7XXXX/XXXXXX'``
- Add your own Slack Webhook : ``SLACK_WEBHOOKURL = 'https://hooks.slack.com/services/TXXXX/BXXXX/XXXXXXX'``
- Add your own Telegram Config : ``TELEGRAM_CONFIG = {
"token": "XXXXX:xXXXXXXXXXXXXX",
@@ -96,6 +98,7 @@ Before to start **gitGraber** you need to modify the configuration file ``config
| Service | Link |
|---------|-----------------------------------------------------------------------------------------------------------------------|
| GitHub | *[How to create GitHub API token](https://github.com/settings/tokens)* |
| Discord | *[How to create Discord Webhook URL](https://help.dashe.io/en/articles/2521940-how-to-create-a-discord-webhook-url)* |
| Slack | *[How to create Slack Webhook URL](https://get.slack.help/hc/en-us/articles/115005265063-Incoming-WebHooks-for-Slack)*|
| Telegram | *[How to create Telegram bot](https://medium.com/@xabaras/sending-a-message-to-a-telegram-channel-the-easy-way-eb0a0b32968)*|

3 changes: 2 additions & 1 deletion config.py
Original file line number Diff line number Diff line change
@@ -5,8 +5,9 @@
GITHUB_SEARCH_PARAMS = '&sort=indexed&o=desc'
GITHUB_BASE_URL = 'https://github.com'
GITHUB_MAX_RETRY = 10
DISCORD_WEBHOOKURL = 'https://discordapp.com/api/webhooks/7XXXXXXXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXX'
SLACK_WEBHOOKURL = 'https://hooks.slack.com/services/TXXXXXXXX/BXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXX'
TELEGRAM_CONFIG = {
"token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"chat_id": -999999999999999
}
}
23 changes: 22 additions & 1 deletion gitGraber.py
Original file line number Diff line number Diff line change
@@ -37,7 +37,16 @@ def clean(result):
def monitor():
cmd='/usr/bin/python3 '+str(path_script)+'/gitGraber.py -q "'+args.query+'"'
my_cron = CronTab(user=True)
if args.slack and config.SLACK_WEBHOOKURL:
if args.discord and config.DISCORD_WEBHOOKURL:
if(args.wordlist):
job = my_cron.new(command=cmd+' -d -k '+args.keywordsFile+' -w '+args.wordlist+'')
job.minute.every(30)
my_cron.write()
else:
job = my_cron.new(command=cmd+' -d -k '+args.keywordsFile+'')
job.minute.every(30)
my_cron.write()
elif args.slack and config.SLACK_WEBHOOKURL:
if(args.wordlist):
job = my_cron.new(command=cmd+' -s -k '+args.keywordsFile+' -w '+args.wordlist+'')
job.minute.every(30)
@@ -91,6 +100,15 @@ def checkToken(content, tokensMap, tokensCombo):

return tokensFound


def notifyDiscord(message):
if not config.DISCORD_WEBHOOKURL:
print('Please define Discord Webhook URL to enable notifications')
exit()
data={}
data['content']=message
requests.post(config.DISCORD_WEBHOOKURL,data=json.dumps(data) , headers={"Content-Type": "application/json"})

def notifySlack(message):
if not config.SLACK_WEBHOOKURL:
print('Please define Slack Webhook URL to enable notifications')
@@ -292,6 +310,8 @@ def doSearchGithub(args,tokenMap, tokenCombos,keyword):
tokensResult = checkToken(content[rawGitUrl][0].text, tokenMap, tokenCombos)
for token in tokensResult.keys():
displayMessage = displayResults(token, tokensResult, rawGitUrl, content[rawGitUrl])
if args.discord:
notifyDiscord(displayMessage)
if args.slack:
notifySlack(displayMessage)
if args.telegram:
@@ -315,6 +335,7 @@ def searchGithub(keywordsFile, args):
parser.add_argument('-t', '--threads', action='store', dest='max_threads', help='Max threads to speed the requests on Github (take care about the rate limit)', default="3")
parser.add_argument('-k', '--keyword', action='store', dest='keywordsFile', help='Specify a keywords file (-k keywordsfile.txt)', default="wordlists/keywords.txt")
parser.add_argument('-q', '--query', action='store', dest='query', help='Specify your query (-q "myorg")')
parser.add_argument('-d', '--discord', action='store_true', help='Enable discord notifications', default=False)
parser.add_argument('-s', '--slack', action='store_true', help='Enable slack notifications', default=False)
parser.add_argument('-tg', '--telegram', action='store_true', help='Enable telegram notifications', default=False)
parser.add_argument('-m', '--monitor', action='store_true', help='Monitors your query by adding a cron job for every 30 mins',default=False)

0 comments on commit 77672d0

Please sign in to comment.