4

Do you know if exists a Java library for LLMNR responder? I looked for jmDns library but it seems designed only for Bonjour services.

If not I may make a UDP responder, but exists a library for parse/write DNS records?

Tobia
  • 9,165
  • 28
  • 114
  • 219

1 Answers1

0

I don't know of a Java LLMNR responder (*), but to your second question for a library to parse/write DNS records, there's dnsjava.

Record[] records = new Lookup("stackoverflow.com", Type.A).run();
for (Record record : records) {
    ARecord a = (ARecord) record;
    System.out.println("Host " + a.getName() + " has address " + a.getAddress().getHostAddress());
}
byte[] ip = {(byte)192, (byte)168, (byte)0, (byte)10};
Name zone = Name.fromString("dyn.test.example.");
Name host = Name.fromString("host", zone);
InetAddress address = InetAddress.getByAddress(ip);
ARecord r = new ARecord(host, DClass.IN, 3600, address);
System.out.println(new sun.misc.HexDumpEncoder().encode(r.toWireCanonical()));

(yes I'm using a Sun-private API to print the hex dump, sue me)

Result:

Host stackoverflow.com. has address 151.101.193.69
Host stackoverflow.com. has address 151.101.129.69
Host stackoverflow.com. has address 151.101.1.69
Host stackoverflow.com. has address 151.101.65.69
0000: 04 68 6F 73 74 03 64 79   6E 04 74 65 73 74 07 65  .host.dyn.test.e
0010: 78 61 6D 70 6C 65 00 00   01 00 01 00 00 0E 10 00  xample..........
0020: 04 C0 A8 00 0A 

(*) or maybe mdnsjava? (which uses dnsjava). Anyway you might want to wait for the bounty to expire before you accept this, in case someone comes up with a complete answer. Also, usually requests for library recommendations are considered off-topic, but this is a rare topic and I find this interesting, I hope this won't be shut down.

Hugues M.
  • 19,846
  • 6
  • 37
  • 65
  • In the meantime I could parse the record, so I get the request from UDP listner but I cannot send the right reply to requester... – Tobia May 14 '17 at 08:30
  • I don't know the LLMNR protocol, but surely it involves writing records as `toWireCanonical` from example above does, so maybe you can check the source code of dnsjava to see how to do that. But if you are stuck in an LLMNR-specific part that won't help :-/ – Hugues M. May 14 '17 at 08:49