From 23b0d9daffe6a309a5089431b3d14bb8c510d9cc Mon Sep 17 00:00:00 2001 From: OviOvocny Date: Wed, 28 Feb 2024 13:52:48 +0100 Subject: [PATCH 01/13] Add .gitignore file and update addJobView.vue, update_be.sh, jobDetailView.vue, and responseModels.py --- .gitignore | 2 + update_be.sh | 24 ++ .../endpoints/hashlists/responseModels.py | 12 +- .../components/hashlist/hashListDetail.vue | 38 ++- .../components/hashlist/hashListLister.vue | 254 ++++++++---------- .../src/components/job/addJobView.vue | 1 + .../components/jobDetail/jobDetailView.vue | 6 +- .../components/selector/hashlistSelector.vue | 53 ++-- 8 files changed, 216 insertions(+), 174 deletions(-) create mode 100644 .gitignore create mode 100755 update_be.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..83550d5f3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.env +fitcrack-data/* \ No newline at end of file diff --git a/update_be.sh b/update_be.sh new file mode 100755 index 000000000..dc5a4ad90 --- /dev/null +++ b/update_be.sh @@ -0,0 +1,24 @@ +#!/bin/bash + +CONTAINER=fc-fitcrack_server-1 +ROOT_INSIDE=/var/www/html +PATH_TO_API=$1 + +# check if cwd is the root of the project +if [ ! -f "Dockerfile" ]; then + echo "You must run this script from the root of the project" + exit 1 +fi + +# Set default value for PATH_TO_API if not provided +if [ -z "$PATH_TO_API" ]; then + PATH_TO_API="fitcrackAPI/src/src" + echo "No path provided, using default path: $PATH_TO_API" +fi + +# remove the old directory inside the container +docker exec -t $CONTAINER rm -rf $ROOT_INSIDE/$PATH_TO_API +# copy the new directory inside the container +docker cp webadmin/$PATH_TO_API $CONTAINER:$ROOT_INSIDE/$PATH_TO_API +# restart the server inside the container +docker exec -t $CONTAINER service apache2 restart \ No newline at end of file diff --git a/webadmin/fitcrackAPI/src/src/api/fitcrack/endpoints/hashlists/responseModels.py b/webadmin/fitcrackAPI/src/src/api/fitcrack/endpoints/hashlists/responseModels.py index 6b7195a0a..b8e9eb2dd 100644 --- a/webadmin/fitcrackAPI/src/src/api/fitcrack/endpoints/hashlists/responseModels.py +++ b/webadmin/fitcrackAPI/src/src/api/fitcrack/endpoints/hashlists/responseModels.py @@ -18,19 +18,13 @@ 'cracked_hash_count' : fields.Integer(readOnly=True, required=True), 'added': fields.DateTime(readOnly=True, required=True), 'job_count' : fields.Integer(readOnly=True, required=True), - 'is_locked' : fields.Boolean(readOnly=True, required=True) + 'is_locked' : fields.Boolean(readOnly=True, required=True), + 'deleted' : fields.Boolean(readOnly=True, required=True) }) -hash_list_model_long = api.model('short hash list', { - 'id': fields.Integer(readOnly=True, required=False), - 'name' : fields.String(readOnly=True,required=True), - 'hash_type_name' : fields.String('hash_type',readOnly=True), - 'added': fields.DateTime(readOnly=True, required=True), - 'hash_count' : fields.Integer(readOnly=True, required=True), - 'cracked_hash_count' : fields.Integer(readOnly=True, required=True), +hash_list_model_long = api.inherit('long hash list', hash_list_model_short, { 'jobs' : fields.List(fields.Nested(job_nano_model)), - 'is_locked' : fields.Boolean(readOnly=True, required=True) }) diff --git a/webadmin/fitcrackFE/src/components/hashlist/hashListDetail.vue b/webadmin/fitcrackFE/src/components/hashlist/hashListDetail.vue index 8a3d7664e..8be00d9a8 100644 --- a/webadmin/fitcrackFE/src/components/hashlist/hashListDetail.vue +++ b/webadmin/fitcrackFE/src/components/hashlist/hashListDetail.vue @@ -21,7 +21,13 @@ {{ info.name }} - Hash type: {{ info.hash_type_name }} +
Created at: {{ new Date(info.added).toLocaleString() }} UTC
+
Hash type: {{ info.hash_type_name }}
+
+ Progress: {{ info.cracked_hash_count }} / {{ info.hash_count }} ({{ Math.round(percentProgress) }} %) + +
+ {{ info.deleted ? 'mdi-delete-restore' : 'mdi-delete' }} + {{ info.deleted ? 'Restore' : 'Discard' }} + + - mdi-delete - Discard or restore + mdi-undo + Purge @@ -63,7 +77,7 @@ - + @@ -88,6 +102,11 @@ import HashTable from './hashTable.vue' mounted: function () { this.loadHashlistData() }, + computed: { + percentProgress() { + return this.info.cracked_hash_count / this.info.hash_count * 100 + } + }, methods: { ...mapMutations('jobForm', ['hashListIdMut', 'stepMut']), fmt, @@ -106,6 +125,17 @@ import HashTable from './hashTable.vue' this.axios.delete(this.$serverAddr + '/hashlist/' + this.$route.params.id).then((response) => { this.$router.push({name: 'hashlists'}) }) + }, + purgeHashlistConfirm() { + this.$root.$confirm('Purge Hashlist', `This will undo all cracking progress for ${this.info.name}. Any attached and running job will be killed with it! Are you sure?`) + .then((confirm) => { + this.purgeHashlist() + }) + }, + purgeHashlist() { + this.axios.post(this.$serverAddr + '/hashlist/' + this.$route.params.id + '/purge').then((response) => { + this.loadHashlistData() + }) } } } diff --git a/webadmin/fitcrackFE/src/components/hashlist/hashListLister.vue b/webadmin/fitcrackFE/src/components/hashlist/hashListLister.vue index 9ad769e6c..57b43f2ed 100644 --- a/webadmin/fitcrackFE/src/components/hashlist/hashListLister.vue +++ b/webadmin/fitcrackFE/src/components/hashlist/hashListLister.vue @@ -8,11 +8,7 @@

Hashlists

- + mdi-book-plus @@ -20,57 +16,36 @@
- - - + + +
- + + +