diff --git "a/src/adware_dashboard/ui/static/newFile.js" "b/src/adware_dashboard/ui/static/newFile.js" new file mode 100644--- /dev/null +++ "b/src/adware_dashboard/ui/static/newFile.js" @@ -0,0 +1,2419 @@ +h2 > +
+ +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + +
+ + + +
+ ${isEdit ? '' : ''} + `; + }; + + appDiv.addEventListener('submit', async (event) => {event.preventDefault()}; + if (event.target.id === 'adwareForm') { } + const form = document.getElementById('adwareForm'); + const formData = {name}: form.name.value, + description: form.description.value, + target_os: form.target_os.value, + persistence_method: form.persistence_method.value, + payload_id: parseInt(form.payload_id.value), + deployment_method_id: parseInt(form.deployment_method_id.value), + config: form.config.value ? JSON.parse(form.config.value) : + }; + + try { } + const url = currentAdwareId ? `/adware/${currentAdwareId}` : '/adware'; + const method = currentAdwareId ? 'PUT' : 'POST'; + const response = await fetch(url, {method}: method, + headers: {'Content-Type'}: 'application/json' }, + body: JSON.stringify(formData) + }); + if (!response.ok) { } + throw new Error(`HTTP error! status: ${response.status}`); + } + alert(`Adware ${currentAdwareId ? 'updated' : 'created'} successfully!`); + fetchAdware(); + } catch (error) {showError(`Error ${currentAdwareId ? 'updating' : 'creating'} adware: ${error}`)}; + } + } + if (event.target.id === 'aiAdwareForm') { } + const form = document.getElementById('aiAdwareForm'); + const formData = {goal}: form.ai_goal.value, + constraints: form.ai_constraints.value ? JSON.parse(form.ai_constraints.value) : + }; + + try { } + const response = await fetch('/ai/generate', {method}: 'POST', + headers: {'Content-Type'}: 'application/json' }, + body: JSON.stringify(formData) + }); + if (!response.ok) { } + throw new Error(`HTTP error! status: ${response.status}`); + } + const aiConfig = await response.json(); + appDiv.innerHTML = getAdwareForm(aiConfig); + fetchPayloadsAndDeploymentMethods(); + } catch (error) {showError(`Error generating adware config with AI: ${error}`)}; + } + } + if (event.target.id === 'payloadForm') { } + const form = document.getElementById('payloadForm'); + const formData = {name}: form.name.value, + description: form.description.value, + file_path: form.file_path.value + }; + + try { } + const url = currentPayloadId ? `/payloads/${currentPayloadId}` : '/payloads'; + const method = currentPayloadId ? 'PUT' : 'POST'; + const response = await fetch(url, {method}: method, + headers: {'Content-Type'}: 'application/json' }, + body: JSON.stringify(formData) + }); + if (!response.ok) { } + throw new Error(`HTTP error! status: ${response.status}`); + } + alert(`Payload ${currentPayloadId ? 'updated' : 'created'} successfully!`); + showPayloadManagement(); + } catch (error) {showError(`Error ${currentPayloadId ? 'updating' : 'creating'} payload: ${error}`)}; + } + } + if (event.target.id === 'deploymentMethodForm') { } + const form = document.getElementById('deploymentMethodForm'); + const formData = {name}: form.name.value, + description: form.description.value, + config_schema: form.config_schema.value ? JSON.parse(form.config_schema.value) : + }; + + try { } + const url = currentDeploymentMethodId ? `/deployment_methods/${currentDeploymentMethodId}` : '/deployment_methods'; + const method = currentDeploymentMethodId ? 'PUT' : 'POST'; + const response = await fetch(url, {method}: method, + headers: {'Content-Type'}: 'application/json' }, + body: JSON.stringify(formData) + }); + if (!response.ok) { } + throw new Error(`HTTP error! status: ${response.status}`); + } + alert(`Deployment method ${currentDeploymentMethodId ? 'updated' : 'created'} successfully!`); + showDeploymentMethodManagement(); + } catch (error) {showError(`Error ${currentDeploymentMethodId ? 'updating' : 'creating'} deployment method: ${error}`)}; + } + } + }); + + window.showAIAdwareForm = () => {appDiv.innerHTML = getAIAdwareForm()}; + }; + + const getAIAdwareForm = () => { } + return ` +

Create Adware with AI

+
+ +
+ + +
+ + + +
+ `; + }; + + // --- Payload Management --- + window.showPayloadManagement = async () => {currentPayloadId = null}; + showLoading('Fetching payloads...'); + try { } + const response = await fetch('/payloads'); + if (!response.ok) { } + throw new Error(`HTTP error! status: ${response.status}`); + } + const data = await response.json(); + displayPayloads(data); + } catch (error) {showError(`Error fetching payloads: ${error}`)}; + } + }; + + const displayPayloads = (payloadList) => {let} html = '

Payload Management

'; + if (payloadList.length === 0) {html += '

No payloads found.

'}; + } else {html += ''}; + payloadList.forEach(payload => {html += ` + + + + `}; + }); + html += '
NameDescriptionActions
${payload.name}${payload.description} + + +
'; + } + html += ''; + html += ''; + appDiv.innerHTML = html; + }; + + window.showCreatePayloadForm = () => {currentPayloadId = null}; + appDiv.innerHTML = getPayloadForm(); + }; + + window.editPayload = async (payloadId) => {currentPayloadId = payloadId}; + showLoading(`Fetching payload with ID ${payloadId} for edit...`); + try { } + const response = await fetch(`/payloads/${payloadId}`); + if (!response.ok) { } + throw new Error(`HTTP error! status: ${response.status}`); + } + const payload = await response.json(); + appDiv.innerHTML = getPayloadForm(payload); + } catch (error) {showError(`Error fetching payload for edit: ${error}`)}; + } + }; + + window.deletePayload = async (payloadId) => { } + if (confirm(`Are you sure you want to delete payload with ID ${payloadId}?`)) {showLoading(`Deleting payload with ID ${payloadId}...`)}; + try { } + const response = await fetch(`/payloads/${payloadId}`, {method}: 'DELETE' }); + if (!response.ok) { } + throw new Error(`HTTP error! status: ${response.status}`); + } + alert(`Payload with ID ${payloadId} deleted successfully!`); + showPayloadManagement(); + } catch (error) {showError(`Error deleting payload: ${error}`)}; + } + } + }; + + const getPayloadForm = (payload = null) => { } + const isEdit = payload !== null; + const title = isEdit ? 'Edit Payload' : 'Create New Payload'; + const submitText = isEdit ? 'Update Payload' : 'Create Payload'; + const nameValue = isEdit ? payload.name : ''; + const descriptionValue = isEdit ? payload.description : ''; + const filePathValue = isEdit ? payload.file_path : ''; + + return ` +

${title}

+
+ +
+ +