From 0ecd6c8f54f4619d20d902177ac1e7c5fb0fe0d1 Mon Sep 17 00:00:00 2001 From: Vincent Rose Date: Sun, 12 Nov 2023 11:56:56 -0700 Subject: [PATCH 1/9] Vuex -> Pinia (#175) * start pinia conversion. Convert listeners * convert stager store * convert bypasses to pinia * convert credential * convert malleable * convert plugins * convert obfuscation * users converted. chat broken * convert modules * finish initial conversion. remove vuex. still have todos * fix axios setup * fixes after reviewing diff * fix a couple bugs on credentials * Changelog * fix more issues --- CHANGELOG.md | 2 + package.json | 8 +- src/App.vue | 21 +- src/api/axios-instance.js | 9 +- src/components/Chat.vue | 25 +- src/components/ClickToEdit.vue | 9 +- src/components/GeneralForm.vue | 43 +- src/components/Login.vue | 19 +- src/components/NotificationBell.vue | 15 +- src/components/SideNav.vue | 7 +- src/components/SocketNotifications.vue | 46 +- src/components/agents/AgentExecuteModule.vue | 21 +- src/components/agents/AgentForm.vue | 25 +- src/components/agents/AgentTasksList.vue | 32 +- src/components/agents/AgentTerminal.vue | 13 +- src/components/agents/AgentsList.vue | 50 +-- src/components/agents/AgentsTable.vue | 42 +- src/components/listeners/ListenersList.vue | 17 +- src/components/listeners/ListenersTable.vue | 16 +- .../listeners/MalleableProfilesList.vue | 17 +- src/components/modules/ModulesTable.vue | 13 +- src/components/plugins/PluginTasksList.vue | 33 +- src/components/plugins/PluginsList.vue | 13 +- src/components/stagers/StagersTable.vue | 21 +- src/main.js | 10 +- src/router/index.js | 6 +- src/store/AgentModule.js | 115 ----- src/store/ApplicationModule.js | 204 --------- src/store/BypassModule.js | 34 -- src/store/CredentialModule.js | 36 -- src/store/ListenerModule.js | 67 --- src/store/MalleableModule.js | 36 -- src/store/ModuleModule.js | 20 - src/store/ObfuscationModule.js | 41 -- src/store/PluginModule.js | 23 - src/store/StagerModule.js | 56 --- src/store/agent-module.js | 99 +++++ src/store/application-module.js | 116 +++++ src/store/bypass-module.js | 25 ++ src/store/credential-module.js | 25 ++ src/store/index.js | 45 -- src/store/listener-module.js | 43 ++ src/store/malleable-module.js | 25 ++ src/store/module-module.js | 16 + src/store/obfuscation-module.js | 28 ++ src/store/plugin-module.js | 16 + src/store/stager-module.js | 36 ++ src/store/{UserModule.js => user-module.js} | 20 +- src/views/AgentEdit.vue | 23 +- src/views/BypassEdit.vue | 6 +- src/views/Bypasses.vue | 16 +- src/views/CredentialEdit.vue | 13 +- src/views/Credentials.vue | 19 +- src/views/ListenerEdit.vue | 15 +- src/views/MalleableProfileEdit.vue | 14 +- src/views/ModuleExecute.vue | 21 +- src/views/Notifications.vue | 15 +- src/views/Obfuscation.vue | 27 +- src/views/Settings.vue | 58 +-- src/views/StagerEdit.vue | 17 +- src/views/Stagers.vue | 33 +- src/views/UserEdit.vue | 7 +- src/views/Users.vue | 19 +- yarn.lock | 407 ++++++++++-------- 64 files changed, 1136 insertions(+), 1233 deletions(-) delete mode 100644 src/store/AgentModule.js delete mode 100644 src/store/ApplicationModule.js delete mode 100644 src/store/BypassModule.js delete mode 100644 src/store/CredentialModule.js delete mode 100644 src/store/ListenerModule.js delete mode 100644 src/store/MalleableModule.js delete mode 100644 src/store/ModuleModule.js delete mode 100644 src/store/ObfuscationModule.js delete mode 100644 src/store/PluginModule.js delete mode 100644 src/store/StagerModule.js create mode 100644 src/store/agent-module.js create mode 100644 src/store/application-module.js create mode 100644 src/store/bypass-module.js create mode 100644 src/store/credential-module.js delete mode 100644 src/store/index.js create mode 100644 src/store/listener-module.js create mode 100644 src/store/malleable-module.js create mode 100644 src/store/module-module.js create mode 100644 src/store/obfuscation-module.js create mode 100644 src/store/plugin-module.js create mode 100644 src/store/stager-module.js rename src/store/{UserModule.js => user-module.js} (66%) diff --git a/CHANGELOG.md b/CHANGELOG.md index c8c409d..3fdcc99 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +- Migrate from Vuex to Pinia + ## [2.6.1] - 2023-09-25 - Make notification bell menu scrollable with a max height diff --git a/package.json b/package.json index 5e45dab..81e0954 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,8 @@ "axios": "^0.24.0", "lodash.debounce": "^4.0.8", "moment": "^2.29.1", + "pinia": "^2.1.7", + "pinia-plugin-persistedstate": "^3.2.0", "portal-vue": "^2.1.7", "qs": "^6.10.3", "semver": "^7.3.5", @@ -28,9 +30,7 @@ "vue": "2.7", "vue-beautiful-chat": "^2.5.0", "vue-router": "^3.5.1", - "vuetify": "^2.6.0", - "vuex": "^3.6.2", - "vuex-persistedstate": "^3.0.1" + "vuetify": "^2.6.0" }, "devDependencies": { "@rushstack/eslint-patch": "^1.2.0", @@ -42,6 +42,6 @@ "prettier": "^3.0.2", "sass": "~1.32", "unplugin-vue-components": "^0.22.12", - "vite": "^3" + "vite": "^4" } } diff --git a/src/App.vue b/src/App.vue index 6db6310..ec4cb59 100644 --- a/src/App.vue +++ b/src/App.vue @@ -1,6 +1,6 @@ diff --git a/src/components/agents/AgentCommandViewer.vue b/src/components/agents/AgentCommandViewer.vue deleted file mode 100644 index dc2674d..0000000 --- a/src/components/agents/AgentCommandViewer.vue +++ /dev/null @@ -1,111 +0,0 @@ - - - - - diff --git a/src/components/agents/AgentCommandViewerEntry.vue b/src/components/agents/AgentCommandViewerEntry.vue deleted file mode 100644 index bfe9b9f..0000000 --- a/src/components/agents/AgentCommandViewerEntry.vue +++ /dev/null @@ -1,79 +0,0 @@ - - - - - From d6fe9c3654cae0c3aed2dcf19ddd6930eee85e3c Mon Sep 17 00:00:00 2001 From: Vince Rose Date: Sun, 12 Nov 2023 12:53:50 -0700 Subject: [PATCH 3/9] store -> stores --- src/App.vue | 2 +- src/api/axios-instance.js | 2 +- src/components/Chat.vue | 4 ++-- src/components/ClickToEdit.vue | 2 +- src/components/GeneralForm.vue | 8 ++++---- src/components/Login.vue | 2 +- src/components/NotificationBell.vue | 2 +- src/components/SideNav.vue | 2 +- src/components/SocketNotifications.vue | 8 ++++---- src/components/agents/AgentExecuteModule.vue | 2 +- src/components/agents/AgentForm.vue | 4 ++-- src/components/agents/AgentTasksList.vue | 4 ++-- src/components/agents/AgentTerminal.vue | 2 +- src/components/agents/AgentsList.vue | 4 ++-- src/components/agents/AgentsTable.vue | 4 ++-- src/components/listeners/ListenersList.vue | 2 +- src/components/listeners/ListenersTable.vue | 2 +- src/components/listeners/MalleableProfilesList.vue | 2 +- src/components/modules/ModulesTable.vue | 2 +- src/components/plugins/PluginTasksList.vue | 4 ++-- src/components/plugins/PluginsList.vue | 2 +- src/components/stagers/StagersTable.vue | 4 ++-- src/router/index.js | 2 +- src/{store => stores}/agent-module.js | 2 +- src/{store => stores}/application-module.js | 0 src/{store => stores}/bypass-module.js | 0 src/{store => stores}/credential-module.js | 0 src/{store => stores}/listener-module.js | 0 src/{store => stores}/malleable-module.js | 0 src/{store => stores}/module-module.js | 0 src/{store => stores}/obfuscation-module.js | 0 src/{store => stores}/plugin-module.js | 0 src/{store => stores}/stager-module.js | 0 src/{store => stores}/user-module.js | 0 src/views/AgentEdit.vue | 2 +- src/views/BypassEdit.vue | 2 +- src/views/Bypasses.vue | 2 +- src/views/CredentialEdit.vue | 2 +- src/views/Credentials.vue | 2 +- src/views/ListenerEdit.vue | 2 +- src/views/MalleableProfileEdit.vue | 2 +- src/views/ModuleExecute.vue | 2 +- src/views/Notifications.vue | 2 +- src/views/Obfuscation.vue | 2 +- src/views/Settings.vue | 4 ++-- src/views/StagerEdit.vue | 2 +- src/views/Stagers.vue | 4 ++-- src/views/UserEdit.vue | 2 +- src/views/Users.vue | 4 ++-- 49 files changed, 55 insertions(+), 55 deletions(-) rename src/{store => stores}/agent-module.js (97%) rename src/{store => stores}/application-module.js (100%) rename src/{store => stores}/bypass-module.js (100%) rename src/{store => stores}/credential-module.js (100%) rename src/{store => stores}/listener-module.js (100%) rename src/{store => stores}/malleable-module.js (100%) rename src/{store => stores}/module-module.js (100%) rename src/{store => stores}/obfuscation-module.js (100%) rename src/{store => stores}/plugin-module.js (100%) rename src/{store => stores}/stager-module.js (100%) rename src/{store => stores}/user-module.js (100%) diff --git a/src/App.vue b/src/App.vue index ec4cb59..56b17aa 100644 --- a/src/App.vue +++ b/src/App.vue @@ -77,7 +77,7 @@ import Confirm from "@/components/Confirm.vue"; import SocketNotifications from "@/components/SocketNotifications.vue"; import StarkillerSnackbar from "@/components/StarkillerSnackbar.vue"; import NotificationBell from "@/components/NotificationBell.vue"; -import { useApplicationStore } from "@/store/application-module"; +import { useApplicationStore } from "@/stores/application-module"; export default { name: "App", diff --git a/src/api/axios-instance.js b/src/api/axios-instance.js index 3b50a0c..49002ec 100644 --- a/src/api/axios-instance.js +++ b/src/api/axios-instance.js @@ -1,5 +1,5 @@ import axios from "axios"; -import { useApplicationStore } from "@/store/application-module"; +import { useApplicationStore } from "@/stores/application-module"; // eslint-disable-next-line import/no-mutable-exports export let axiosInstance = null; diff --git a/src/components/Chat.vue b/src/components/Chat.vue index b14576e..a8c449a 100644 --- a/src/components/Chat.vue +++ b/src/components/Chat.vue @@ -43,8 +43,8 @@ diff --git a/src/components/agents/AgentForm.vue b/src/components/agents/AgentForm.vue index 55fff89..67251ac 100644 --- a/src/components/agents/AgentForm.vue +++ b/src/components/agents/AgentForm.vue @@ -277,6 +277,7 @@ export default { return; } this.$snack.info(`Agent ${this.agent.name} name updated`); + this.$emit("refresh-agent"); }, async updateListener() { if (this.agent.listener === this.form.listener) return; @@ -293,7 +294,7 @@ export default { this.$snack.info( `Tasked agent to change listener to: ${this.form.listener}`, ); - await this.agentStore.getAgent({ sessionId: this.form.name }); + this.$emit("refresh-agent"); }, async updateKillDate() { let date = ""; @@ -309,7 +310,7 @@ export default { return; } this.$snack.info(`Tasked agent to change kill date to: ${date}`); - await this.agentStore.getAgent({ sessionId: this.form.name }); + this.$emit("refresh-agent"); }, async updateWorkingHours() { if (this.agent.working_hours === this.form.working_hours) return; @@ -326,6 +327,7 @@ export default { this.$snack.info( `Tasked agent to change working hours to: ${this.form.working_hours}`, ); + this.$emit("refresh-agent"); }, async updateDelay() { if (this.agent.delay === this.form.delay) return; @@ -341,6 +343,7 @@ export default { return; } this.$snack.info(`Tasked agent to change delay to: ${this.form.delay}`); + this.$emit("refresh-agent"); }, async updateJitter() { if (this.agent.jitter === this.form.jitter) return; @@ -356,6 +359,7 @@ export default { return; } this.$snack.info(`Tasked agent to change jitter to: ${this.form.jitter}`); + this.$emit("refresh-agent"); }, fieldExists(name) { return this.fields.filter((el) => el.name === name).length > 0; diff --git a/src/components/agents/AgentTasksList.vue b/src/components/agents/AgentTasksList.vue index 43da49b..307a3b8 100644 --- a/src/components/agents/AgentTasksList.vue +++ b/src/components/agents/AgentTasksList.vue @@ -1,11 +1,15 @@ @@ -87,6 +92,7 @@ export default { selectedTags: [], tags: [], moment, + autoRefresh: true, }; }, computed: { diff --git a/src/components/agents/AgentsTable.vue b/src/components/agents/AgentsTable.vue index d77f5b5..c47d3da 100644 --- a/src/components/agents/AgentsTable.vue +++ b/src/components/agents/AgentsTable.vue @@ -158,6 +158,10 @@ export default { type: Boolean, required: true, }, + refreshAgents: { + type: Boolean, + default: false, + }, }, data() { return { @@ -246,6 +250,7 @@ export default { selectedHeadersTemp: [], selected: [], showHeaderMenu: false, + refreshInterval: null, moment, }; }, @@ -319,6 +324,23 @@ export default { selected(val) { this.$emit("input", val); }, + refreshAgents: { + handler(newVal) { + if (newVal) { + this.getAgents(); + this.refreshInterval = setInterval(() => { + this.getAgents(); + }, 8000); + } else { + console.log("Clearing interval"); + clearInterval(this.refreshInterval); + } + }, + immediate: true, + }, + }, + beforeDestroy() { + clearInterval(this.refreshInterval); }, async mounted() { this.getAgents(); diff --git a/src/components/plugins/PluginTasksList.vue b/src/components/plugins/PluginTasksList.vue index 664533d..b0e57bd 100644 --- a/src/components/plugins/PluginTasksList.vue +++ b/src/components/plugins/PluginTasksList.vue @@ -1,11 +1,15 @@