├── LICENSE ├── README.md ├── decrypt.sh └── encrypt.sh /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UniFi backup file (.unf) / support file (.supp) decryption 2 | 3 | ## Requirement 4 | 5 | * openssl 6 | * zip 7 | 8 | ## Some code snippet 9 | 10 | ``` 11 | final Cipher instance = Cipher.getInstance("AES/CBC/NoPadding"); 12 | instance.init(2, new SecretKeySpec("bcyangkmluohmars".getBytes(), "AES"), new IvParameterSpec("ubntenterpriseap".getBytes())); 13 | return new CipherInputStream(inputStream, instance); 14 | ``` 15 | 16 | malformed zip files require fixing before unzip 17 | 18 | ## Database 19 | 20 | `db.gz` contains a stream of BSON document for each collections of `ace` database. 21 | 22 | You can view its content by `gunzip -c db.gz | bsondump`. 23 | 24 | It should be trivial to write a script that helps import/export. If anybody wants to contribute, PRs are welcomed. 25 | -------------------------------------------------------------------------------- /decrypt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Authors: 4 | # 2017-2019 Youfu Zhang 5 | # 2019 Balint Reczey 6 | 7 | set -e 8 | 9 | usage() { 10 | echo "Usage: $0 " 11 | } 12 | 13 | if [ -z "$2" -o ! -f "$1" ]; then 14 | usage 15 | exit 1 16 | fi 17 | 18 | INPUT_UNF=$1 19 | OUTPUT_ZIP=$2 20 | 21 | TMP_FILE=$(mktemp) 22 | trap "rm -f ${TMP_FILE}" EXIT 23 | 24 | openssl enc -d -in "${INPUT_UNF}" -out "${TMP_FILE}" -aes-128-cbc -K 626379616e676b6d6c756f686d617273 -iv 75626e74656e74657270726973656170 -nopad 25 | yes | zip -FF "${TMP_FILE}" --out "${OUTPUT_ZIP}" > /dev/null 2>&1 26 | -------------------------------------------------------------------------------- /encrypt.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Authors: 4 | # 2019 Balint Reczey 5 | # 2019 Youfu Zhang 6 | 7 | set -e 8 | 9 | usage() { 10 | echo "Usage: $0 " 11 | } 12 | 13 | if [ -z "$2" -o ! -f "$1" ]; then 14 | usage 15 | exit 1 16 | fi 17 | 18 | INPUT_ZIP=$1 19 | OUTPUT_UNF=$2 20 | 21 | openssl enc -e -in "${INPUT_ZIP}" -out "${OUTPUT_UNF}" -aes-128-cbc -K 626379616e676b6d6c756f686d617273 -iv 75626e74656e74657270726973656170 22 | --------------------------------------------------------------------------------