Fix copy paste support

This commit is contained in:
alanfoster 2021-03-16 00:14:01 +00:00
parent 822fc9aa66
commit 9b1aa31c16

View File

@ -538,6 +538,21 @@
}); });
} }
const uiElements = {
[CommandType.ReverseShell]: {
listSelection: '#reverse-shell-selection',
command: '#reverse-shell-command'
},
[CommandType.BindShell]: {
listSelection: '#bind-shell-selection',
command: '#bind-shell-command',
},
[CommandType.MSFVenom]: {
listSelection: '#msfvenom-selection',
command: '#msfvenom-command'
}
};
const rsg = { const rsg = {
selectedValues: { selectedValues: {
[CommandType.ReverseShell]: filterCommandData(rsgData.reverseShellCommands, { commandType: CommandType.ReverseShell })[0].name, [CommandType.ReverseShell]: filterCommandData(rsgData.reverseShellCommands, { commandType: CommandType.ReverseShell })[0].name,
@ -548,15 +563,15 @@
filter: FilterType.All, filter: FilterType.All,
copyToClipboard: (text) => { copyToClipboard: (text) => {
// if (navigator ?.clipboard ?.writeText) { if (navigator ?.clipboard ?.writeText) {
// navigator.clipboard.writeText(text) navigator.clipboard.writeText(text)
// $('#clipboard-toast').toast('show') $('#clipboard-toast').toast('show')
// } else if (window ?.clipboardData ?.setData) { } else if (window ?.clipboardData ?.setData) {
// window.clipboardData.setData('Text', text); window.clipboardData.setData('Text', text);
// $('#clipboard-toast').toast('show') $('#clipboard-toast').toast('show')
// } else { } else {
// $('#clipboard-failure-toast').toast('show') $('#clipboard-failure-toast').toast('show')
// } }
}, },
escapeHTML: (text) => String(text).replace(/</, '&lt;').replace(/>/, '&gt;'), escapeHTML: (text) => String(text).replace(/</, '&lt;').replace(/>/, '&gt;'),
@ -685,13 +700,8 @@
documentFragment.appendChild(selectionButton); documentFragment.appendChild(selectionButton);
}) })
const listTargets = { const listSelectionElement = uiElements[rsg.commandType].listSelection;
[CommandType.ReverseShell]: '#reverse-shell-selection', document.querySelector(listSelectionElement).replaceChildren(documentFragment)
[CommandType.BindShell]: '#bind-shell-selection',
[CommandType.MSFVenom]: '#msfvenom-selection'
};
const listTarget = listTargets[rsg.commandType];
document.querySelector(listTarget).replaceChildren(documentFragment)
}, },
updateListenerCommand: () => { updateListenerCommand: () => {
@ -746,14 +756,8 @@
) )
} }
const commandTargets = { const commandElement = uiElements[rsg.commandType].command;
[CommandType.ReverseShell]: '#reverse-shell-command', document.querySelector(commandElement).innerHTML = command;
[CommandType.BindShell]: '#bind-shell-command',
[CommandType.MSFVenom]: '#msfvenom-command'
};
const commandTarget = commandTargets[rsg.commandType];
document.querySelector(commandTarget).innerHTML = command;
}, },
updateSwitchStates: () => { updateSwitchStates: () => {