Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    pfSense XML config file, can we decrypt it manually?

    Scheduled Pinned Locked Moved General pfSense Questions
    32 Posts 9 Posters 7.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      SeaMonkey @bingo600
      last edited by

      @bingo600 Tried that and I still get the same result.

      *** WARNING : deprecated key derivation used.
      Using -iter or -pbkdf2 would be better.
      bad decrypt
      140140608259392:error:06065064:digital envelope routines:EVP_DecryptFinal_ex:bad decrypt:../crypto/evp/evp_enc.c:610:
      

      Thanks for the suggestion, though.

      bingo600B 1 Reply Last reply Reply Quote 0
      • bingo600B
        bingo600 @SeaMonkey
        last edited by bingo600

        @seamonkey

        Did you try both variants ?

        What version is the encryption made with
        Re: @jimp post here
        https://forum.netgate.com/post/884969

        /Bingo

        If you find my answer useful - Please give the post a 👍 - "thumbs up"

        pfSense+ 23.05.1 (ZFS)

        QOTOM-Q355G4 Quad Lan.
        CPU  : Core i5 5250U, Ram : 8GB Kingston DDR3LV 1600
        LAN  : 4 x Intel 211, Disk  : 240G SAMSUNG MZ7L3240HCHQ SSD

        S 1 Reply Last reply Reply Quote 0
        • S
          SeaMonkey @bingo600
          last edited by SeaMonkey

          @bingo600

          I should have checked the docs before the forum. File I was trying first was from 2.5.0 which uses different encryption.

          https://docs.netgate.com/pfsense/en/latest/backup/restore.html#encrypted-configuration-files

          bingo600B 1 Reply Last reply Reply Quote 0
          • bingo600B
            bingo600 @SeaMonkey
            last edited by

            @seamonkey

            For helping future users :
            Please post the working solution (command line).

            /Bingo

            If you find my answer useful - Please give the post a 👍 - "thumbs up"

            pfSense+ 23.05.1 (ZFS)

            QOTOM-Q355G4 Quad Lan.
            CPU  : Core i5 5250U, Ram : 8GB Kingston DDR3LV 1600
            LAN  : 4 x Intel 211, Disk  : 240G SAMSUNG MZ7L3240HCHQ SSD

            S 1 Reply Last reply Reply Quote 0
            • S
              SeaMonkey @bingo600
              last edited by SeaMonkey

              Encrypted Configuration files
              The GUI can automatically determine the correct decryption method when restoring an encrypted configuration backup file, whether it’s from a current version or an older version. When restoring an encrypted configuration file, check Configuration file is encrypted then enter the password in the Password field, and restore as usual from there.

              Encrypted configuration files can be manually decrypted using the correct password for offline inspection.

              The method used to encrypt configuration files changed in version 2.5.0, so use the method appropriate for the version which generated the encrypted configuration file. In either case, replace <PASSWORD> with the appropriate password string, and change the filenames as needed.

              2.5.0 and later:

              grep -v "config.xml" config-encrypted.xml | base64 -d | \
                openssl enc -d -aes-256-cbc -out dencryptedfile.xml \
                -pass pass:<PASSWORD> -salt -md sha256 -pbkdf2
              

              Older versions:

              grep -v "config.xml" config-encrypted.xml | base64 -d | \
                openssl enc -d -aes-256-cbc -out dencryptedfile.xml \
                -pass pass:<PASSWORD> -salt -md md5
              

              In my case, I changed pass pass:<PASSWORD> to pass file:<PASSFILE>.

              D 1 Reply Last reply Reply Quote 2
              • K
                KevinRice
                last edited by

                So...what is the password??? Same as admin?

                S 1 Reply Last reply Reply Quote 0
                • S
                  SeaMonkey @KevinRice
                  last edited by

                  @kevinrice No, the password is whatever you put in the password box that appears after ticking the 'Encryption' checkbox.

                  K 1 Reply Last reply Reply Quote 1
                  • K
                    KevinRice @SeaMonkey
                    last edited by

                    @seamonkey Oh, no. Not good. I'm using a Calix brand router running pfSense that is locked-down. So there's no way to decrypt its config file then.

                    Calix.png

                    S 1 Reply Last reply Reply Quote 0
                    • S
                      SeaMonkey @KevinRice
                      last edited by SeaMonkey

                      @kevinrice If you have the admin password and you're just trying to get an unencrypted copy of the current configuration, you can just login, go to Diagnostics | Backup & Restore, and download the configuration file.

                      K 1 Reply Last reply Reply Quote 0
                      • K
                        KevinRice @SeaMonkey
                        last edited by

                        @seamonkey I don't think that is possible. The Calix router is crippled. While there is a configuration backup page, the encryption is baked-in. I can't see any way of getting an unencrypted config file here.

                        Calix-backup.png

                        1 Reply Last reply Reply Quote 0
                        • stephenw10S
                          stephenw10 Netgate Administrator
                          last edited by stephenw10

                          Well that's..... um... interesting.

                          Reboot into single user mode, check the code?

                          Are you sure that's a pfSense rebrand and not just a cached favicon in your browser?

                          Edit: Yeah, almost certainly that ^

                          Steve

                          K 1 Reply Last reply Reply Quote 0
                          • K
                            KevinRice @stephenw10
                            last edited by KevinRice

                            @stephenw10 Yeah, I suppose that's likely. Login screen sure looks familiar. And the config file begins:

                            <!--CalixVersion="0.0.0.0" crc32="03933f14" type="backup" product="17717" ConfigVersion="21.2.0.0.39" model="GS4220E" -->
                            

                            pfSense v.21.2 is very contemporary!

                            In any case, if I don't have access to the password, it would seem I'm chasing ghosts.

                            S stephenw10S 2 Replies Last reply Reply Quote 0
                            • S
                              SeaMonkey @KevinRice
                              last edited by

                              @kevinrice Why do you need a password? It appears that your config is unencrypted.

                              K 1 Reply Last reply Reply Quote 0
                              • K
                                KevinRice @SeaMonkey
                                last edited by

                                @seamonkey You haven't seen the rest of the file...

                                <!--CalixVersion="0.0.0.0" crc32="03933f14" type="backup" product="17717" ConfigVersion="21.2.0.0.39" model="GS4220E" -->
                                jïÍ)ïQµY]™ô茛–YtõúgêôTˆKù\¸´Ë7öJC"€ËJ<¯Çñ¹•úã
                                ˜
                                .8/4Aê¦qm•	VSœ^6kjïÚ|ã-	|ÁÓ8Ât·§vB–î Uò)uçµa‘ù@Û4ÕßÚ"ˆŠŒ2y,¯Yâòƒ`HÞ¤š(i°',}䫏ö‚HRÚÞÛÈ#q þD0v‡*uhx±[
                                àµ
                                l®é2…èGöÀ‚GrØ=®ˆÔˆ
                                ‹R
                                9º`ß„ºdÍi¹nÕe0Â
                                ³¨
                                ™G vu¼ÔøSí;ŸN‡±*r¹ÍrôkËôK¨âZð`¹Cçj›œÂú
                                
                                S 1 Reply Last reply Reply Quote 0
                                • S
                                  SeaMonkey @KevinRice
                                  last edited by

                                  @kevinrice Heh... oh.

                                  K 1 Reply Last reply Reply Quote 1
                                  • K
                                    KevinRice @SeaMonkey
                                    last edited by

                                    @seamonkey Appears to be a waste of time, regardless if this is pfSense or not.

                                    1 Reply Last reply Reply Quote 0
                                    • stephenw10S
                                      stephenw10 Netgate Administrator @KevinRice
                                      last edited by

                                      @kevinrice said in pfSense XML config file, can we decrypt it manually?:

                                      Login screen sure looks familiar.

                                      Bootstrap is omnipresent at this point! 😉

                                      Yeah I would be amazed if that's pfSense. It's almost certainly an ARM device to start with.

                                      That config is not close to anything we have.

                                      Steve

                                      K 1 Reply Last reply Reply Quote 1
                                      • K
                                        KevinRice @stephenw10
                                        last edited by

                                        @stephenw10 said in pfSense XML config file, can we decrypt it manually?:

                                        That config is not close to anything we have.

                                        Steve

                                        I agree. I think it was a cached favicon that led me astray.

                                        1 Reply Last reply Reply Quote 0
                                        • D
                                          Draco @SeaMonkey
                                          last edited by

                                          @seamonkey I found your note when I was looking for a way to decrypt newer pfSense backups that had been encrypted. Your OpenSSL command is almost correct, at least based on my testing on Windows with OpenSSL 1.1.1. What you are missing is the -iter parameter.

                                          As @vlurk noted earlier, the key is in the crypt.inc source code. You need -iter 50000. After I added that parameter, all my post 2.5.0 CE backup files are decrypting on Windows with OpenSLL. If you add "-a" to the command line as well, then you can skip the grep and base64 calls. The command line I use in a CMD file is:

                                          openssl enc -d -aes-256-cbc -salt -md sha256 -pbkdf2 -salt -iter 500000 -a -in %1 -out %2
                                          

                                          Where %1 is the input file and %2 is the output file; fewer calls so should be quicker too. I hope this saves someone else the pain I went through to figure this out. While it's possible that Unix/Linux and Windows OpenSSL behave differently w.r.t. the passphrase, I would be surprised if they are that much different. I am curious though, how what you posted could decrypt the file without the -iter argument... maybe an OpenSSL CNF file difference?

                                          I've submitted a ticket to Netgate asking if they should update their documentation on manual backup decryption as well.

                                          1 Reply Last reply Reply Quote 3
                                          • stephenw10S
                                            stephenw10 Netgate Administrator
                                            last edited by

                                            Where did you submit that? As a redmine bug report?

                                            D 1 Reply Last reply Reply Quote 0
                                            • First post
                                              Last post
                                            Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.