import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.util.Random;
import javax.swing.ImageIcon;
import javax.swing.JComponent;
import javax.swing.JFrame;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableCellRenderer;
/**
*
* @author Leyer
*
*/
public class JTableBackground extends JFrame{
private static final long serialVersionUID = -6650115843758904110L;
private static final String pathImage="d:\\12.jpg";
public static final short WINDOW_WIDTH = 930;
public static final short WINDOW_HEIGTH = 420;
protected JTable mainTable =null;
protected TableModel tableModel =null;
public JTableBackground(){
super("Imagen de Fondo JTable");
initComponents();
this.setSize(WINDOW_WIDTH,WINDOW_HEIGTH);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
private class TableModel extends DefaultTableModel{
private static final long serialVersionUID = 1L;
public TableModel(){
addColumn("1");addColumn("2");
addColumn("3");addColumn("4");
for(int index=0;index<20;index++){
Object row[]={
new Random().nextInt(100001),
new Random().nextInt(100001),
new Random().nextInt(100001),
new Random().nextInt(100001)};
addRow(row);
}
}
}
private void initComponents(){
tableModel=new TableModel();
mainTable=new JTable(tableModel){
private static final long serialVersionUID = 1L;
ImageIcon imageBackground = new ImageIcon(pathImage);
@Override
public Component prepareRenderer(TableCellRenderer renderer, int row, int column) {
final Component c = super.prepareRenderer(renderer, row, column);
if (c instanceof JComponent){
((JComponent) c).setOpaque(false);
}
return c;
}
@Override
public void paint(Graphics graphics) {
graphics.drawImage(imageBackground.getImage(), 0, 0,getWidth(),getHeight(),null);
super.paint(graphics);
}
};
mainTable.setFillsViewportHeight(true);
mainTable.setOpaque(false);
mainTable.setForeground(Color.white);
JScrollPane scrollPane= new JScrollPane(mainTable);
getContentPane().add(scrollPane);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new JTableBackground().setVisible(true);
}
});
}
}
Imagen de Fondo JTable
Loguearse en un foro SMF
Librerias necesarias
import java.io.IOException;
import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.PostMethod;
/**
* @author Leyer
*/
public class SMF {
protected HttpClient client = new HttpClient();
public static final String USER ="user";
public static final String PASSWORD="passwrd";
public static final int REDIRECT = HttpStatus.SC_MOVED_TEMPORARILY;
private boolean login = false;
public boolean isLogin(){
return login;
}
/**
* Inicia sesion
*
* @param formAction Accion del formulario
* @param user Nombre de Usuario
* @param password Contrasena
* @param minutes Duracion de la sesion en minutos
*
* @return boolean
*/
public boolean login(String formAction,String user,String password,int minutes){
PostMethod postMethod = new PostMethod(formAction);
if(user!=null&password!=null&&minutes>0){
postMethod.addParameter(USER, user);
postMethod.addParameter(PASSWORD,password);
postMethod.addParameter("cookielength",String.valueOf(minutes));
int statusCode = -1;
try {
statusCode = client.executeMethod( postMethod );
if(statusCode == REDIRECT){
postMethod.releaseConnection();
login = true;
}
} catch (HttpException e) {e.printStackTrace();
} catch (IOException e) {e.printStackTrace();
}
}else{
System.err.println("Datos no validos");
}
return login;
}
public Cookie[] getCookies(){
if(isLogin()){
return client.getState().getCookies();
}else{
System.err.println("No te has logueado");
return null;
}
}
public static void main( String[] args ) {
//<form action="http://foro.elhacker.net/login2.html" method="post"
String formAction = "http://foro.elhacker.net/login2.html";
SMF smf=new SMF();
boolean login=smf.login(formAction,"user", "password",90);
if(login){
System.out.println("Te has logueado correctamente!");
}else{
System.err.println("usuario o contrasena incorrectos");
}
}
}
Realizar una busqueda en Google
Libreria necesarias:
Salida
=====================================================
[ Resultados de la Busqueda ]
Titulo: Python Tutorials – Tutorialized
URL : http://www.tutorialized.com/tutorials/Python/1
Titulo: PyCon 2011: Advanced Python 1 Tutorial « The Mouse Vs. The Python
URL : http://www.blog.pythonlibrary.org/2011/03/09/pycon-2011-advanced-python-1-tutorial/
Titulo: Tutorial Python 1 – Android Market
URL : https://market.android.com/details%3Fid%3Dappinventor.ai_nitronat.tutorial_python_1
Titulo: Python 1: Installation and beginner's tutorial.? – YouTube
URL : http://www.youtube.com/watch%3Fv%3DNlK_f39eXCE
=====================================================
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.util.Iterator;
import java.util.Vector;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
/**
* @author Leyer
*/
public class GoogleSearch{
public static String baseUrl = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=";
private String securityStuff = null;
public static final int DEFAULT_PAGE_NUMBER =1;
private int page = -1;
private Vector<Result> _results =new Vector<GoogleSearch.Result>();
private String key;
public GoogleSearch(String key){
this.key =key;
this.securityStuff="&key="+key+"&start=";
}
class Result {
private String title = null;
private URL url = null;
public Result(String title,URL url){
this.title= title;
this.url=url;
}
public String getTitle() {
return title;
}
public URL getUrl() {
return url;
}
}
public Vector<Result> search(String query,int page){
try {
setPageNumber(page);
_results= search(query);
} catch (IOException e) {
e.printStackTrace();
}
return _results;
}
private int getPageNumber() {
return page;
}
private void setPageNumber(int page) {
this.page = page;
}
public Vector<Result> search(String query) throws IOException{
URLConnection connection = null;
try {
if(page != -1){
this.securityStuff="&key="+key+"&source=uds&filter=0&start="+getPageNumber();
}
else{
this.securityStuff="&key="+key+"&source=uds&filter=0&start="+DEFAULT_PAGE_NUMBER;
}
connection = new URL( baseUrl + URLEncoder.encode(query,"UTF-8") + securityStuff ).openConnection();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
if(connection != null){
String line = null;
StringBuffer response = new StringBuffer();
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
while((line = reader.readLine()) != null)response.append(line);
reader.close();
JSONObject obj = (JSONObject)JSONObject.fromObject(response.toString());
if(obj.get("responseData") instanceof JSONObject){
JSONObject responseData = (JSONObject)obj.get("responseData");
if(responseData!=null){
JSONArray results=(JSONArray)responseData.get("results");
Iterator<?> iterator= results.iterator();
while(iterator.hasNext()){
JSONObject result=(JSONObject)iterator.next();
String title=(String) result.get("titleNoFormatting");
URL url= new URL(result.get("url").toString());
Result r =new Result(title, url);
_results.add(r);
}
}
}else{
System.exit(0);
}
}
return _results;
}
public static void main(String[] args) {
String key = "***********";
String query ="tutorial python";
GoogleSearch googleSearch=new GoogleSearch(key);
try {
Vector<Result> results = googleSearch.search(query);
if(results.size()>0){
Iterator<Result> iterator = results.iterator();
System.out.println("[ Resultados de la Busqueda ]");
System.out.println();
while(iterator.hasNext()){
Result result = iterator.next();
System.out.println("Titulo: "+result.getTitle());
System.out.println("URL : "+result.getUrl());
}
}else{
System.out.println("No hubieron resultados");
}
} catch (Exception e) {
e.printStackTrace();
}
}
Enviar imagen por sockets
Salida
===========================================================
Server started port 8081
Waiting for connections…
New connection /127.0.0.1
Image received!
Server close.
===========================================================
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import javax.imageio.ImageIO;
/**=
* @author leyer
*/
class _Server extends ServerSocket implements Runnable{
public _Server(int port, int backlog, InetAddress bindAddr)throws IOException {
super(port, backlog, bindAddr);
System.out.println("Server started port "+port);
}
public void start(){
new Thread(this).start();
}
@Override
public void run() {
System.out.println("Waiting for connections...");
try {
Socket socket=accept();
System.out.println("New connection "+socket.getInetAddress());
BufferedImage bufferedImage = ImageIO.read(socket.getInputStream());
ImageIO.write(bufferedImage,"png", new FileOutputStream("/home/leyer/image.png"));
System.out.println("Image received!");
socket.close();
close();
System.out.println("Server close.");
} catch (IOException e) {
e.printStackTrace();
}
}
}
public class Transfer {
public static void main(String args[]){
try {
new _Server(8081, 1, InetAddress.getByName("127.0.0.1")).start();
Socket socket=new Socket( InetAddress.getByName("127.0.0.1"),8081);
BufferedImage bufferedImage = ImageIO.read(new File("/home/leyer/lsm.png"));
ImageIO.write(bufferedImage, "png", socket.getOutputStream());
socket.getOutputStream().flush();
}catch (Exception e) {
e.printStackTrace();
}
}
}
Subir un archivo a un servidor FTP usando sockets
Salida
=====================================================================
220———- Welcome to Pure-FTPd [privsep] [TLS] ———-
220-You are user number 62 of 500 allowed.
220-Local time is now 00:29. Server port: 21.
220-This is a private system – No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 2 minutes of inactivity.
331 User **** OK. Password required
230-User **** has group access to: vhosts
230-OK. Current restricted directory is /
230 7846 Kbytes used (0%) – authorized: 6144000 Kb
250 OK. Current directory is /test
200 TYPE is now ASCII
227 Entering Passive Mode (67,220,217,230,134,37)
150 Accepted data connection
uploading file…
File sucessfully transferred!
=====================================================================
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.net.MalformedURLException;
import java.net.Socket;
import java.util.StringTokenizer;
/**
*@author Leyer
*/
public class ftp {
/**
* Sube un archivo a un servidor FTP
*
* @param ftpServer Servidor FTP
* @param user Usuario
* @param password Contraseña
* @param location Directorio donde se subira el archivo
* @param file Archivo que se va a subir
* @param debug Para Mostrar las respuestas del servidor
*
*/
public static void uploadFileToFTP(String ftpServer,String user,String password,String location,File file, boolean debug ){
try {
if(file.exists()){
Socket socket=new Socket(ftpServer,21);
BufferedWriter bufferedWriter=new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
BufferedReader bufferedReader=new BufferedReader(new InputStreamReader(socket.getInputStream()));
bufferedWriter.write("USER "+user+"\r\n");
bufferedWriter.flush();
bufferedWriter.write("PASS "+password+"\r\n");
bufferedWriter.flush();
bufferedWriter.write("CWD "+location+"\r\n");
bufferedWriter.flush();
bufferedWriter.write("TYPE A\r\n");
bufferedWriter.flush();
bufferedWriter.write("PASV\r\n");
bufferedWriter.flush();
String response=null;
while((response=bufferedReader.readLine())!=null){
if(debug)
System.out.println(response);
if(response.startsWith("530")){
System.err.println("Login aunthentication failed");
break;
}
if(response.startsWith("227")){
String address = null;
int port = -1;
int opening = response.indexOf('(');
int closing = response.indexOf(')', opening + 1);
if (closing > 0) {
String dataLink = response.substring(opening + 1, closing);
StringTokenizer tokenizer = new StringTokenizer(dataLink, ",");
try {
address = tokenizer.nextToken() + "." + tokenizer.nextToken() + "." + tokenizer.nextToken() + "." + tokenizer.nextToken();
port = Integer.parseInt(tokenizer.nextToken()) * 256 + Integer.parseInt(tokenizer.nextToken());
}
catch (Exception e) {
e.printStackTrace();
}
try{
Socket transfer =new Socket(address,port);
bufferedWriter.write("STOR "+file.getName()+"\r\n");
bufferedWriter.flush();
response=bufferedReader.readLine();
if(debug)
System.out.println(response);
if(response.startsWith("150")){
FileInputStream fileInputStream=new FileInputStream(file);
final int BUFFER_SIZE=1024;
byte buffer[]=new byte[BUFFER_SIZE];
int len=0,off=0;
if(debug)
System.out.println("uploading file...");
while((len=fileInputStream.read(buffer))!=-1)
transfer.getOutputStream().write(buffer, off, len);
transfer.getOutputStream().flush();
transfer.close();
bufferedWriter.write("QUIT\r\n");
bufferedWriter.flush();
bufferedReader.close();
socket.close();
System.out.println("File sucessfully transferred!");
break;
}
}catch (Exception e) {
System.err.println(e);
}
}
}
}
}else{
System.err.println(file+"no exist!");
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
public static void main(String[] args) {
uploadFileToFTP("***.net","*******","*******","/test", new File("c:\\readme.txt"),true);
}
}
Troyano Java ARLeyer RAT
Mi mas reciente proyecto ARLeyer RAT se trada de un troyano en java, me falta poco para terminarlo
[ VERSION 1.0 ]
Funciones Actuales
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Tipo de Conexion TCP
Conexion Directa
Conexion Inversa
El Cliente genera el servidor
Permite abrir N cantidad de puertos
Captura de Pantalla + captura por tiempo
Lectura texto y archivos copiados
Informacion del Sistema, para optener informacion adicional requiere usar usar el plugin AD1Info.jar
Subir Archivos
Descargar Archivos se puede pausar cancelar y reanudar descargas
Lista de Procesos
Envios de Mensajes Planos
Patalla Remota
Chat
Consola Remota
Keylogger
Captura de Sonido
Lectura y Escritura en el Registro requiere plugin AD1Registry.jar
Explorador de Archivos {Abrir,
Informacion del Archivo,
Renombrar,
Extraccion de archivos jar y zip,
Eliminar archivos y carpetas,
Buscar Archivos,
Cambiar atributos,
Crear carpetas,
Mover}
Otras Funciones
-Apagar, reiniciar y cerrar sesion
-Escribir
-Descontrolar el raton
-Visitar una pagina web
-Precionar Teclas especificas
-Reproducir sonidos
-Monitoriar la modificacion de un archivo
-Precioanar Teclas especificas y realizar combinadiones de teclas
-Compilador Interno
-Ejecuar funciones de una DLL
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Link En JLabel
import java.awt.Cursor;
import java.awt.Desktop;
import java.awt.FlowLayout;
import java.awt.Desktop.Action;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.SwingUtilities;
/**
* @author Leyer
*/
public class _Main extends JDialog{
private static final long serialVersionUID = 1L;
private JLabel label;
public _Main(){
this.setTitle("Link on Jlabel");
this.setDefaultCloseOperation(DISPOSE_ON_CLOSE);
this.setSize(200,100);
this.setLayout(new FlowLayout(FlowLayout.CENTER));
label=new JLabel("");
addLinkToJLabel(label, "www.google.com");
add(label);
}
public void addLinkToJLabel(final JLabel label,final String url){
label.setText("<html><a href=>http//"+url+"</html>");
label.addMouseListener(new MouseListener() {
@Override public void mouseReleased(MouseEvent arg0) {}
@Override public void mousePressed(MouseEvent arg0) {}
@Override
public void mouseExited(MouseEvent arg0) {
label.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
@Override
public void mouseEntered(MouseEvent arg0) {
label.setCursor(new Cursor(Cursor.HAND_CURSOR));
}
@Override
public void mouseClicked(MouseEvent arg0) {
try {
if(Desktop.getDesktop().isSupported(Action.BROWSE)){
label.setCursor(new Cursor(Cursor.WAIT_CURSOR));
Desktop.getDesktop().browse(new URI(url));
label.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
}
else
System.err.println("Not supported!");
} catch (IOException e1) {e1.printStackTrace();
} catch (URISyntaxException e1) {System.err.println("URI Syntax error!");
}
}
});
}
public static void main(String[] argv) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
new _Main().setVisible(true);
}
});
}
}
Funcion Recursiva para Eliminar una Llave en el Registro de Windows (WinRegistry)
public void delKey(Key root,Key a,Key b){
try {
List listKeys = registry.listKeys(a);
String subKey="";
Key newKey=null;
Iterator iterator=null;
try{
iterator = listKeys.iterator();
while(iterator.hasNext()){
newKey = registry.openKey(a, iterator.next());
if(root == Regor.HKEY_LOCAL_MACHINE)subKey=newKey.getPath().substring(19);
subKey=newKey.getPath().substring(18);
registry.listKeys(newKey).size();
delKey(root,newKey,b);
}
delKey(root,a,b);
}catch (Exception exception) {
boolean deleted=false;
try{
registry.delKey(root,subKey);
deleted=true;
}catch (Exception ex) {
deleted=false;
return;
}
if(!deleted){
newKey = registry.openKey(a, iterator.next());
delKey(root,newKey,b);
}else{
delKey(root,a,b);
}
}
} catch (RegistryErrorException e) {
e.printStackTrace();
}
}
Imagen en Filas del JTable
This slideshow requires JavaScript.
http://jleyer.files.wordpress.com/2011/07/d1.jpg
[img]
import javax.swing.JFrame; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.SwingUtilities; import javax.swing.table.DefaultTableCellRenderer; import javax.swing.table.DefaultTableModel; public class CellRendererImagen extends DefaultTableCellRenderer { private static final long serialVersionUID = 1L; static class TableModel extends DefaultTableModel{ private static final long serialVersionUID = 1L; public TableModel(){ addColumn("Imagen"); addColumn("A"); addColumn("B"); addColumn("C"); } } public CellRendererImagen() { super(); } public void setValue(Object value) { if (value == null) setText(""); else{ if(value.toString().equals("OK")){ setIcon(Icons.ICON_ACCEPT);//modf }else{ setIcon(Icons.ICON_CANCEL);//modf } } } static class Frame extends JFrame{ private static final long serialVersionUID = 1L; public Frame(){ TableModel tableModel = new TableModel(); JTable table = new JTable(tableModel); table.getColumnModel().getColumn(0).setCellRenderer(new CellRendererImagen()); JScrollPane scrollPane=new JScrollPane(table); getContentPane().add(scrollPane); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setSize(500,200); tableModel.addRow(new Object[]{"OK","A","B","C"}); tableModel.addRow(new Object[]{"OK","A","B","C"}); tableModel.addRow(new Object[]{"OK","A","B","C"}); tableModel.addRow(new Object[]{"OK","A","B","C"}); tableModel.addRow(new Object[]{"FAIL","A","B","C"}); tableModel.addRow(new Object[]{"FAIL","A","B","C"}); } public static void main(String args[]){ SwingUtilities.invokeLater(new Runnable() { @Override public void run() { new Frame().setVisible(true); } }); } } }








