JavaScript Reversing For Newbies 
by The Sandman
4th February 1999 
here
 
Title
 
JavaScript Example 1
A Simple "Hello World" Routine
Written by The Sandman 
 
Rating
( X )Beginner   ( )Intermediate   ( )Advanced   ( )Expert 
 
Introduction
Greetings Reversers, 

JavaScript Reversing has, on the whole, been neglected by crackers in favour of the more, abundant source of software programs that litter the web. It's all too easy to fall into the trap of thinking that if you can crack software based programs then you must be a cracker.. Wrong.  

Crackers / Reversers need to understand that they need to develop and sharpen their skills by encompassing all computer languages that span the web, since each language brings forth it's own skills and knowledge that, in turn, prepare the cracker / reverser for all eventualities. 

Okay, here's a JavaScript tutorial for newbies, I know it's for newbies because I'm also a newbie in JavaScript Reversing, so bear with me while I'm finding my feet in this new area of cracking. 

JavaScript is, in many ways, far easier to grasp than Assembler, for this reason it is also very much limited in what it can do. This is where the similarities end. Assembler is software based, JavaScript is web page based. With this out of the way lets proceed with this tutorial. 
 

Tools
Required
1 Pen.  
1 sheet of A4 paper.  
An open mind.  
 
About this
tutorial
  
We are going to build up a JavaScript routine from the ground upwards. We will start with the idea, then gradually build this up in easy stages, using JavaScript as our choice of language.  Simplicity will be our base for the foundation and at this stage, elegance of our script will not be a major consideration. This tutorial will serve as an introduction to the structure of JavaScripts, with explanations to show how we might write a simple JavaScript routine. 

Primarily, we will start with some of the very basic JavaScript commands to create our routine, then progress in later tutorials  to using alternative methods to give our original idea more functionality and style. 
 

T
H
E
E
S
S
A
Y
  
Key Colors:  
JavaScript Objects Names marked in Blue  
JavaScript Properties marked  in Red  
JavaScript Methods marked in purple  

For this essay we shall be creating a simple JavaScript routine that will display those famous words "Hello World". I say famous because these words are often the first words to be used when anyone starts to learn a new computer language and represents a mile stone for the would be programmer.   Yes that's right, we're going to learn some programming since this is the way to learn a new programming language.   

Okay, we have the idea, now what?..   

Patience dear reverser, I know you want to crack on and dive blindly into this code but a little thought along the way never hurt anyone..  

Okay, we have the words "Hello World" and we want to see them shown right in front of us using JavaScript, but what commands can we use to do this?.  

Well first we have to decide exactly where we want these holy words to be show. Perhaps we want them written to this web page perhaps?. Yes, this sounds like a great idea so let us proceed.  

In JavaScript web pages are considered as 'Objects', there are many other 'Objects' in JavaScript as well, but for the sake of keeping this tutorial simple and to the point we will stick with working with this web page for now.  

If your interested in knowing what all the other 'objects' are in JavaScript then why not browse through 'The JavaScript Reference Guide' right now and lookup the 'object' document and see what properties & methods are associated with it. Incidentally, if you don't have a JavaScript Reference Guide of your own then feel free to download this page, it's quite large to read online so makes sense to view it off-line..  

Right, we see that for the document object it says "The document is perhaps the single most important JavaScript function there is. It contains information on the current page, and provides ways of displaying HTML output to the viewer.".  This sounds interesting, perhaps we can use the document object to our advantage.. If we continue reading up on the document object we get to the Properties..  

Think of the Properties as a means of reading and setting the characteristics of an object, which in our case relate to the appearance of our web page. A little further down we come to the methods associated with our document.  

Think of methods as inbuilt functions in JavaScript that we can use to carry out a specific task on.  

Whoa, what this, we have two methods that looks promising!  

write()     - Writes text to the document   
writeln()  - Writes text to the document and adds a carriage return that is 
                    ignored by HTML, so writeln() and write() are the same.  

The example given for write() explains that we can display any text we want as long as it is enclosed within a pair of speech marks. Here that example:-  
   
example: document.write("text")   

Here is what this example show's us..  

