Bin-format shellcode to vb (bin2vb. vbs)

Source: Internet
Author: User

If (lcase (right (wscript. fullname, 11) = "wscript.exe") then
Wscript. echo "Execute it under the cmd.exe Plz! Thx ."
Wscript. quit
End if

If Wscript. Arguments. count = 0 Then
Usage ()
Wscript. quit
End If


Function ReadGif (sStr)
Dim I, iHex, sPath, oStream
Set oStream = CreateObject ("Adodb. Stream ")
OStream. Type = 1
OStream. Open
OStream. LoadFromFile sStr

For I = 1 To LenB (oStream. Read ())
OStream. Position = 0
IHex = Hex (AscB (MidB (oStream. Read (), I, 1 )))
If Len (iHex) = 1 Then iHex = "0" & iHex
ReadGif = ReadGif & iHex
Next

OStream. Close
Set oStream = Nothing
End Function


Function CutAndJoin (sSource, iLong, sJoiner)

Dim I, N

N = Len (sSource)/iLong
If (N <> Fix (N) Then N = Fix (N) + 1

For I = 0 To N-1
CutAndJoin = CutAndJoin & Mid (sSource, I * iLong + 1, iLong) & sJoiner
Next

If (N> 0) Then CutAndJoin = Left (CutAndJoin, Len (CutAndJoin)-Len (sJoiner ))

End Function


Function ReplaceTest (str, patrn, replStr)
Dim regEx and str1 create variables.
Set regEx = New RegExp to create a regular expression.
RegEx. Pattern = patrn setting mode.
RegEx. IgnoreCase = True is case sensitive.
ReplaceTest = regEx. Replace (str, replStr) to Replace.
End Function

Set Arg = Wscript. Arguments

Temp = "& H" & CutAndJoin (ReadGif (arg (0), 2, "& H ")
Temp1 = CutAndJoin (temp, 4 ,",")
Temp2 = CutAndJoin (temp1, 80, Chr (13 ))
Temp3 = Split (temp2, Chr (13 ))

For I = 0 To UBound (temp3)
Temp4 = temp4 & Replacetest (ReplaceTest (temp3 (I), "^", "a = a &" & Chr (34), "$", Chr (34 )) & Chr (13)
Next


Function writef (cpp)
Set FSO = CreateObject ("Scripting. FileSystemObject ")
With fso. opentextfile (cpp, 2, true)
. Writeline temp4

. Close
End
Set fso = Nothing
End Function

Writef (arg (1 ))

Function usage ()
Wscript. echo "| Useage: |"
Wscript. echo "| cscript.exe shellcode. vbs x. bin test. bas |"
Wscript. echo "| ex: |"
Wscript. echo "| cscript.exe shellcode. vbs c: pythonivy. bin c: est. bas |"
Wscript. echo "+ ------------------------------------------------------------------- +" & chr (10)
End function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.