/unifi-backup-decrypt

decrypt UniFi Network Application backup (.unf <=> .zip)

Primary LanguageShellThe UnlicenseUnlicense

UniFi backup file (.unf) / support file (.supp) decryption

Requirement

  • openssl
  • zip

Some code snippet

final Cipher instance = Cipher.getInstance("AES/CBC/NoPadding");
instance.init(2, new SecretKeySpec("bcyangkmluohmars".getBytes(), "AES"), new IvParameterSpec("ubntenterpriseap".getBytes()));
return new CipherInputStream(inputStream, instance);

malformed zip files require fixing before unzip

Database

db.gz contains a stream of BSON document for each collections of ace database.

You can view its content by gunzip -c db.gz | bsondump.

It should be trivial to write a script that helps import/export. If anybody wants to contribute, PRs are welcomed.

NB: these instructions are for Ubuntu; they work under WSL on Windows 10 as well

Get the decrypt.sh file from here: https://github.com/zhangyoufu/unifi-backup-decrypt

Make sure prerequisites are installed:

sudo apt update && sudo apt install zip unzip openssl mongo-tools

Then put your .unf backup file somewhere convenient (for our example, we'll assume it's in the home directory and named backup.unf):

bash decrypt.sh ~/backup.unf ~/backup.zip
mkdir backup
cd backup
unzip ~/backup.zip
gunzip db.zip
bsondump db.zip > db.json

This will:

  1. convert the .unf into an unencrypted .zip file,
  2. unzip that into the backup directory,
  3. uncompress the backup database
  4. convert the backup databse from "binary JSON" (bson) to plain text JSON

You can then see the contents of the backup database with any JSON-aware tool or simply read it in a text editor.