GTFOBins.github.io/_includes/bin_table.html

95 lines
2.8 KiB
HTML
Raw Normal View History

2018-05-29 21:32:26 +02:00
<input id="bin-search" type="text" placeholder="Search among {{ site.gtfobins | size }} 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>
function filter(query) {
// consistently update the URL
location.hash = query;
2018-05-21 21:14:41 +02:00
// determine the query type
2018-05-23 16:00:31 +02:00
var queryType = query[0];
if (queryType === '/') {
query = query.slice(1);
}
// filter rows
var noResults = true;
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 = Array.from(row.children[1].firstElementChild.children)
.map(function (x) { return x.innerText })
.join('\n').toLowerCase();
2018-05-23 16:00:31 +02:00
var against = (queryType === '/' ? functions : binName);
2018-05-23 16:00:31 +02:00
if (against.indexOf(query) !== -1) {
2018-05-21 21:14:41 +02:00
row.style.display = '';
noResults = false;
} else {
row.style.display = 'none';
}
});
// update the search message visibility
var searchMessage = document.getElementById('search-message');
searchMessage.style.display = noResults ? 'initial' : 'none';
}
(function () {
var searchBox = document.getElementById('bin-search');
// ensure height during filtering
var binTableWrapper = document.getElementById('bin-table-wrapper');
binTableWrapper.style.height = binTableWrapper.clientHeight + 'px';
// handle user input
searchBox.addEventListener('input', function () {
var query = searchBox.value.toLowerCase().trim();
filter(query);
});
2018-05-29 12:10:30 +02:00
// handle shortcuts
addEventListener('keydown', function (event) {
2018-05-29 12:10:30 +02:00
// focus search box on valid keydown
if (event.key.toLowerCase().match(/^[\/a-z]$/) &&
!(event.ctrlKey || event.altKey || event.metaKey)) {
searchBox.focus();
}
2018-05-29 12:10:30 +02:00
// clear filter on escape
else if (event.key === 'Escape') {
searchBox.value = '';
searchBox.focus();
filter('');
}
});
2018-05-21 21:14:41 +02:00
// filter on load according to the URL
var query = decodeURIComponent(location.hash.slice(1));
filter(query);
if (query) {
searchBox.value = query;
2018-05-21 21:14:41 +02:00
searchBox.focus();
}
})();
2018-05-21 21:14:41 +02:00
</script>