When working with Metasploit Framework on Kali Linux (2016.2 in this case), you might encounter this persistent warning during module searches:
msf > search samba
[!] Module database cache not built yet, using slow search
This occurs even after successfully starting PostgreSQL and verifying database connectivity:
systemctl start postgresql
msf > db_status
[*] postgresql connected to msf
The typical solution db_rebuild_cache
often doesn't resolve the issue. Let's examine the underlying reasons:
msf > db_rebuild_cache
# No visible output or confirmation
msf > search samba
[!] Module database cache not built yet, using slow search
Here's what actually works to permanently fix the cache issue:
# First, exit msfconsole
msf > exit
# Then run these commands:
sudo service postgresql restart
msfdb reinit
msfconsole
# Now inside msfconsole:
msf > db_rebuild_cache
# Wait for completion (may take 2-5 minutes)
msf > search samba
# Should now show immediate results without warning
This occurs because:
- Metasploit's module cache depends on PostgreSQL's FTS (Full Text Search) capabilities
- The initial database schema might not include proper FTS configurations
msfdb reinit
creates fresh database structures with proper indexing
After applying the fix, you can verify proper cache operation:
msf > time search samba
# Should return results in < 1 second
msf > time search type:exploit
# Should be nearly instantaneous
If the issue persists, try these additional steps:
# Completely reset the database:
sudo msfdb delete
sudo msfdb init
# Then rebuild all caches:
msfconsole -x "db_rebuild_cache; exit"
The "slow search" warning indicates:
- Searches scan all module files sequentially
- Typical slowdown of 10-50x compared to cached searches
- Particularly noticeable with large searches (
search platform:windows
)
When setting up a fresh Metasploit installation on Kali Linux, you might encounter this persistent message during searches:
msf > search samba
[!] Module database cache not built yet, using slow search
Even after running db_rebuild_cache
, the issue persists. Let's dive deeper into why this happens and how to properly resolve it.
First, verify your database connection status:
msf > db_status
[*] postgresql connected to msf
While this shows connectivity, it doesn't guarantee proper cache initialization. The database service might be running, but the cache tables haven't been populated.
The standard db_rebuild_cache
command sometimes needs additional steps:
msf > db_disconnect
msf > db_connect -y /usr/share/metasploit-framework/config/database.yml
msf > db_rebuild_cache
This sequence ensures a fresh connection before rebuilding the cache.
If the above doesn't work, try this nuclear option:
sudo service postgresql restart
msfconsole -x "db_status; db_rebuild_cache; exit"
Then restart msfconsole normally. This often resolves stubborn cache issues.
After applying these steps, test with:
msf > search samba
The warning message should disappear, and results should appear instantly.
To avoid future cache issues:
- Always initialize the database properly during installation
- Use
msfdb init
when setting up Metasploit - Regularly run
db_rebuild_cache
after major updates
Remember that cache rebuilding may take several minutes on slower systems.