Send reports to Hackerone working yayy 🚀

This commit is contained in:
Yogesh Ojha
2021-08-11 02:41:55 +05:30
parent c57029ddba
commit 654ea7dbe0
9 changed files with 148 additions and 16 deletions
+57 -1
View File
@@ -9,7 +9,7 @@ from discord_webhook import DiscordWebhook
from django.db.models import Q
from functools import reduce
from scanEngine.models import *
from startScan.models import Subdomain, EndPoint
from startScan.models import *
def get_lookup_keywords():
@@ -206,3 +206,59 @@ def get_random_proxy():
print('Using proxy: ' + proxy_name)
return proxy_name
return False
def send_hackerone_report(vulnerability_id):
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
# get hackerone creds
if Hackerone.objects.all().exists():
hackerone = Hackerone.objects.all()[0]
vulnerability = Vulnerability.objects.get(id=vulnerability_id)
if vulnerability.severity == 0:
severity_value = 'info'
elif vulnerability.severity == 1:
severity_value = 'low'
elif vulnerability.severity == 2:
severity_value = 'medium'
elif vulnerability.severity == 3:
severity_value = 'high'
elif vulnerability.severity == 4:
severity_value = 'critical'
report_template = hackerone.report_template
# Replace syntax of report template with actual content
if '{vulnerability_name}' in report_template:
report_template = report_template.replace('{vulnerability_name}', vulnerability.name)
if '{vulnerable_url}' in report_template:
report_template = report_template.replace('{vulnerable_url}', vulnerability.http_url)
if '{vulnerability_severity}' in report_template:
report_template = report_template.replace('{vulnerability_severity}', severity_value)
if '{vulnerability_description}' in report_template:
report_template = report_template.replace('{vulnerability_description}', vulnerability.description if vulnerability.description else '')
if '{vulnerability_extracted_results}' in report_template:
report_template = report_template.replace('{vulnerability_extracted_results}', vulnerability.extracted_results if vulnerability.extracted_results else '')
if '{vulnerability_reference}' in report_template:
report_template = report_template.replace('{vulnerability_reference}', vulnerability.reference if vulnerability.reference else '')
data = {
"data": {
"type": "report",
"attributes": {
"team_handle": vulnerability.target_domain.h1_team_handle,
"title": '{} found in {}'.format(vulnerability.name, vulnerability.http_url),
"vulnerability_information": report_template,
"severity_rating": severity_value,
"impact": " " + vulnerability.reference if vulnerability.reference else "N/A",
}
}
}
r = requests.post(
'https://api.hackerone.com/v1/hackers/reports',
auth=(hackerone.username, hackerone.api_key),
json = data,
headers = headers
)
print(r.json())
+2 -1
View File
@@ -470,8 +470,9 @@ class HackeroneForm(forms.ModelForm):
self.initial['send_medium'] = False
self.initial['report_template'] = '''Hi Team, while testing, a {vulnerability_severity} severity vulnerability has been discovered in {vulnerable_url} and below is the findings.
# Vulnerability
{vulnerability_title}
{vulnerability_name}
## Issue Description
{vulnerability_description}
+4 -3
View File
@@ -84,13 +84,14 @@ def update_engine(request, id):
def wordlist_list(request):
wordlists = Wordlist.objects.all().order_by('id')
context = {
'scan_engine_nav_active':
'active', 'wordlists': wordlists}
'scan_engine_nav_active': 'active',
'wordlist_li': 'active',
'wordlists': wordlists}
return render(request, 'scanEngine/wordlist/index.html', context)
def add_wordlist(request):
context = {'scan_engine_nav_active': 'active'}
context = {'scan_engine_nav_active': 'active', 'wordlist_li': 'active'}
form = AddWordlistForm(request.POST or None, request.FILES or None)
if request.method == "POST":
if form.is_valid() and 'upload_file' in request.FILES:
+2 -2
View File
@@ -84,7 +84,7 @@ class AddOrganizationForm(forms.Form):
class UpdateTargetForm(forms.ModelForm):
class Meta:
model = Domain
fields = ['name', 'description']
fields = ['name', 'description', 'h1_team_handle']
name = forms.CharField(
validators=[validate_domain],
required=True,
@@ -113,7 +113,7 @@ class UpdateTargetForm(forms.ModelForm):
}
))
def set_value(self, domain_value, description_value):
def set_value(self, domain_value, description_value, h1_team_handle):
self.initial['name'] = domain_value
self.initial['description'] = description_value
self.initial['h1_team_handle'] = h1_team_handle
@@ -24,6 +24,31 @@
{{ form.description }}
</div>
</div>
<div class="creative3-accordion-content">
<div id="iconsAccordion" class="accordion-icons">
<div class="card">
<div class="card-header" id="headingOne3">
<section class="mb-0 mt-0">
<div role="menu" class="collapsed" data-toggle="collapse" data-target="#hackerone_accordion" aria-expanded="true" aria-controls="hackerone_accordion">
<div class="accordion-icon"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-crosshair"><circle cx="12" cy="12" r="10"></circle><line x1="22" y1="12" x2="18" y2="12"></line><line x1="6" y1="12" x2="2" y2="12"></line><line x1="12" y1="6" x2="12" y2="2"></line><line x1="12" y1="22" x2="12" y2="18"></line></svg></div>
Bug Bounty (Hackerone) (Optional) <div class="icons"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
</section>
</div>
<div id="hackerone_accordion" class="collapse" aria-labelledby="headingOne4" data-parent="#hackerone_accordion">
<div class="card-body">
<div class="col-md-12 mb-4">
<label for="domainDescription">Hackerone Target <b>team_handle</b>
<br>
This is used to send vulnerability reports to Hackerone Program automatically. Team handle can be found from program url, hackerone.com/team_handle
</label>
{{ form.h1_team_handle }}
</div>
</div>
</div>
</div>
</div>
</div>
<button class="btn btn-primary submit-fn mt-2 float-right" type="submit">{{button_title}}</button>
</form>
</div>
+51 -6
View File
@@ -8,6 +8,7 @@ Add target for Recon
{% block custom_js_css_link %}
<link href="{% static 'assets/css/elements/alert.css' %}" rel="stylesheet" type="text/css" />
<link href="{% static 'assets/css/components/tabs-accordian/custom-accordions.css' %}" rel="stylesheet" type="text/css" />
{% endblock custom_js_css_link %}
{% block breadcrumb_title %}
@@ -60,12 +61,30 @@ Add target for Recon
<label for="domainDescription">Description (Optional)</label>
{{ form.description }}
</div>
<div class="col-md-6 mb-4">
<label for="domainDescription">Hackerone Target <b>team_handle</b> (Optional)
<br>
This is used to send vulnerability reports to Hackerone Program automatically. Team handle can be found from program url, hackerone.com/team_handle
</label>
{{ form.h1_team_handle }}
</div>
<div class="creative3-accordion-content">
<div id="iconsAccordion" class="accordion-icons">
<div class="card">
<div class="card-header" id="headingOne3">
<section class="mb-0 mt-0">
<div role="menu" class="collapsed" data-toggle="collapse" data-target="#hackerone_accordion" aria-expanded="true" aria-controls="hackerone_accordion">
<div class="accordion-icon"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-crosshair"><circle cx="12" cy="12" r="10"></circle><line x1="22" y1="12" x2="18" y2="12"></line><line x1="6" y1="12" x2="2" y2="12"></line><line x1="12" y1="6" x2="12" y2="2"></line><line x1="12" y1="22" x2="12" y2="18"></line></svg></div>
Bug Bounty (Hackerone) (Optional) <div class="icons"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
</section>
</div>
<div id="hackerone_accordion" class="collapse" aria-labelledby="headingOne4" data-parent="#hackerone_accordion">
<div class="card-body">
<div class="col-md-12 mb-4">
<label for="domainDescription">Hackerone Target <b>team_handle</b>
<br>
This is used to send vulnerability reports to Hackerone Program automatically. Team handle can be found from program url, hackerone.com/team_handle
</label>
{{ form.h1_team_handle }}
</div>
</div>
</div>
</div>
</div>
</div>
<button class="btn btn-primary submit-fn mt-2 float-right" disabled type="submit" name="add-target" id="add-target" value="submit"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus"><line x1="12" y1="5" x2="12" y2="19"></line><line x1="5" y1="12" x2="19" y2="12"></line></svg> Add Target</button>
@@ -84,6 +103,31 @@ Add target for Recon
<label for="targetDescription">Target Description (Optional)</label>
<input type="text" class="form-control" id="targetDescription" placeholder="Interesting Target" name="targetDescription">
</div>
<div class="creative3-accordion-content">
<div id="iconsAccordion" class="accordion-icons">
<div class="card">
<div class="card-header" id="headingOne3">
<section class="mb-0 mt-0">
<div role="menu" class="collapsed" data-toggle="collapse" data-target="#hackerone_accordion" aria-expanded="true" aria-controls="hackerone_accordion">
<div class="accordion-icon"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-crosshair"><circle cx="12" cy="12" r="10"></circle><line x1="22" y1="12" x2="18" y2="12"></line><line x1="6" y1="12" x2="2" y2="12"></line><line x1="12" y1="6" x2="12" y2="2"></line><line x1="12" y1="22" x2="12" y2="18"></line></svg></div>
Bug Bounty (Hackerone) (Optional) <div class="icons"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down"><polyline points="6 9 12 15 18 9"></polyline></svg></div>
</div>
</section>
</div>
<div id="hackerone_accordion" class="collapse" aria-labelledby="headingOne4" data-parent="#hackerone_accordion">
<div class="card-body">
<div class="col-md-12 mb-4">
<label for="domainDescription">Hackerone Target <b>team_handle</b>
<br>
This is used to send vulnerability reports to Hackerone Program automatically. Team handle can be found from program url, hackerone.com/team_handle
</label>
<input type="text" class="form-control" id="targetH1TeamHandle" placeholder="team_handle" name="targetH1TeamHandle">
</div>
</div>
</div>
</div>
</div>
</div>
<button class="btn btn-primary submit-fn mt-2 float-right" type="submit" id="addTargetButton" name="add-multiple-targets" value="submit">Add 0 Target</button>
</form>
</div>
@@ -128,6 +172,7 @@ Add target for Recon
{% block page_level_script %}
<script src="{% static 'assets/js/scrollspyNav.js' %}"></script>
<script src="{% static 'assets/js/components/ui-accordions.js' %}"></script>
<script type="text/javascript">
var addTargetsButton = document.getElementById("addTargetButton");
addTargetsButton.disabled = true;
@@ -9,6 +9,7 @@ Update Target
{% block custom_js_css_link %}
<script src="{% static 'plugins/notification/snackbar/snackbar.min.js' %}"></script>
<link href="{% static 'plugins/notification/snackbar/snackbar.min.css' %}" rel="stylesheet" type="text/css">
<link href="{% static 'assets/css/components/tabs-accordian/custom-accordions.css' %}" rel="stylesheet" type="text/css" />
{% endblock custom_js_css_link %}
{% block main_content %}
@@ -18,4 +19,5 @@ Update Target
{% block page_level_script %}
<script src="{% static 'assets/js/scrollspyNav.js' %}"></script>
<script src="{% static 'assets/js/components/ui-accordions.js' %}"></script>
{% endblock page_level_script %}
+4 -2
View File
@@ -47,6 +47,7 @@ def add_target(request):
for target in request.POST['addTargets'].split('\n')]
bulk_targets = [target for target in bulk_targets if target]
description = request.POST['targetDescription'] if 'targetDescription' in request.POST else ''
h1_team_handle = request.POST['targetH1TeamHandle'] if 'targetH1TeamHandle' in request.POST else None
target_count = 0
for target in bulk_targets:
if not Domain.objects.filter(
@@ -54,6 +55,7 @@ def add_target(request):
Domain.objects.create(
name=target.rstrip("\n"),
description=description,
h1_team_handle=h1_team_handle,
insert_date=timezone.now())
target_count += 1
if target_count:
@@ -123,7 +125,7 @@ def add_target(request):
"target_data_active": "active",
'form': add_target_form}
return render(request, 'target/add.html', context)
def list_target(request):
domains = Domain.objects.all().order_by('-insert_date')
context = {
@@ -183,7 +185,7 @@ def update_target(request, id):
'Domain {} modified!'.format(domain.name))
return http.HttpResponseRedirect(reverse('list_target'))
else:
form.set_value(domain.name, domain.description)
form.set_value(domain.name, domain.description, domain.h1_team_handle)
context = {
'list_target_li': 'active',
'target_data_active': 'active',
+1 -1
View File
@@ -89,7 +89,7 @@
<li class="{{ engine_li }}">
<a href="{% url 'scan_engine_index' %}">Scan Engines</a>
</li>
<li class="{{ engine_li }}">
<li class="{{ wordlist_li }}">
<a href="{% url 'wordlist_list' %}">Wordlists</a>
</li>
<li class="{{ interesting_lookup_li }}">