[VBS and Batch] Embed multiple binary data in/out of Batch file in Base64, No external tool or TMP.

Discussion in 'Scripting' started by hearywarlot, May 19, 2017.

  1. hearywarlot

    hearywarlot MDL Member

    Jul 31, 2015
    110
    113
    10
    #1 hearywarlot, May 19, 2017
    Last edited: Jul 23, 2017
    This is a VBS which can be used to embed binary data's using Base64 without external tools or making TMP files.

    CMD/Batch capability is pretty limited. You can embed in some way using 'Certutil', but that requires extracting the base64, since Microsoft did not think piping StdIn is useful with CertUtil...
    Now if you were to want a single file containing multiple Base64 encoded data's and use native Windows tools, you probably would want VBS and have it able to separately decode the data's.

    So here I come in with this script so everything is already there for you to use.


    Usage:
    The script will accept 3 switches.

    The switches:
    Required:

    • /ID:"<Identifier>"
    • /InFile:"<Source File>"
    Optional:

    • /OutFile:"[Output File]"

    If you do not use '/Outfile', the VBS will echo the decoded data.

    You must properly enclose Base64 using identifiers on both start and end of the encoded data.
    You must not use the identifier anywhere else in the script.

    You can have embed the Base64 in the script or point it from a external file(s).

    It would look like:
    Code:
    Random text that will
    get ignored
    
    <base64Lorem>
    TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2Np
    bmcgZWxpdCwgc2VkIGRvIGVpdXNtb2QgdGVtcG9yIGluY2lkaWR1bnQgDQp1dCBs
    YWJvcmUgZXQgZG9sb3JlIG1hZ25hIGFsaXF1YS4gVXQgZW5pbSBhZCBtaW5pbSB2
    ZW5pYW0sIHF1aXMgbm9zdHJ1ZCBleGVyY2l0YXRpb24gdWxsYW1jbyANCmxhYm9y
    aXMgbmlzaSB1dCBhbGlxdWlwIGV4IGVhIGNvbW1vZG8gY29uc2VxdWF0LiBEdWlz
    IGF1dGUgaXJ1cmUgZG9sb3IgaW4gcmVwcmVoZW5kZXJpdCBpbiB2b2x1cHRhdGUg
    DQp2ZWxpdCBlc3NlIGNpbGx1bSBkb2xvcmUgZXUgZnVnaWF0IG51bGxhIHBhcmlh
    dHVyLiBFeGNlc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QsIA0Kb21uaXMgZG9s
    b3IgcmVwZWxsZW5kdXMuIFRlbXBvcmlidXMgYXV0ZW0gcXVpYnVzZGFtIGV0IGF1
    dCBvZmZpY2lpcyBkZWJpdGlzIGF1dCByZXJ1bSBuZWNlc3NpdGF0aWJ1cyANCnNh
    ZXBlIGV2ZW5pZXQgdXQgZXQgdm9sdXB0YXRlcyByZXB1ZGlhbmRhZSBzaW50IGV0
    IG1vbGVzdGlhZSBub24gcmVjdXNhbmRhZS4gDQpJdGFxdWUgZWFydW0gcmVydW0g
    aGljIHRlbmV0dXIgYSBzYXBpZW50ZSBkZWxlY3R1cywgdXQgYXV0IHJlaWNpZW5k
    aXMgdm9sdXB0YXRpYnVzIG1haW9yZXMgYWxpYXMgY29uc2VxdWF0dXIgDQphdXQg
    cGVyZmVyZW5kaXMgZG9sb3JpYnVzIGFzcGVyaW9yZXMgcmVwZWxsYXQu
    <base64Lorem>
    
    More text, etc, etc


    You can execute the VBS from a script or from CMD.
    Code:
    Code:
    Base64Decode.vbs /ID:"base64Lorem" /InFile:"file.txt" /OutFile:"loremipsum.txt"
    Edit this example command to suit your needs.


    I also made a code to expand variables the VBS echo's.
    Code:
    FOR /f "delims=" %%A in (' cscript //nologo Base64Decode.vbs /ID:"base64WithVars" /InFile:"file.txt" ') do (
        FOR /f "delims=" %%B in (' ECHO( ^| SET /p "tmp=%%A" ') do (
            ECHO(%%B
        )
    )

    Code:
    In case you only want the VBS code, use the code below.

    Base64Decode.vbs
    Code:
    Set strArg=WScript.Arguments.Named
    colNamedArg= WScript.Arguments.Count
    
    if colNamedArg < 1 then
        Wscript.Echo "Switches:",vbCrLf,"/ID:<'<Identifier>'>",vbCrLf,"/InFile:<Source File>",vbCrLf,"/OutFile:[Output File]"
        WScript.Quit 1
    ElseIf Not strArg.Exists("ID") Then
        Wscript.Echo "ERROR: Switch /ID:<'<Identifier>'> is missing."
        WScript.Quit 1
    ElseIf Not strArg.Exists("InFile") Then
        Wscript.Echo "ERROR: Switch /InFile:<Source File> is missing."
        WScript.Quit 1
    ElseIf colNamedArg > 3 And Not strArg.Exists("OutFile") Then
        WScript.Echo "Invalid parameters"
        WScript.Quit 1
    End If
    
    Set outStream=CreateObject("ADODB.Stream") : outStream.Type = 1 : outStream.Open
    
    Set oFS=CreateObject("Scripting.FileSystemObject")
    Set inStream=oFS.OpenTextFile(strArg("InFile"),1,0,0)
    
    Set oXML=CreateObject("MSXml2.DOMDocument")
    Set oItem=oXML.createElement("tmp") : oItem.DataType="bin.base64"
    
    Do Until inStream.AtEndOfStream
        tmpStr = inStream.readline
        If InStr(tmpStr, "<" & strArg("ID") & ">") > 0 Then
            i=i+1
            If i = 2 Then
                Exit do
            End If
        Elseif i = 1 Then
            oItem.text=tmpStr
            decodedBytes=oItem.NodeTypedValue
            outStream.Write decodedBytes
        End If
    Loop
    If IsEmpty(decodedBytes) Then
        If IsEmpty(i) Then
            Wscript.Echo "ERROR: Identifier:'<" & strArg("ID") & ">' could not be found."
        Else
            Wscript.Echo "ERROR: Identifier:'<" & strArg("ID") & ">' seems to be empty."
        End If
        WScript.Quit 1
    End if
    
    If strArg.Exists("OutFile") Then
        outStream.SaveToFile strArg("OutFile"),2
    Else
        outStream.Position = 0 : outStream.Type = 2 : outStream.CharSet = "us-ascii"
        WScript.Echo outStream.ReadText
    End If
    
    inStream.close
    outStream.close

    In case you want to use a single Hybrid Batch/VBS file without TMP files, Checkout the code below.
    This the sample file I use for Base64 examples, edit to your needs.
    Note: the first line is part of the script, it tells WSH this is a Job script, so the VBS is executed without TMP.

    Base64Decode.cmd
    Code:
    <!-- : Begin batch script
    @ECHO OFF
    SETLOCAL EnableDelayedExpansion
    ECHO(Embedded VBS with no arguments
    CSCRIPT //nologo "%~f0?.wsf" //job:B64DEC
    ECHO(
    ECHO(
    ECHO(Extracting loremipsum.txt
    CSCRIPT //nologo "%~f0?.wsf" //job:B64DEC /ID:"base64Lorem" /InFile:"%~f0" /OutFile:"loremipsum.txt"
    ECHO(
    ECHO(Extracting prefs.js
    CSCRIPT //nologo "%~f0?.wsf" //job:B64DEC /ID:"base64Firefox" /InFile:"%~f0" /OutFile:"prefs.js"
    ECHO(
    ECHO(Extracting registrymodifications.xcu
    CSCRIPT //nologo "%~f0?.wsf" //job:B64DEC /ID:"base64Libre" /InFile:"%~f0" /OutFile:"registrymodifications.xcu"
    ECHO(
    ECHO(Extracting googleg_lodp.ico
    CSCRIPT //nologo "%~f0?.wsf" //job:B64DEC /ID:"base64GoogleIcon" /InFile:"%~f0" /OutFile:"googleg_lodp.ico"
    ECHO(
    ECHO(
    ECHO(Non existant identifier test
    CSCRIPT //nologo "%~f0?.wsf" //job:B64DEC /ID:"NonExistantIdentifier" /InFile:"%~f0"
    ECHO(
    ECHO(Invalid identifier test
    CSCRIPT //nologo "%~f0?.wsf" //job:B64DEC /ID:"base64Invalid" /InFile:"%~f0"
    ECHO(
    PAUSE
    ECHO(
    ECHO(Setting var "testvar" with content "test1234"
    SET "testvar=test1234"
    ECHO(
    ECHO(############################### Plain text ###############################
    CSCRIPT //nologo "%~f0?.wsf" //job:B64DEC /ID:"base64Test" /InFile:"%~f0"
    PAUSE
    ECHO(
    ECHO(############################# Expanded text #############################
    FOR /f "delims=" %%A in (' CSCRIPT //nologo "%~f0?.wsf" //job:B64DEC /ID:"base64Test" /InFile:"%~f0" ') do (
       FOR /f "delims=" %%B in (' ECHO( ^| SET /p "tmp=%%A" ') do (
           SET /a "NUM+=1"
           ECHO(!NUM!: %%B
       )
    )
    PAUSE
    EXIT /b
    <base64Lorem>
    TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNlY3RldHVyIGFkaXBpc2Np
    bmcgZWxpdCwgc2VkIGRvIGVpdXNtb2QgdGVtcG9yIGluY2lkaWR1bnQgDQp1dCBs
    YWJvcmUgZXQgZG9sb3JlIG1hZ25hIGFsaXF1YS4gVXQgZW5pbSBhZCBtaW5pbSB2
    ZW5pYW0sIHF1aXMgbm9zdHJ1ZCBleGVyY2l0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G9ydGluZy5oZWFsdGhyZXBv
    cnQudXBsb2FkRW5hYmxlZCIsIGZhbHNlKTsNCnVzZXJfcHJlZigiZGF0YXJlcG9y
    dGluZy5wb2xpY3kuZGF0YVN1Ym1pc3Npb25Qb2xpY3lCeXBhc3NOb3RpZmljYXRp
    b24iLCB0cnVlKTsNCnVzZXJfcHJlZigiYnJvd3Nlci5zbG93U3RhcnR1cC5ub3Rp
    ZmljYXRpb25EaXNhYmxlZCIsIHRydWUpOw0KdXNlcl9wcmVmKCJicm93c2VyLmRp
    c2FibGVSZXNldFByb21wdCIsIHRydWUpOw0KdXNlcl9wcmVmKCJicm93c2VyLnJp
    Z2h0cy4zLnNob3duIiwgdHJ1ZSk7DQp1c2VyX3ByZWYoInRvb2xraXQudGVsZW1l
    dHJ5LnByb21wdGVkIiwgMik7DQp1c2VyX3ByZWYoInRvb2xraXQudGVsZW1ldHJ5
    LnJlamVjdGVkIiwgdHJ1ZSk7
    <base64Firefox>
    <base64Libre>
    PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4KPG9vcjppdGVt
    cyB4bWxuczpvb3I9Imh0dHA6Ly9vcGVub2ZmaWNlLm9yZy8yMDAxL3JlZ2lzdHJ5
    IiB4bWxuczp4cz0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEiIHht
    bG5zOnhzaT0iaHR0cDovL3d3dy53My5vcmcvMjAwMS9YTUxTY2hlbWEtaW5zdGFu
    Y2UiPgo8aXRlbSBvb3I6cGF0aD0iL29yZy5vcGVub2ZmaWNlLlNldHVwL09mZmlj
    ZS9GYWN0b3JpZXMvb3JnLm9wZW5vZmZpY2UuU2V0dXA6RmFjdG9yeVsnY29tLnN1
    bi5zdGFyLnByZXNlbnRhdGlvbi5QcmVzZW50YXRpb25Eb2N1bWVudCddIj48cHJv
    cCBvb3I6bmFtZT0ib29TZXR1cEZhY3RvcnlEZWZhdWx0RmlsdGVyIiBvb3I6b3A9
    ImZ1c2UiPjx2YWx1ZT5NUyBQb3dlclBvaW50IDk3PC92YWx1ZT48L3Byb3A+PC9p
    dGVtPgo8aXRlbSBvb3I6cGF0aD0iL29yZy5vcGVub2ZmaWNlLlNldHVwL09mZmlj
    ZS9GYWN0b3JpZXMvb3JnLm9wZW5vZmZpY2UuU2V0dXA6RmFjdG9yeVsnY29tLnN1
    bi5zdGFyLnNoZWV0LlNwcmVhZHNoZWV0RG9jdW1lbnQnXSI+PHByb3Agb29yOm5h
    bWU9Im9vU2V0dXBGYWN0b3J5RGVmYXVsdEZpbHRlciIgb29yOm9wPSJmdXNlIj48
    dmFsdWU+TVMgRXhjZWwgOTc8L3ZhbHVlPjwvcHJvcD48L2l0ZW0+CjxpdGVtIG9v
    cjpwYXRoPSIvb3JnLm9wZW5vZmZpY2UuU2V0dXAvT2ZmaWNlL0ZhY3Rvcmllcy9v
    cmcub3Blbm9mZmljZS5TZXR1cDpGYWN0b3J5Wydjb20uc3VuLnN0YXIudGV4dC5U
    ZXh0RG9jdW1lbnQnXSI+PHByb3Agb29yOm5hbWU9Im9vU2V0dXBGYWN0b3J5RGVm
    YXVsdEZpbHRlciIgb29yOm9wPSJmdXNlIj48dmFsdWU+TVMgV29yZCA5NzwvdmFs
    dWU+PC9wcm9wPjwvaXRlbT4KPC9vb3I6aXRlbXM+
    <base64Libre>
    <base64GoogleIcon>
    AAABAAIAEBAAAAEAIABoBAAAJgAAACAgAAABACAAqBAAAI4EAAAoAAAAEAAAACAA
    AAABACAAAAAAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//
    /zD9/f2W/f392P39/fn9/f35/f391/39/ZT+/v4uAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAA/v7+Cf39/Zn///////////////////////////////////////////39
    /ZX///8IAAAAAAAAAAAAAAAA/v7+Cf39/cH/////+v35/7TZp/92ul3/WKs6/1iq
    Ov9yuFn/rNWd//j79v///////f39v////wgAAAAAAAAAAP39/Zn/////7PXp/3G3
    WP9TqDT/U6g0/1OoNP9TqDT/U6g0/1OoNP+Or1j//vDo///////9/f2VAAAAAP//
    /zD/////+vz5/3G3V/9TqDT/WKo6/6LQkf/U6cz/1urO/6rUm/+Zo0r/8IZB//ad
    Z////v7///////7+/i79/f2Y/////4nWzf9Lqkj/Vqo4/9Xqzv//////////////
    /////////ebY//SHRv/0hUL//NjD///////9/f2U/f392v////8sxPH/Ebzt/43R
    sP/////////////////////////////////4roL/9IVC//i1jf///////f391/39
    /fr/////Cr37/wW8+/+16/7/////////////////9IVC//SFQv/0hUL/9IVC//SF
    Qv/3pnX///////39/fn9/f36/////wu++/8FvPv/tuz+//////////////////SF
    Qv/0hUL/9IVC//SFQv/0hUL/96p7///////9/f35/f392/////81yfz/CrL5/2uk
    9v///////////////////////////////////////////////////////f392P39
    /Zn/////ks/7/zdS7P84Rur/0NT6///////////////////////9/f//////////
    //////////////39/Zb+/v4y//////n5/v9WYu3/NUPq/ztJ6/+VnPT/z9L6/9HU
    +v+WnfT/Ul7t/+Hj/P////////////////////8wAAAAAP39/Z3/////6Or9/1hj
    7v81Q+r/NUPq/zVD6v81Q+r/NUPq/zVD6v9sdvD////////////9/f2YAAAAAAAA
    AAD///8K/f39w//////5+f7/paz2/11p7v88Suv/Okfq/1pm7v+iqfX/+fn+////
    ///9/f3B/v7+CQAAAAAAAAAAAAAAAP///wr9/f2d////////////////////////
    ///////////////////9/f2Z/v7+CQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP7+
    /jL9/f2Z/f392/39/fr9/f36/f392v39/Zj///8wAAAAAAAAAAAAAAAAAAAAAPAP
    AADAAwAAgAEAAIABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIAB
    AACAAQAAwAMAAPAPAAAoAAAAIAAAAEAAAAABACAAAAAAAAAQAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP7+
    /g3+/v5X/f39mf39/cj9/f3q/f39+f39/fn9/f3q/f39yP39/Zn+/v5W////DAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP7+/iT9/f2c/f399f//////////////////
    ///////////////////////////////////9/f31/f39mv7+/iMAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP7+
    /gn9/f2K/f39+///////////////////////////////////////////////////
    /////////////////////////f39+v39/Yf///8IAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+/v4k/f390v//////////////////
    ////////////////////////////////////////////////////////////////
    //////////////39/dD///8iAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAA////MP39/er//////////////////////////+r05v+v16H/gsBs/2Wx
    Sf9Wqjj/Vqk3/2OwRv99vWX/pdKV/97u2P////////////////////////////39
    /ej+/v4vAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP7+/iT9/f3q////////
    /////////////+v15/+Pxnv/VKk2/1OoNP9TqDT/U6g0/1OoNP9TqDT/U6g0/1Oo
    NP9TqDT/U6g0/36+Z//d7tf///////////////////////39/ej///8iAAAAAAAA
    AAAAAAAAAAAAAAAAAAD///8K/f390//////////////////////E4bn/XKw+/1Oo
    NP9TqDT/U6g0/1OoNP9TqDT/U6g0/1OoNP9TqDT/U6g0/1OoNP9TqDT/U6g0/1ap
    N/+x0pv///////////////////////39/dD///8IAAAAAAAAAAAAAAAAAAAAAP39
    /Yv/////////////////////sdij/1OoNP9TqDT/U6g0/1OoNP9TqDT/U6g0/1Oo
    NP9TqDT/U6g0/1OoNP9TqDT/U6g0/1OoNP9TqDT/YKU1/8qOPv/5wZ//////////
    //////////////39/YcAAAAAAAAAAAAAAAD+/v4l/f39+////////////////8Lg
    t/9TqDT/U6g0/1OoNP9TqDT/U6g0/1OoNP9utlT/n86N/7faqv+426v/pdKV/3u8
    ZP9UqDX/U6g0/3egN//jiUH/9IVC//SFQv/82MP//////////////////f39+v7+
    /iMAAAAAAAAAAP39/Z3////////////////q9Ob/W6w+/1OoNP9TqDT/U6g0/1Oo
    NP9nskz/zOXC/////////////////////////////////+Dv2v+osWP/8YVC//SF
    Qv/0hUL/9IVC//WQVP/++fb//////////////////f39mgAAAAD+/v4O/f399v//
    /////////////4LHj/9TqDT/U6g0/1OoNP9TqDT/dblc//L58P//////////////
    ///////////////////////////////8+v/3p3f/9IVC//SFQv/0hUL/9IVC//rI
    qf/////////////////9/f31////DP7+/ln////////////////f9v7/Cbz2/zOw
    hv9TqDT/U6g0/2KwRv/v9+z/////////////////////////////////////////
    //////////////738//1kFT/9IVC//SFQv/0hUL/9plg////////////////////
    ///+/v5W/f39nP///////////////4jf/f8FvPv/Bbz7/yG1s/9QqDz/vN2w////
    //////////////////////////////////////////////////////////////rH
    qP/0hUL/9IVC//SFQv/0hUL//vDn//////////////////39/Zn9/f3L////////
    ////////R878/wW8+/8FvPv/Bbz7/y7C5P/7/fr/////////////////////////
    /////////////////////////////////////////ere//SFQv/0hUL/9IVC//SF
    Qv/718H//////////////////f39yP39/ez///////////////8cwvv/Bbz7/wW8
    +/8FvPv/WNL8///////////////////////////////////////0hUL/9IVC//SF
    Qv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//rIqv//////////////
    ///9/f3q/f39+v///////////////we9+/8FvPv/Bbz7/wW8+/993P3/////////
    //////////////////////////////SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SF
    Qv/0hUL/9IVC//SFQv/0hUL/+cGf//////////////////39/fn9/f36////////
    ////////B737/wW8+/8FvPv/Bbz7/33c/f//////////////////////////////
    ////////9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//SF
    Qv/6xaX//////////////////f39+f39/e3///////////////8cwvv/Bbz7/wW8
    +/8FvPv/WdP8///////////////////////////////////////0hUL/9IVC//SF
    Qv/0hUL/9IVC//SFQv/0hUL/9IVC//SFQv/0hUL/9IVC//vVv///////////////
    ///9/f3q/f39y////////////////0bN/P8FvPv/Bbz7/wW8+/8hrvn/+/v/////
    ////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////39/cj9/f2c////////
    ////////ht/9/wW8+/8FvPv/FZP1/zRJ6/+zuPf/////////////////////////
    ////////////////////////////////////////////////////////////////
    /////////////////////////f39mf7+/lr////////////////d9v7/B7n7/yB3
    8f81Q+r/NUPq/0hV7P/u8P3/////////////////////////////////////////
    ////////////////////////////////////////////////////////////////
    ///+/v5X////D/39/ff///////////////9tkPT/NUPq/zVD6v81Q+r/NUPq/2Fs
    7//y8v7////////////////////////////////////////////09f7/////////
    /////////////////////////////////////////f399f7+/g0AAAAA/f39n///
    /////////////+Tm/P89Suv/NUPq/zVD6v81Q+r/NUPq/1Bc7f/IzPn/////////
    ////////////////////////x8v5/0xY7P+MlPP/////////////////////////
    ///////////////////9/f2cAAAAAAAAAAD+/v4n/f39/P///////////////7W6
    9/81Q+r/NUPq/zVD6v81Q+r/NUPq/zVD6v9ZZe7/k5v0/6609/+vtff/lJv0/1pm
    7v81Q+r/NUPq/zVD6v+GjvL//v7//////////////////////////////f39+/7+
    /iQAAAAAAAAAAAAAAAD9/f2N/////////////////////6Cn9f81Q+r/NUPq/zVD
    6v81Q+r/NUPq/zVD6v81Q+r/NUPq/zVD6v81Q+r/NUPq/zVD6v81Q+r/NUPq/zVD
    6v+BivL////////////////////////////9/f2KAAAAAAAAAAAAAAAAAAAAAP7+
    /gv9/f3V/////////////////////7W69/8+S+v/NUPq/zVD6v81Q+r/NUPq/zVD
    6v81Q+r/NUPq/zVD6v81Q+r/NUPq/zVD6v81Q+r/P0zr/7q/+P//////////////
    /////////f390v7+/gkAAAAAAAAAAAAAAAAAAAAAAAAAAP7+/ib9/f3r////////
    /////////////+Xn/P94gfH/NkTq/zVD6v81Q+r/NUPq/zVD6v81Q+r/NUPq/zVD
    6v81Q+r/NkTq/3Z/8f/l5/z///////////////////////39/er+/v4kAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP7+/jL9/f3r////////////////////////
    ///k5vz/nqX1/2p08P9IVez/OEbq/zdF6v9GU+z/aHLv/5qh9f/i5Pz/////////
    ///////////////////9/f3q////MAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAP7+/ib9/f3V////////////////////////////////////////
    /////////////////////////////////////////////////////////f390v7+
    /iQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP//
    /wr9/f2N/f39/P//////////////////////////////////////////////////
    /////////////////////////f39+/39/Yv+/v4JAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD+/v4n/f39n/39
    /ff//////////////////////////////////////////////////////f399v39
    /Z3+/v4lAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/v7+Dv7+/lr9/f2c/f39y/39
    /e39/f36/f39+v39/ez9/f3L/f39nP7+/ln+/v4OAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAAAAAAAAAAAAAP/AA///AAD//AAAP/gAAB/wAAAP4AAAB8AA
    AAPAAAADgAAAAYAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
    AAAAAAAAAAAAAAAAAACAAAABgAAAAcAAAAPAAAAD4AAAB/AAAA/4AAAf/AAAP/8A
    AP//wAP/
    <base64GoogleIcon>
    <base64Invalid>
    <base64Invalid>
    ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAN
    CiAgICAgICAgICwtLS4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
    DQogICAgICAgLC0tLid8ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
    IA0KICAgLC0tLDogIDogfCAgICAgICAgICAgICAgICAgICAgICAgICAgICAsLS0t
    LCANCixgLS0uJ2B8ICAnIDogICAgICAgICAgICAgIF9fICAsLS4gICAgICwtLS0u[invalidtext]
    J3wgDQp8ICAgOiAgOiAgfCB8ICAgICAgICAgICAgLCcgLCcvIC98ICAgICB8ICAg
    fCA6IA0KOiAgIHwgICBcIHwgOiAgICAsLS0tLiAgICcgIHwgfCcgfCAgICAgfCAg
    IHwgfCANCnwgICA6ICcgICc7IHwgICAvICAgICBcICB8ICB8ICAgLCcgICAsLS0u
    X198IHwgDQonICAgJyA7LiAgICA7ICAvICAgIC8gIHwgJyAgOiAgLyAgICAvICAg
    LCcgICB8IA0KfCAgIHwgfCBcICAgfCAuICAgICcgLyB8IHwgIHwgJyAgICAuICAg
    JyAgLyAgfCANCicgICA6IHwgIDsgLicgJyAgIDsgICAvfCA7ICA6IHwgICAgJyAg
    IDsgfDogIHwgDQp8ICAgfCAnYC0tJyAgICcgICB8ICAvIHwgfCAgLCA7ICAgIHwg
    ICB8ICcvICAnIA0KJyAgIDogfCAgICAgICB8ICAgOiAgICB8ICAtLS0nICAgICB8
    ICAgOiAgICA6fCANCjsgICB8LicgICAgICAgIFwgICBcICAvICAgICAgICAgICAg
    IFwgICBcICAvICAgDQonLS0tJyAgICAgICAgICAgYC0tLS0nICAgICAgICAgICAg
    ICAgYC0tLS0nICAgIA0KICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
    ICAgICAgICAgICAgICA=
    base64Invalid>
    <base64Test>
    I1RoZSAnIScgd2lsbCBkaXNhcHBlYXIgdXBvbiBleHBhbmRpbmcgd2l0aCAgJ0Rl
    bGF5ZWQgRXhwYW5zaW9uJw0KU0VUIHRlc3R2YXI9IUAjJCVeJiooKV8rDQoNCiNU
    aGlzIHZhciB3aWxsIG5vdCBiZSBzZXQgYnkgdGhlIGFib3ZlIGxpbmUNCiV0ZXN0
    dmFyJQ0KDQolQUxMVVNFUlNQUk9GSUxFJQ0KJUFQUERBVEElDQolQ29tbW9uUHJv
    Z3JhbUZpbGVzJQ0KJUNvbW1vblByb2dyYW1GaWxlcyh4ODYpJQ0KJUNvbW1vblBy
    b2dyYW1XNjQzMiUNCiVDT01QVVRFUk5BTUUlDQolQ29tU3BlYyUNCiVIT01FRFJJ
    VkUlDQolSE9NRVBBVEglDQolTE9DQUxBUFBEQVRBJQ0KJUxPR09OU0VSVkVSJQ0K
    JU5VTUJFUl9PRl9QUk9DRVNTT1JTJQ0KJU9uZURyaXZlJQ0KJU9TJQ0KJVBhdGgl
    DQolUEFUSEVYVCUNCiVQUk9DRVNTT1JfQVJDSElURUNUVVJFJQ0KJVBST0NFU1NP
    Ul9JREVOVElGSUVSJQ0KJVBST0NFU1NPUl9MRVZFTCUNCiVQUk9DRVNTT1JfUkVW
    SVNJT04lDQolUHJvZ3JhbURhdGElDQolUHJvZ3JhbUZpbGVzJQ0KJVByb2dyYW1G
    aWxlcyh4ODYpJQ0KJVByb2dyYW1XNjQzMiUNCiVQUk9NUFQlDQolUFNNb2R1bGVQ
    YXRoJQ0KJVBVQkxJQyUNCiVTRVNTSU9OTkFNRSUNCiVTeXN0ZW1Ecml2ZSUNCiVT
    eXN0ZW1Sb290JQ0KJVRFTVAlDQolVE1QJQ0KJVVTRVJET01BSU4lDQolVVNFUkRP
    TUFJTl9ST0FNSU5HUFJPRklMRSUNCiVVU0VSTkFNRSUNCiVVU0VSUFJPRklMRSUN
    CiV3aW5kaXIl
    <base64Test>
    ----- Begin wsf script --->
    <package>
       <job id="B64DEC">
           <script language="VBScript">
               Set strArg=WScript.Arguments.Named
               colNamedArg= WScript.Arguments.Count
    
               if colNamedArg < 1 then
                  Wscript.Echo "Switches:",vbCrLf,"/ID:<'<Identifier>'>",vbCrLf,"/InFile:<Source File>",vbCrLf,"/OutFile:[Output File]"
                   WScript.Quit 1
               ElseIf Not strArg.Exists("ID") Then
                   Wscript.Echo "ERROR: Switch /ID:<'<Identifier>'> is missing."
                   WScript.Quit 1
               ElseIf Not strArg.Exists("InFile") Then
                   Wscript.Echo "ERROR: Switch /InFile:<Source File> is missing."
                   WScript.Quit 1
               ElseIf colNamedArg > 3 And Not strArg.Exists("OutFile") Then
                   WScript.Echo "Invalid parameters"
                   WScript.Quit 1
               End If
    
               Set outStream=CreateObject("ADODB.Stream") : outStream.Type = 1 : outStream.Open
    
               Set oFS=CreateObject("Scripting.FileSystemObject")
               Set inStream=oFS.OpenTextFile(strArg("InFile"),1,0,0)
    
               Set oXML=CreateObject("MSXml2.DOMDocument")
               Set oItem=oXML.createElement("tmp") : oItem.DataType="bin.base64"
    
               Do Until inStream.AtEndOfStream
                   tmpStr = inStream.readline
                   If InStr(tmpStr, "<" & strArg("ID") & ">") > 0 Then
                       i=i+1
                       If i = 2 Then
                           Exit do
                       End If
                   Elseif i = 1 Then
                       oItem.text=tmpStr
                       decodedBytes=oItem.NodeTypedValue
                       outStream.Write decodedBytes
                   End If
               Loop
               If IsEmpty(decodedBytes) Then
                   If IsEmpty(i) Then
                       Wscript.Echo "ERROR: Identifier:'<" & strArg("ID") & ">' could not be found."
                   Else
                       Wscript.Echo "ERROR: Identifier:'<" & strArg("ID") & ">' seems to be empty."
                   End If
                   WScript.Quit 1
               End if
    
               If strArg.Exists("OutFile") Then
                   outStream.SaveToFile strArg("OutFile"),2
               Else
                   outStream.Position = 0 : outStream.Type = 2 : outStream.CharSet = "us-ascii"
                   WScript.Echo outStream.ReadText
               End If
    
               inStream.close
               outStream.close
           </script>
       </job>
    </package>

    I hope it will be a good contribution to the internet, since I have tried making a end of all base64 scripts solution.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...