My version of nbtstat, when run on myself, gave me this output:use strict; open IP,"<IP.txt" or die "Couldn't open IP.txt, $!"; while(<IP>) { chomp; # does the while form of <> autochomp? I don't remember =[ my $out = `nbtstat -A $_`; if($out=~/WORKGROUP\s+<(\d+)>/) { my $domain = $1; #do something } }
I have no real idea what those numbers in the pointy brackets are, but I decided to capture them in my regex anyways. My version above just searches through the entire output for anything that matches the regex /WORKGROUP\s+<(\d+)>/ and then sets the $domain variable. However you could also easily do something like for(split/\n/,$out){ #operate on each line }.C:\LiteStep>nbtstat -A 192.168.1.2 Local Area Connection: Node IpAddress: [192.168.1.2] Scope Id: [] NetBIOS Remote Machine Name Table Name Type Status --------------------------------------------- H4X0R-B0X <00> UNIQUE Registered WORKGROUP <00> GROUP Registered H4X0R-B0X <20> UNIQUE Registered MAC Address = 00-02-E3-14-A4-C5
In reply to Re: How can I get which Windows domain an IP belongs to?
by BUU
in thread How can I get which Windows domain an IP belongs to?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |