+ Reply to Thread
Results 1 to 14 of 14

Obfuscate Code

  1. #1
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Obfuscate Code

    .

    I've grown tired of the 3rd party commercial products that claim to obfuscate VBA code only to learn it requires multi-steps; a lot of manual input/post-process cleanup; can only produce under specific circumstances that are not routine; etc. etc.

    Oh ... and costs an arm and a leg.

    Has anyone created an obfuscator of their own that really works ? Would you be willing to share ?
    Last edited by 6StringJazzer; 01-25-2018 at 09:57 AM. Reason: Moved from Excel General

  2. #2
    Valued Forum Contributor ranman256's Avatar
    Join Date
    07-29-2012
    Location
    Kentucky
    MS-Off Ver
    Excel 2003
    Posts
    1,177

    Re: Obfuscate Code

    cant you just password protect the VB code?
    vbe: tools, project properties, protection

  3. #3
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Obfuscate Code

    Quote Originally Posted by ranman256 View Post
    cant you just password protect the VB code?
    vbe: tools, project properties, protection
    It takes me less than 1 min with a hex editor to overcome that.

    The answer to your question is either build your macros as COM addins which allows better means to protect your code or rely on third party solutions which as you are finding, may not offer quality results or require alot of jumping and hoops to get what you want.

    The last option is to not use VBA at all and build your "program" outside of Excel/Office.

    VBA was never intended to be a full fledged programming language/IDE with all the same considerations. The honest truth is 99.9% of the code people write isnt special or worth protecting. The code that is most people take the measures to do so.
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Obfuscate Code

    .
    Thank you for your answers.

    Yes, Excel is security challenged.

    I'm not concerned with the individual who can manipulate a HEX editor or spends their time on the 'dark web'. Those folks will always get what they want no matter.
    It's the hobbyist programmer to be targeted. I'd like to erect a reasonable number of walls to discourage him/her, without having to spend alot of money. Obfuscation
    is one of the 'walls'.

    Wish I had the knowledge to write and implement a COM add-in or could compile a workbook into a stand alone executable. The products that claim to compile don't and the
    ones that do cost tons.

  5. #5
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Obfuscate Code

    In that case VBA project protection as mentioned may be "good enough" for you. Its a speed bump on the way to your code. It will deter those not overly concerned with getting to your code. However anyone armed with google, the desire and 10 mins will get past it.

    Otherwise 3rd party is your only option and I cant recommend any as I have never bothered.

    As you mentioned Excel is "security challenged" as you put it. Usually people wanting to protect their code fall into 1 of 2 groups:
    • You wrote something you feel is unique and valuable and dont want others to determine the methods you used (like an algorithm for doing something no other code you know of can do)
    • You want to keep someone from seeing the exact methods used to get x results (like how you calculate salaries, markup on products, etc)

    If you are in the first boat, then COM addin/standalone program is your only bet and if your in this boat you likely have the ability to do it. I have personally written a few macros that fall in this category (kind of), which I primarily use for myself and do not distribute nor discuss with others the methodology of how I do it. I have considered moving them to standalone programs but simply dont have the time to bring myself up to speed on another programming language to accomplish it, nor a pressing need to.

    The second boat is more of a "wrong tool for the job" kind of issue. If you need to, for example, share product pricing with a customer and you use a macro that adjusts markup based on # of units and dont want them to see how this is calculated...then you are better off giving them a static copy, a copy exported to another format (like PDF), using IRM (99% of companies dont have the setup in place for this) or find a program that can dynamically present them the information while protecting the "backend" of it.

    If however its a preventative measure (as opposed to a security measure) then the built in project protection is for you. It will keep those who may accidentally, on a whim, or with limited skills from deleting or altering code. It comes with the understanding that someone who really wants at it will get at it.

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Obfuscate Code

    .
    First boat.

  7. #7
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Obfuscate Code

    Quote Originally Posted by Logit View Post
    .
    First boat.
    So whats the macro do?

  8. #8
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Obfuscate Code

    Hello Logit,

    You should be aware that obfuscating VBA code is a favorite malware technique. Your code could be flagged by antivirus programs as dangerous.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  9. #9
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,015

    Re: Obfuscate Code

    .
    Zer0Cool : Time travel. Shhh .... be vwery, vwery quiet.

    Leith Ross : Great ! One step forward ... five steps back. If you have an installer with the extension .EXE sometimes the Anti-Virus thinks that is a problem because the extension is not .MSI

  10. #10
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Obfuscate Code

    Quote Originally Posted by Logit View Post
    Time travel. Shhh .... be vwery, vwery quiet.
    Bah you must be using Excel on a Mac...

    (For those who dont get it...Mac's backup software is called Time Machine)

  11. #11
    Forum Guru Winon's Avatar
    Join Date
    02-20-2007
    Location
    East Rand, R.S.A.
    MS-Off Ver
    2010
    Posts
    6,113

    Re: Obfuscate Code

    Hello Logit,

    I have also been wondering about this for some time now. But I will only be able to test it with the enlisted help of Leith Ross. For instance, creating Code which states if Workbook or VBE Password does not equal "xyz" then automatically display Msgbox "Unauthorized action", and close Workbook and/or VBA. Even with trying the Hex Editor.

    Please tell us if this is doable Leith.

    Regards.
    Please consider:

    Be polite. Thank those who have helped you. Then Click on the star icon in the lower left part of the contributor's post and add Reputation. Cleaning up when you're done. If you are satisfied with the help you have received, then Please do Mark your thread [SOLVED] .

  12. #12
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: Obfuscate Code

    Quote Originally Posted by Winon View Post
    Please tell us if this is doable
    Nope. It is very easy to circumvent anything you implement via VBA itself.

    Open the file holding shift prevents code from firing off via events. Once they have removed the password to the code and can open it without triggering the code they can simply remove any effort to check for it.

    Lets say you put a check in to re-apply the protection, that requires access to the VBA object model if I recall which is disabled by default and generally no one would go enable it as its a big security issue to trust access to the object model. You would also have to include a password to apply, which could be extracted from the module without opening it in Excel. You now have literally given an intruder the keys they need to get in.

    The gist is basically its there to help prevent issues (like accidentally changing code), not to securely protect the code.

  13. #13
    Forum Contributor
    Join Date
    07-23-2016
    Location
    Texas
    MS-Off Ver
    2016
    Posts
    273

    Re: Obfuscate Code

    Protecting the code is not normally to prevent someone from copying it, it is to prevent a normal user from changing it such the spreadsheet doesn't perform as designed. As you said, protecting vb code to prevent someone from stealing it is a total waste of time.

  14. #14
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

    Re: Obfuscate Code

    Excel is not built to keep secrets. It does have protection features to protect against thumb fingered users, but....if you want to keep some thing secret, don't put it in an Excel file.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Need help with VBA code. Tons of code seperated in two, second part of code doesn't work.
    By FragaGeddon in forum Excel Programming / VBA / Macros
    Replies: 20
    Last Post: 11-30-2015, 11:46 AM
  2. [SOLVED] Pattern Building VBA Code - Working code, would like to use cleaner code
    By Benisato in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 02-10-2015, 03:05 PM
  3. Obfuscate Text
    By james598 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-30-2014, 11:39 AM
  4. [SOLVED] Excel VB code. Message pops up while code running asking question. Code must not wait.
    By Heinrich Venter in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-28-2014, 06:10 AM
  5. [SOLVED] VBA code for assigning a numeric code to text; then numeric code populates table
    By cteaster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 05-14-2014, 08:01 PM
  6. Replies: 2
    Last Post: 03-09-2013, 04:30 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1