|
|
|
@@ -389,7 +389,7 @@ const PINEAP_TABS = [
|
|
|
|
|
|
|
|
|
|
// The Pager daemon can change these states but cannot read them back. Keep
|
|
|
|
|
// them explicitly unknown until this WebUI successfully changes them.
|
|
|
|
|
const PINEAP_SESSION = { mode: null, karma: null, advertise: null, collect: null };
|
|
|
|
|
const PINEAP_SESSION = { karma: null, advertise: null, collect: null };
|
|
|
|
|
|
|
|
|
|
function setKnownCheckbox(cb, value) {
|
|
|
|
|
cb.indeterminate = value == null;
|
|
|
|
@@ -430,27 +430,6 @@ views.pineap = (root) => {
|
|
|
|
|
});
|
|
|
|
|
box.appendChild(statWrap);
|
|
|
|
|
|
|
|
|
|
const mode = h('span', { class: 'badge', text: '—' });
|
|
|
|
|
let selectedMode = 'unknown';
|
|
|
|
|
let modeDirty = false;
|
|
|
|
|
let modePending = false;
|
|
|
|
|
const segBtns = {};
|
|
|
|
|
const modeBar = h('div', { class: 'seg' });
|
|
|
|
|
['passive', 'active', 'advanced'].forEach((m) => {
|
|
|
|
|
const b = h('button', { class: 'seg-btn', text: m[0].toUpperCase() + m.slice(1) });
|
|
|
|
|
b.addEventListener('click', () => selectMode(m, true));
|
|
|
|
|
modeBar.appendChild(b);
|
|
|
|
|
segBtns[m] = b;
|
|
|
|
|
});
|
|
|
|
|
const modeInfo = h('div', { class: 'muted', style: 'margin-top:8px;font-size:12px' });
|
|
|
|
|
const saveModeBtn = btn('Save Mode', saveMode, 'ghost');
|
|
|
|
|
saveModeBtn.disabled = true;
|
|
|
|
|
const modeCard = h('div', { class: 'pineap-title-card' },
|
|
|
|
|
h('div', { class: 'pineap-card-title-flex' }, mode),
|
|
|
|
|
h('div', { class: 'pineap-card-button-group' }, modeBar),
|
|
|
|
|
modeInfo,
|
|
|
|
|
h('div', { class: 'pineap-mode-save' }, saveModeBtn));
|
|
|
|
|
|
|
|
|
|
const quick = {
|
|
|
|
|
collect: h('input', { type: 'checkbox', id: 'po-collect' }),
|
|
|
|
|
advertise: h('input', { type: 'checkbox', id: 'po-advertise' })
|
|
|
|
@@ -465,11 +444,6 @@ views.pineap = (root) => {
|
|
|
|
|
quickCard.appendChild(h('div', { class: 'muted', style: 'margin-top:8px;font-size:12px' },
|
|
|
|
|
'Client connect/disconnect notifications are handled by the Pager alert payload system.'));
|
|
|
|
|
|
|
|
|
|
const modeRow = h('div', { class: 'pineap-title-card-container' });
|
|
|
|
|
modeRow.appendChild(modeCard);
|
|
|
|
|
modeRow.appendChild(quickCard);
|
|
|
|
|
box.appendChild(modeRow);
|
|
|
|
|
|
|
|
|
|
const rfSel = h('select', {},
|
|
|
|
|
h('option', { value: 'uplink', text: 'Uplink (station)' }),
|
|
|
|
|
h('option', { value: 'attack', text: 'Attack' }),
|
|
|
|
@@ -523,9 +497,11 @@ views.pineap = (root) => {
|
|
|
|
|
h('label', {}, 'Uplink Password', rfPsk)));
|
|
|
|
|
rfCard.appendChild(rfApply);
|
|
|
|
|
rfCard.appendChild(rfResult);
|
|
|
|
|
const rfRow = h('div', { class: 'pineap-title-card-container' });
|
|
|
|
|
rfRow.appendChild(rfCard);
|
|
|
|
|
box.appendChild(rfRow);
|
|
|
|
|
|
|
|
|
|
const modeRow = h('div', { class: 'pineap-title-card-container' });
|
|
|
|
|
modeRow.appendChild(rfCard);
|
|
|
|
|
modeRow.appendChild(quickCard);
|
|
|
|
|
box.appendChild(modeRow);
|
|
|
|
|
|
|
|
|
|
const cards = { karma: {}, open: {}, wpa: {} };
|
|
|
|
|
const cardWrap = h('div', { class: 'pineap-title-card-container' });
|
|
|
|
@@ -559,9 +535,6 @@ views.pineap = (root) => {
|
|
|
|
|
}
|
|
|
|
|
function rememberAdvanced(key, value) {
|
|
|
|
|
PINEAP_SESSION[key] = value;
|
|
|
|
|
PINEAP_SESSION.mode = 'advanced';
|
|
|
|
|
modeDirty = false;
|
|
|
|
|
selectMode('advanced', false);
|
|
|
|
|
}
|
|
|
|
|
bind(quick.collect, (v) => PagerAPI.post('/api/pineap/ssidpool/collect', { enable: v }),
|
|
|
|
|
(v) => rememberAdvanced('collect', v));
|
|
|
|
@@ -569,80 +542,16 @@ views.pineap = (root) => {
|
|
|
|
|
(v) => rememberAdvanced('advertise', v));
|
|
|
|
|
setKnownCheckbox(quick.advertise, PINEAP_SESSION.advertise);
|
|
|
|
|
|
|
|
|
|
function renderModeInfo(m) {
|
|
|
|
|
modeInfo.innerHTML = '';
|
|
|
|
|
if (m === 'unknown') {
|
|
|
|
|
modeInfo.textContent = 'Select a mode to establish the Pager\'s PineAP preset.';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const descriptions = {
|
|
|
|
|
passive: ['Capture SSIDs to the impersonation pool', 'Do not broadcast the pool', 'Keep the PineAP response engine disabled'],
|
|
|
|
|
active: ['Capture SSIDs to the impersonation pool', 'Enable the PineAP response engine', 'Pool broadcast stays disabled (firmware crash fix)']
|
|
|
|
|
};
|
|
|
|
|
if (m === 'advanced') {
|
|
|
|
|
modeInfo.textContent = 'All supported PineAP features are individually customizable from Quick Settings and the PineAP tabs.';
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
modeInfo.appendChild(h('div', { text: 'In ' + m[0].toUpperCase() + m.slice(1) + ' Mode:' }));
|
|
|
|
|
const list = h('ul', { class: 'pineap-mode-features' });
|
|
|
|
|
descriptions[m].forEach((text) => list.appendChild(h('li', { text })));
|
|
|
|
|
modeInfo.appendChild(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function selectMode(m, dirty) {
|
|
|
|
|
selectedMode = m;
|
|
|
|
|
if (dirty) modeDirty = true;
|
|
|
|
|
Object.keys(segBtns).forEach((k) => segBtns[k].classList.toggle('active', k === m));
|
|
|
|
|
mode.textContent = m === 'unknown' ? 'Unknown' : m[0].toUpperCase() + m.slice(1);
|
|
|
|
|
mode.className = 'badge ' + (m === 'unknown' ? 'unknown' : 'on');
|
|
|
|
|
renderModeInfo(m);
|
|
|
|
|
saveModeBtn.disabled = !modeDirty || modePending || m === 'unknown';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function saveMode() {
|
|
|
|
|
if (!modeDirty || modePending || selectedMode === 'unknown') return;
|
|
|
|
|
modePending = true;
|
|
|
|
|
saveModeBtn.disabled = true;
|
|
|
|
|
saveModeBtn.classList.add('busy');
|
|
|
|
|
saveModeBtn.setAttribute('aria-busy', 'true');
|
|
|
|
|
PagerAPI.post('/api/pineap/mode', { mode: selectedMode }).then((r) => {
|
|
|
|
|
const state = r.data || {};
|
|
|
|
|
PINEAP_SESSION.mode = state.mode || selectedMode;
|
|
|
|
|
['karma', 'advertise', 'collect'].forEach((key) => {
|
|
|
|
|
if (typeof state[key] === 'boolean') PINEAP_SESSION[key] = state[key];
|
|
|
|
|
});
|
|
|
|
|
modeDirty = false;
|
|
|
|
|
selectMode(PINEAP_SESSION.mode, false);
|
|
|
|
|
App.toast('Mode: ' + PINEAP_SESSION.mode[0].toUpperCase() + PINEAP_SESSION.mode.slice(1));
|
|
|
|
|
load();
|
|
|
|
|
}).catch(() => { App.toast('Failed to save PineAP mode', 'error'); })
|
|
|
|
|
.finally(() => {
|
|
|
|
|
modePending = false;
|
|
|
|
|
saveModeBtn.classList.remove('busy');
|
|
|
|
|
saveModeBtn.removeAttribute('aria-busy');
|
|
|
|
|
saveModeBtn.disabled = !modeDirty;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let loadPending = false;
|
|
|
|
|
function load() {
|
|
|
|
|
if (loadPending) return;
|
|
|
|
|
loadPending = true;
|
|
|
|
|
const stateRequest = Promise.all([
|
|
|
|
|
PagerAPI.get('/api/pineap/get_config').catch(() => ({ data: {} })),
|
|
|
|
|
PagerAPI.get('/api/pineap/hostapd').catch(() => ({ data: {} })),
|
|
|
|
|
PagerAPI.post('/api/pineap/wifi/get_ap').catch(() => ({ data: {} })),
|
|
|
|
|
PagerAPI.get('/api/pineap/mode').catch(() => ({ data: {} }))
|
|
|
|
|
]).then(([cfg, host, ap, preset]) => {
|
|
|
|
|
const c = cfg.data || {}, hh = host.data || {}, a = ap.data || {}, p = preset.data || {};
|
|
|
|
|
const disabled = Object.prototype.hasOwnProperty.call(hh, 'pineap_disabled') ? !!hh.pineap_disabled : null;
|
|
|
|
|
PagerAPI.post('/api/pineap/wifi/get_ap').catch(() => ({ data: {} }))
|
|
|
|
|
]).then(([cfg, ap]) => {
|
|
|
|
|
const c = cfg.data || {}, a = ap.data || {};
|
|
|
|
|
const wpa = a.wpa || {};
|
|
|
|
|
PINEAP_SESSION.mode = ['passive', 'active', 'advanced'].indexOf(p.mode) !== -1 ? p.mode : 'unknown';
|
|
|
|
|
['karma', 'advertise', 'collect'].forEach((key) => {
|
|
|
|
|
if (typeof p[key] === 'boolean') PINEAP_SESSION[key] = p[key];
|
|
|
|
|
});
|
|
|
|
|
if (!modeDirty) selectMode(PINEAP_SESSION.mode, false);
|
|
|
|
|
mode.className = 'badge ' + (disabled === true ? 'off' : disabled === false ? 'on' : 'unknown');
|
|
|
|
|
const collect = typeof PINEAP_SESSION.collect === 'boolean'
|
|
|
|
|
? PINEAP_SESSION.collect
|
|
|
|
|
: Object.prototype.hasOwnProperty.call(c, 'autossidpool') ? !!c.autossidpool : null;
|
|
|
|
|