Results 1 to 4 of 4

Thread: VB6 Security Issue

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2009
    Posts
    9

    VB6 Security Issue

    Hi,

    I have a security issue with the program, and was wondering if there is a way to "encrypt" the program. Basically, if I compile a program I have made, then open it in notepad, I can see snippets of code. I understand that the form may be viewable, but I don't want the actual code viewable in notepad.

    For example, if it create a new "Log In Dialogue", and put the following code:

    Code:
    Private Sub cmdOK_Click()
        'check for correct password
        If txtUserName = "Bob" And txtPassword = "ABC123" Then
            'place code to here to pass the
            'success to the calling sub
            'setting a global var is the easiest
            LoginSucceeded = True
            Me.Hide
        Else
            MsgBox "Invalid Password, try again!", , "Login"
            txtPassword.SetFocus
            SendKeys "{Home}+{End}"
        End If
    End Sub
    If I then compile the code, make the program, then open the program with notepad, I am given the following:

    Code:
    MZ       ÿÿ  ¸       @                                   ¸   º ´	Í!¸LÍ!This program cannot be run in DOS mode.
    
    $       ŠùÛËë—ˆËë—ˆËë—ˆH÷™ˆÊë—ˆ¢ôžˆÊë—ˆ"ôšˆÊë—ˆRichËë—ˆ        PE  L ßMgJ        à              ¸      0    @                     P     Ýà                                ”"  (    @  ¤                                                                  (         ¨                           .text   °                           `.data   ø	   0      0              @  À.rsrc   ¤   @      @              @  @†¡H           MSVBVM60.DLL                                                                                                                                                                                            Æ‘Qs9Qs1hRsbrRsú QsžOsQsÀ*Os® QsP\Qs=žOs~ÏOsFQsFQs>ÎNs‰]Qs.“Qs*aQsÏ™NsÚ“Ps6Qsâ™NsÓ“Qsà˜Ns$FPsÉQsúQsuRsk’QszQszQsEjPs®QséûPs¤5BsömRs ‘Qs-íPs„”QsQÛPsûOs      º@   -"@     4"@ ÿ%D@ ÿ%`@ ÿ%l@ ÿ%0@ ÿ% @ ÿ%t@ ÿ%@ ÿ%„@ ÿ%4@ ÿ%€@ ÿ%x@ ÿ%h@ ÿ%P@ ÿ%d@ ÿ%@ ÿ%@ ÿ%@ ÿ% @ ÿ%œ@ ÿ%p@ ÿ%@@ ÿ%X@ ÿ%˜@ ÿ%”@ ÿ%@ ÿ%8@ ÿ%*@ ÿ%@ ÿ%Œ@ ÿ%,@ ÿ%@ ÿ%|@ ÿ%(@ ÿ%L@ ÿ%@ ÿ%\@ ÿ%H@ ÿ%T@ ÿ%$@ ÿ%<@ ÿ%ˆ@   h@ èîÿÿÿ      0   @       œ[»øÔfI€¢^÷¼hA               Project1            ÿÌ1 ›M§zçâêA‚uÃG‡Ù…*	ÑVK*yµPŒÅq>:O*3™fÏ· ª `Ó“                                    a  Y     frmLogin 
     Login           ¶Rˆ?®¤Ø?C "#ÿÿÿÿ$ Form1 & ' 5  ˜
      ¦  	  D Fÿ!    txtUserName 
    ‡ 	Y ÿ#    cmdOK  OK ïüt† ÿÿ+   	 cmdCancel  Cancel 4üt† ÿÿ(    txtPassword 
    
    	Y " * (ÿ3  €  	 lblLabels  &User Name:   i – 8  ÿ2  € 	 lblLabels 
     &Password:  i 8 ÿ  P   ›M§zçâêA‚uÃG‡                                          º      @ L   VB5!ð*             ~             
     	          ¨@ ð0  ÿÿÿ         é   Ä@ Ä@ Ä@ x      Š   ‹                   Project1 Project1  Project1 ô  ä@     @@ "@ ð	  0@ Æ@  0@ * \ A P r o j e c t 1                                                                                                                                                                                                                                                                                                                      Ä@         ,0@ Ì@ ÿÿÿÿ    0@ Ç€]kfI÷@—6Î*¶t§
        8@             |@ 	  	         @ ÿÿÿÿ¼@             p@    h@ ÿÿ  ƒ€             frmLogin    Project1    Ù…*	ÑVK*yµPŒÅq>Kö˜†ÌJ—´’ñäSI›M§zçâêA‚uÃG‡àü¥gÄõxB¦Åa&r’#âN*3™fÏ· ª `Ó“txtUserName .=ûüú*h§8 +3qµC:\Program Files\Microsoft Visual Studio\VB98\VB6.OLB   VB  ä@        	   ô@ ,@ Ð2@         ¸Ã òN*3™fÏ· ª `Ó“cmdOK   ÛN*3™fÏ· ª `Ó“lblLabels   txtPassword :O*3™fÏ· ª `Ó“Form    cmdCancel    X            
    B o b   áN*3™fÏ· ª `Ó“   A B C 1 2 3     8   I n v a l i d   P a s s w o r d ,   t r y   a g a i n !     
       L o g i n      { H o m e } + { E n d }     VBA6.DLL    __vbaFreeVar    __vbaFreeObj    __vbaFreeVarList    __vbaVarDup __vbaFreeObjList    __vbaFreeStrList    __vbaObjSet __vbaStrCmp __vbaHresultCheckObj       ä@     Œ@ ÿÿÿÿ    8@ 0@     À             „@    ˜@     „@    Œ@     ˆ@    Œ@  ·h l |@ ä2@     Ä„ ¨@ ¸@ @  8   È@           Œ@ ¸y Ø@   @  <   X@           @ Èy h@   @  @   p@           `@ Øy €@   @  D   È@           À@ ¸y Œ@   @  H   ˜@ ÿÿÿÿ        8@ èy ¨@ ÿÿÿÿ@  L   X@           Ì@ Èy °@   (@ 7@ N@ [@     Œ@ @ ’@ ˜@ ž@                                                                                                     ´@ @ ’@ ˜@ ž@ S@                                                                     Ü@ @ ’@ ˜@ ž@                                                                             @ @ ’@ ˜@ ž@                                                                                                     ,@ @ ’@ ˜@ ž@                                                                                                                                 T@ @ ’@ ˜@ ž@ F@                                                                 D$4   ¹¤@ ÿáD$4   ¹ª@ ÿál$K   éý   l$;   é€  Œ@ p@         $@           @ ø4          @ ÿÿÿÿ           h@     d@ `@ `@             X          ä@ ÿÿÿÿ    `@             ÿÿÿÿ    0@ È@ Ô2@ 0@ X@ Ø2@     p@ Ü2@ 0@ ˜@ à2@ LoginSucceeded  ÌÌÌÌÌÌÌÌÌÌÌÌééééÌÌÌÌÌÌÌÌÌÌÌÌU‹ìƒìhÆ@ d¡    Pd‰%    ƒìSVW‰eôÇEø¨@ ‹u‹Æƒà‰EüƒæþV‰u‹ÿQ‹3ÿVf‰~4ÿ’´  ;ÇÛâ}h´  hˆ@ VPÿ@ ‰}ü‹EP‹ÿQ‹Eü‹Mì_^d‰
        [‹å] U‹ìƒìhÆ@ d¡    Pd‰%    ì¬   SVW‰eôÇEø°@ ‹u‹Æƒà‰EüƒæþV‰u‹ÿQ‹3ÛV‰]è‰]ä‰]à‰]܉]̉]¼‰]¬‰]œ‰]Œ‰|ÿÿÿÿ’ü  PEàPÿ(@ ‹øUèRW‹ÿ‘*   ;ÃÛâ}h*   hÔ@ WPÿ@ ‹Vÿ  MÜPQÿ(@ ‹øEäPW‹ÿ’*   ;ÃÛâ}h*   hÔ@ WPÿ@ ‹MäQhè@ ÿL@ ‹Uè‹ø÷ßÿRGhÌ@ ÷ßÿL@ ÷ØÀMè@÷Ø#øEäPQjÿ|@ U܍EàRPjÿ@ ƒÄf;ût0‹VfÇF4ÿÿÿ‘´  ;ÃÛâý   h´  hˆ@ VPÿ@ éæ   ‹=Œ@ ¹ €‰M¤¸
       ‰M´•|ÿÿÿM¼‰Eœ‰E¬ÇE„<@ Ç…|ÿÿÿ   ÿ׍UŒMÌÇE”ü@ ÇEŒ   ÿ׍UœE¬RM¼PQUÌSRÿ,@ EœM¬PU¼QEÌRPjÿ@ ‹ƒÄVÿ‘  UàPRÿ(@ ‹ðV‹ÿ  ;ÃÛâ}h  hÔ@ VPÿ@ Màÿ*@ MÌÇEÔ €QhL@ ÇEÌ
       ÿ8@ MÌÿ@ ‰]ühq"@ ë<UäEèRPjÿ|@ M܍UàQRjÿ@ EœM¬PU¼QEÌRPjÿ@ ƒÄ,ÃËEP‹ÿQ‹Eü‹Mì_^d‰
        [‹å] žžžž¼"  ÿÿÿÿÿÿÿÿd#                         r#  |#  Š#  š#  ®#  ¾#  Ò#  à#  ø#  , €$  S €$  ($  W €2 €:$  D$  R$  f$  t$  ‚$  ˜$  ¢$  ¾$  Ô$  â$  ô$  %  %  $%  6%  J%  \%  d  €j%  x%  ‚%  Œ%  –%  *%      MSVBVM60.DLL    _CIcos    _adj_fptan    __vbaFreeVar    __vbaFreeVarList    _adj_fdiv_m64   __vbaFreeObjList    _adj_fprem1   __vbaHresultCheckObj    _adj_fdiv_m32   __vbaObjSet   _adj_fdiv_m16i    _adj_fdivr_m16i   _CIsin    __vbaChkstk   EVENT_SINK_AddRef   __vbaStrCmp   _adj_fpatan   EVENT_SINK_Release    _CIsqrt   EVENT_SINK_QueryInterface   __vbaExceptHandler    _adj_fprem    _adj_fdivr_m64    __vbaFPException    _CIlog    _adj_fdiv_m32i    _adj_fdivr_m32i   __vbaFreeStrList    _adj_fdivr_m32    _adj_fdiv_r   __vbaVarDup   _CIatan   _allmul   _CItan    _CIexp    __vbaFreeObj                                                                                                                                                                                              ßMgJu         X  €   @  €   (  €    ßMgJu         €  €    ßMgJu         ˜  €    ßMgJu      1u  à  €2u  È  €3u  °  €    ßMgJu      	  ø       ßMgJu                ßMgJu                ßMgJu          (      ßMgJu          8  PA  ä  °      4C  0   °      dC  (  °      ŒD  è  °      tG  0  °              ä4   V S _ V E R S I O N _ I N F O     ½ïþ                                           D     V a r F i l e I n f o     $    T r a n s l a t i o n     	°D   S t r i n g F i l e I n f o       0 4 0 9 0 4 B 0   4   P r o d u c t N a m e     P r o j e c t 1     , 
      F i l e V e r s i o n     1 . 0 0     0 
      P r o d u c t V e r s i o n   1 . 0 0     4   I n t e r n a l N a m e   P r o j e c t 1     D   O r i g i n a l F i l e n a m e   P r o j e c t 1 . e x e              0  1u     è  2u   (  3u(                À                         €  €   €€ €   € € €€  €€€ ÀÀÀ   ÿ  ÿ   ÿÿ ÿ   ÿ ÿ ÿÿ  ÿÿÿ                             ðw   ÿÿðwp ÿÿÿðp  ÿÿÿð   ÿÿÿð   ÿÿ€    € à    îà    à                                     ÿÿ  ÿÿ  ÿ  ø  À  À  À  À  À  À  À  À  Çÿ  ÿÿ  ÿÿ  ÿÿ  (       @         €                        €  €   €€ €   € € €€  €€€ ÀÀÀ   ÿ  ÿ   ÿÿ ÿ   ÿ ÿ ÿÿ  ÿÿÿ                                                                                                          ÿp          ÿÿÿwp      ÿÿÿÿÿÿwwp    ÿÿÿÿÿÿÿÿwp     ÿÿÿÿÿÿÿÿp      ÿÿÿÿÿÿÿÿ        ÿÿÿÿÿÿÿÿ        ÿÿÿÿÿÿÿÿ        ÿÿÿÿÿÿÿÿ        ÿÿÿÿÿÿÿÿ        ÿÿÿÿÿÿÿÿ        ÿÿÿÿÿÿÿÿ        ÿÿÿÿÿÿˆˆ        ÿÿÿÿˆˆ          ÿÿˆˆ  îî        ˆˆ  îî            îî            îî                                                                                                                                           ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÁÿÿü ÿ€ ø  ø  ø  ø ÿø ÿø ÿø ÿø ÿø ÿø ÿø ÿø ÿø ÿø ÿø ?ÿøÿÿø?ÿÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ(       @                                ÿÿÿ ÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÁÿÿü<ÿÃüø?üûÿüûÿüûÿýÿûÿýÿûÿýÿûÿýÿûÿýÿûÿýÿûÿýÿûÿýÿûÿÁÿûü=ÿûÃÁÿø<?ÿûÃÿÿø?ÿÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÁÿÿü ÿÀ ø  ø  ø  ø ÿø ÿø ÿø ÿø ÿø ÿø ÿø ÿø ÿø ÿø ÿø ?ÿøÿÿø?ÿÿûÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿÿ
    As you can see, this is not the ideal security!

    Is there a way to "encrypt" the program so it cannot be opened in notepad?

    Best regards,


    Leo

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: VB6 Security Issue

    There are products out there that can do it if you are willing to spend the money (ExeShield, Armadillo, and many more).

    Regarding strings, an easy fix but a little bit of a hassle is not to use strings that way.
    Instead of: "BOB"
    Use: Chr$(66) & Chr$(79) & Chr$(66)

    The above is far from hacker proof but should hide the text in NotePad.
    Edited: Hardcoding password and usernames in an exe is never a good idea when thinking of security.
    Last edited by LaVolpe; Jul 22nd, 2009 at 02:50 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3
    Former Admin/Moderator MartinLiss's Avatar
    Join Date
    Sep 1999
    Location
    San Jose, CA
    Posts
    33,431

    Re: VB6 Security Issue

    Or create a function that uses the asc values.

    Public Function ValidPassword(strPass As String) As Boolean

    Dim lngIndex As Integer

    If Len(strPass) <> 3 _
    Or Asc(Left$(UCase(strPass), 1)) <> 66 _
    Or Asc(Mid$(UCase(strPass), 2, 1)) <> 79 _
    Or Asc(Right$(UCase(strPass), 1)) <> 66 Then
    Exit Function
    End If

    ValidPassword = True

    End Function

  4. #4
    Frenzied Member
    Join Date
    Dec 2007
    Posts
    1,072

    Re: VB6 Security Issue

    Fixed up Martin's code:
    Code:
    Public Function ValidPassword(ByVal strPass As String) As Boolean
    
    strPass = UCase$(strPass)
    ValidPassword = LenB(strPass) = 6 _
    And AscW(Left$(strPass, 1)) = 66 _
    And AscW(Mid$(strPass, 2, 1)) = 79 _
    And AscW(Right$(strPass, 1)) = 66 
    
    End Function
    Or you can store it on a website and use INET or Winsock to get the Page's HTML and then parse it accordingly.

Tags for this Thread

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