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???
The first mistake I can see in your code is that you are using
sr()and provide theEtherlayer. You can either usesrp(), or let Scapy deal with theEtherlayer.Also, since you expect only one packet, you can use
sr1()orsrp1()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: