Skip to content

Commit

Permalink
Added support of theHarvester
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Shaposhnikov committed Dec 5, 2021
1 parent a82fdfa commit cccb1bb
Show file tree
Hide file tree
Showing 5 changed files with 179 additions and 7 deletions.
70 changes: 64 additions & 6 deletions routes/ui/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -4612,12 +4612,12 @@ def dnsrecon_page_form(project_id, current_project, current_user):

for hostname_row in scan_result:

hostname = hostname_row.get('target') if hostname_row.get('target') else ''
hostname_name = hostname_row.get('name') if hostname_row.get('name') else ''
host_ip = hostname_row.get('address') if hostname_row.get('address') else ''
host_port = hostname_row.get('port') if hostname_row.get('port') else ''
hostname_info = hostname_row.get('strings') if hostname_row.get('strings') else ''
hostname_type = hostname_row.get('type') if hostname_row.get('type') else ''
hostname = hostname_row.get('target') if hostname_row.get('target') else ''
hostname_name = hostname_row.get('name') if hostname_row.get('name') else ''
host_ip = hostname_row.get('address') if hostname_row.get('address') else ''
host_port = hostname_row.get('port') if hostname_row.get('port') else ''
hostname_info = hostname_row.get('strings') if hostname_row.get('strings') else ''
hostname_type = hostname_row.get('type') if hostname_row.get('type') else ''

'''
1. Name <--> Address
Expand Down Expand Up @@ -4715,3 +4715,61 @@ def dnsrecon_page_form(project_id, current_project, current_user):
current_project=current_project,
tab_name='DNSrecon',
errors=errors)


@routes.route('/project/<uuid:project_id>/tools/theharvester/', methods=['GET'])
@requires_authorization
@check_session
@check_project_access
@send_log_data
def theharvester_page(project_id, current_project, current_user):
return render_template('project/tools/import/theharvester.html',
current_project=current_project,
tab_name='theHarvester')


@routes.route('/project/<uuid:project_id>/tools/theharvester/', methods=['POST'])
@requires_authorization
@check_session
@check_project_access
@send_log_data
def theharvester_page_form(project_id, current_project, current_user):
form = theHarvesterForm()
form.validate()
errors = []
if form.errors:
for field in form.errors:
for error in form.errors[field]:
errors.append(error)

if not errors:
for file in form.xml_files.data:
if file.filename:
soup = BeautifulSoup(file.read(), "html.parser")

scan_result = soup.findAll('host')

for hostname_row in scan_result:
ips_str = hostname_row.find('ip').text
hostname = hostname_row.find('hostname').text

ip_array = ips_str.split(', ')
for ip_address in ip_array:
# check valid ip
ipaddress.ip_address(ip_address)

current_host = db.select_project_host_by_ip(current_project['id'], ip_address)
if current_host:
host_id = current_host[0]['id']
else:
host_id = db.insert_host(current_project['id'], ip_address, current_user['id'],
form.hosts_description.data)

current_hostname = db.select_ip_hostname(host_id, hostname)
if not current_hostname:
hostname_id = db.insert_hostname(host_id, hostname, form.hostnames_description.data, current_user['id'])

return render_template('project/tools/import/theharvester.html',
current_project=current_project,
tab_name='theHarvester',
errors=errors)
Binary file added static/images/theHarvester-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion system/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1155,6 +1155,11 @@ class DNSreconForm(FlaskForm):
csv_files = MultipleFileField('csv_files')
json_files = MultipleFileField('json_files')
hosts_description = StringField('hosts_description', default='Added from DNSrecon scan')
hostnames_description = StringField('hostnames_description', default='Added from DNSrecon scan')
ports_description = StringField('ports_description', default='Added from DNSrecon scan')
ignore_ipv6 = IntegerField('ignore_ipv6', default=0)


class theHarvesterForm(FlaskForm):
xml_files = MultipleFileField('xml_files')
hosts_description = StringField('hosts_description', default='Added from theHarvester scan')
hostnames_description = StringField('hostnames_description', default='Added from theHarvester scan')
104 changes: 104 additions & 0 deletions templates/project/tools/import/theharvester.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<!DOCTYPE html>
<html lang="en">
{% include 'header.html' %}
<body>
<div id="segment_id">
{% include 'menu.html' %}
<div class="ui grid">
<div class="ui column" style="width: 75px; padding-top: 50px;">
{% include 'project/sidebar.html' %}
</div>
<script>
$(document).ready(function () {
$('.message .close')
.on('click', function () {
$(this)
.closest('.message')
.transition('fade')
;
});
});
</script>
<div class="ui column" style="width: calc(100% - 75px)">
<h1 class="ui dividing header">DNSrecon</h1>
<div class="ui container" style="width: 100%">
<div class="ui relaxed divided items">
<div class="item">
<div class="ui small image">
{% if external_img %}
<img src="https://i.ibb.co/CQfVf1P/the-Harvester-logo.png">
{% else %}
<img src="/static/images/theHarvester-logo.png">
{% endif %}
</div>
<div class="content">
<a class="header">theHarvester</a>
<div class="meta">
<a>DNS subdomain finder</a>
</div>
<div class="description">
theHarvester is a very simple to use, yet powerful and effective tool designed to be used in the early stages of a penetration test or red team engagement. Use it for open source intelligence (OSINT) gathering to help determine a company's external threat landscape on
the internet.
</div>
<div class="extra">
<a href="https://github.com/laramies/theHarvester" class="ui right floated purple button" target="_blank" rel="noopener noreferrer">
Official site
<i class="right chevron icon"></i>
</a>
</div>
</div>
</div>
</div>
<div class="ui divider"></div>
<h2 class="ui header">Upload reports</h2>
<form class="ui form" enctype="multipart/form-data" method="post" action="/project/{{ current_project['id'] }}/tools/theharvester/">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
<div class="two fields">
<div class="ui field">
<label>XML-reports:</label>
<input type="file" name="xml_files" placeholder="" multiple accept=".xml">
</div>
<div class="ui field">
<label>Hosts description:</label>
<input type="text" name="hosts_description" placeholder="Added from theHarvester scan" value="Added from theHarvester scan">
</div>
</div>
<div class="two fields">
<div class="ui field">
<button style="margin-top:20px" type="submit" class="ui button blue"><i class="plus icon"></i>Submit</button>
</div>
<div class="ui field">
<label>Hostnames description:</label>
<input type="text" name="hostnamems_description" placeholder="Added from theHarvester scan" value="Added from theHarvester scan">
</div>
</div>


</form>
{% if errors is defined and errors %}
<div class="ui error message visible">
<i class="close icon"></i>
<div class="header">
There were some errors with host
</div>
<ul class="list">
{% for error in errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
</div>
{% elif errors is defined and not errors %}
<div class="ui success message visible">
<i class="close icon"></i>
<div class="header">
Successfully uploaded!
</div>
</div>
{% endif %}
</div>
</div>
{% include 'footer.html' %}
</div>
</div>
</body>
</html>
5 changes: 5 additions & 0 deletions templates/project/tools/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ <h1 class="ui dividing header">Tools</h1>
<td><h4>DNSRecon is a simple python script that enables to gather DNS-oriented information on a given target.</h4></td>
<td><a class="ui button blue" href="dnsrecon/" style="width:100px;"><i class="share icon"></i>Open</a></td>
</tr>
<tr>
<td><h4>theHarvester</h4></td>
<td><h4>theHarvester is a very simple to use, yet powerful and effective tool designed to be used in the early stages of a penetration test or red team engagement. Use it for open source intelligence (OSINT) gathering to help determine a company's external threat landscape on the internet.</h4></td>
<td><a class="ui button blue" href="theharvester/" style="width:100px;"><i class="share icon"></i>Open</a></td>
</tr>
</tbody>
</table>
</div>
Expand Down

0 comments on commit cccb1bb

Please sign in to comment.