cfrcrypt - A tool to encrypt or decrypt ColdFusion Report files.
cfrcrypt <-e|-d> <-o output> <input>
ColdFusion sports a custom report file format (.cfr) which is, unfortunately, encoded, such that these files become opaque blobs which can only be edited by ColdFusion Report Builder, and so cannot be version controlled, modified via scripts, etc. This tool makes it possible to decrypt/decode these files, modify them, and then re-encrypt them for use with ColdFusion.
By default, the tool reads from standard input and writes to standard output. However, if an input file is specified, the data is read from that location, and if an output file is specified, the results are written there (note, the file indicated is overwritten).
If neither -e nor -d are specified, the operation to be performed is inferred based on the input data:
If an explicit input file name is specified, then the name is checked to see if it ends in ".cfr". If so, the file is decrypted, otherwise it's encrypted.
If the tool is reading from standard input, the data is checked for a magic header string present in all ColdFusion Report files. If that string is present, the data is decrypted. Otherwise the data is encrypted.
- -e
-
Encrypt the input data provided.
- -d
-
Decrypt the input data provided.
- -o
-
Write the output to the specified file.
ColdFusion report file is structured with a header of 39 bytes, followed by an XTEA-encrypted payload. XTEA (http://en.wikipedia.org/wiki/XTEA) is a simple symmetric cipher employing 64-bit blocks and a 128-bit key. The actual file structure is as follows:
| Header (27) | Size (4) |
| K4 (4) | K0 (4) |
| Data |
Where K0 and K4 represent the first and last 32-bit words of the key. The middle 64 bits are a hard-coded shared key. The size represents the size of the compressed payload (including any additional padding).
Copyright (C) 2011 by Brett Kosinski
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This software was originally written by Brett Kosinski, and you can find it's home on github at: