How to avoid readable strings in EXE file

Everything else that doesn't fall into one of the other PB categories.
flashbob
User
User
Posts: 92
Joined: Sat May 11, 2024 4:04 pm

How to avoid readable strings in EXE file

Post by flashbob »

Hi,
many strings and also SQL-Statements are stored as a readable string in an exe file. I want to avoid that.

Is there a workaround so that e.g. SQL statements are not recognizable as text ?
User avatar
spikey
Enthusiast
Enthusiast
Posts: 750
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: How to avoid readable strings in EXE file

Post by spikey »

The Cipher library contains Base64Encoder and Base64Decoder which should hinder casual snoopers. Or there are some ideas in viewtopic.php?t=51055. But you'd need proper AES encryption if you're concerned about determined hackers. See AESEncoder.
BarryG
Addict
Addict
Posts: 4124
Joined: Thu Apr 18, 2019 8:17 am

Re: How to avoid readable strings in EXE file

Post by BarryG »

I use this technique -> viewtopic.php?p=584753#p584753

Works fantastic and I don't need to do anything - the compiler does it. You can't use the C compiler, though (only ASM).
flashbob
User
User
Posts: 92
Joined: Sat May 11, 2024 4:04 pm

Re: How to avoid readable strings in EXE file

Post by flashbob »

Thanks for the answers, I'll test it out. But this helps ...

@BarryG
I think this solution is not working for MAC ?
BarryG
Addict
Addict
Posts: 4124
Joined: Thu Apr 18, 2019 8:17 am

Re: How to avoid readable strings in EXE file

Post by BarryG »

Oh right... yeah it's Windows-only. You didn't mention Mac in your first post, and your title says "EXE" file. Macs are "APP" files. ;)
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: How to avoid readable strings in EXE file

Post by NicTheQuick »

The real question is: Do you just want to obfuscate the strings so they are not easily readable or do you want perfect security? The latter is only possible by using an encryption key that does not exist in the executable but has to be entered every time you start the application or something similar.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
flashbob
User
User
Posts: 92
Joined: Sat May 11, 2024 4:04 pm

Re: How to avoid readable strings in EXE file

Post by flashbob »

NicTheQuick wrote: Sat Nov 23, 2024 3:51 pm The real question is: Do you just want to obfuscate the strings so they are not easily readable or do you want perfect security? The latter is only possible by using an encryption key that does not exist in the executable but has to be entered every time you start the application or something similar.
Good question !
For me it is only important that you cannot read SQL-statements etc directly from the application (Win, Mac) with a simple (hex) editor.
Last edited by flashbob on Sat Nov 23, 2024 6:12 pm, edited 1 time in total.
flashbob
User
User
Posts: 92
Joined: Sat May 11, 2024 4:04 pm

Re: How to avoid readable strings in EXE file

Post by flashbob »

BarryG wrote: Sat Nov 23, 2024 1:13 pm Oh right... yeah it's Windows-only. You didn't mention Mac in your first post, and your title says "EXE" file. Macs are "APP" files. ;)
sorry, my mistake ;-)
flashbob
User
User
Posts: 92
Joined: Sat May 11, 2024 4:04 pm

Re: How to avoid readable strings in EXE file

Post by flashbob »

Hi, found another way to hide strings in exe file:

1. You can use constants instead of strings when possible (Win, Mac)

2. You can use packer for exe files like Molebox, Mpress, ... (Win)
I don't know if there is also a packer for Mac.

Regards
User avatar
blueb
Addict
Addict
Posts: 1111
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: How to avoid readable strings in EXE file

Post by blueb »

Simply encrypt the whole SQLite database using 'DB Browser for SQLCipher'.
see: https://sqlitebrowser.org/

Here's a sample starter example from my Password manager...

Code: Select all

;========================================================================
;
; Author:     blueb    
; Date:       December 24, 2023
;
; Explain:    Password Manager (using 'DB Browser for SQLCipher') 
;                (Only the sqlcipher.dll is actually required)
; Credits:
;             DB Browser for SQLCipher (freeware)
; =================================================================
;
; DB Browser for SQLCipher is a powerful and user-friendly tool for working with SQLCipher-encrypted SQLite databases.
; If you need to manage and query such databases, this tool is a reliable and secure choice.
;
;Explanation:  This program uses the 'sqlcipher.dll' And 'libcrypto-1_1-x64.dll' from the freeware 
;              program 'DB Browser for SQLCipher'. see: https://sqlitebrowser.org/
;              
;              For downloads visit: https://sqlitebrowser.org/dl/
;
;              You do not need the full program unless you want to make changes to the 'SALT' password I have used to create the DB (e.g. 'Great tasting Pizza')
;
;              PassKeeper is totally freeware, but I cannot be responsible for any problems you might encounter.
;              Feel free to make any changes you see fit.
; =================================================================

; ****************************************************************************************************************************************
; HINT:  Do NOT keep this source code any where near the EXE file.. anyone with the database SALT will find your passcodes!
; ****************************************************************************************************************************************

EnableExplicit

; Libraries required
UseSQLiteDatabase("sqlcipher.dll")   ; Use the encryption DLL from 'DB Browser for SQLCipher'

Declare CheckDatabaseUpdate(Database, Query$)
Declare.s Requester(Title$,Message$,DefaultString$)

;- Globals
Global DatabaseFile.s = GetCurrentDirectory()+"PassKeeper.db"
Global theImage.s
Global Quit

If OpenDatabase(0, DatabaseFile, "", "") 
   CheckDatabaseUpdate(0, "PRAGMA key = 'Great tasting Pizza'")  ; Database 'SALT' (Don't worry.. that's not the real salt haha)
   
   If DatabaseQuery(0, "SELECT * FROM Keeper WHERE Website LIKE '%AAAA Passcode%';") ;get the password string from row selected (AAAA Passcode 'Item Name' should be unique)
      While NextDatabaseRow(0)
         theImage = GetDatabaseString(0, 3) 
      Wend
      
      FinishDatabaseQuery(0)
   EndIf
   
EndIf
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: How to avoid readable strings in EXE file

Post by NicTheQuick »

@blueb:
He does not want to encrypt the database, he just does not want the queries he is throwing against the database to be seen.

@flashbob:
But I do not understand why you want to obfuscate the queries. Who should be interested in seeing that? People could just have a look into the database anyway.
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
flashbob
User
User
Posts: 92
Joined: Sat May 11, 2024 4:04 pm

Re: How to avoid readable strings in EXE file

Post by flashbob »

@NicTheQuick

... that is basically right, but my tables are encrypted. At the moment there is only one (readable) column for primary key and one
additional column for encrypted informations. So you cannot get any usable informations or column names from database.

The question was not only because of SQL statements, but also strings. Both cases can be solved using constants...as far as
I can realize.
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: How to avoid readable strings in EXE file

Post by NicTheQuick »

How do you hide keys to encrypt and decrypt the data?
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
flashbob
User
User
Posts: 92
Joined: Sat May 11, 2024 4:04 pm

Re: How to avoid readable strings in EXE file

Post by flashbob »

... keys, salt etc. are generated at runtime and depend on the login and other mechanisms.
If you forget the password, the data will be lost.
User avatar
NicTheQuick
Addict
Addict
Posts: 1504
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: How to avoid readable strings in EXE file

Post by NicTheQuick »

That sounds really good!
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Post Reply