Honhar Engineer

Honhar Engineer
Thanks for visiting,stay connected for more updates !

Thursday, September 26, 2013

Definition of RMI & RPC,Difference between RPC & RMI,Codes for RPC & RMI

Remote Procedure Call (RPC)
Remote Procedure Call (RPC) is a powerful technique for constructing distributed client-server based applications.

RPC is a client /server infrastructure that increases the interoperability, portability and flexibility of an application by allowing the application to be distributed over multiple heterogeneous platforms.

An RPC is analogous to function call.

How RPC Works

An RPC is analogous to a function call. Like a function call, when an RPC is made, the calling arguments are passed to the remote procedure and the caller waits for a response to be returned from the remote procedure. Figure 32.1 shows the flow of activity that takes place during an RPC call between two networked systems. The client makes a procedure call that sends a request to the server and waits. The thread is blocked from processing until either a reply is received, or it times out. When the request arrives, the server calls a dispatch routine that performs the requested service, and sends the reply to the client. After the RPC call is completed, the client program continues. RPC specifically supports network applications.

Fig. 32.1 Remote Procedure Calling Mechanism A remote procedure is uniquely identified by the triple: (program number, version number, procedure number) The program number identifies a group of related remote procedures, each of which has a unique procedure number. A program may consist of one or more versions. Each version consists of a collection of procedures which are available to be called remotely. Version numbers enable multiple versions of an RPC protocol to be available simultaneously. Each version contains a a number of procedures that can be called remotely. Each procedure has a procedure number.

RPC Application Development

Consider an example:

A client/server lookup in a personal database on a remote machine. Assuming that we cannot access the database from the local machine (via NFS).

We use UNIX to run a remote shell and execute the command this way. There are some problems with this method:

* the command may be slow to execute.
* You require an login account on the remote machine.

The RPC alternative is to

* establish an server on the remote machine that can repond to queries.
* Retrieve information by calling a query which will be quicker than previous approach.

To develop an RPC application the following steps are needed:

* Specify the protocol for client server communication
* Develop the client program
* Develop the server program

The programs will be compiled seperately. The communication protocol is achieved by generated stubs and these stubs and rpc (and other libraries) will need to be linked in.

Reomote Procedure Calling Mechanism

A remote procedure is uniquely identified by the triple: ( program number, version number, procedure number).

ADVANTAGES:

Many distributed systems use Remote Procedure Calls(RPCs) as their main communication mechanism.

RMI is a Remote method invocation


- RMI (Remote Method Invocation) is a way that a programmer, using the Java programming language and development environment, can write object-oriented programming in which objects on different computers can interact in a distributed network. RMI is the Java version of what is generally known as a remote procedure call (RPC), but with the ability to pass one or more objects along with the request. The object can include information that will change the service that is performed in the remote computer. Sun Microsystems, the inventors of Java, calls this "moving behavior." For example, when a user at a remote computer fills out an expense account, the Java program interacting with the user could communicate, using RMI, with a Java program in another computer that always had the latest policy about expense reporting. In reply, that program would send back an object and associated method information that would enable the remote computer program to screen the user's expense account data in a way that was consistent with the latest policy. The user and the company both would save time by catching mistakes early. Whenever the company policy changed, it would require a change to a program in only one computer.

Sun calls its object parameter-passing mechanism object serialization. An RMI request is a request to invoke the method of a remote object. The request has the same syntax as a request to invoke an object method in the same (local) computer. In general, RMI is designed to preserve the object model and its advantages across a network.

RMI is implemented as three layers:

* A stub program in the client side of the client/server relationship, and a corresponding skeleton at the server end. The stub appears to the calling program to be the program being called for a service. (Sun uses the term proxy as a synonym for stub.)
* A Remote Reference Layer that can behave differently depending on the parameters passed by the calling program. For example, this layer can determine whether the request is to call a single remote service or multiple remote programs as in a multicast.
* A Transport Connection Layer, which sets up and manages the request.

