mbt masai
 
Welcome !
         

                                
After experiencing a lot of down time, We decided to move this site to CrystalTech.com. CrystalTech.com is powered by only the finest Windows servers providing the best performance, reliability, and value anywhere.

 Decode base64 Strings

Author Message
DiGiTAL.SkReAM

  • Total Posts : 1259
  • Scores: 7
  • Reward points : 0
  • Joined: 9/7/2005
  • Location: Clearwater, FL, USA
  • Status: offline
Decode base64 Strings Saturday, June 24, 2006 4:03 PM (permalink)
0
I find this function to be usefull when dealing with nosy users. :)
I find that sometimes I am forced to have a sensitive password buried in a script.  I can try to wrap the script in an executable via primalscript (really, just a self-extracting/executing zip file), but if the script hangs due to OS instability or SOMETHING, the bald script itself is found in the temp directory, along with the cleartext password.
And encoded scripts are ok, but when the user has access to the internet, they would be able to find 'script decoder' pretty easily.
So.  What to do?  In the rare events that I HAVE to embed a password, I use Base64 to scramble it, include a decoder in the script, and then wrap it all in one of those .EXE's.
That way, even if the script bombs for some reason, the user would have to find the temp file, open it, and understand it enough to rewrite it to show them the password through decoding.
Still not perfect, or even close, but best I could do with vbscript. lol
Have fun.
 
Function fDecode(sStringToDecode)
 'This function will decode a Base64 encoded string and returns the decoded string.
 'This becomes usefull when attempting to hide passwords from prying eyes.
  Const CharList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
  Dim iDataLength, sOutputString, iGroupInitialCharacter
  sStringToDecode = Replace(Replace(Replace(sStringToDecode, vbCrLf, ""), vbTab, ""), " ", "")
  iDataLength = Len(sStringToDecode)
   If iDataLength Mod 4 <> 0 Then
    fDecode = "Bad string passed to fDecode() function."
    Exit Function
   End If
   For iGroupInitialCharacter = 1 To iDataLength Step 4
    Dim iDataByteCount, iCharacterCounter, sCharacter, iData, iGroup, sPreliminaryOutString
    iDataByteCount = 3
    iGroup = 0
     For iCharacterCounter = 0 To 3
      sCharacter = Mid(sStringToDecode, iGroupInitialCharacter + iCharacterCounter, 1)
       If sCharacter = "=" Then
        iDataByteCount = iDataByteCount - 1
        iData = 0
       Else
        iData = InStr(1, CharList, sCharacter, 0) - 1
         If iData = -1 Then
          fDecode = "Bad string passed to fDecode() function."
          Exit Function
         End If
       End If
      iGroup = 64 * iGroup + iData
     Next
    iGroup = Hex(iGroup)
    iGroup = String(6 - Len(iGroup), "0") & iGroup
    sPreliminaryOutString = Chr(CByte("&H" & Mid(iGroup, 1, 2))) & Chr(CByte("&H" & Mid(iGroup, 3, 2))) & Chr(CByte("&H" & Mid(iGroup, 5, 2)))
    sOutputString = sOutputString & Left(sPreliminaryOutString, iDataByteCount)
   Next
  fDecode = sOutputString
 End Function
 

 
"Would you like to touch my monkey?" - Dieter (Mike Meyers)

"It is better to die like a tiger, than to live like a pussy."
-Master Wong, from Balls of Fury
#1
    ebgreen

    • Total Posts : 8140
    • Scores: 95
    • Reward points : 0
    • Joined: 7/12/2005
    • Status: offline
    RE: Decode base64 Strings Sunday, June 25, 2006 10:02 AM (permalink)
    0
    Thanks for the handy function. Research Alternative Data Streams on the web. With them you can hide a script in a perfectly normal looking text file and execute it from there. Nothing is exposed to the user unless they know the name of the stream.
    "... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
    Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
    http://www.visualbasicscript.com/m_47117/tm.htm
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.8
      mbt shoes www.wileywilson.com