diff options
-rw-r--r-- | .gitignore | 3 | ||||
-rw-r--r-- | Capture-decryption/.gitignore | 2 | ||||
-rw-r--r-- | Capture-decryption/Capture.proto | 23 | ||||
-rw-r--r-- | Capture-decryption/Capture_pb2.py | 193 | ||||
-rw-r--r-- | Capture-decryption/Dockerfile (renamed from qc_decrypt/Dockerfile) | 0 | ||||
-rw-r--r-- | Capture-decryption/Makefile (renamed from qc_decrypt/Makefile) | 0 | ||||
-rw-r--r-- | Capture-decryption/README.md | 42 | ||||
-rw-r--r-- | Capture-decryption/decode_capture.py | 24 | ||||
-rw-r--r-- | Capture-decryption/qc_decrypt.c (renamed from qc_decrypt/qc_decrypt.c) | 36 | ||||
-rw-r--r-- | Capture-decryption/requirements.txt | 1 | ||||
-rw-r--r-- | QC-dev-environment/Dockerfile | 4 | ||||
-rw-r--r-- | qc_decrypt/.gitignore | 1 | ||||
-rw-r--r-- | qc_decrypt/README.md | 23 |
13 files changed, 325 insertions, 27 deletions
@@ -1 +1,2 @@ -.vscode
\ No newline at end of file +.vscode +Capture-decryption/__pycache__ diff --git a/Capture-decryption/.gitignore b/Capture-decryption/.gitignore new file mode 100644 index 0000000..e698163 --- /dev/null +++ b/Capture-decryption/.gitignore @@ -0,0 +1,2 @@ +qc_decrypt +/data/*
\ No newline at end of file diff --git a/Capture-decryption/Capture.proto b/Capture-decryption/Capture.proto new file mode 100644 index 0000000..01e66ad --- /dev/null +++ b/Capture-decryption/Capture.proto @@ -0,0 +1,23 @@ +syntax = "proto3"; + +package captureProto; + +message Capture { + float sample_rate = 1; + uint32 pre_filter_length = 2; + uint32 post_filter_length = 3; + repeated float pre_filter_coefficients = 4; + repeated float post_filter_coefficients = 5; + float constant_pre_gain = 6; + float constant_post_gain = 7; + uint32 number_of_layers = 8; + repeated uint32 layer_sizes = 9; + repeated layerWeightsAndBiases weights_and_biases = 10; + float high_pass_frequency = 11; + float high_pass_bandwidth = 12; +} + +message layerWeightsAndBiases { + repeated float weights = 1; + repeated float biases = 2; +}
\ No newline at end of file diff --git a/Capture-decryption/Capture_pb2.py b/Capture-decryption/Capture_pb2.py new file mode 100644 index 0000000..fb6b9eb --- /dev/null +++ b/Capture-decryption/Capture_pb2.py @@ -0,0 +1,193 @@ +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: Capture.proto + +import sys +_b=sys.version_info[0]<3 and (lambda x:x) or (lambda x:x.encode('latin1')) +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database +from google.protobuf import descriptor_pb2 +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + + + +DESCRIPTOR = _descriptor.FileDescriptor( + name='Capture.proto', + package='captureProto', + syntax='proto3', + serialized_pb=_b('\n\rCapture.proto\x12\x0c\x63\x61ptureProto\"\xf9\x02\n\x07\x43\x61pture\x12\x13\n\x0bsample_rate\x18\x01 \x01(\x02\x12\x19\n\x11pre_filter_length\x18\x02 \x01(\r\x12\x1a\n\x12post_filter_length\x18\x03 \x01(\r\x12\x1f\n\x17pre_filter_coefficients\x18\x04 \x03(\x02\x12 \n\x18post_filter_coefficients\x18\x05 \x03(\x02\x12\x19\n\x11\x63onstant_pre_gain\x18\x06 \x01(\x02\x12\x1a\n\x12\x63onstant_post_gain\x18\x07 \x01(\x02\x12\x18\n\x10number_of_layers\x18\x08 \x01(\r\x12\x13\n\x0blayer_sizes\x18\t \x03(\r\x12?\n\x12weights_and_biases\x18\n \x03(\x0b\x32#.captureProto.layerWeightsAndBiases\x12\x1b\n\x13high_pass_frequency\x18\x0b \x01(\x02\x12\x1b\n\x13high_pass_bandwidth\x18\x0c \x01(\x02\"8\n\x15layerWeightsAndBiases\x12\x0f\n\x07weights\x18\x01 \x03(\x02\x12\x0e\n\x06\x62iases\x18\x02 \x03(\x02\x62\x06proto3') +) +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + + + + +_CAPTURE = _descriptor.Descriptor( + name='Capture', + full_name='captureProto.Capture', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='sample_rate', full_name='captureProto.Capture.sample_rate', index=0, + number=1, type=2, cpp_type=6, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='pre_filter_length', full_name='captureProto.Capture.pre_filter_length', index=1, + number=2, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='post_filter_length', full_name='captureProto.Capture.post_filter_length', index=2, + number=3, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='pre_filter_coefficients', full_name='captureProto.Capture.pre_filter_coefficients', index=3, + number=4, type=2, cpp_type=6, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='post_filter_coefficients', full_name='captureProto.Capture.post_filter_coefficients', index=4, + number=5, type=2, cpp_type=6, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='constant_pre_gain', full_name='captureProto.Capture.constant_pre_gain', index=5, + number=6, type=2, cpp_type=6, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='constant_post_gain', full_name='captureProto.Capture.constant_post_gain', index=6, + number=7, type=2, cpp_type=6, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='number_of_layers', full_name='captureProto.Capture.number_of_layers', index=7, + number=8, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='layer_sizes', full_name='captureProto.Capture.layer_sizes', index=8, + number=9, type=13, cpp_type=3, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='weights_and_biases', full_name='captureProto.Capture.weights_and_biases', index=9, + number=10, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='high_pass_frequency', full_name='captureProto.Capture.high_pass_frequency', index=10, + number=11, type=2, cpp_type=6, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='high_pass_bandwidth', full_name='captureProto.Capture.high_pass_bandwidth', index=11, + number=12, type=2, cpp_type=6, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=32, + serialized_end=409, +) + + +_LAYERWEIGHTSANDBIASES = _descriptor.Descriptor( + name='layerWeightsAndBiases', + full_name='captureProto.layerWeightsAndBiases', + filename=None, + file=DESCRIPTOR, + containing_type=None, + fields=[ + _descriptor.FieldDescriptor( + name='weights', full_name='captureProto.layerWeightsAndBiases.weights', index=0, + number=1, type=2, cpp_type=6, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + _descriptor.FieldDescriptor( + name='biases', full_name='captureProto.layerWeightsAndBiases.biases', index=1, + number=2, type=2, cpp_type=6, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + options=None), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=411, + serialized_end=467, +) + +_CAPTURE.fields_by_name['weights_and_biases'].message_type = _LAYERWEIGHTSANDBIASES +DESCRIPTOR.message_types_by_name['Capture'] = _CAPTURE +DESCRIPTOR.message_types_by_name['layerWeightsAndBiases'] = _LAYERWEIGHTSANDBIASES + +Capture = _reflection.GeneratedProtocolMessageType('Capture', (_message.Message,), dict( + DESCRIPTOR = _CAPTURE, + __module__ = 'Capture_pb2' + # @@protoc_insertion_point(class_scope:captureProto.Capture) + )) +_sym_db.RegisterMessage(Capture) + +layerWeightsAndBiases = _reflection.GeneratedProtocolMessageType('layerWeightsAndBiases', (_message.Message,), dict( + DESCRIPTOR = _LAYERWEIGHTSANDBIASES, + __module__ = 'Capture_pb2' + # @@protoc_insertion_point(class_scope:captureProto.layerWeightsAndBiases) + )) +_sym_db.RegisterMessage(layerWeightsAndBiases) + + +# @@protoc_insertion_point(module_scope) diff --git a/qc_decrypt/Dockerfile b/Capture-decryption/Dockerfile index b8daecc..b8daecc 100644 --- a/qc_decrypt/Dockerfile +++ b/Capture-decryption/Dockerfile diff --git a/qc_decrypt/Makefile b/Capture-decryption/Makefile index d446c7a..d446c7a 100644 --- a/qc_decrypt/Makefile +++ b/Capture-decryption/Makefile diff --git a/Capture-decryption/README.md b/Capture-decryption/README.md new file mode 100644 index 0000000..4a9a8e8 --- /dev/null +++ b/Capture-decryption/README.md @@ -0,0 +1,42 @@ +# NeuralDSP QuadCortex Neural Capture file decryptor. + +This tool can be used to take one of the encrypted `.cns` or `.json` files, and decrypt them to a usable format. The `.cns` files are actually protobufs and can be decoded with the Python decoder. + +Build the image: + +```sh +docker build . -t qc_decrypt +``` + +To decrypt user files (pass the serial number found in `/etc/qc_sn` as command line argument): + +```sh +docker run -v/path/to/your/files/:/data qc_decrypt QA00XXXXX /data/encrypted.json +``` + +To decrypt update files instead, provide an empty serial: + +```sh +docker run -v/path/to/your/files/:/data qc_decrypt "" /data/encrypted.json +``` + +## License + +This tool was made with ♥ by [Simone Margaritelli](https://www.evilsocket.net/) and it is released under the GPL 3 license. + +# Unencrypted Neural Capture file decoder + +This tool allows you to decode the files, decrypted using the tool above. + +## Dependencies +You need to use the protobuf 3.20 package for this to work. You can get it by running: + +``` +pip install protobuf==3.20.* +``` + +## Usage + +``` +python decode_capture.py <your-file>.cns.dec +```
\ No newline at end of file diff --git a/Capture-decryption/decode_capture.py b/Capture-decryption/decode_capture.py new file mode 100644 index 0000000..dd3d413 --- /dev/null +++ b/Capture-decryption/decode_capture.py @@ -0,0 +1,24 @@ +import sys +import google.protobuf.json_format as json_format +import Capture_pb2 + +if len(sys.argv) != 2: + print(f"Usage: {sys.argv[0]} <protobuf_file>") + sys.exit(1) + +protobuf_file = sys.argv[1] + +# Read the input protobuf from the file +with open(protobuf_file, "rb") as f: + input_data = f.read() + +# Parse the input protobuf into a message object +message = Capture_pb2.Capture() +message.ParseFromString(input_data) + +# Convert the message object to a JSON string +json_string = json_format.MessageToJson(message) + +# Save the JSON string to a file +with open("capture.json", "w") as f: + f.write(json_string)
\ No newline at end of file diff --git a/qc_decrypt/qc_decrypt.c b/Capture-decryption/qc_decrypt.c index 0f86e5d..f04947f 100644 --- a/qc_decrypt/qc_decrypt.c +++ b/Capture-decryption/qc_decrypt.c @@ -48,6 +48,16 @@ int main(int argc, char **argv) char *serialNumber = argv[1], *inputFileName = argv[2]; + printf("Input file name: %s\n", inputFileName); + + // Split into the path and the file name + char *path = strrchr(inputFileName, '/'); + if (path == NULL) + { + printf("No path found in %s\n", inputFileName); + return 1; + } + unsigned long serialSize = strlen(serialNumber); if (serialSize != 9 && serialSize != 0) { @@ -132,12 +142,36 @@ int main(int argc, char **argv) return 1; } - // print it + // Print and save the decrypted file for (int i = 0; i < outlen; i++) { printf("%c", plaintext[i]); } printf("\n"); + // Save the decrypted file to disk + // It should be saved to the same directory as the encrypted file with the extension .dec + char *outputFileName = (char *)malloc(strlen(inputFileName) + 5); + strcpy(outputFileName, inputFileName); + strcat(outputFileName, ".dec"); + + fp = fopen(outputFileName, "wb"); + if (!fp) + { + printf("can't open %s\n", outputFileName); + return 1; + } + + fwrite(plaintext, 1, outlen, fp); + + fclose(fp); + + free(key_material); + free(input); + free(plaintext); + free(outputFileName); + + EVP_CIPHER_CTX_free(ctx); + return 0; }
\ No newline at end of file diff --git a/Capture-decryption/requirements.txt b/Capture-decryption/requirements.txt new file mode 100644 index 0000000..bed47cd --- /dev/null +++ b/Capture-decryption/requirements.txt @@ -0,0 +1 @@ +protobuf==3.20.*
\ No newline at end of file diff --git a/QC-dev-environment/Dockerfile b/QC-dev-environment/Dockerfile index a1bd7c4..e6da7c5 100644 --- a/QC-dev-environment/Dockerfile +++ b/QC-dev-environment/Dockerfile @@ -3,7 +3,7 @@ FROM ubuntu:18.04 as builder # Add required packages in the noninteractive mode RUN apt-get -y update -RUN DEBIAN_FRONTEND=noninteractive apt-get -y -q install curl net-tools build-essential minicom tftpd-hpa git-all subversion openssh-server ncurses-dev php gawk g++ m4 libncurses5-dev texinfo flex bison php-cli vim php-xml python-setuptools python-dev make unzip rsync cpio bc lib32z1 lib32stdc++6 qemu qemu-user-static +RUN DEBIAN_FRONTEND=noninteractive apt-get -y -q install curl dos2unix net-tools build-essential minicom tftpd-hpa git-all subversion openssh-server ncurses-dev php gawk g++ m4 libncurses5-dev texinfo flex bison php-cli vim php-xml python-setuptools python-dev make unzip rsync cpio bc lib32z1 lib32stdc++6 qemu qemu-user-static # Set the workspace in /sc5xx_dev ARG TOOLCHAIN_PATH=/sc5xx_dev @@ -21,6 +21,8 @@ WORKDIR ${TOOLCHAIN_PATH} # Copy the install_toolchain.sh to /sc5xx_dev COPY install_toolchain.sh . +RUN dos2unix install_toolchain.sh +RUN chmod +x install_toolchain.sh RUN ./install_toolchain.sh ${TOOLCHAIN_PATH} # # Set toolchain PATH for remote container diff --git a/qc_decrypt/.gitignore b/qc_decrypt/.gitignore deleted file mode 100644 index 0a38d0d..0000000 --- a/qc_decrypt/.gitignore +++ /dev/null @@ -1 +0,0 @@ -qc_decrypt
\ No newline at end of file diff --git a/qc_decrypt/README.md b/qc_decrypt/README.md deleted file mode 100644 index e16b33e..0000000 --- a/qc_decrypt/README.md +++ /dev/null @@ -1,23 +0,0 @@ -NeuralDSP QuadCortex file decryptor. - -Build the image: - -```sh -docker build . -t qc_decrypt -``` - -To decrypt user files (pass the serial number found in `/etc/qc_sn` as command line argument): - -```sh -docker run -v/path/to/your/files/:/data qc_decrypt QA00XXXXX /data/encrypted.json -``` - -To decrypt update files instead, provide an empty serial: - -```sh -docker run -v/path/to/your/files/:/data qc_decrypt "" /data/encrypted.json -``` - -## License - -This tool was made with ♥ by [Simone Margaritelli](https://www.evilsocket.net/) and it is released under the GPL 3 license. |