A single request travels down through the layers on one computer and up through the layers at the other end.



Difference between RMI and RPC?


RMI or Remote Method Invokation is very similar to RPC or Remote Proceedure call in that the client both send proxy objects (or stubs) to the server however the subtle difference is that client side RPC invokes FUNCTIONS through the proxy function and RMI invokes METHODS through the proxy function. RMI is considered slightly superior as it is an object-oriented version of RPC.




Application Difference Between RPC and RMI?


The only real difference between RPC and RMI is that there is objects involved in RMI: instead of invoking functions through a proxy function, we invoke methods through a proxy.

What this means in practice is that we now want the client to hold references to remote objects that it can invoke methods on. These references should behave just like local objects, but when invoked dispatch the method invocation to the remote object.

Because we need to refer to both an object and a method now - not just a function - we extend the protocol so it first sends an object id across the socket, then the method and then the arguments. The server then dispatches the method to the remote object based on id and method name.-Rituparno Ganguly


Name :- SANJAY KUMAR JHA
Assignment name :- Remote Procedure Call (RPC)

// SERVER

import java.io.*;
import java.net.*;

class ClientHandler extends Thread {
protected Socket incoming;

public ClientHandler(Socket incoming) {
this.incoming = incoming;
}
public void run() {
int x,y;
try {
BufferedReader in = new BufferedReader(new InputStreamReader(incoming.getInputStream()));
PrintWriter out=null ;// = new PrintWriter(new OutputStreamWriter(incoming.getOutputStream()));
out=new PrintWriter(incoming.getOutputStream(),true);
String str = in.readLine();
if (str.equals("add"))
{
x=Integer.parseInt(in.readLine());
y=Integer.parseInt(in.readLine());
int z=add(x,y);
out.flush();
out.println(z);
}
else if(str.equals("sub"))
{
x=Integer.parseInt(in.readLine());
y=Integer.parseInt(in.readLine());
int z=sub(x,y);
String s1="" + z;
out.println(s1);
}
incoming.close();
} catch (Exception e) {
System.out.println("Error: " + e);
}
}

public int add(int x1,int y1)
{
return x1+y1;
}
public int sub(int x1,int y1)
{
return x1-y1;
}

}

public class Server {
public static void main(String[] args) {
System.out.println("Server started.");
try {
ServerSocket s = new ServerSocket(9090);
for (;;) {
Socket incoming = s.accept();
new ClientHandler(incoming).start();
}
} catch (Exception e) {
System.out.println("Error: " + e);
}
}
}




// CLIENT



import java.applet.Applet;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import java.net.*;

@SuppressWarnings("serial")
public class Client extends Applet implements ActionListener
{
Button ADD,SUB;
TextField t1,t2,t3;
public void init()
{
ADD=new Button("ADD");
SUB=new Button("SUB");
t1=new TextField(10);
t2=new TextField(10);
t1.setBounds(430,00,70,20);
t2.setBounds(500, 00, 70, 20);
ADD.setBounds(430, 50, 70, 20);
SUB.setBounds(500, 50, 70, 20);
ADD.addActionListener(this);
SUB.addActionListener(this);
t3=new TextField(10);
t3.setBounds(500, 100, 70, 20);
add(t3);
add(t1);
add(t2);
add(ADD);
add(SUB);
}
public void start() {
}
public void actionPerformed(ActionEvent ae)
{
String x1;
String s=ae.getActionCommand();
String p1,p2;
if(s.equals("ADD"))
{
BufferedReader in=null;
PrintWriter out=null;
Socket t=null;
String line1="add";
try {
String host="localhost";
t = new Socket(host, 9090);
in=new BufferedReader(new InputStreamReader(t.getInputStream()));
out=new PrintWriter(t.getOutputStream(),true);
out.println(line1);
p1=t1.getText();
p2=t2.getText();
System.out.println("x= "+p1+ "y= "+p2);
out.println(p1);
out.println(p2);
System.out.println("add1");
x1=in.readLine();
System.out.println("Addition of " + p1 + "and " + p2 + " : " + x1);
t3.setText(x1);
} catch (Exception e) {System.out.println("Error: " + e); }
System.out.println("Addition Performed");
}
else if(s.equals("SUB"))
{
BufferedReader in=null;
PrintWriter out=null;
Socket t=null;
String line1="sub";
try {
String host="localhost";
t = new Socket(host, 9090);
in=new BufferedReader(new InputStreamReader(t.getInputStream()));
out=new PrintWriter(t.getOutputStream(),true);
out.println(line1);
p1=t1.getText();
p2=t2.getText();
out.println(p1);
out.println(p2);
x1=in.readLine();
System.out.println("Subtraction of " + p1 + "and " + p2 + " : " + x1);
t3.setText(x1);
} catch (Exception e) { System.out.println("Error: " + e); }
System.out.println("Subtraction Performed");
}
}
}


