Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
# 10.10.01 Sweeps a subnet for the status of DHCP and outputs to DHCPs +weep.txt # Usage DHCPsweep.pl [subnet] [outputfile] # eg. DHCPsweep.pl 10.17.117 DHCPsweep81.txt [enter] use strict; use Net::Ping; use Win32::TieRegistry; my (%Hash, @accounts); open OUT, ">$ARGV[1]" or die "can't open outfile\n"; for(10..239){ my $clsid; my $ip="$ARGV[0].$_"; my $p = Net::Ping->new("icmp",2); print OUT "$ip\t"; print "$ip\t"; if ($p->ping("$ip")){ $Registry->Delimiter("/"); my $NT=$Registry->{"//$ip/HKEY_LOCAL_MACHINE/Software/Microsoft/ +Windows NT/CurrentVersion//CurrentVersion"}; my $W95=$Registry->{"//$ip/HKEY_LOCAL_MACHINE/Software/Microsoft +/Windows/CurrentVersion//Version"}; if ($W95){ print "\t$W95\t"; print OUT "\t$W95\t" or die "no print"; }elsif($NT eq '4.0'){ print "\tNT $NT\t"; print OUT "\tNT $NT\t"; my $services=$Registry->{"//$ip/HKEY_LOCAL_MACHINE/System/Cu +rrentControlSet/Services/"}; if ($services){ for (keys %$services){ if ((/CPQANC\d/)||(/AMDPCN\d/)||(/DC21X41/)){ s/\///; $clsid=$_; } } my $dhcp=$Registry->{"//$ip/HKEY_LOCAL_MACHINE/System/Curr +entControlSet/Services/$clsid/parameters/tcpip//enableDHCP"} or print + "Can\'t access DHCPEnabled key"; if ($dhcp eq '0x00000001'){ print "enabled"; print OUT "enabled"; } if ($dhcp eq '0x00000000'){ print "DISABLED"; print OUT "DISABLED"; } }else{ print OUT "Can\'t access Services Key"; print "Can\'t access Services Key"; } }elsif($NT eq '5.0'){ my $machine=$Registry->{"//$ip/HKEY_LOCAL_MACHINE/SYSTEM/Cur +rentControlSet/Control/ComputerName/ComputerName//ComputerName"}; print "$machine\t"; print OUT "$machine\t"; print "NT $NT\t"; print OUT "NT $NT\t"; my $services=$Registry->{"//$ip/HKEY_LOCAL_MACHINE/System/Cu +rrentControlSet/Services/"}; if ($services){ for (keys %$services){ if (/{/){ s/\///; $clsid=$_; } } my $dhcp=$Registry->{"//$ip/HKEY_LOCAL_MACHINE/System/Curr +entControlSet/Services/$clsid/parameters/tcpip//enableDHCP"} or print + "Can\'t access DHCPEnabled key"; if ($dhcp eq '0x00000001'){ print "enabled"; print OUT "enabled"; } if ($dhcp eq '0x00000000'){ print "DISABLED"; print OUT "DISABLED"; } }else{ print OUT "Can\'t access Services Key"; print "Can\'t access Services Key"; } }else{ print OUT "--\tCan\'t access Registry"; print "--\tCan\'t access Registry"; } }else{ print "--\tno ping response"; print OUT "--\tno ping response"; } $p->close(); print "\n"; print OUT "\n" }

In reply to DHCP Sweep by OzzyOsbourne

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-19 10:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found