elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Recuerda que debes registrarte en el foro para poder participar (preguntar y responder)


+  Foro de elhacker.net
|-+  Programación
| |-+  Ingeniería Inversa (Moderadores: karmany, .:UND3R:., MCKSys Argentina)
| | |-+  JUSB.JAR-JUSB.CLASS
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: JUSB.JAR-JUSB.CLASS  (Leído 3,089 veces)
blanes20

Desconectado Desconectado

Mensajes: 5


Ver Perfil
JUSB.JAR-JUSB.CLASS
« en: 2 Junio 2009, 17:05 pm »

¿Cómo modificarlos para saltar necesidad de dispositivo USB?

Archivo ControlMessage

el class:

package usb.core;

import java.io.IOException;

// Referenced classes of package usb.core:
//            USBException, Device

public final class ControlMessage
{

    public ControlMessage()
    {
    }

    public byte getRequestType()
    {
        return requestType;
    }

    public void setRequestType(byte byte0)
    {
        requestType = byte0;
    }

    public byte getRequest()
    {
        return request;
    }

    public void setRequest(byte byte0)
    {
        request = byte0;
    }

    public short getValue()
    {
        return value;
    }

    public void setValue(short word0)
    {
        value = word0;
    }

    public short getIndex()
    {
        return index;
    }

    public void setIndex(short word0)
    {
        index = word0;
    }

    public void setBuffer(byte abyte0[])
    {
        if(abyte0 == null || abyte0.length >= 65535)
        {
            throw new IllegalArgumentException();
        } else
        {
            buf = abyte0;
            len = (short)abyte0.length;
            return;
        }
    }

    public byte[] getBuffer()
    {
        return buf;
    }

    public void setLength(int i)
    {
        len = (short)i;
    }

    public short getLength()
    {
        return len;
    }

    public static boolean getBit(int i, byte abyte0[], int j)
    {
        byte byte0 = abyte0[j + i / 8];
        byte0 >>= i % 8;
        return (byte0 & 1) != 0;
    }

    public boolean getBit(int i, int j)
    {
        return getBit(i, buf, j);
    }

    public static byte[] getStandardDescriptor(Device device, byte byte0, byte byte1, int i, int j)
        throws IOException
    {
        return getDescriptor(device, (byte)0, byte0, byte1, i, j);
    }

    public static byte[] getClassDescriptor(Device device, byte byte0, byte byte1, int i, int j)
        throws IOException
    {
        return getDescriptor(device, (byte)32, byte0, byte1, i, j);
    }

    public static byte[] getVendorDescriptor(Device device, byte byte0, byte byte1, int i, int j)
        throws IOException
    {
        return getDescriptor(device, (byte)64, byte0, byte1, i, j);
    }

    static byte[] getDescriptor(Device device, byte byte0, byte byte1, byte byte2, int i, int j)
        throws IOException
    {
        byte abyte0[] = new byte[j];
        ControlMessage controlmessage = new ControlMessage();
        ControlMessage _tmp = controlmessage;
        controlmessage.setRequestType((byte)(0xffffff80 | byte0 | 0));
        controlmessage.setRequest((byte)6);
        controlmessage.setValue((short)(byte1 << 8 | 0xff & byte2));
        controlmessage.setIndex((short)i);
        controlmessage.setLength(j);
        device.control(controlmessage);
        return controlmessage.getBuffer();
    }

    public static void setDescriptor(Device device, byte byte0, byte byte1, byte byte2, int i, byte abyte0[])
        throws IOException
    {
        if(i > 65535 || abyte0.length > 65535)
        {
            throw new IllegalArgumentException();
        } else
        {
            ControlMessage controlmessage = new ControlMessage();
            ControlMessage _tmp = controlmessage;
            controlmessage.setRequestType((byte)(0 | byte0 | 0));
            controlmessage.setRequest((byte)7);
            controlmessage.setValue((short)(byte1 << 8 | 0xff & byte2));
            controlmessage.setIndex((short)i);
            controlmessage.setBuffer(abyte0);
            device.control(controlmessage);
            return;
        }
    }

    public static int[] getLanguages(Device device)
        throws IOException
    {
        byte abyte0[] = null;
        try
        {
            abyte0 = getStandardDescriptor(device, (byte)3, (byte)0, 0, 256);
        }
        catch(USBException usbexception)
        {
            if(!usbexception.isStalled())
                throw usbexception;
        }
        if(abyte0 == null || abyte0.length < 4)
            return null;
        int i = 0xff & abyte0[0];
        i >>= 1;
        if(--i <= 0)
            return null;
        int ai[] = new int;
        for(int j = 0; j < i; j++)
        {
            int k = 2 + 2 * j;
            ai[j] = 0xff & abyte0[k];
            ai[j] += (0xff & abyte0[k + 1]) << 8;
        }

        return ai;
    }