We first start with an Object that we wish to work with, in our case it is our web page. Next, we need to associate with this object some kind of action, which in this example is write().  

Remember, we need to assign a method to an object before we can use it, else JavaScript will not know what to do or where to carry out your command.  

Now by combining document.write("hello World") we are ready to write our first JavaScript routine, right?. Well almost..  

All javaScript routines must begin with the tag <script> or <SCRIPT> which marks the start of a JavaScript routine..  Just as with normal HTML code where we mark the beginning and ending of our use of fonts, colors etc, must also tell the browser where out JavaScript routine will end and we can do this with: </script> or </SCRIPT>. Capital or lowercase letters are acceptable for these tags.  
   
Because there are different versions of JavaScript around and because some browsers either have no capability to run JavaScript or may have this facility switched off, then we have to take all of this into account, else the visitor with no JavaScript capability will receive an error in their browser as it tries to execute non-html code that it knows nothing about.  Therefore, we can first limit the browser's capability to see and execute our script code by replacing the standard <SCRIPT> tag with any of the following tags..   
  
  

 <Script> Replacement Tags Comments 
<SCRIPT LANGUAGE="JavaScript">
 
 
<SCRIPT LANGUAGE="JavaScript1.1">
 
 
<SCRIPT LANGUAGE="JavaScript1.2">
 
Allows the script to work with Netscape 2.0+ 

Allows the script to work with Netscape 3.0+ but not anything below it. 

Allows the script to work with Netscape 4.0+ but not anything below it.

   

In addition to this, we can tell any browser not capable of executing JavaScript to completely ignore our script code. If we didn't do this  then our script code would show through our web pages instead of being executed.. Not a pretty sight.  To this end we would then need to use <!--   after our <SCRIPT> tag and  //--> before the </SCRIPT> tag.   
   
   

Our Script so far Comments 
<script> 
  
<!-- 
  
document.write("Hello World")  
  
//--> 
  
</script>
Start of our script code 
  
Hide script from non JS Browsers. 
  
Script to execute 
  
unhide our script code 
  
Finish executing script
   
Unlike most other computer languages, there is no facility or software program that we can use to test or debug our scripts, it a case of write our scripts then paste/insert them directly into our web pages and hope we've done our homework well.    

If you are using Netscape and new to JavaScript and or editing HTML code directly though Notepad then I recommend you follow this procedure for inserting this example script into your web page.    

1. Click on the Insert menu option then select HTML Tag, this will pop up a small window where it's waiting for you to type in your JavaScript code. Before selecting the OK button it's always best to click on the Verify button just to check that you've made no syntax mistakes. If all checks out okay then click on the OK button.    

If your using Micro$oft Explorer (Shame on you!) then you've no choice but to dive straight into the HTML source code of your web page and paste your whole JavaScript into the web page. In this case:-    

1. While in edit mode, click once on the View menu option then, select Source, this should bring up Notepad with the full source code of your web page. Here you can either type the whole script into your web page source code, making sure to verify you've made no mistakes such as missing an opening or closing tag or you can cut then paste your whole script directly into the web page source code.  A little care needs to be exercised here to where you place your script. For now, and for the sake of this tutorial I would suggest that you place this script code well away from the top of your web page.    
   
 If you've followed this tutorial so far and you are now out of edit mode then you should now see your script code has been executed with the result like this:-  
   

If you can see Hello World on your web page then CONGRATULATIONS!, you've just written your first JavaScript routine!.  If not then re-check your script, make sure all the tags are in place and that your browser has the Run JavaScript option ENABLED, it may have been switched off by default.  

  
In Part II of this tutorial, we will be expanding further on this script by encapsulating the Hello World idea into a function, that we will be able to execute anywhere within our web page. Extra functionality will also be carried out to give this routine more versatility and usefulness. 
 
 

Ob duh
I wont even bother explaining you that you should BUY your software if you intend to use it for a longer period than the allowed one. Should you want to STEAL software instead, you don't need to crack its protection scheme at all: you'll find it on most Warez sites, complete and already regged, farewell. 
Final Notes
Original format of this tut by (c) flipper (upg) 12/30/97 All rights reversed. 
way out
 
 

Page  by The Sandman  
Page Created: 4th February 1999