// RMI

//SERVER


import java.net.*;
import java.rmi.*;

public class server
{
public static void main(String args[])
{
try
{
serverImpl serverImpl=new serverImpl();
Naming.rebind("Server",serverImpl);

}
catch (Exception ex)
{
System.out.println ("Exception .."+ex);
}
}
}

//SERVERIMPL

import java.rmi.*;
import java.rmi.server.*;
public class serverImpl extends UnicastRemoteObject implements

Serverintf
{

public serverImpl()throws RemoteException
{}
public double add(double d1,double d2)throws RemoteException
{
return d1+d2;
}
public double sub(double d1,double d2)throws RemoteException
{
return d1-d2;
}
public double mm(double d1,double d2)throws RemoteException
{
return d1*d2;
}
public double dd(double d1,double d2)throws RemoteException
{
return d1/d2;
}
}

// SERVER INTF

import java.rmi.*;

public interface Serverintf extends Remote
{
double add(double d1,double d2)throws RemoteException;
double sub(double d1,double d2)throws RemoteException;
double mm(double d1,double d2)throws RemoteException;
double dd(double d1,double d2)throws RemoteException;

}

// CALCULATOR

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.rmi.*;

class calculator extends JFrame implements ActionListener
{
String op,o1,o2;
JButton

b1,b2,b3,b4,b5,b6,b7,b8,b9,b10,b11,b12,b13,b14,b15,b16,b17,b;
JTextField r;
JPanel p;
calculator()
{
p=(JPanel)getContentPane();
r=new JTextField(15);
b1=new JButton("1");
b2=new JButton("2");
b3=new JButton("3");
b4=new JButton("4");
b5=new JButton("5");
b6=new JButton("6");
b7=new JButton("7");
b8=new JButton("8");
b9=new JButton("9");
b10=new JButton("0");

b11=new JButton("+");
b12=new JButton("-");
b13=new JButton("*");
b14=new JButton("/");
b15=new JButton(".");
b16=new JButton("=");
b17=new JButton("Clear");

b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
b4.addActionListener(this);
b5.addActionListener(this);
b6.addActionListener(this);
b7.addActionListener(this);
b8.addActionListener(this);
b9.addActionListener(this);
b10.addActionListener(this);
b11.addActionListener(this);
b12.addActionListener(this);
b13.addActionListener(this);
b14.addActionListener(this);
b15.addActionListener(this);
b16.addActionListener(this);
b17.addActionListener(this);

b1.setActionCommand("1");
b2.setActionCommand("2");
b3.setActionCommand("3");
b4.setActionCommand("4");
b5.setActionCommand("5");
b6.setActionCommand("6");
b7.setActionCommand("7");
b8.setActionCommand("8");
b9.setActionCommand("9");
b10.setActionCommand("0");
b11.setActionCommand("+");
b12.setActionCommand("-");
b13.setActionCommand("*");
b14.setActionCommand("/");
b15.setActionCommand(".");
b16.setActionCommand("=");
b17.setActionCommand("Clear");

p.setLayout(new FlowLayout());
p.add(r);
p.add(b1);
p.add(b2);
p.add(b3);
p.add(b4);
p.add(b5);
p.add(b6);
p.add(b7);
p.add(b8);
p.add(b9);
p.add(b10);
p.add(b11);
p.add(b12);
p.add(b13);
p.add(b14);
p.add(b15);
p.add(b16);
p.add(b17);

addWindowListener(new WEvent());

}
class WEvent extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
dispose();
System.exit(0);
}
}
public void actionPerformed(ActionEvent e)
{
String s,s1;
s=e.getActionCommand();
if (s.equals("="))
{

try
{
String

ServerURL="rmi://127.0.0.1/Server";
// String ServerURL="rmi://192.168.100.10/Server";
Serverintf

serverintf=(Serverintf)Naming.lookup(ServerURL);
o2=r.getText();
double

d1=Double.valueOf(o1).doubleValue();
double

d2=Double.valueOf(o2).doubleValue();

double res=0;

if(op.equals("+"))
{
res=serverintf.add(d1,d2);
}

else if(op.equals("-"))
{
res=serverintf.sub(d1,d2);
}
else if(op.equals("*"))
{
res=serverintf.mm(d1,d2);
}
else if(op.equals("/"))
{
res=serverintf.dd(d1,d2);
}

String result=""+res;
r.setText(result);

}
catch(Exception ee)
{
System.out.println("Exception"+ee);
}
}
else

if(s.equals("+")||s.equals("-")||s.equals("*")||s.equals("/"))
{
op=s;
o1=r.getText();
r.setText("");
}

else if(s.equals("Clear"))
{
op="";
o1="";
o2="";
r.setText("");
}
else
{
s1=r.getText();
r.setText(s1+s);
}
}

public static void main(String args[])
{
calculator c;
c=new calculator();
c.setSize(200,250);
c.setTitle("CALCULATOR");
c.setVisible(true);

}
}

Sunday, September 8, 2013

To convert a FAT partition to NTFS

1) Open 'Command Prompt'.
 

2) At the command prompt, type the following-
CONVERT [driveletter]: /FS:NTFS.
'Convert.exe' will attempt to convert the partition to NTFS.
 

NOTE :- Although the chance of corruption or data loss
during the conversion from FAT to NTFS is minimum, it is
best to perform a full backup of the data on the drive that it
is to be converted prior to executing the convert command.

Which Programming Language Should I Learn For Hacking ?

Every hacking beginner can have plenty of doubts like: 
"Which programming language should I learn for Hacking?", 
"How to become A professional Pen tester / Hacker?" etc, 
so today I will show you a few suggestions on the Programming Languages that you should learn.
 

 I. Why Programming?
The first question, many people will ask, is why
should I learn any programming language when
there are so many tools and Frameworks such as
MSF (Metasploit framework) to do my job. All I
need to know is how the tool works and what is
the purpose of it. The Answer for the question is
both yes and no. You can become a Pentester/
Hacker without knowing any programming, however
you are not going to become a GOOD pentester/Hacker.
 

So Knowing Programming Will:
*Differentiate you from Script Kiddies and Tool Lovers
*Help You in Understanding About Vulnerabilities
*Help You in writing Your own tools, scripts
*Help You in writing exploits, Shell codes etc
*Help You modifying Existing scripts, tools according to your needs
 

II. Which Programming Language should I Learn?
So now that you have understood the importance
of knowing programming, the next question in your
mind is which programming language should I learn
- the answer for this question depends on your
interests and goals.
 

1. For Web App Pentesting /Hacking:
1.1. HTML
Hypertext Markup Language (HTML) is the basics
for creating web pages and other information that
can be displayed in a web browser. So if you don't
know HTML you should first learn it.
1.2. JAVAScript
Learning java script. It will help you to understand the basics of Cross Site Scripting.
1.3. PHP/SQL
Majority of web applications are written using PHP
and MySQL. So it is a must to learn PHP.

For Writing/Understanding Exploits, Shell Codes, Root kits etc:
 

C & C++
More than 60 % of the exploits you will find on the
web are written in C & C ++. Learning C & C++ will
help you to understand about Buffer overflows,
Stack overflow etc - so learning C and C ++ is
must for every hacker/Pen tester.
 

Assembly
Learning assembly will help you in Writing/
understanding Shell codes, it will also help you in
Reverse Engineering applications and software's
3. For Building Tools And Scripts:
 

Python
Python is a very powerful high level language, its
easy to learn and code, most of the tools and
scripts for automation are written in Python.
Knowing Python socket programming will help you
a lot in Exploit writing.
 

 Ruby
Ruby is an another language which is used to write
scripts, tools. Metasploit Framework is written in
Learning ruby will help you understand the in
and outs of msf.
 

Bash
Learning Bash is very useful in writing small scripts
for automation.

Internet/GPRS Balance Check Codes for Airtel, Aircel, Idea, Vodafone, DOCOMO,Virgin,Spice

Balance Codes for Airtel

  • Airtel codes- Checking your Balance at *123#
  • Checking the validity period of your Plan.
  • Check your local Airtel to Airtel talktime balance enter *123*3#
  •  Check GPRS Data Balance *123*10#

Balance Codes for Aircel

  • Aircel Codes – Balance and Validity – *111#
  • Checking GPRS Data Balance – *111*10# 
  • Checking Special Balance – *111*6#
  • Checking your 3G Balance – *111*9#

Other Balance Codes

  • Vodafone -*141# (Earlier *111#). GPRS balance-*225*6#
  • BSNL-*123#  GPRS balance- *112#
  • Videocon- *123#
  • Reliance GSM-*367# or SMS to 53670  GPRS balance- MBAL to 55333
  • Tata Docomo-*111#
  • Idea-*130#,*212#
  • Virgin Mobile-SMS BA To 58576
  • Spice-*456#

Solution to avast black screen problem in windows 8

Open Avast
go to  security >Behavior Shield > Settings. and click on  Trusted Processes

Add the following 2  files by browsing them to this paths
” C:\Windows\explorer.exe ” and
” C:\Windows\ImmersiveControlPanel\SystemSettings.exe “

 IF you have difficulties in browsing those two files then you can copy them and directly past them into the fields.

    C:\Windows\explorer.exe

    C:\Windows\ImmersiveControlPanel\SystemSettings.exe

avast black screen problem in windows 8

this technique should have solved your black screen problem ….. :) :)

 If the information on our website has helped you then pay us with a like in Facebook :)  .

If the above feedback does not work for your computer.You can even follow below procedure and solve your problem with windows 8.
Alternative way !

     Start your computer and log in to your windows 8 OS
    After you login with your password or a direct login with out password as usually you will get a black screen if you have an installed avast anti-virus
    press ctrl+alt+del and choose task manager , you can also do it by pressing  ctrl+shift+Esc .
    Go to startup tab in Task manager and right-click your avast! Antivirus there and choose  Open file location.
    A window will open , click on AvastUI  which will take you to avast user interface .
    Now go to security >Behavior Shield > Settings.
    Uncheck the  ” Monitor the system for unauthorized modifications  ” box .
    You are done now press ctrl+alt+del and sign out and login again. You are with your windows 8 desktop and your windows 8 black screen problem is gone. If you feel this knowledge helped you, you can comment and subscribe for forzeal to get more updates.

If your problem is sill not yet solved after trying the above 2 procedures then you  can comment your experience . I am glad to tell you if there is an alternative to your problem . Mostly your problem will be solved if you correctly follow the above procedures.