)
Settings
Log out
As we all know to become an ethical hacker or a bug bounty hunter needs more expertise in many languages.
For ex. If you want to become a web security expert, you should be famliar with web development languages like asp, jsp,.net, python,perl,php etc.
With that in mind, we are going to learn some compilation methods of few languages like c, python, bash.The reason for this session is, there are so many tools available in Github for penetration testing and vulnerability assessment. we should learn to explore new tools that is available on Github and other software markets.
Moslty open source tools written in php, perl, python, c, cpp and many come with the source codes. we have to compile it and execute it.
The Programming Process
Programming languages are for humans to read and understand. The program (source code) must be translated into machine language so that the computer can execute the program (as the computer only understands machine language). The way that this translation occurs depends on whether the programming language is a compiled language or an interpreted language.Compiled languages (e.g. C, C++)
The following illustrates the programming process for a compiled programming language.
A compiler takes the program code (source code) and converts the source code to a machine language module (called an object file). Another specialized program, called a linker, combines this object file with other previously compiled object files (in particular run-time modules) to create an executable file. This process is diagrammed below. Click Initial build to see an animation of how the executable is created. Click Run executable to simulate the running of an already created executable file. Click Rebuild to simulate rebuilding of the executable file.
Interpreted programming languages (e.g. Python, Perl)
The process is different for an interpreted language. Instead of translating the source code into machine language before the executable file is created, an interpreter converts the source code into machine language at the same time the program runs. This is illustrated below:
Interpreted languages use a special program called an interpreter that converts the source code, combines with runtime libraries, and executes the resulting machine instructions all during runtime. Unlike a compiled language, there is no precompiled program to run. The conversion process and combination with runtime libraries takes place every time an interpreted language program is run. This is why programs written in compiled languages tend to run faster than comparable programs written in interpreted languages. Click Start to run the simulation of an interpreted program. Click Restart if you want to run the simulation again.
Each time an interpreted program is run, the interpreter must convert source code into machine code and also pull in the runtime libraries. This conversion process makes the program run slower than a comparable program written in a compiled language.
Because an interpreter performs the conversion from source to machine language during the running of the program, interpreted languages usually result in programs that execute more slowly than compiled programs. But what is often gained in return is that interpreted languages are often platform independent because a different interpreter can be used for each different operating system. Java
The Java programming language does not fit into either the compiled language or interpreted language models. This is illustrated in the figure below.
The Java compiler (javac) converts the source code into bytecode. Bytecode is a kind of average machine language. This bytecode file (.class file) can be run on any operating system by using the Java interpreter (java) for that platform. The interpreter is referred to as a Virtual Machine. Thus, Java is an example of a Virtual Machine programming language.
Virtual machine languages were created to be a compromise between compiled and interpreted languages. Under ideal conditions, virtual machine language programs run closer in speed to compiled language programs but have the platform indepency of interpreted language programs.
Virtual machine languages makes use of both a compiler and an interpreter. The compiler converts the source code into a kind of average machine language. In Java, this average machine language is called bytecode. In Visual Studio.NET languages, this average machine language is called MSIL (Microsoft Intermediate Language). (To keep the discussion on this page simpler, this compiled code will be referred to generically as bytecode from this point on.) The interpreter for virtual machine languages is a special program that provides the runtime libraries for the given operating system. That means that there is a different virtual machine interpreter for all of the supported operating systems.
Once again, note that the bytecode does not need to be recompiled to run on any of the different operating systems. The only reason to recompile a program is if you changed the source code.Details of the Java programming process
The source code for a Java program is a text file that ends in ".java". Suppose you typed out the following file, "Hello.java".
class Hello { public static void main(String[] args) { System.out.println("Hello"); } }
To compile this program, you would type the following at the command line:
javac Hello.java
The Java compiler is named javac. The javac program is unique in that it does not produce actual machine code. Instead it produces something called bytecode. Unlike machine code, bytecode is not platform specific. The bytecode produced on a Windows machine is the same bytecode that is produced on a Linux machine. This means that the bytecode can be run (without recompiling) on any platform that has a Java interpreter.
If the compilation into bytecode is successful, the bytecode will be contained in a file called "Hello.class" is created. To run this bytecode, the Java interpreter is invoked in the following way.
java Hello
Note the name of the Java interpreter is java. Also note that you do not include the .class at the end of the filename when invoking the interpreter. By default, the .class file is created in the same directory as the directory you are running the compiler from.
guage.
Open your leafpad in Kali linux and write a program in
C, CPP, Python, Php, Perl, Bash to display Hello world and
note down the compilation methodology of the programming languages.