Results 1 to 27 of 27

Thread: Encryption DLLs

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Posts
    195

    Encryption DLLs

    I have written an encryptor in VC++ and made a DLL out of it. I want to use this in a VB Program I'm writing.
    The problem is that functions used in the DLL are accessable outside of the VB program which means anyone could access the cryption routines. Is there any way I can put C++ code directly into a VB program, or a way I can ensure that only my VB program can use the DLL?
    Using Visual Studio .NET 2005

  2. #2
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Well, you could port it to VB... Bad idea though
    Could also call GetModuleFileName and compare it to the expected name of the exe.
    Can't think of any simple way that can't be easily hacked by anyone who's a little bit experienced though.

  3. #3
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    It's very very primitive, but it works. Try making the functions not work without an Init function. This function has a hardcoded value that the parameter passed must match. You can use a CRC only of the correct parameter there. If the CRC of the passed function is equal to the CRC inside the sub, bingo you've got a match and the functions become usable.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  4. #4
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Originally posted by Yonatan
    Can't think of any simple way that can't be easily hacked by anyone who's a little bit experienced though.

  5. #5
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    There's no way to get the original value from the CRC, so the only way to get past that would be bruteforce.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  6. #6
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Yeah... Just load the DLL and edit its memory (specifically, the value that specifies the Init status) so it thinks the Init function was successfully called.

  7. #7
    Fanatic Member twanvl's Avatar
    Join Date
    Dec 2001
    Posts
    771
    Or just temporaraly replace the DLL with your own, and record what value the VB program passes to it.

  8. #8
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    *sigh*. If only encryption wasn't needed
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  9. #9
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Can VB embed binary resources? If so then you could maybe embed the DLL, extract it on startup into a temporary file, load it and on closedown delete the file.

    But I don't think VB can use LoadLibrary and GetProcAddress properly, especially GetProcAddress...

    And you could still force crash the VB app to hinder it from deleting the DLL, or even simpler extract the resource.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  10. #10
    Good Ol' Platypus Sastraxi's Avatar
    Join Date
    Jan 2000
    Location
    Ontario, Canada
    Posts
    5,134
    Web-based authing.
    All contents of the above post that aren't somebody elses are mine, not the property of some media corporation.
    (Just a heads-up)

  11. #11
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    People will love you when your app requires an internet connection for no apparent reason.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  12. #12
    Guru Yonatan's Avatar
    Join Date
    Apr 1999
    Location
    Israel
    Posts
    892
    Originally posted by Sastraxi
    Web-based authing.
    ...and it still can be bypassed.

    Web based authorizing is only useful when the actual service is Internet-based. If the authorizing is Internet-based, and the service itself is independent of the Internet (so that the whole code is compiled for you), people will crack the authorization.

    On that note, you can make a server that requires authorization, and does the encryption. However, you should note two things:
    [list=1][*]You have to think of a good authorization method, or it won't be secure enough.[*]Depending on the type of encryption and the geographical location of the server, it might be subject to encryption export laws in the country it's in. (For example, in the USA, you cannot export encryption that uses keys larger than 40 bits.)[/list=1]
    Last edited by Yonatan; Jan 1st, 2003 at 01:27 PM.

  13. #13
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Do it from Canada or the UK then
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  14. #14
    C# Aficionado Lord_Rat's Avatar
    Join Date
    Sep 2001
    Location
    Cave
    Posts
    2,497
    VB can use resources.

    You have to add the VB resource editor to the project. -- Plenty on this in the VB section.

    Once you insert it, you can extract it at run time when you need it using a save as routine.

    When you do, randomly create a folder name and put it there, run it, delete the file and the folder.

    Other things to do:

    Have the DLL check the calling app for an initialization value (discussed above). Change this value using the time as a seed.

    Send back encrypted results. Just less encrypted than usual and easy (relatively) to decrypt just in case someone tries to intercept the sent back data, which can be done easily. At least they wont recognize it right off

    Place a dummy DLL file that looks like it does the same thing, but strip the code from the routines. Leave any String data, however, so that they appear in the compiled DLL.
    Need to re-register ASP.NET?
    C:\WINNT\Microsoft.NET\Framework\v#VERSIONNUMBER#\aspnet_regiis -i

    (Edit #VERSIONNUMBER# as needed - do a DIR if you don't know)

  15. #15
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Originally posted by Lord_Rat
    Send back encrypted results. Just less encrypted than usual and easy (relatively) to decrypt just in case someone tries to intercept the sent back data, which can be done easily. At least they wont recognize it right off
    He wants to hinder people from using the DLL, not intercepting the data decrypted by it (they get that presented by the VB app anyway).
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  16. #16
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Why do you want to stop people using the DLL?
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  17. #17
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    To hinder other apps from decrypting the data. He doesn't want that the user notices the encryption, so he can't use a password.

    At least I think that's the reason, if I remember correctly Barguast asked about such things a while ago.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  18. #18
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Security through obscurity is no security.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  19. #19

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Posts
    195
    Lord_Rat's solution sounds doable. Although I'd have thought they're be a way to embed a C++ function in a Visual Basic project...
    Using Visual Studio .NET 2005

  20. #20
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    There is. It involves messing around with VB's linking procedure to insert your own code to a matching VB function, hence replacing it.
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  21. #21

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Posts
    195
    I don't suppose you could tell me how?
    Using Visual Studio .NET 2005

  22. #22
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Nope, I don't remember it any more, and don't have copies of either VB, Visual C++, or Windows any more, so you'll just have to use Google
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  23. #23

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Posts
    195
    I'm no expert at this, so what exactly should I be searching for? "function embedding"?
    Using Visual Studio .NET 2005

  24. #24
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Search for VB, C++, and Linking.

    And pick random words from what you think you're doing
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  25. #25

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Posts
    195
    ak, I'm finding sod all. Is there a proper name for this technique? Is it anything to do with OBJ files?
    Using Visual Studio .NET 2005

  26. #26
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  27. #27

    Thread Starter
    Addicted Member
    Join Date
    Nov 2002
    Posts
    195
    I take it you meant the third one down.
    It mentions a Compile Controller Add-in which I don't have, and all the example code is gone.
    Using Visual Studio .NET 2005

Posting Permissions

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



Click Here to Expand Forum to Full Width