Forgot the username and password of *fdb (firebird) database. Is there anyway I can crack this database?
Asked Answered
F

1

5

I have database of firebird of more than 8 GB and I want to migrate all the data from it. But I have forgotten the username and password. Is there anyway or any tool through which I can crack this database and can get my data back?

Felixfeliza answered 26/9, 2018 at 7:32 Comment(10)
firebirdfaq.org/faq55Cammack
I dont have the password of my .FDB file. I am unable to export it into any tool and link you have given me to is related to serverFelixfeliza
Is the database using the central security database (the default), or does it contain its own security database?Borg
usernames and passwords are stored in the security database file, not in the data database file. Granted, with FB 3.0 there is a trick that a data database file can be a security database file for itself. However it is a rare case and you do not need to go that way. Use the Firebird's SYSDBA "absolute user" and do what you like with that database.Baresark
...unless what he actually meant by "password" was some arcane encryption plugin.Baresark
@Arioch'The I have just one file haveing extension .FDB and I want to export tha data to my sql server. I am just new to the Firebird and I cant understand how could I use the server. If you could help me setting this then I would be greatful to youFelixfeliza
@RanaHadaiqAhmad In that case you don't even have this problem: install Firebird and you can open the database with the default sysdba account. Note though that transferring a Firebird database by copying the fdb file is tricky; it may have platform specific layout. It would be better to have a (gbak) backup from the original location and restore that backup to a new database. But it looks like you are looking for more support than is suitable for StackOverflow. Consider subscribing to the firebird-support mailing list and asking your questions there.Borg
@MarkRotteveel It would be better to have a (gbak) backup from the original location - and gbak would ask for username/password. Hen and egg. Or Pkunzip.zip if you will.Baresark
@MarkRotteveel if so then FB admin can just run fbExport or a tool like that and pass text files (CSV, XML, SQL, etc) to the topicstarterBaresark
Also, I have just one file having extension .FDB - how do we know, it is 1) FB3 database, not FB2- ? 2) Firebird database, not some other format with changed filename extension? Houston, I smell a problem! Does IBExpert Personal edition have dbExtractor feature, that can look into the database without having server? Just to check ODS, absence of encryption and principal ability to parse the data out. If it would turn out to be non-Firebird file or encrypted FB3 file - it all is for naught.Baresark
B
6

In most Firebird setups, the username and password is kept in a central security database (security3.fdb in the case of Firebird 3). If you don't know the username and password of a user anymore, you have the following options.

Be aware, this answer uses Firebird 3 as its base, but most options also apply to Firebird 2.5 and earlier. Instead of security3.fdb, use security2.fdb. The create user and alter user steps only work in Firebird 2.5 or higher.

  1. Use the sysdba account (or another user with RDB$ADMIN role in the security database) to reset the password of the user through any other database
  2. Use gsec as SYSDBA in embedded mode to reset the password
  3. Replace the security database with a copy with a known password for the user

If your database uses itself as its security database, you will first have to remove that setting from the databases.conf by commenting out the SecurityDatabase setting for that database.

For Firebird 3, this answer assumes the creation of a user for the Srp authentication mechanism, and the steps below assume that the firebird.conf in the Firebird installation has setting AuthServer = Srp (or at least that setting AuthServer contains Srp) and setting UserManager = Srp (or at least that Srp is the first entry for UserManager).

Option 1: reset a password

Works on Firebird 2.5 and higher

Connect to a database with SYSDBA (or another user with admin role on the security database), and use

ALTER USER <username> SET PASSWORD '<new password>';

This is probably not an option in your case though.

Option 1a: reset with embedded connection (passwordless)

Works on Linux for Firebird 2.5 or higher, on Windows requires Firebird 3.0 or higher.

Stop Firebird server, and use ISQL to connect to the database in embedded mode (which doesn't require a password):

isql -user sysdba <database>

With a default Firebird 3 installation, you can use employee for <database>, which will use the employee example database.

Alter the password as described above. Alternatively, try replacing sysdba with the actual username in the isql commandline.

Start Firebird server again.

Option 2: use gsec to change the password

Works on Linux for all version, on Windows this only works for Firebird 3.0 and higher.

Be aware that gsec is deprecated since Firebird 3 and may be removed from future Firebird versions.

Stop the Firebird server, open the command line, and in the Firebird installation folder do:

gsec -user sysdba

and on the gsec prompt

modify <username> -pw <new password>

or if the user doesn't exist yet:

add <username> -pw <new password>

Start Firebird server again.

Option 3: replace security database

Most of these steps also apply if you are using a new Firebird install; just skip the replacing of the security database.

Stop Firebird server and make a copy of your current security3.fdb as a backup.

Obtain a default security3.fdb for your platform (eg download a zipkit from the Firebird 3 download page) or use a security3.fdb with a known password, and replace your current security3.fdb with this default version. Don't start Firebird yet.

For earlier Firebird versions, look for your version on the download page.

The default password for sysdba is normally 'masterkey', but on Firebird 3 the default security3.fdb only contains this user for the legacy authentication mechanism, which is disabled in a default Firebird 3 installation.

To add a sysdba user, use an embedded connection to any database and create a sysdba account. On the command prompt from the Firebird installation folder, run:

isql -u sysdba <database>

Within ISQL execute:

create user sysdba password '<sysdba password>';
commit;

To add another user, connect using SYSDBA - similar to the previous step 2 - to any database and execute

create user <username> password '<new password>';
commit;

And exit isql (with quit;)

Then start Firebird server again, and you should be able to connect with this user and its password.


Most of these steps assume you already have a database to connect to, if you don't yet have one, then you'll need to create on first.

Start isql as user sysdba:

isql -u sysdba

And create a database

create database '<path-of-database>';

You can then use that database for the earlier steps.

Borg answered 26/9, 2018 at 12:7 Comment(2)
One of the reason we are not switching to FB3... We want to retain that "dba-admin not required" state of good old Interbase, some our clients are needing itBaresark
@Arioch'The You were right, I have updated which versions the answer works for.Borg

© 2022 - 2024 — McMap. All rights reserved.