/* ESPILON Honeypot Dashboard — Credentials Tab */
import { S } from './state.js';
import { $id, escHtml, maskPassword, svcIcon, emptyState, skeletonRows } from './utils.js';
import { api } from './api.js';
export async function renderCredentials() {
const ml = $id('main-list');
if (!ml) return;
ml.innerHTML = skeletonRows(5);
if (!S.credentials) {
S.credentials = await api('/api/honeypot/credentials');
}
const c = S.credentials;
if (!c) {
ml.innerHTML = emptyState('\uD83D\uDD12', 'No credential data', 'Captured credentials will be shown here');
return;
}
let html = '
';
// Top Usernames
html += '
';
html += '
| # | Username | Count | Services |
';
const users = c.top_usernames || [];
for (let i = 0; i < users.length; i++) {
const u = users[i];
html += '| ' + (i + 1) + ' | '
+ '' + escHtml(u.username) + ' | '
+ '' + u.cnt + ' | '
+ '' + escHtml(Array.isArray(u.services) ? u.services.join(', ') : (u.services || '')) + ' |
';
}
html += '
';
// Top Passwords
html += '
';
html += '
| # | Password | Count | Services |
';
const passwords = c.top_passwords || [];
for (let i = 0; i < passwords.length; i++) {
const p = passwords[i];
const masked = maskPassword(p.password);
html += '| ' + (i + 1) + ' | '
+ '' + escHtml(masked) + ' | '
+ '' + p.cnt + ' | '
+ '' + escHtml(Array.isArray(p.services) ? p.services.join(', ') : (p.services || '')) + ' |
';
}
html += '
';
// Top Combos
html += '
';
html += '
| # | Username:Password | Count | Service |
';
const combos = c.top_combos || [];
for (let i = 0; i < combos.length; i++) {
const cb = combos[i];
html += '| ' + (i + 1) + ' | '
+ '' + escHtml(cb.username) + ':' + escHtml(maskPassword(cb.password)) + ' | '
+ '' + cb.cnt + ' | '
+ '' + escHtml(cb.service || '') + ' |
';
}
html += '
';
// By Service
html += '
';
html += '
| Service | Unique Users | Total Attempts |
';
const bySvc = c.by_service || [];
for (let i = 0; i < bySvc.length; i++) {
const sv = bySvc[i];
html += '| ' + svcIcon(sv.service) + ' ' + escHtml(sv.service) + ' | '
+ '' + sv.unique_users + ' | '
+ '' + sv.total_attempts + ' |
';
}
html += '
';
html += '
';
ml.innerHTML = html;
}