aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorThomas Van Iseghem <[email protected]>2023-04-22 16:14:54 +0200
committerThomas Van Iseghem <[email protected]>2023-04-22 16:14:54 +0200
commit6a137cabf733983d2f6c117839a170a0f11c3dbd (patch)
tree9d9e0cec74474081e8f50ab3e79cad51b1777285
parent8c4ee86826fcfcdfca30602e76e069f442736e88 (diff)
downloadOpenCortex-6a137cabf733983d2f6c117839a170a0f11c3dbd.tar.gz
OpenCortex-6a137cabf733983d2f6c117839a170a0f11c3dbd.zip
Added tool to decode .cns captures to JSON
-rw-r--r--.gitignore3
-rw-r--r--Capture-decryption/Capture.proto23
-rw-r--r--Capture-decryption/Capture_pb2.py193
-rw-r--r--Capture-decryption/README.md21
-rw-r--r--Capture-decryption/decode_capture.py24
-rw-r--r--Capture-decryption/requirements.txt1
6 files changed, 263 insertions, 2 deletions
diff --git a/.gitignore b/.gitignore
index 600d2d3..6834822 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
-.vscode \ No newline at end of file
+.vscode
+Capture-decryption/__pycache__
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/Capture-decryption/README.md b/Capture-decryption/README.md
index e16b33e..b0d0f12 100644
--- a/Capture-decryption/README.md
+++ b/Capture-decryption/README.md
@@ -1,4 +1,6 @@
-NeuralDSP QuadCortex file decryptor.
+## 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:
@@ -21,3 +23,20 @@ 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 > <output-name>.json
+``` \ 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..e841c55
--- /dev/null
+++ b/Capture-decryption/decode_capture.py
@@ -0,0 +1,24 @@
+import sys
+import json
+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)
+
+# Print the JSON string to stdout
+sys.stdout.write(json_string)
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