Tuesday, May 25, 2010

Visual Basis Script (.vbs)

"VBS" or Visual Basic Script. It is commonly attached to HTML and help optimize a website interaction with the user. It is different from the full blown programming language which is Visual Basic. It's just a scripting language. Just like the difference of Java Script from Java.

A file with an extension of .vbs is also a VB Script. But this file can be accessed just like an executable file in your desktop.

It is very common to see a .vbs virus in your flash drive, CD or Hard Drive. Yes! You can create a virus using .vbs. It's either by altering a process, automatically do a process you don't want to execute, or doing a process repeatedly via infinite loops 'till the computer crashes. However, Using VBS can be helpful also with the proper use of the script. You can automatically macro a whole process that could take you minutes to finish with just one click on your .vbs files. It's just a matter of how you use the script.

Example, You have a computer shop and you don't want your customers to access task manager. It is doable with the use of vb. You can turn On or Off the access to task manager. And thus regedit and other shell writing capabilities to protect your business from hacking.

Here's an example of a code to turn off the Task Manager Access.

1. First, Open Notepad or Wordpad.

2. Type this series of codes.


Set shell = CreateObject("Wscript.shell")

This Code will set "shell", A variable, to an Object which will allow you to write commands on shell.

X=Inputbox("Enter choice, 1 to disable, 0 to enable")

Now we declare that "X" to be an input box. It can take two parameters.

e.g. Inputbox("Message","Title")

but as you can see on our example, we only typed in one parameter for message.
If X=1 Then

Now, We'll Check the user input on our input box. since "X" is the variable for our inputbox, The value we typed in was stored in "X".

Shell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr", 1, "REG_DWORD"


Now, This code will trigger to Disable Task manager. It is simply a Path directing to a command where we can disable task manager.


Else

This will execute if the variable "X" is not equal to "1"

Shell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System\DisableTaskMgr", 0, "REG_DWORD"


This functions same as the code above. but the only difference is the 1 and 0. We'll, Since the It is a path and DisableTaskMgr takes parameters as well. It takes 1 to disable and 0 to Enable. We'll discuss some more of this on my other posts. Don't worry.

End If


Always End your if statement with "End if"


3. Since we are done typing the codes. Save the file. Save it as .vbs. Just ad ".vbs" to what ever filename. in our example: taskmanager.vbs



4. After Saving, You'll see an icon with Blue "S" Image on it. It signifies that it is a "Script". The image is like this.




5. Now if you double click it. It wouldn't show you a wordprocessor GUI like java. Instead, It functions as an executable file. Directly executing whatever command that is written in that script.

6. Now, Let's see our product.



7. If you Input "1". Try hitting Alt-Ctrl-Del. You'll get this error message.



8. If you Input "0". You can access Task Manager again.



We'll, That's just It! Simple use of VBS. You can pull a prank to your friends just by using a little imagination. There are many things that can be done with VB script because it can write to your computer's shell (core). Explore them and you'll love VB Script as an easy to use non-expensive scripting language.

Have fun coding!

[/code]


No comments: