Skip to content

Commit

Permalink
Only notify for valid routes (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewjkerr authored Jul 8, 2019
1 parent ad1ac05 commit 51d32be
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# :rocket: CHANGELOG

How Bug Bounty in a Box is _currently_ versioned:
* Lil' bug fixes that don't modify any features will be revisionary version releases.
* New features, changes in functionality, or major refactoring will be minor version releases.
* After 1.0, the versioning strategy will change. :smile:

## :relieved: Version 0.03

This lil' release only logs requests for valid, non-index routes 'cause it gets noisy :sweat_smile:.

## :soccer: Version 0.02

This second pre-release version contains some new routes:
Expand Down
25 changes: 18 additions & 7 deletions app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@
# @return [String] The default config file location.
DEFAULT_CONFIG_FILE = 'config/application.yml'

# Execute this method before any request! Currently all this does is
# log the request to our request log.
before do
@incoming_request = Request.new(request)
@incoming_request.log!
end

# GET /
#
# A nice lil' "Hello world!" index.
Expand All @@ -55,6 +48,8 @@
# 1. Logs the callback parameters
# 2. Alerts in Slack
route *ALL_HTTP_METHODS, '/callback' do
log_request!

payload = Payload::create_payload_from_request_parameters(params)
payload.log! unless payload.nil?
"Callback successful!\n"
Expand All @@ -70,6 +65,8 @@
#
# Example: GET /payload?type=js&exploit=xss&target=www.example.com
route *ALL_HTTP_METHODS, '/payload' do
log_request!

halt 400, 'No type provided.' if params['type'].nil?
halt 400, 'No exploit provided.' if params['exploit'].nil?

Expand Down Expand Up @@ -116,6 +113,8 @@
# Required parameters:
# * `redirect`: The URL to redirect to.
route *ALL_HTTP_METHODS, '/redirect' do
log_request!

halt 400, 'Empty redirect parameter' if params['redirect'].nil?
redirect params['redirect']
end
Expand All @@ -131,6 +130,8 @@
#
# Example: GET /unauthorized?content_type=audio_mpeg
route *ALL_HTTP_METHODS, '/unauthorized' do
log_request!

unless params['content_type'].nil?
content_type_constant = params['content_type'].upcase
if ContentType.const_defined?(content_type_constant)
Expand All @@ -147,6 +148,16 @@
halt 401
end

helpers do
# Logs an incoming request & sends a Slack message.
#
# @return [Void]
def log_request!
@incoming_request = Request.new(request)
@incoming_request.log!
end
end

##
# Load our configuration file!
#
Expand Down

0 comments on commit 51d32be

Please sign in to comment.