-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement local report endpoint (#22)
* Implement report endpoint * Add script tags
- Loading branch information
Showing
9 changed files
with
239 additions
and
12 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as request from 'request'; | ||
import config from './config'; | ||
import * as Debug from 'debug'; | ||
|
||
const debug = Debug('gcaptcha'); | ||
|
||
/** | ||
* Verify a Google Captcha response | ||
*/ | ||
export const verifyResponse = (response: string): Promise<any> => { | ||
return new Promise((resolve, reject) => { | ||
if (config.apiKeys.Google_Captcha) { | ||
request.post( | ||
'https://www.google.com/recaptcha/api/siteverify?secret=' + | ||
encodeURIComponent(config.apiKeys.Google_Captcha) + | ||
'&response=' + | ||
encodeURIComponent(response), | ||
{ json: true }, | ||
(err, response, body) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
debug(body); | ||
resolve(body.success); | ||
} | ||
} | ||
); | ||
} else { | ||
reject('No Google Captcha secret found!'); | ||
} | ||
}); | ||
}; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import * as request from 'request'; | ||
import config from './config'; | ||
import * as Debug from 'debug'; | ||
|
||
const debug = Debug('slack'); | ||
|
||
/** | ||
* Send report through Slack | ||
*/ | ||
export const sendReport = (report: any): Promise<any> => { | ||
return new Promise((resolve, reject) => { | ||
if (config.apiKeys.Slack_Webhook) { | ||
let message = ''; | ||
if (report.reportType == 'generalDomainReport') { | ||
message += '*Domain*: '; | ||
message += report.args.domain || '(none)'; | ||
message += '\n'; | ||
message += '*Reason*: '; | ||
message += report.args.reason || '(none)'; | ||
} else if (report.reportType == 'generalAddressReport') { | ||
message += '*Address*: '; | ||
if (report.args.address) { | ||
message += '<https://etherscan.io/address/' + report.args.address + '|'; | ||
} | ||
message += report.args.address || '(none)'; | ||
if (report.args.address) { | ||
message += '>'; | ||
} | ||
message += '\n'; | ||
message += '*Reason*: '; | ||
message += report.args.reason || '(none)'; | ||
} else if (report.reportType == 'uniqueReport') { | ||
message += '*Report*: '; | ||
message += report.args.unique || '(none)'; | ||
} else if (report.reportType == 'urgentDomainReport') { | ||
message += '*Domain*: '; | ||
message += report.args.domain || '(none)'; | ||
message += '\n'; | ||
message += '*Victim address*: '; | ||
if (report.args.from) { | ||
message += '<https://etherscan.io/address/' + report.args.from + '|'; | ||
} | ||
message += report.args.from || '(none)'; | ||
if (report.args.from) { | ||
message += '>'; | ||
} | ||
message += '\n'; | ||
message += '*Attacker addresses*: '; | ||
if (report.args.to) { | ||
message += report.args.to | ||
.split('\n') | ||
.map( | ||
address => | ||
'<https://etherscan.io/address/' + address + '|' + address + '>' | ||
) | ||
.join(', '); | ||
} else { | ||
message += '(none)'; | ||
} | ||
} else if (report.reportType == 'urgentMessageAddressReport') { | ||
message += '*Reason*: '; | ||
message += report.args.message || '(none)'; | ||
message += '\n'; | ||
message += '*Victim address*: '; | ||
if (report.args.from) { | ||
message += '<https://etherscan.io/address/' + report.args.from + '|'; | ||
} | ||
message += report.args.from || '(none)'; | ||
if (report.args.from) { | ||
message += '>'; | ||
} | ||
message += '\n'; | ||
message += '*Attacker addresses*: '; | ||
if (report.args.to) { | ||
message += report.args.to | ||
.split('\n') | ||
.map( | ||
address => | ||
'<https://etherscan.io/address/' + address + '|' + address + '>' | ||
) | ||
.join(', '); | ||
} else { | ||
message += '(none)'; | ||
} | ||
} else if (report.reportType == 'urgentDomainAddressReport') { | ||
message += '*Reason*: '; | ||
message += report.args.message || '(none)'; | ||
message += '\n'; | ||
message += '*Victim address*: '; | ||
if (report.args.from) { | ||
message += '<https://etherscan.io/address/' + report.args.from + '|'; | ||
} | ||
message += report.args.from || '(none)'; | ||
if (report.args.from) { | ||
message += '>'; | ||
} | ||
message += '\n'; | ||
message += '*Attacker addresses*: '; | ||
if (report.args.to) { | ||
message += report.args.to | ||
.split('\n') | ||
.map( | ||
address => | ||
'<https://etherscan.io/address/' + address + '|' + address + '>' | ||
) | ||
.join(', '); | ||
} else { | ||
message += '(none)'; | ||
} | ||
} else { | ||
message += '*Unknown reportType*: `' + report.reportType + '`\n\n'; | ||
report.args.captcha = null; | ||
message += '```' + JSON.stringify(report.args, null, 4) + '```'; | ||
} | ||
request.post( | ||
config.apiKeys.Slack_Webhook, | ||
{ | ||
json: true, | ||
body: { | ||
text: message | ||
} | ||
}, | ||
(err, response, body) => { | ||
if (err) { | ||
reject(err); | ||
} else { | ||
resolve(body); | ||
} | ||
} | ||
); | ||
} else { | ||
reject('No Slack webhook found!'); | ||
} | ||
}); | ||
}; |
This file contains 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
This file contains 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
This file contains 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
This file contains 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