    public static String getString(Device device, byte byte0, int i)
        throws IOException
    {
        if(byte0 == 0)
            throw new IllegalArgumentException();
        byte abyte0[] = getStandardDescriptor(device, (byte)3, byte0, i, 256);
        int j;
        if(abyte0.length < 2 || abyte0[1] != 3 || (j = 0xff & abyte0[0]) > abyte0.length || (j -= 2) % 2 != 0)
            return null;
        char ac[] = new char[j >> 1];
        for(int k = 0; k < ac.length; k++)
        {
            int l = 2 * k + 2;
            ac[k] = (char)((abyte0[l + 1] << 8) + (0xff & abyte0[l]));
        }

        return new String(ac);
    }

    public static byte[] getStatus(Device device, int i, int j, int k, int l)
        throws IOException
    {
        ControlMessage controlmessage = new ControlMessage();
        controlmessage.setRequestType((byte)(i | 0xffffff80));
        controlmessage.setRequest((byte)0);
        controlmessage.setValue((short)j);
        controlmessage.setIndex((short)k);
        controlmessage.setLength(l);
        device.control(controlmessage);
        return controlmessage.getBuffer();
    }

    public static void clearFeature(Device device, int i, int j, int k)
        throws IOException
    {
        ControlMessage controlmessage = new ControlMessage();
        controlmessage.setRequestType((byte)(i & 0x7f));
        controlmessage.setRequest((byte)1);
        controlmessage.setValue((short)(j & 0xff));
        controlmessage.setIndex((short)k);
        device.control(controlmessage);
    }

    public static void setFeature(Device device, int i, int j, int k)
        throws IOException
    {
        ControlMessage controlmessage = new ControlMessage();
        controlmessage.setRequestType((byte)(i & 0x7f));
        controlmessage.setRequest((byte)3);
        controlmessage.setValue((short)(j & 0xff));
        controlmessage.setIndex((short)k);
        device.control(controlmessage);
    }

    private byte requestType;
    private byte request;
    private short value;
    private short index;
    private byte buf[];
    private short len;
    public static final byte DIR_TO_HOST = -128;
    public static final byte DIR_TO_DEVICE = 0;
    public static final byte TYPE_STANDARD = 0;
    public static final byte TYPE_CLASS = 32;
    public static final byte TYPE_VENDOR = 64;
    public static final byte RECIPIENT_DEVICE = 0;
    public static final byte RECIPIENT_INTERFACE = 1;
    public static final byte RECIPIENT_ENDPOINT = 2;
    public static final byte RECIPIENT_OTHER = 3;
    public static final byte GET_STATUS = 0;
    public static final byte CLEAR_FEATURE = 1;
    public static final byte SET_FEATURE = 3;
    public static final byte SET_ADDRESS = 5;
    public static final byte GET_DESCRIPTOR = 6;
    public static final byte SET_DESCRIPTOR = 7;
    public static final byte GET_CONFIGURATION = 8;
    public static final byte SET_CONFIGURATION = 9;
    public static final byte GET_INTERFACE = 10;
    public static final byte SET_INTERFACE = 11;
    public static final byte SYNCH_FRAME = 12;


y el jad:

package usb.core;

import java.io.IOException;

// Referenced classes of package usb.core:
//            USBException, Device

public final class ControlMessage
{

    public ControlMessage()
    {
    }

    public byte getRequestType()
    {
        return requestType;
    }

    public void setRequestType(byte byte0)
    {
        requestType = byte0;
    }

    public byte getRequest()
    {
        return request;
    }

    public void setRequest(byte byte0)
    {
        request = byte0;
    }

    public short getValue()
    {
        return value;
    }

    public void setValue(short word0)
    {
        value = word0;
    }

    public short getIndex()
    {
        return index;
    }

    public void setIndex(short word0)
    {
        index = word0;
    }

    public void setBuffer(byte abyte0[])
    {
        if(abyte0 == null || abyte0.length >= 65535)
        {
            throw new IllegalArgumentException();
        } else
        {
            buf = abyte0;
            len = (short)abyte0.length;
            return;
        }
    }

    public byte[] getBuffer()
    {
        return buf;
    }

    public void setLength(int i)
    {
        len = (short)i;
    }

    public short getLength()
    {
        return len;
    }

    public static boolean getBit(int i, byte abyte0[], int j)
    {
        byte byte0 = abyte0[j + i / 8];
        byte0 >>= i % 8;
        return (byte0 & 1) != 0;
    }

    public boolean getBit(int i, int j)
    {
        return getBit(i, buf, j);
    }

    public static byte[] getStandardDescriptor(Device device, byte byte0, byte byte1, int i, int j)
        throws IOException
    {
        return getDescriptor(device, (byte)0, byte0, byte1, i, j);
    }

    public static byte[] getClassDescriptor(Device device, byte byte0, byte byte1, int i, int j)
        throws IOException
    {
        return getDescriptor(device, (byte)32, byte0, byte1, i, j);
    }

    public static byte[] getVendorDescriptor(Device device, byte byte0, byte byte1, int i, int j)
        throws IOException
    {
        return getDescriptor(device, (byte)64, byte0, byte1, i, j);
    }

