Thanks Thanks:  5
Likes Likes:  4
Dislikes Dislikes:  0
Page 1 of 3 123 LastLast
Results 1 to 10 of 26
  1. #1
    3D Printer Noob
    Join Date
    Mar 2017
    Posts
    12
    Post Thanks / Like

    .cube3 file decoder

    I have never been able to get the cube-decoder on github to work so I sat down with a friend last night and rewrote the code a bit. So here is the compiled program. We will post the source later this month once it has been cleaned up a bit. *note* I don't think this will work with .cubepro files but it should work all .cube3 files. If you do have issues, please post your .cube3 for me to look at. To run the program just drag your .cube3 onto the decoder and it should output a .bfb in the same directory as your input.

    https://drive.google.com/open?id=0B3...1B1M0dfdjFUZG8

    -Swinson

    Edit: My friend is doing more work on the program to make it function closer to what the OP wanted. He said he is going to upload it to github once he is done adding options for the cubex, cubepro < V2.0, and image prefix detection. I will add his link/credit once its posted. In the mean time I wanted to go ahead and post the code for this program (solution for just .cube3 files)The blowfish includes can be found here on the OP's original page: https://github.com/fritzw/cube-utils
    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <assert.h>
    #include "blowfish.h"
    long int fsize(FILE *f) {
    long int original, size;
    original = ftell(f);
    fseek(f, 0, SEEK_END);
    size = ftell(f);
    fseek(f, original, SEEK_SET);
    return size;
    }
    
    
    struct file_struct {
    size_t size;
    BYTE *data;
    };
    
    
    struct file_struct *create_file_struct(size_t size, BYTE *data);
    struct file_struct *read_file(char *name);
    struct file_struct *truncate_padding(struct file_struct *data);
    void load_data(BYTE *data, size_t infilesize, FILE *infile);
    void decrypt(struct file_struct *data, char *userkey);
    void write_file(FILE *outfile, struct file_struct *data);
    void save_output_file(char *name, struct file_struct *f);
    BYTE *allocate_data(size_t size);
    FILE *get_file(char *infilename);
    FILE *get_output_file(char *name);
    size_t get_file_size(FILE *infile);
    size_t get_model_data_offset(BYTE *data, size_t size);
    
    
    int main(int argc, char **argv) {
    char cubepro_key[] = "221BBakerMycroft";
    char bfb[] = ".bfb";
    char *infilename;
    char *outfilename;
    if (argc < 2) {
    return -1;
    }
    infilename = argv[1]; //assign argument
    struct file_struct *f = truncate_padding(read_file(infilename)); //read input file and remove prefix
    decrypt(f, cubepro_key); //run data through blowfish
        outfilename = strcat(infilename, bfb); //make outfile name
    save_output_file(outfilename, f); //save output file
    return 0;
    }
    
    
    FILE *get_file(char *infilename) {
    FILE *infile = fopen(infilename, "rb");
    if (infile == NULL) {
    perror("Unable to open input file");
    }
    return infile;
    }
    
    
    size_t get_file_size(FILE *infile) {
    size_t infilesize = fsize(infile);
    if (infilesize < 0) {
    perror("Unable to determine size of input file");
    return 3;
    } 
    return infilesize;
    }
    
    
    BYTE *allocate_data(size_t size) {
    BYTE *data = malloc(size); 
    if (data == NULL) {
    perror("Unable to allocate memory for input file");
    }
    return data;
    }
    
    
    void load_data(BYTE *data, size_t infilesize, FILE *infile) {
    size_t readcount = fread(data, 1, infilesize, infile);
    if (readcount != infilesize) {
    printf("Unable to read the whole input file: %zd != %zd\n", readcount, infilesize);
    }
    }
    
    
    struct file_struct *create_file_struct(size_t size, BYTE *data) {
    struct file_struct *f = malloc(sizeof(struct file_struct));
    f->size = size;
    f->data = data;
    return f;
    }
    
    
    struct file_struct *read_file(char *name) {
    FILE *infile = get_file(name);
    size_t size = get_file_size(infile);
    BYTE *data = allocate_data(size);
    load_data(data, size, infile);
    fclose(infile);
    return create_file_struct(size, data);
    }
    
    
    size_t get_model_data_offset(BYTE *data, size_t size) {
        int i;
    for (i=0; i < size; i++) {
    if (data[i] == 0xc8) {
    return i;
    }
    }
    }
    
    
    struct file_struct *truncate_padding(struct file_struct *data) {
    size_t offset = get_model_data_offset(data->data, data->size);
    size_t truncated_size = data->size - offset;
    BYTE *truncated_data = malloc(truncated_size);
    memcpy(truncated_data, data->data+offset, truncated_size );
    return create_file_struct(truncated_size, truncated_data);
    }
    
    
    void decrypt(struct file_struct *data, char *userkey) {
    BLOWFISH_KEY key;
    blowfish_key_setup((BYTE*) userkey, &key, strlen(userkey));
    int i;
    for (i = 0; i < data->size; i += 8) {
    blowfish_decrypt(&data->data[i], &data->data[i], &key, 1);
    }
    }
    
    
    FILE *get_output_file(char *name) {
    FILE *outfile = fopen(name, "wb");
    if (outfile == NULL) {
    perror("Unable to open output file");
    }
    return outfile;
    }
    
    
    void write_file(FILE *outfile, struct file_struct *data) {
    size_t writecount = fwrite(data->data, 1, data->size, outfile);
    if (writecount != data->size) {
    printf("Unable to write the whole output file: %zd != %zd\n", writecount, data->size);
    }
    }
    
    
    void save_output_file(char *name, struct file_struct *f) {
    FILE *outfile = get_output_file(name);
    write_file(outfile, f);
    fclose(outfile);
    }
    Last edited by swwinterry; 10-10-2017 at 12:32 AM.

  2. Thanks bolsoncerrado, TommyDee, ztoddman1, AdamKempenich thanked for this post
    Likes bolsoncerrado, garufa liked this post
  3. #2
    Administrator bolsoncerrado's Avatar
    Join Date
    Nov 2014
    Posts
    3,075
    Post Thanks / Like
    THanks for sharing!

  4. #3
    3D Printer Noob
    Join Date
    Mar 2017
    Posts
    12
    Post Thanks / Like
    If anyone has any ideas for dealing with the .cubepro files I'm all ears. This program works by reading in the file, searching for 0xC8 (the char where the gcode starts), chopping off the prefix then running it through the blowfish algorithm. I can't seem to figure out how the .cubepro files are formatted. When I cut off the prefix (or what I think is the prefix) on the .cubepro files and run it through blowfish I get these 25 lines then encrypted nonsense after that.
    Code:
    ^JLP09vrwPeAvZmrzyY.aWfg4.u.7FwFfAcA4QUFs3rIWLvmZSrX8qW8fC
    ^PrinterModel:CUBEPRO
    ^Firmware:V2.00
    ^Minfirmware:V2.0
    ^ForceMinfirmware:V1.14B
    ^DRM:000000000000
    ^ConfigAndConfiguration:No-
    ^MaterialCodeE1:259
    ^MaterialCodeE2:-1
    ^MaterialCodeE3:-1
    ^MaterialLengthE1:9103.6
    ^MaterialLengthE2:0.0
    ^MaterialLengthE3:0.0
    ^ExtruderTypeE1:0
    ^ExtruderTypeE2:0
    ^ExtruderTypeE3:0
    ^ModelHeight:94.00
    ^LayerCount:470
    ^LayerHeight:0.2000
    ^Supports:-1
    ^Sidewalks:259
    ^Density:Strong
    ^Pattern:Diamond
    ^Time: 139
    G50
    - - - - - - - - - -

    The source is now posted at the top. Feel free to let me know if you have any questions.
    Last edited by swwinterry; 09-22-2017 at 08:20 PM.

  5. Thanks garufa thanked for this post
  6. #4
    3D Printer God(dess)
    Join Date
    Nov 2016
    Posts
    1,526
    Post Thanks / Like
    How did I overlook this.
    This is the 1st decoder I got working.

    Win10.

    Much thanks!

    - - - - - - - - - -

    Yep, BFB files can be used for reverse engineering.
    I've been wondering about that.
    Not easy but possible.

  7. #5
    Regular 3D Printer
    Join Date
    Sep 2017
    Posts
    38
    Post Thanks / Like

    Wink @ swwinteryy, Try This

    Quote Originally Posted by swwinterry View Post
    If anyone has any ideas for dealing with the .cubepro files I'm all ears.
    Try changing your source code to search for 0x75 A5 B3 F9 instead of 0xC8. Delete anything preceding 0x75.
    Also, the Build and configuration files of both CubePro and Cube3 builder .exe apps located in their respective folders are encrypted. Run 'em through blowfish and you'll end up with a .xml file with all parameters for printing with either printer.
    Cubepro and Cube 3 use the same Motherboard. The CubePro Trio adds a daughterboard if the 3rd extruder is installed. In essence, the two printers, hardware and software, are interchangeable with many parts and software.
    If you really want to have some fun and learn the ins and outs of cubify try using CubePro.exe to create a Cube 3 build.
    Also, Axon3 v3.0 alpha 3 release 12 Nov 2012 (the original cubify slightly before 3DSytems hacked everything) can be used to create CubePro and Cube 3 files. The files are archived in 3ds's suppository (suppository is deliberately used as opposed to repository) here: http://cubify.s3.amazonaws.com/. Walk thru the Http: link and you will find a plethora of cool stuff...G70

    - - - - - - - - - -

    Good job on this app. Saves alot of time and less confusing. Thanks...G70
    Last edited by JackMeoff; 01-10-2018 at 06:02 PM.

  8. #6
    Regular 3D Printer
    Join Date
    Jan 2018
    Posts
    46
    Post Thanks / Like
    G70, my browser cannot interpret this (http://cubify.s3.amazonaws.com/) I get an xml listing with no usable links to files.

    swwinterry, do you have a version that will also encode. The decoder is working great.

    Tim

  9. #7
    Regular 3D Printer
    Join Date
    Sep 2017
    Posts
    38
    Post Thanks / Like
    That's right. (http://cubify.s3.amazonaws.com/) is the main part of the Link.
    Browse down the xml dump to find what you are interested in DL'ing.
    Example:
    <Contents><Key>Printers/Cube/cube V1.11F.ar</Key><LastModified>2015-08-18T07:04:17.000Z</LastModified><ETag>"f674d13ad8262bdb78b44593fe0464 41"</ETag><Size>22284502</Size><StorageClass>STANDARD</StorageClass></Contents>

    <Key>Printers/Cube/cube V1.11F.ar<Key> is the data you would need to append to the URL.

    So, putting "http://cubify.s3.amazonaws.com/Printers/Cube/cube V1.11F.ar" in your browser will D/L the file cube V1.11F.ar which is Firmware.
    Learn how to "walk" a URL....
    G70

  10. #8
    Expert 3D Printer
    Join Date
    Jan 2017
    Posts
    479
    Post Thanks / Like
    Quote Originally Posted by JackMeoff View Post
    That's right. (http://cubify.s3.amazonaws.com/) is the main part of the Link.
    Browse down the xml dump to find what you are interested in DL'ing.
    Example:
    <Contents><Key>Printers/Cube/cube V1.11F.ar</Key><LastModified>2015-08-18T07:04:17.000Z</LastModified><ETag>"f674d13ad8262bdb78b44593fe0464 41"</ETag><Size>22284502</Size><StorageClass>STANDARD</StorageClass></Contents>

    <Key>Printers/Cube/cube V1.11F.ar<Key> is the data you would need to append to the URL.

    So, putting "http://cubify.s3.amazonaws.com/Printers/Cube/cube V1.11F.ar" in your browser will D/L the file cube V1.11F.ar which is Firmware.
    Learn how to "walk" a URL....
    G70
    That is pretty awesome! It has links to older firmware and software that nobody could seem to find before!

    So I decided to do some scripting and a bit of manual editing and came up with an html file where you can just browse and click the links to download what you need. (attached below)

    Thanks G70!!
    Attached Files Attached Files

  11. #9
    Regular 3D Printer
    Join Date
    Jan 2018
    Posts
    46
    Post Thanks / Like
    Awesome guys. I'll just keep asking dumb questions and hope for brilliant answers.
    Tim

  12. Likes JackMeoff liked this post
  13. #10
    3D Printer Noob
    Join Date
    Mar 2017
    Posts
    12
    Post Thanks / Like
    Quote Originally Posted by tprothma View Post
    G70, my browser cannot interpret this (http://cubify.s3.amazonaws.com/) I get an xml listing with no usable links to files.

    swwinterry, do you have a version that will also encode. The decoder is working great.

    Tim
    You can use the "cube_encoder" file found here. https://github.com/fritzw/cube-utils I only had issues with the decoder so that the only one I rewrote. Here is a link to the compiled version https://drive.google.com/open?id=0B3...F9WZnRFSWRjaU0
    Last edited by swwinterry; 02-08-2018 at 03:53 PM.

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •