Java Decompilers: Exploring Tools for Reverse Engineering Java Code

JAVA DECOMPILERS -

Java Decompilers: Exploring Tools for Reverse Engineering Java Code





1. JD Project

2. Cavaj Java Decompiler

3. DJ Java Decompiler

4. JBVD

5. AndroChef Java Decompiler

6. Procyon

7. CFR Decompiler

8. FernFlower

9. Krakatau


JAVA TOOLS -

JAVA TOOLS

  • javac- The java compiler- javac is the java compiler it compiles java source code into java byte code. the java compiler is itself written in java.                                                                                                                              
  • java- Interpreter- it is java byte code interpreter. it runs java programs. and the program to be run is the class specified by classname.                                                                                            
  • javap- Java disassembler-   javap disassembler the class files specified by the class names on the command line and prints a human readable version of those classes.                                                                           
  • javah- Java header file generator- javah generates c header and source files with .h and .c files that describe the specified classes.                                                                                                       
  • javadoc- Document genrator- javadoc genrates API documentation in html format for the specified package or for the individual java source files specified on the command line.                                                                                        
  • jdb- Java debugger- jdb is a debugger for java classes. it is text based and command line oriented.                                                               
  • jar- Java archive tool- jar is a tool that can be used to create and manipulate java archive files.                                                           
  • Appletviewer - appletviewer is a standalone command line program used to run java applets.                                           
APPLET -

  • applet is a window application.
  • applet is a html tag.
  • it is a internet application.
  • applet having its own life cycle.
  • applet does not have main function. because its havingg it own life cycle.
  • applet does not containg system.out.println statement.

LIFE CYCLE OF APPLET -

  • init()
  • start()
  • stop()
  • destroy()

e.g -

impor

import java.applet.*;
public class Demo extends Applet
{
public void init()
{
}
public void start()
{
}
public void stop()
{
}
public void destroy()
{
}
<html>
<applet code=Demo.class width=300 height= 300>
</applet>
</html>
-------------------------------------------------------------
Examples -
-------------------------------------------------------------

Q1)Create an Applet which displays a message in the center of the screen. The message
indicates the events taking place on the applet window. Handle events like mouse
click, mouse moves, mouse dragged, mouse pressed. The message should update
each time an event occurs. The message should give details of the event such as
which mouse button was pressed (Hint: Use repaint(), MouseListener,
MouseMotionListener).

--->

import java.applet.Applet;
import java.awt.Graphics;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class MouseUpdate extends Applet implements MouseListener,MouseMotionListener{

int flag,x,y,count,b;
public void init(){
addMouseListener(this);
addMouseMotionListener(this);
}
public void paint(Graphics g){
String str="";
if(b==1)str="Left Button Clicked";
else if(b==3)str="Right Button Clicked";
if(flag==1)g.drawString("Mouse Draggged\t"+str+"\t"+count,x,y);
else if(flag==2)g.drawString("Mouse Moved\t"+str+"\t"+count,x,y);
else if(flag==3)g.drawString("Mouse Clicked\t"+str+"\t"+count,x,y);
else if(flag==4)g.drawString("Mouse  Entered\t"+str+"\t"+count,x,y);
else if(flag==5)g.drawString("Mouse Pressed\t"+str+"\t"+count,x,y);
else if(flag==6)g.drawString("Mouse Released\t"+str+"\t"+count,x,y);
}

public void mouseDragged(MouseEvent me) {

flag=1;
x=me.getX();
y=me.getY();
repaint();
}


public void mouseMoved(MouseEvent me) {

flag=2;
x=me.getX();
y=me.getY();
repaint();
}


public void mouseClicked(MouseEvent me) {

flag=3;
x=me.getX();
y=me.getY();
b=me.getButton();
count=me.getClickCount();
repaint();
}


public void mouseEntered(MouseEvent me) {

flag=4;
x=me.getX();
y=me.getY();
repaint();
}

public void mouseExited(MouseEvent me) {
}

public void mousePressed(MouseEvent me) {
flag=5;
x=me.getX();
y=me.getY();
b=me.getButton();
count=me.getClickCount();
repaint();
}


public void mouseReleased(MouseEvent me) {

flag=6;
x=me.getX();
y=me.getY();
repaint();
}

}


Q2)Create an Applet which displays a message in the center of the screen. The message
indicates the event taking place on the applet window. Handle various keyboard
related events. The message should update each time an event occurs. The message
should give details of the event such as which key was pressed, related, typed etc.
(Hint: Use repaint(), KeyListener).

--->

package slip19;

import java.applet.*;
import java.awt.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

/* <Applet code=MyAPplet width=300 height=300>
 * </Applet>
 */
public class MyApplet extends Applet implements KeyListener{

char ch;
int flag;
@Override
public void init() {
// TODO Auto-generated method stub
addKeyListener(this);
}
@Override
public void paint(Graphics g) {
// TODO Auto-generated method stub
g.setColor(Color.black);
g.fillRect(0, 0, 300, 300);
if(flag==1) {
g.setColor(Color.red);
g.drawString(ch+" is Pressed",150,150);
}
else if(flag==2) {
g.setColor(Color.green);
g.drawString(ch+" is Released",150,150);
}
else if(flag==3) {
g.setColor(Color.blue);
g.drawString(ch+" is Typed",150,150);
}
}
@Override
public void keyPressed(KeyEvent ke) {
// TODO Auto-generated method stub
ch=ke.getKeyChar();
flag=1;
repaint();
showStatus("Key Presseed");
}
@Override
public void keyReleased(KeyEvent ke) {
// TODO Auto-generated method stub
ch=ke.getKeyChar();
flag=2;
repaint();
showStatus("Key Released");
}
@Override
public void keyTyped(KeyEvent ke) {
// TODO Auto-generated method stub
ch=ke.getKeyChar();
flag=3;
repaint();
showStatus("Key Typed");
}

}




Post a Comment

3 Comments