Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion bountyplz
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ report_args () {
--draft|-d)
_draft="1"
;;
--scope)
_scope="1"
;;
--force|-f)
_force="1"
;;
Expand All @@ -63,7 +66,7 @@ report_args () {
shift
done
[ "${_program}" != "" ] || doc_error "program not found"
[ "${_report_file}" != "" ] || doc_error "report file not found"
if [ "${_report_file}" != "" ] && [ "${_scope}" = "" ]; then doc_error "report file not found"; fi
}

trim () {
Expand Down Expand Up @@ -262,10 +265,26 @@ help)
doc 'h1 -p <markdown-file>' 'to only preview the parsing of the file for hackerone'
doc 'bc -p <markdown-file>' 'to only preview the parsing of the file for bugcrowd'
echo ''
doc 'h1 <program> --scope' 'fetches assets in scope (h1 only)'
echo ''
;;
h1)
h1_init "$@"
if [ "${_scope}" == "1" ]; then
#echo "Domains in scope:"
h1_api "current_user"
_signed_in=$(echo "${_user_info}" | jq $'.["signed_in?"]')
_csrf_token=$(echo "${_user_info}" | jq -r $'.["csrf_token"]')
if [ "${_signed_in}" == "false" ]; then
h1_api "sign-in"
else
doc_success "already signed in!"
fi
_csrf_token=$(echo "${_user_info}" | jq -r $'.["csrf_token"]')
h1_api "scope"
exit 0
fi

h1_parse "${_report_file}"
h1_preview
if [ "${_preview}" != "1" ]; then
Expand Down
28 changes: 28 additions & 0 deletions h1
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,34 @@ h1_api() {

:
;;
scope)
doc_action "retrieving scope"

doc_action "fetching graphql-token..."

curl_parse "$(curl -H "${_user_agent}" -H "${_accept_lang}" -H "Expect: " \
-b "${_h1_session_file}" -c "${_h1_session_file}" -sD - "https://hackerone.com/current_user/graphql_token.json")"

[ "${_response_code}" != "200" ] && \
doc_error "could not fetch graphql-token: ${_response_code} ${_response_body}"

_h1_gql_token=$(echo "${_response_body}" | jq -r '.graphql_token')

doc_action "fetching assets..."

_assets_gql_query=$(echo '{"query":"$query"}' | jq --arg p "${_program}" '.query = "query Structured_scopes_selector { query { assets:team(handle:\"" + $p + "\") { list:structured_scopes(first:100,archived:false) { edges { node { _id, asset_identifier, eligible_for_submission } } } } } }"')

curl_parse "$(curl -X POST -H "${_user_agent}" -H "${_accept_lang}" -H "Expect: " \
-H "X-Auth-Token: ${_h1_gql_token}" -H "Content-Type: application/json" --data "${_assets_gql_query}" -b "${_h1_session_file}" -c "${_h1_session_file}" -sD - "https://hackerone.com/graphql")"

[ "${_response_code}" != "200" ] && \
doc_error "error fetching socpe for '${_program}': ${_response_code}"

#echo "${_response_body}" | jq -r '[ .data.query.assets.list.edges[].node | select (.eligible_for_submission == true)]'
doc_action "in scope: "
echo "${_response_body}" | jq -r '[ .data.query.assets.list.edges[].node | select (.eligible_for_submission == true)] | .[] | .asset_identifier'
:
;;
report-attributes)

doc_action "finding report attributes..."
Expand Down