Git Product home page Git Product logo

Comments (4)

DrBrad avatar DrBrad commented on August 10, 2024

Hi, I havent implemented a small part. All you would need to do is take the forwarded udp packets and send them to the socks5 server. I believe that the udp packets are already being captured.

I may come back to this project in a month or so and fix the bugs.

from jtun2socks.

trinhthu avatar trinhthu commented on August 10, 2024

Thanks for your answer.
I'm trying to request UDP associate. But when I send VER CMD RSV ATYP DST.ADDR DST.PORT to establish a connection to send UDP packets, Socks server didn't send me a response and then I can't read BND.ADDR and BND.PORT to perform to connect DatagramSocket.
Here is my code:

        `DatagramSocket clientSocket = new DatagramSocket();
        byte[] response = new byte[256];
        InetSocketAddress destination = new InetSocketAddress("1.1.1.1", 1080); //EDIT THIS WITH THE IP AND PORT OF THE PROXY

        Socket socketProxy = new Socket();
        socketProxy.bind(new InetSocketAddress(0));
        service.protect(socketProxy);
        socketProxy.setSoTimeout(5000);
        socketProxy.connect(destination, 5000);

        DataOutputStream writer = new DataOutputStream(new BufferedOutputStream(socketProxy.getOutputStream()));
        DataInputStream reader = new DataInputStream(new BufferedInputStream(socketProxy.getInputStream()));

        // connect/authorization request
        writer.writeByte(0x05); // VER
        writer.writeByte(0x01); // NMETHODS
        writer.writeByte(0x00); // METHODS
        writer.flush();

        // connect/authorization response
        reader.read(response); // RESPONSE IS: 5 0

        // udp associate request
        writer.writeByte(0x05); // VER
        writer.writeByte(0x03); // CMD - UDP ASSOCIATE
        writer.writeByte(0x00); // RSV
        writer.writeByte(0x01); // ATYP
        // is what I'm sending here as DST.ADDR & DST.PORT okay?
        writer.write(clientSocket.getLocalAddress().getAddress()); // DST.ADDR
        writer.writeShort(clientSocket.getLocalPort()); // DST.PORT
        writer.flush();

        // udp associate response
        Log.d(TAG, "udp associate response");
        reader.skipBytes(4); // skip VER, REP, RSV, ATYP bytes
        int relayAddress = reader.readInt();
        InetAddress relayInetAddress = InetAddress.getByAddress(ByteBuffer.allocate(4).putInt(relayAddress).array());
        int relayPort = reader.readUnsignedShort(); // server returns some random port

        // connect to relay server via datagramsocket
        clientSocket.connect(relayInetAddress, relayPort);`

Please help me, I spent a lot of time, but I can't find the cause.

from jtun2socks.

DrBrad avatar DrBrad commented on August 10, 2024

Hey, sorry for the late reply, the last couple months have been busy. Have you resolved this issue?

from jtun2socks.

trinhthu avatar trinhthu commented on August 10, 2024

Hey, sorry for the late reply, the last couple months have been busy. Have you resolved this issue?

Hi, I'm so sorry for the late response. I changed to use another solution for this and don't use your lib.

from jtun2socks.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.