Ubiquiti Configuration Importer - Metasploit
This page contains detailed information about how to use the auxiliary/admin/networking/ubiquiti_config metasploit module. For list of all metasploit modules, visit the Metasploit Module Library.
Module Overview
Name: Ubiquiti Configuration Importer
Module: auxiliary/admin/networking/ubiquiti_config
Source code: modules/auxiliary/admin/networking/ubiquiti_config.rb
Disclosure date: -
Last modification time: 2022-03-23 11:32:45 +0000
Supported architecture(s): -
Supported platform(s): -
Target service / protocol: -
Target network port(s): 22
List of CVEs: -
This module imports an Ubiquiti device configuration. The db file within the .unf backup is the data file for Unifi. This module can take either the db file or .unf.
Module Ranking and Traits
Module Ranking:
- normal: The exploit is otherwise reliable, but depends on a specific version and can't (or doesn't) reliably autodetect. More information about ranking can be found here.
Stability:
- crash-safe: Module should not crash the service.
Basic Usage
msf > use auxiliary/admin/networking/ubiquiti_config
msf auxiliary(ubiquiti_config) > show targets
... a list of targets ...
msf auxiliary(ubiquiti_config) > set TARGET target-id
msf auxiliary(ubiquiti_config) > show options
... show and set options ...
msf auxiliary(ubiquiti_config) > exploit
Required Options
CONFIG: Path to configuration to import
RHOSTS: The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
Knowledge Base
Vulnerable Application
General Notes
This module imports an Ubiquiti Unifi configuration file into the database.
This is similar to post/multi/gather/ubiquiti_unifi_backup
only access isn't required,
and assumes you already have the file.
This module is able to take a unf file, from the controller and perform the following actions:
- Decrypt the file
- Fix the zip file if a
zip
utility is on the system - Extract db.gz
- Unzip the db file
- Import the db file
Or simply pass the db file for import directly.
Verification Steps
- Have a Ubiquiti Unifi configuration file (db or unf)
- Start
msfconsole
use auxiliary/admin/networking/ubiquiti_config
set RHOST x.x.x.x
set CONFIG /tmp/file.unf
run
Options
RHOST
Needed for setting services and items to. This is relatively arbitrary.
CONFIG
File path to the configuration unf or db file..
Scenarios
Unf File
resource (unifi_config.rb)> use auxiliary/admin/networking/ubiquiti_config
resource (unifi_config.rb)> set rhosts 127.0.0.1
rhosts => 127.0.0.1
resource (unifi_config.rb)> set config /root/.msf4/loot/20190825172544_default_1.1.1.1_ubiquiti.unifi.b_740136.unf
config => /root/.msf4/loot/20190825172544_default_1.1.1.1_ubiquiti.unifi.b_740136.unf
resource (unifi_config.rb)> run
[*] Running module against 127.0.0.1
[+] File DECRYPTED. Still needs to be repaired
[*] Attempting to repair zip file (this is normal and takes some time)
[+] File DECRYPTED and REPAIRED and saved to /tmp/fixed_zip.zip20190825-6283-1merolj.
[*] extracting db.gz
[*] Converting config BSON to JSON
[+] Admin user unifiadmin with email [email protected] found with password hash $6$R6qnBHgF$CHYrf4t.fXu0pcoloju5a85m3ujrjJLhIO.lN1xZqHZPQoUXXsJB98jgtsvt4Qo2/8t3epzbVLiba7Ls7GCVxcV.
[+] Radius server: 1.1.1.1:1812 with secret ''
[+] Mesh Wifi Network vwire-111117d211c1c1ea password 113b9b872b1114a9111f1a11ae11cdfe
[+] SSH user admin found with password lyxGYOF9UalubyyG and hash $6$37uelU/k$EkJuteQiAIP.CrRaJj4xC9gt61n95FJP3fQuQQmE9TqtFKtmIGsV5XSIJI.muBLOMKMkdlsPl8E3BvjJit.F21
[+] Config import successful
[*] Auxiliary module execution completed
db File
resource (unifi_config.rb)> use auxiliary/admin/networking/ubiquiti_config
resource (unifi_config.rb)> set rhosts 127.0.0.1
rhosts => 127.0.0.1
msf5 auxiliary(admin/networking/ubiquiti_config) > set config /root/.msf4/loot/db
config => /root/.msf4/loot/db
msf5 auxiliary(admin/networking/ubiquiti_config) > run
[*] Running module against 127.0.0.1
[*] Converting config BSON to JSON
[+] Admin user unifiadmin with email [email protected] found with password hash $6$R6qnBHgF$CHYrf4t.fXu0pcoloju5a85m3ujrjJLhIO.lN1xZqHZPQoUXXsJB98jgtsvt4Qo2/8t3epzbVLiba7Ls7GCVxcV.
[+] Radius server: 1.1.1.1:1812 with secret ''
[+] Mesh Wifi Network vwire-111117d211c1c1ea password 113b9b872b1114a9111f1a11ae11cdfe
[+] SSH user admin found with password lyxGYOF9UalubyyG and hash $6$37uelU/k$EkJuteQiAIP.CrRaJj4xC9gt61n95FJP3fQuQQmE9TqtFKtmIGsV5XSIJI.muBLOMKMkdlsPl8E3BvjJit.F21
[+] Config import successful
[*] Auxiliary module execution completed
Go back to menu.
Msfconsole Usage
Here is how the admin/networking/ubiquiti_config auxiliary module looks in the msfconsole:
msf6 > use auxiliary/admin/networking/ubiquiti_config
msf6 auxiliary(admin/networking/ubiquiti_config) > show info
Name: Ubiquiti Configuration Importer
Module: auxiliary/admin/networking/ubiquiti_config
License: Metasploit Framework License (BSD)
Rank: Normal
Provided by:
h00die
Check supported:
No
Basic options:
Name Current Setting Required Description
---- --------------- -------- -----------
CONFIG yes Path to configuration to import
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 22 yes The target port
Description:
This module imports an Ubiquiti device configuration. The db file
within the .unf backup is the data file for Unifi. This module can
take either the db file or .unf.
Module Options
This is a complete list of options available in the admin/networking/ubiquiti_config auxiliary module:
msf6 auxiliary(admin/networking/ubiquiti_config) > show options
Module options (auxiliary/admin/networking/ubiquiti_config):
Name Current Setting Required Description
---- --------------- -------- -----------
CONFIG yes Path to configuration to import
RHOSTS yes The target host(s), range CIDR identifier, or hosts file with syntax 'file:<path>'
RPORT 22 yes The target port
Advanced Options
Here is a complete list of advanced options supported by the admin/networking/ubiquiti_config auxiliary module:
msf6 auxiliary(admin/networking/ubiquiti_config) > show advanced
Module advanced options (auxiliary/admin/networking/ubiquiti_config):
Name Current Setting Required Description
---- --------------- -------- -----------
VERBOSE false no Enable detailed status messages
WORKSPACE no Specify the workspace for this module
Auxiliary Actions
This is a list of all auxiliary actions that the admin/networking/ubiquiti_config module can do:
msf6 auxiliary(admin/networking/ubiquiti_config) > show actions
Auxiliary actions:
Name Description
---- -----------
Evasion Options
Here is the full list of possible evasion options supported by the admin/networking/ubiquiti_config auxiliary module in order to evade defenses (e.g. Antivirus, EDR, Firewall, NIDS etc.):
msf6 auxiliary(admin/networking/ubiquiti_config) > show evasion
Module evasion options:
Name Current Setting Required Description
---- --------------- -------- -----------
Go back to menu.
Error Messages
This module may fail with the following error messages:
Check for the possible causes from the code snippets below found in the module source code. This can often times help in identifying the root cause of the problem.
Unifi config file <I_FILE> does not exist!
Here is a relevant code snippet related to the "Unifi config file <I_FILE> does not exist!" error message:
38: datastore['CONFIG'].to_s
39: end
40:
41: def run
42: unless ::File.exist?(i_file)
43: fail_with Failure::BadConfig, "Unifi config file #{i_file} does not exist!"
44: end
45: # input_file could be a unf (encrypted zip), or the db file contained within.
46: input_file = ::File.open(i_file, 'rb')
47: f = input_file.read
48: input_file.close
<I_FILE> read at 0 bytes. Either file is empty or error reading.
Here is a relevant code snippet related to the "<I_FILE> read at 0 bytes. Either file is empty or error reading." error message:
46: input_file = ::File.open(i_file, 'rb')
47: f = input_file.read
48: input_file.close
49:
50: if f.nil?
51: fail_with Failure::BadConfig, "#{i_file} read at 0 bytes. Either file is empty or error reading."
52: end
53:
54: if i_file.end_with? '.unf'
55: decrypted_data = decrypt_unf(f)
56: if decrypted_data.nil? || decrypted_data.empty?
Unable to decrypt
Here is a relevant code snippet related to the "Unable to decrypt" error message:
52: end
53:
54: if i_file.end_with? '.unf'
55: decrypted_data = decrypt_unf(f)
56: if decrypted_data.nil? || decrypted_data.empty?
57: fail_with Failure::Unknown, 'Unable to decrypt'
58: end
59: print_good('File DECRYPTED. Still needs to be repaired')
60: loot_path = Rex::Quickfile.new('decrypted_zip.zip')
61: loot_path.write(decrypted_data)
62: loot_path.close
Repair failed on <LOOT_PATH.PATH>
Here is a relevant code snippet related to the "Repair failed on <LOOT_PATH.PATH>" error message:
62: loot_path.close
63: # ruby zip can't repair, we can try on command line but its not likely to succeed on all platforms
64: # tested on kali
65: repaired = repair_zip(loot_path.path)
66: if repaired.nil?
67: fail_with Failure::Unknown, "Repair failed on #{loot_path.path}"
68: end
69: loot_path = Rex::Quickfile.new('fixed_zip.zip')
70: loot_path.write(repaired)
71: loot_path.close
72: print_good("File DECRYPTED and REPAIRED and saved to #{loot_path.path}.")
Unable to locate db.gz config database file
Here is a relevant code snippet related to the "Unable to locate db.gz config database file" error message:
70: loot_path.write(repaired)
71: loot_path.close
72: print_good("File DECRYPTED and REPAIRED and saved to #{loot_path.path}.")
73: config_db = extract_and_process_db(loot_path.path)
74: if config_db.nil?
75: fail_with Failure::Unknown, 'Unable to locate db.gz config database file'
76: end
77: print_status('Converting BSON to JSON.')
78: unifi_config_db_json = bson_to_json(config_db)
79: if unifi_config_db_json == {}
80: fail_with Failure::Unknown, 'Error in file conversion from BSON to JSON.'
Error in file conversion from BSON to JSON.
Here is a relevant code snippet related to the "Error in file conversion from BSON to JSON." error message:
75: fail_with Failure::Unknown, 'Unable to locate db.gz config database file'
76: end
77: print_status('Converting BSON to JSON.')
78: unifi_config_db_json = bson_to_json(config_db)
79: if unifi_config_db_json == {}
80: fail_with Failure::Unknown, 'Error in file conversion from BSON to JSON.'
81: end
82: unifi_config_eater(datastore['RHOSTS'], datastore['RPORT'], unifi_config_db_json)
83: print_good('Config import successful')
84: end
85: end
Go back to menu.
Related Pull Requests
- #15192 Merged Pull Request: Enforce Style/RedundantBegin for new modules
- #13870 Merged Pull Request: Arista processor
- #13750 Merged Pull Request: Centralize networking
Go back to menu.
See Also
Check also the following modules related to this module:
- auxiliary/admin/networking/arista_config
- auxiliary/admin/networking/brocade_config
- auxiliary/admin/networking/cisco_asa_extrabacon
- auxiliary/admin/networking/cisco_config
- auxiliary/admin/networking/cisco_dcnm_auth_bypass
- auxiliary/admin/networking/cisco_dcnm_download
- auxiliary/admin/networking/cisco_secure_acs_bypass
- auxiliary/admin/networking/cisco_vpn_3000_ftp_bypass
- auxiliary/admin/networking/f5_config
- auxiliary/admin/networking/juniper_config
- auxiliary/admin/networking/mikrotik_config
- auxiliary/admin/networking/vyos_config
- auxiliary/scanner/ubiquiti/ubiquiti_discover
- exploit/linux/http/ubiquiti_airos_file_upload
- exploit/multi/http/ubiquiti_unifi_log4shell
- post/multi/gather/ubiquiti_unifi_backup
- auxiliary/admin/misc/sercomm_dump_config
- auxiliary/gather/cisco_pvc2300_download_config
- auxiliary/gather/cisco_rv320_config
- auxiliary/scanner/http/epmp1000_dump_config
- auxiliary/admin/citrix/citrix_netscaler_config_decrypt
- auxiliary/admin/sap/sap_configservlet_exec_noauth
- auxiliary/scanner/http/binom3_login_config_pass_dump
- auxiliary/scanner/misc/dvr_config_disclosure
- auxiliary/scanner/snmp/cisco_config_tftp
- exploit/linux/http/op5_config_exec
- exploit/linux/local/vmware_alsa_config
- exploit/multi/browser/opera_configoverwrite
- exploit/multi/http/zenworks_configuration_management_upload
- exploit/unix/webapp/awstats_configdir_exec
- exploit/unix/webapp/freepbx_config_exec
- exploit/unix/webapp/phpmyadmin_config
- exploit/windows/http/sap_configservlet_exec_noauth
- post/linux/gather/enum_configs
Authors
- h00die
Version
This page has been produced using Metasploit Framework version 6.2.23-dev. For more modules, visit the Metasploit Module Library.
Go back to menu.