    static byte[] getDescriptor(Device device, byte byte0, byte byte1, byte byte2, int i, int j)
        throws IOException
    {
        byte abyte0[] = new byte[j];
        ControlMessage controlmessage = new ControlMessage();
        ControlMessage _tmp = controlmessage;
        controlmessage.setRequestType((byte)(0xffffff80 | byte0 | 0));
        controlmessage.setRequest((byte)6);
        controlmessage.setValue((short)(byte1 << 8 | 0xff & byte2));
        controlmessage.setIndex((short)i);
        controlmessage.setLength(j);
        device.control(controlmessage);
        return controlmessage.getBuffer();
    }

    public static void setDescriptor(Device device, byte byte0, byte byte1, byte byte2, int i, byte abyte0[])
        throws IOException
    {
        if(i > 65535 || abyte0.length > 65535)
        {
            throw new IllegalArgumentException();
        } else
        {
            ControlMessage controlmessage = new ControlMessage();
            ControlMessage _tmp = controlmessage;
            controlmessage.setRequestType((byte)(0 | byte0 | 0));
            controlmessage.setRequest((byte)7);
            controlmessage.setValue((short)(byte1 << 8 | 0xff & byte2));
            controlmessage.setIndex((short)i);
            controlmessage.setBuffer(abyte0);
            device.control(controlmessage);
            return;
        }
    }

    public static int[] getLanguages(Device device)
        throws IOException
    {
        byte abyte0[] = null;
        try
        {
            abyte0 = getStandardDescriptor(device, (byte)3, (byte)0, 0, 256);
        }
        catch(USBException usbexception)
        {
            if(!usbexception.isStalled())
                throw usbexception;
        }
        if(abyte0 == null || abyte0.length < 4)
            return null;
        int i = 0xff & abyte0[0];
        i >>= 1;
        if(--i <= 0)
            return null;
        int ai[] = new int;
        for(int j = 0; j < i; j++)
        {
            int k = 2 + 2 * j;
            ai[j] = 0xff & abyte0[k];
            ai[j] += (0xff & abyte0[k + 1]) << 8;
        }

        return ai;
    }

    public static String getString(Device device, byte byte0, int i)
        throws IOException
    {
        if(byte0 == 0)
            throw new IllegalArgumentException();
        byte abyte0[] = getStandardDescriptor(device, (byte)3, byte0, i, 256);
        int j;
        if(abyte0.length < 2 || abyte0[1] != 3 || (j = 0xff & abyte0[0]) > abyte0.length || (j -= 2) % 2 != 0)
            return null;
        char ac[] = new char[j >> 1];
        for(int k = 0; k < ac.length; k++)
        {
            int l = 2 * k + 2;
            ac[k] = (char)((abyte0[l + 1] << 8) + (0xff & abyte0[l]));
        }

        return new String(ac);
    }

    public static byte[] getStatus(Device device, int i, int j, int k, int l)
        throws IOException
    {
        ControlMessage controlmessage = new ControlMessage();
        controlmessage.setRequestType((byte)(i | 0xffffff80));
        controlmessage.setRequest((byte)0);
        controlmessage.setValue((short)j);
        controlmessage.setIndex((short)k);
        controlmessage.setLength(l);
        device.control(controlmessage);
        return controlmessage.getBuffer();
    }

    public static void clearFeature(Device device, int i, int j, int k)
        throws IOException
    {
        ControlMessage controlmessage = new ControlMessage();
        controlmessage.setRequestType((byte)(i & 0x7f));
        controlmessage.setRequest((byte)1);
        controlmessage.setValue((short)(j & 0xff));
        controlmessage.setIndex((short)k);
        device.control(controlmessage);
    }

    public static void setFeature(Device device, int i, int j, int k)
        throws IOException
    {
        ControlMessage controlmessage = new ControlMessage();
        controlmessage.setRequestType((byte)(i & 0x7f));
        controlmessage.setRequest((byte)3);
        controlmessage.setValue((short)(j & 0xff));
        controlmessage.setIndex((short)k);
        device.control(controlmessage);
    }

    private byte requestType;
    private byte request;
    private short value;
    private short index;
    private byte buf[];
    private short len;
    public static final byte DIR_TO_HOST = -128;
    public static final byte DIR_TO_DEVICE = 0;
    public static final byte TYPE_STANDARD = 0;
    public static final byte TYPE_CLASS = 32;
    public static final byte TYPE_VENDOR = 64;
    public static final byte RECIPIENT_DEVICE = 0;
    public static final byte RECIPIENT_INTERFACE = 1;
    public static final byte RECIPIENT_ENDPOINT = 2;
    public static final byte RECIPIENT_OTHER = 3;
    public static final byte GET_STATUS = 0;
    public static final byte CLEAR_FEATURE = 1;
    public static final byte SET_FEATURE = 3;
    public static final byte SET_ADDRESS = 5;
    public static final byte GET_DESCRIPTOR = 6;
    public static final byte SET_DESCRIPTOR = 7;
    public static final byte GET_CONFIGURATION = 8;
    public static final byte SET_CONFIGURATION = 9;
    public static final byte GET_INTERFACE = 10;
    public static final byte SET_INTERFACE = 11;
    public static final byte SYNCH_FRAME = 12;
}
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines