Made database queries a thing for filtering. Tweaked gitignore again oof, added a toggle listener for marking hosts on the web page
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
app/scanned.db
|
app/scanned.db
|
||||||
*.xml
|
*.xml
|
||||||
**/*.pyc
|
**/*.pyc
|
||||||
|
**/*.swp
|
||||||
|
|||||||
@@ -41,6 +41,9 @@ tbody tr:hover td {
|
|||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tbody tr.active td {
|
||||||
|
background-color: #FFEFC6;
|
||||||
|
}
|
||||||
|
|
||||||
table tr:last-child td:first-child {
|
table tr:last-child td:first-child {
|
||||||
border-bottom-left-radius: 10px;
|
border-bottom-left-radius: 10px;
|
||||||
|
|||||||
+7
-18
@@ -1,20 +1,9 @@
|
|||||||
function filter_ports(filter) {
|
|
||||||
let portCol = document.querySelectorAll("tbody tr td:last-child");
|
|
||||||
portCol.forEach((item) => {
|
|
||||||
if(!new RegExp(filter).test(item.innerText)){
|
|
||||||
item.parentNode.style.display = "none";
|
|
||||||
} else {
|
|
||||||
item.parentNode.style.display = "table-row";
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
document.querySelector("#ports").addEventListener("keyup", (event) => {
|
|
||||||
if (event.key === "Enter") {
|
|
||||||
filter_ports(event.srcElement.value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
function count_rows() {
|
function count_rows() {
|
||||||
return document.querySelectorAll('tr:not([style*="display:none"]):not([style*="display: none"])').length;
|
return document.querySelectorAll('tr:not([style*="display:none"]):not([style*="display: none"])').length;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document.querySelectorAll("tbody tr").forEach(function(elem) {
|
||||||
|
elem.addEventListener("click", function() {
|
||||||
|
elem.classList.toggle('active');
|
||||||
|
});
|
||||||
|
});
|
||||||
Binary file not shown.
@@ -24,5 +24,5 @@
|
|||||||
{% block main %}
|
{% block main %}
|
||||||
<h1>404</h1>
|
<h1>404</h1>
|
||||||
<p>That page doesn't even exist.</p>
|
<p>That page doesn't even exist.</p>
|
||||||
<p>Why don't you just <a href="{{ url_for('home') }}">go back home</a>?</p>
|
<p>Why don't you just <a href="{{ url_for('get_home') }}">go back home</a>?</p>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -7,26 +7,26 @@
|
|||||||
<table id="scan-table">
|
<table id="scan-table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr class="table-header">
|
<tr class="table-header">
|
||||||
<th>OS</td>
|
<form method="POST">
|
||||||
<th>HOSTNAME</td>
|
<input type="submit" value="Submit Query" hidden>
|
||||||
<th>ADDRESS</td>
|
<th><input type="text" name="os" id="os" placeholder="OS" value="{{ os }}"></th>
|
||||||
<th><input type="text" name="ports" id="ports" placeholder="ports"></td>
|
<th><input type="text" name="hostname" id="hostname" placeholder="HOSTNAME" value="{{ hostname }}"></th>
|
||||||
|
<th><input type="text" name="address" id="address" placeholder="ADDRESS" value="{{ address }}"></th>
|
||||||
|
<th><input type="text" name="ports" id="ports" placeholder="PORTS" value="{{ ports }}"></th>
|
||||||
|
</form>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
{% for target in targets %}
|
{% for target in targets %}
|
||||||
<tr>
|
<tr>
|
||||||
<td class='{{target.os|lower}}'><img onerror="this.onerror=null;this.src='static/media/unsure.png';" src='static/media/{{target.os|lower}}.png'></td>
|
<td class='{{target.os|lower}}'><img onerror="this.onerror=null;this.src='static/media/unsure.png';" src='static/media/{{target.os|lower}}.png'></td>
|
||||||
<td>{{ target.hostname }}</td>
|
<td>{{ target.hostname }}</td>
|
||||||
<td>{{ target.address }}</td>
|
<td>{{ target.address }}</td>
|
||||||
<td>{{ target.ports }}</td>
|
<td>{{ target.ports[1:-1]|replace('|', ', ') }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
+31
-3
@@ -1,13 +1,41 @@
|
|||||||
from app import app, db
|
|
||||||
from flask import render_template, request, redirect, url_for, flash
|
from flask import render_template, request, redirect, url_for, flash
|
||||||
|
from sqlalchemy import select
|
||||||
from app.models import target
|
from app.models import target
|
||||||
|
from sqlalchemy import func
|
||||||
|
from app import app, db
|
||||||
|
|
||||||
@app.route('/')
|
@app.route('/', methods=['GET'])
|
||||||
def home():
|
def get_home():
|
||||||
"""Render website's home page."""
|
"""Render website's home page."""
|
||||||
targets = db.session.query(target).all()
|
targets = db.session.query(target).all()
|
||||||
return render_template('home.html', targets=targets)
|
return render_template('home.html', targets=targets)
|
||||||
|
|
||||||
|
@app.route('/', methods=['POST'])
|
||||||
|
def post_home():
|
||||||
|
"""Render website's home page with applied filters."""
|
||||||
|
targets = db.session.query(target)
|
||||||
|
|
||||||
|
os = request.form.get("os")
|
||||||
|
if os:
|
||||||
|
targets = targets.where(target.os == os)
|
||||||
|
|
||||||
|
hostname = request.form.get("hostname")
|
||||||
|
if hostname:
|
||||||
|
targets = targets.where(target.hostname == hostname)
|
||||||
|
|
||||||
|
address = request.form.get("address")
|
||||||
|
if address:
|
||||||
|
targets = targets.where(target.address == address)
|
||||||
|
|
||||||
|
ports = request.form.get("ports")
|
||||||
|
if ports:
|
||||||
|
for port in ports.replace(' ','').split(','):
|
||||||
|
targets = targets.filter(target.ports.like('%|'+port+'|%'))
|
||||||
|
|
||||||
|
|
||||||
|
return render_template('home.html', targets=targets.all(), os=os,hostname=hostname,address=address,ports=ports)
|
||||||
|
|
||||||
|
|
||||||
@app.after_request
|
@app.after_request
|
||||||
def add_header(response):
|
def add_header(response):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user