VBA Code Protection/Password Encryption

Maryz

Board Regular
Joined
Dec 10, 2002
Messages
197
Can anyone with some past experience with trying to protect VBA tell me what the current state of affairs is with regard to trying to keep hackers from seeing your VBA code? By using google, I see that there are VBA password removers available. I suspect 99% of the users of these products have not forgotten the password to their code, but would rather have a peek at someone else’s code. Is there anything that can be done to deter hackers or users of these products? A form of encryption maybe?

I was told to try creating a COM addin using VB and placing code in a dll or exe file. This is as clear as mud to me as I have no clue how to even test this procedure. Has anyone come up or discovered any creative ways to deter the 1% who are determined to get in? Any comments are welcomed.
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Has anyone come up or discovered any creative ways to deter the 1% who are determined to get in?
If this is what you're dealing with, then you should probably re-evaluate your working conditions. :huh:

As far as someone "really wanting" to get into your code, just look at Microsoft's woes; if someone wants in badly enough they can.

Password Protecting your VBA project and worksheets/workbooks should be a sufficient deterrent to most. If you still have some curious snoopers, there are some workarounds, a quick board search will turn up a ton. One method that I use is to use Environ(UserName) to identify the person/PC opening your workbook. If it's not someone who should be there, then automatically Quit Excel, along with a nasty message. ("You aren't authorized to view this file...Your hardrive will now be reformatted") :diablo:

You can even throw in an automatic e-mail to their boss...If it is a serious problem at your work, then see my first response, or get your/their boss involved. The threat of being fired has a funny tendency of making people stop what they're doing.

Just note that Excel is NOT a secure operating environment. If it's really such a huge concern, you might want to think about Access or even a stand-alone VB (6 or .NET)solution.

HTH,

Smitty

(I've been told that a bottle of Scotch to the Security guys also goes a long way)... :beerchug:
 
Upvote 0
Pennysaver,

Unfortunately, Access is a database platform and not a rich analytical tool like Excel. Excel is the perfect platform for the task at hand. If users open the file and disable the macros, I cannot control anything they do (let alone leave them nasty messages).

What I did find out below was not encouraging. I may be SOL.

VBA passwords
This password type protects VBA source code from being viewed or changed. For example, a
developer may use it to stop users from changing macros.
Different approaches are used in Office 97 (VBE 5.0) than Office 2000 and later (VBE 5.1)
This uses a proprietary Microsoft protection scheme which is very insecure (Office 97) and fairly
insecure (Office 2000 and later).
How it works
With Office 97, the password is protected using a simple encryption algorithm, and stored in the
file.
With Office 2000 and later, the password is hashed using the 192 bit SHA algorithm, and then
encrypted.
In neither case is the VBA itself protected – only the password is encrypted. This is a key
weakness of the scheme. Consequently, in both cases the VBA source code is readily unlocked.
Recovery approaches
For Office 97 VBA, use software that will recover the original password.
For Office 2000 and later VBA, use software that can either replace the password with another
known password, or remove the password.
:banghead:
 
Upvote 0
Mary,
If users open the file and disable the macros, I cannot control anything they do
There are workarounds to this.

See Phantom's suggestion: http://www.mrexcel.com/board2/viewtopic.php?t=53314&highlight=password+protect

PaddyD and NateO also have some good suggestions regarding hidden sheets, but I can't seem to find them at the moment. (I'm sure that Iridium will dig them up for me...)

Goblin also has a uniquie way of attacking it: http://www.mrexcel.com/board2/viewtopic.php?t=59966&postdays=0&postorder=asc&start=10

HTH,

Smitty
 
Upvote 0
Hi Mary, just to reiterate what penysaver has said. Excel IS NOT SECURE.
Advanced users can by pass ANY elaborate security schemes you set up,
and I have set up some elaborate ones, until I realised that @ the heart of the protection
was the VBA code protection ie geting into this and then viewing the code nullifies anything
you do, and doing this is easy if you have a good HEX Editor and know what Structured storage
stream to look for and the bytes to get. In fact it only takes a minute or 2 to get in.
Your best option is to write a COM addin or DLL. Search Microsoft on how to do these.
 
Upvote 0
Has anyone tried LockXLS (www.lockxls.com)? I just started to use it and it appears to protect the VBA code and formulas.
 
Upvote 0
Hi Mary, just to reiterate what penysaver has said. Excel IS NOT SECURE.
Advanced users can by pass ANY elaborate security schemes you set up,
and I have set up some elaborate ones, until I realised that @ the heart of the protection
was the VBA code protection ie geting into this and then viewing the code nullifies anything
you do, and doing this is easy if you have a good HEX Editor and know what Structured storage
stream to look for and the bytes to get. In fact it only takes a minute or 2 to get in.
Your best option is to write a COM addin or DLL. Search Microsoft on how to do these.

Kia Ora Ivan,

Writing to yourself from the city of sails too...:)

Whats the best (optimal ) solution one can go in for as regds protecting VBA code... I'm pretty new to VBA and yet I've created a pretty good code and wouldn't want for that to be hacked....

Encrypted password: would that be sufficient deterrance ? and what level of protection could one expect of it?
& further, could it be done from within the project to protect individual sheets as well
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,286
Members
452,902
Latest member
Knuddeluff

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top