-1

How to track the user browser url by using local vpn in android programmatically? I am using ToyShark local vpn code. By using this library i can capture the user browser action with in socket data worker.

private void writeTCP(Session session) {
    SocketChannel channel = (SocketChannel) session.getChannel();
    String name = PacketUtil.intToIPAddress(session.getDestIp()) + ":" + session.getDestPort() +
            "-" + PacketUtil.intToIPAddress(session.getSourceIp()) + ":" + session.getSourcePort();
    byte[] data = session.getSendingData();

    String s = new String(data);
    System.out.println(TAG+"writeTCP-----> " + s);

    ByteBuffer buffer = ByteBuffer.allocate(data.length);
    buffer.put(data);
    buffer.flip();

    try {
        channel.write(buffer);
        //Log.d(TAG,"finished writing data to: "+name);
    } catch (NotYetConnectedException ex) {
        Log.e(TAG, "failed to write to unconnected socket: " + ex.getMessage());
    } catch (IOException e) {
        Log.e(TAG, "Error writing to server: " + e.getMessage());

        //close connection with vpn client
        byte[] rstData = TCPPacketFactory.createRstData(
                session.getLastIpHeader(), session.getLastTcpHeader(), 0);
        try {
            writer.write(rstData);
            SocketData socketData = SocketData.getInstance();
            socketData.addData(rstData);
        } catch (IOException ex) {
            ex.printStackTrace();
        }
        //remove session
        Log.e(TAG, "failed to write to remote socket, aborting connection");
        session.setAbortingConnection(true);
    }
}

above write TCP method there is line

byte[] data = session.getSendingData();
String url = new String(data); 
System.out.println(TAG+"writeTCP-----> " + url);

by using the above writeTCP log i can track the user url, but the url result will be like

��������������������������www.videocond2h.com��������#����Ǹޮ̷�;�[+敊+�>M�N)Hi���o� S�j�.i��x������g�ν    �ShڄVO쨿k��4X�Oӷ>�-�kt:����|+�K�ƣ&�-b���*״%�o�=Y�O�Λ���.��ĊU���6~�ݓ����6f�xt=*Q�UQ��O}������������������������������h2http/1.1uP������������3��+��)::�������� ��k0b�E�x�Z������-�Q�o!�OT���v��-����+��

how can i get correct full url from below line of code . The url is www.videocond2h.com

 byte[] data = session.getSendingData();

Karthik . N
  • 45
  • 1
  • 6

1 Answers1

0

If you already have local vpn you can obtain info from tcp/udp ByteBuffer

        ByteBuffer packet_buffer = packet.backingBuffer;
        packet_buffer.mark();
        byte[] tmp_bytes = new byte[packet_buffer.remaining()];
        packet_buffer.get(tmp_bytes);
        packet_buffer.reset();
        Message message = new Message(tmp_bytes);
        Name query_domain = message.getQuestion().getName();
        String query_string = query_domain.toString();
Stanislav Bondar
  • 6,056
  • 2
  • 34
  • 46