GTFOBins.github.io/_includes/bin_table.html

66 lines
1.8 KiB
HTML
Raw Normal View History

2018-05-23 16:00:31 +02:00
<input id="bin-search" type="text" placeholder="Filter binaries by name (e.g., 'ftp') or by function (e.g., '/shell')"/>
2018-05-21 21:14:41 +02:00
<div id="bin-table-wrapper">
<table id="bin-table">
<thead>
<tr>
<th>Binary</th>
<th>Functions</th>
</tr>
</thead>
<tbody>
{% for file in site.gtfobins %}
<tr>
<td><a href="{{ file.url }}" class="bin-name">{% include get_bin_name path=file.path %}</a></td>
<td>{% include function_list.html bin=file %}</td>
</tr>
{% endfor %}
</tbody>
<tfoot>
<tr><td id="search-message" colspan="2">No binary matches...</td></tr>
</tfoot>
</table>
</div>
<script>
var searchBox = document.querySelector('#bin-search');
var searchMessage = document.querySelector('#search-message');
searchMessage.style.display = 'none';
// ensure height during filtering
var binTableWrapper = document.querySelector('#bin-table-wrapper');
binTableWrapper.style.height = binTableWrapper.clientHeight + 'px';
searchBox.addEventListener('input', function () {
var query = searchBox.value.toLowerCase().trim();
2018-05-23 16:00:31 +02:00
var queryType = query[0];
2018-05-21 21:14:41 +02:00
var noResults = true;
2018-05-23 16:00:31 +02:00
if (queryType === '/') {
query = query.slice(1);
}
2018-05-21 21:14:41 +02:00
document.querySelectorAll('#bin-table tbody tr').forEach(function (row) {
2018-05-23 16:00:31 +02:00
var binName = row.children[0].firstElementChild.innerText.toLowerCase();
var functions = row.children[1].firstElementChild.innerText.toLowerCase();
var against = (queryType === '/' ? functions : binName);
if (against.indexOf(query) !== -1) {
2018-05-21 21:14:41 +02:00
row.style.display = '';
noResults = false;
} else {
row.style.display = 'none';
}
});
searchMessage.style.display = noResults ? '' : 'none';
});
addEventListener('keydown', function (event) {
2018-05-23 16:00:31 +02:00
if (event.key.toLowerCase().match(/^[\/a-z]$/)) {
2018-05-21 21:14:41 +02:00
searchBox.focus();
}
});
</script>