Skip to content

Instantly share code, notes, and snippets.

@dustinbutterworth
Created November 20, 2020 15:35
Show Gist options
  • Save dustinbutterworth/7fc2144e23689d5d8cd8dac43e89c43e to your computer and use it in GitHub Desktop.
Save dustinbutterworth/7fc2144e23689d5d8cd8dac43e89c43e to your computer and use it in GitHub Desktop.
Rapid7 Scan Hosts via API
# Rapid7 Scan Request
# Sites and their corresponding ID:
# ATL = 1
# NYC = 2
#
# Scan Engines and their corresponding ID:
# ATLSCANNER = 1
# NYCSCANNER = 2
#
# Which Scan Engines Go with Which Sites:
# ATLSCANNER = ATL
# NYCSCANNER = NYC
#
# Variables:
# INSIGHTVM_AUTH variable must be environment variable, preferably run through orchestration tool or pulled from parameter store.
SITE="1"
ENGINE="1"
HOSTS='"10.10.10.10","10.10.10.11","10.10.10.12"'
SCAN_NAME="Test"
TEMPLATE="a-test-template"
BASE_URL="https://rapid7consoleurl.com:3780"
curl --location --request POST ''${BASE_URL}'/api/3/sites/'${SITE}'/scans' \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic '${INSIGHTVM_AUTH}'' \
--data-raw '{
"engineId": "'${ENGINE}'",
"hosts": [
'${HOSTS}'
],
"name": "'${SCAN_NAME}'",
"templateId": "'${TEMPLATE}'"
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment