Advertisement
Guest User

Untitled

a guest
Feb 14th, 2012
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.62 KB | None | 0 0
  1. package test.borrar;
  2.  
  3. import java.io.ObjectInputStream;
  4. import java.io.ObjectOutputStream;
  5.  
  6. import net.denrit.deployer.pentest.application.ApplicationInteraction;
  7. import net.denrit.deployer.pentest.application.msf.MSFClientInteraction;
  8.  
  9. import org.silvertunnel.netlib.api.NetFactory;
  10. import org.silvertunnel.netlib.api.NetLayer;
  11. import org.silvertunnel.netlib.api.NetLayerIDs;
  12. import org.silvertunnel.netlib.api.NetSocket;
  13. import org.silvertunnel.netlib.api.util.TcpipNetAddress;
  14.  
  15. public class ClientSocketTest {
  16.    
  17.     public static void main(String ... s) throws Exception {
  18.         ApplicationInteraction returnApplicationInteraction = null;
  19.         ObjectOutputStream oos = null;
  20.         ObjectInputStream ois = null;
  21.    
  22.         // open a socket connection
  23.         TcpipNetAddress remoteAddress = new TcpipNetAddress("127.0.0.1", 30000);
  24.         NetLayer netLayer = NetFactory.getInstance().getNetLayerById(NetLayerIDs.TCPIP);
  25.         netLayer.waitUntilReady();
  26.     //
  27.     //    // open connection to remote address - this connection is tunneled through the TOR anonymity network
  28.         NetSocket netSocket = netLayer.createNetSocket(null, null, remoteAddress);
  29.        
  30.     //  socket = new Socket(remoteHost, remotePort);
  31.         // open I/O streams for objects
  32.         oos = new ObjectOutputStream(netSocket.getOutputStream());
  33.         ois = new ObjectInputStream(netSocket.getInputStream());
  34.         oos.writeObject(new MSFClientInteraction());
  35.         oos.flush();
  36.         // read an object from the server
  37.         returnApplicationInteraction = (ApplicationInteraction) ois.readObject();
  38.         oos.close();
  39.         ois.close();
  40.         System.out.println("returnApplicationInteraction"+returnApplicationInteraction);
  41.     }  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement