-
Notifications
You must be signed in to change notification settings - Fork 6
/
vbshell.vbs
121 lines (105 loc) · 3.38 KB
/
vbshell.vbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
Wscript.Echo "VBShell 1.2"
Wscript.Echo "Copyright (c) 2012-2013 Marc Ruef"
Do While True
'Read input line
Wscript.Stdout.Write(">>>")
ln = Wscript.Stdin.Readline
If Lcase(Trim(ln)) = "exit" OR Lcase(Trim(ln)) = "quit" Then
Exit Do
ElseIf Lcase(Trim(ln)) = "help" Then
Wscript.Echo "---------------------------------------------------"
Wscript.Echo "Buit-In Commands"
Wscript.Echo "---------------------------------------------------"
Wscript.Echo "exit" & vbTab & vbTab & vbTab & "quit shell"
Wscript.Echo
Wscript.Echo "---------------------------------------------------"
Wscript.Echo "Extended Functions"
Wscript.Echo "---------------------------------------------------"
Wscript.Echo "hexencode(sString)" & vbTab & "convert string to hex"
Wscript.Echo "md5(sString)" & vbTab & vbTab & "generate md5 hash"
Wscript.Echo "processkill(sProcess)" & vbTab & "terminate a process by name"
Wscript.Echo "readfile(sFile)" & vbTab & vbTab & "read file to string"
Wscript.Echo "sha1(sString)" & vbTab & vbTab & "generate sha1 hash"
Wscript.Echo "sleep(iSeconds)" & vbTab & vbTab & "wait for a few seconds"
ElseIf LenB(ln) Then
On Error Resume Next
Err.Clear
'Execute line
If InStr(2, ln, " = ") OR InStr(2, ln, Lcase(" then")) Then
Execute ln
Else
Wscript.Echo Eval(ln)
End If
If Err.Number <> 0 Then
Wscript.Echo("Error Code #" & Err.Number & ": " & Err.Description & " [" & Mid(ln, 1, 20) & "]")
On Error Goto 0
End If
End If
Loop
'''Remapping existing functions
Function repeat(i, s)
repeat = String(i, s)
End Function
'''Extended Functions
Function readfile(sFile)
Set objFileSystem = CreateObject("Scripting.FileSystemObject")
Set objInputFile = objFileSystem.OpenTextFile(sFile, 1)
readfile = objInputFile.ReadAll
objInputFile.Close
Set objFileSystem = Nothing
End Function
Function hexencode(sAscii)
For i = 1 to Len(sAscii)
If (i Mod 4) = 1 Then
strEncoded = Trim(strEncoded & " 0x")
End If
strEncoded = strEncoded & Hex(Asc(Mid(sAscii, i, 1)))
Next
hexencode = strEncoded
End Function
Function processkill(sProcess)
Set objShell = CreateObject("WScript.Shell")
Set objWmi = GetObject("winmgmts:")
strWmiq = "select * from Win32_Process where name='" & sProcess & "'"
Set objQResult = objWmi.Execquery(strWmiq)
For Each objProcess In objQResult
processkill = objProcess.Terminate(1)
Next
End Function
Function md5(sString)
Dim asc, enc, bytes, s, pos
Set asc = CreateObject("System.Text.UTF8Encoding")
Set enc = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider")
bytes = asc.GetBytes_4(sString)
bytes = enc.ComputeHash_2((bytes))
s = ""
For pos = 1 To Lenb(bytes)
s = s & LCase(Right("0" & Hex(Ascb(Midb(bytes, pos, 1))), 2))
Next
Set asc = Nothing
Set enc = Nothing
md5 = s
End Function
Function sha1(sString)
Dim asc, enc, bytes, s, pos
Set asc = CreateObject("System.Text.UTF8Encoding")
Set enc = CreateObject("System.Security.Cryptography.SHA1CryptoServiceProvider")
bytes = asc.GetBytes_4(sString)
bytes = enc.ComputeHash_2((bytes))
s = ""
For pos = 1 To Lenb(bytes)
s = s & LCase(Right("0" & Hex(Ascb(Midb(bytes, pos, 1))), 2))
Next
Set asc = Nothing
Set enc = Nothing
sha1 = s
End Function
Function increment(sStart, sEnd)
For i = sStart To sEnd
s = s & i & vbCrLf
Next
increment = s
End Function
Function sleep(iSeconds)
WScript.Sleep (iSeconds * 1000)
End Function