Netbios name query not working

1k views Asked by At

Recently I have started working on my new python project of mine in which I would like to include something that takes an ip address and converts it to a netbios name, So by using scapy I tried executing the following piece of code:

sr(Ether() / IP(flags=0x02, dst = '10.0.0.0') / UDP(sport=RandShort()) / NBNSQueryRequest(NAME_TRN_ID=0x8228, QUESTION_NAME= '*', QUESTION_TYPE='NBSTAT') )

But so far with no success.....

Does anybody have an idea of how to make this work???

1

There are 1 answers

0
Pierre On

The first mistake I can see in your code is that you are using sr() and provide the Ether layer. You can either use srp(), or let Scapy deal with the Ether layer.

Also, since you expect only one packet, you can use sr1() or srp1() that should return the first answer it gets.

And, you are targeting what could be a network IP, not a host IP. Here is something you could try:

sr1(IP(dst='10.0.0.1') /
       UDP(sport=RandShort()) /
       NBNSQueryRequest(NAME_TRN_ID=0x8228, QUESTION_NAME= '*', QUESTION_TYPE='NBSTAT'))