VBscript hell

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AHMEDYO
    New Member
    • Nov 2007
    • 112

    VBscript hell

    hi all, first its my first time to post question in internet, but vbs really let me crazy.

    my problem is :
    ----------------------
    i wanna to transfer exe file to machine that i can access by real ip no VPN and i cant access machine sharing but i can remote to this machine using remote desktop, sure u will ask me for download, but this machine cant go online because of physical security and firewall.

    i was think about 2 solution

    1-i was thinking about what the problem if i open exe file in notebad and copy data in clipboard and then past it to new file, but this solution isnt work, almost clipboard cant work with unprintable & control characters

    then i think about the second solution

    2-what if i convert exe file to ascii of characters example and separate them by dot char as 65.77.90.140.26 .36.25.45.21.55 ..........etc, now this file can transfer using clipboard and no problem except convert it back to exe using vbscript

    i do all of that and this idea working good and i convert exe to digits and back to exe using Visual Basic 6, but sure the remote machine dont have visual basic then i must use VBscript , and i can copy script text too using clipboard

    the same functions i was made in vb6 didnt work in vbs

    my first problem was in textstream.writ e(Str) in VBS it result run-time error (invalid procedure call or arguments) and i dont know why!!!!!, i was trace what character write function fail in, and i think it any character greater than 128

    second problem i was search and search and i was found that i can use ADODB.Stream to write binary data and i was meet the very funny thing in the world :D lol , Stream.Write(Bu ff) take one argument as Array Of Bytes and i cant define Array of byte in VBS, just array of variants!!!!!, when i pass my array of variant variable to stream.write function i got error (wrong number of arguments, or argument type is conflict with another and so on)....and sure because array of variants and array of bytes conflict type!!!!!, then i was think and i got another solution, i was open file using stream.read(n) and i was check about Vartype of returned array and it was array of bytes not variant ,,thats very good!!!!, i got it!!!!,when im trying to access this array of bytes as array using brakets bytearr(n) i got type mismatch lol, vbs is still working with anytype as variant as soon as vartype(var) return vbarray | vbbyte type, when i pass it to stream.write (bytearr) ir working , but i cant assign or get value from this array byt using brackets, then im trying to work with it using mid instead of array brakets i got type mistamch too because Mid() function work wih string and it not string type lool

    i will past my two ways for converting to exe , and sry about my dancing english :D

    '--------------------------------------------------------------------------------------
    Ascii File Example
    M.Z..........et c
    77.90.144.0.3.0 .0.0.4.0.0.0.25 5.255.0.0.184.0 .0.0.0.0.0.0.64 .
    '---------------------------------------------------------------------------------------

    '============== =============== =============== ============
    'you can ignore this function it just as visual basic Val Function and it work to muliple numbers by 10 , 100 , and ignore unicode second byte character=0 placed by last convert exe to ascii function and sure i must leave it using unicode to copy it using clipboard

    Function Val(ByVal Strvar)
    Dim CurrentChr
    Dim ChrValue
    Dim GetChar
    Dim FieldValue
    GetChar=true
    FieldValue=1
    ChrValue=0
    For CurrentChr = LenB(Strvar) To 1 step -1
    If (GetChar = False) Then
    if(CurrentChr<( LenB(Strvar)-1)) Then FieldValue=Fiel dValue * 10
    ChrValue =ChrValue +((AscB(MidB(St rvar, CurrentChr, 1))-48) * FieldValue)
    End If
    GetChar = Not GetChar
    Next
    Val =cbyte(ChrValue )
    End Function
    =============== =============== =============== ===========
    Function ConvertToExeUsi ngFSO(ByVal FilePath)
    Dim FileSys
    Dim ExeFile
    Dim FileData
    Dim CurrentChar
    Dim DotOffset
    Dim NewString
    Set FileSys = CreateObject("S cripting.FileSy stemObject")
    Set ExeFile = FileSys.OpenTex tFile(FilePath)
    FileData = ExeFile.ReadAll
    Do
    DotOffset = InStr(FileData, ".") 'search about dot char
    If (DotOffset = 0) Then Exit Do 'if no dot char found then file comlpete
    CurrentChar = Val(Mid(FileDat a, 1, DotOffset - 1)) 'call my val function
    FileData = Mid(FileData, DotOffset + 1) 'clear char ascii value and dot
    NewString = NewString & Chr(CurrentChar ) 'ascii back to 1 byte
    'exmaple in file it 77 in 2 byte memory now it will be 1 byte = 77
    'using chr() or chrB() or chrW() is not the problem i was try
    Loop
    Call ExeFile.Close
    Set ExeFile = FileSys.CreateT extFile(Left(Fi lePath, Len(FilePath) - 4)) '
    Call ExeFile.Write(N ewString) * the problem here invalid procudure call :49
    Call ExeFile.Close
    MsgBox "done"
    End Function

    =============== =============== =============== ===========

    Function ConvertExeUsing ADOSTREAM(ByVal FilePath)
    Dim FileSys
    Dim ExeFile
    Dim FileData
    Dim CurrentChar
    Dim DotOffset
    Dim NewString()
    Dim CharOffset
    Set FileSys = CreateObject("S cripting.FileSy stemObject")
    Set ExeFile = FileSys.OpenTex tFile(FilePath)
    FileData = ExeFile.ReadAll
    Call ExeFile.Close
    Set ExeFile = CreateObject("A DODB.Stream")
    ExeFile.Type = 1
    Call ExeFile.Open
    Do
    CharOffset = CharOffset + 1
    DotOffset = InStr(FileData, ".")
    If (DotOffset = 0) Then Exit Do
    CurrentChar = Val(Mid(FileDat a, 1, DotOffset - 1))
    FileData = Mid(FileData, DotOffset + 1)
    Redim Preserve NewString(CharO ffset-1)
    NewString(CharO ffset - 1) = CurrentChar
    Loop
    Call ExeFile.Write(N ewString)
    Call ExeFile.SaveToF ile(Left(FilePa th, Len(FilePath) - 4), 2)
    Call ExeFile.Close
    Set FileSys = Nothing
    Set ExeFile = Nothing
    MsgBox "done"
    End Function

    Thanx....
Working...