12 our @ISA = qw(LWP::UserAgent);
15 return LWP::UserAgent::new(@_);
18 sub get_basic_credentials {
19 return ("admin", "removed");
26 GetOptions ("read|r" => \$read, "write|w" => \$write);
27 my $target_mask = $ARGV[0] ? $ARGV[0] : 'e%-%sw';
31 my $dbh = nms::db_connect();
32 my $sth = $dbh->prepare("SELECT sysname,ip FROM switches WHERE sysname LIKE ? ORDER BY ip");
33 $sth->execute($target_mask);
35 while (my ($sysname,$ip) = $sth->fetchrow_array) {
39 if ($ip =~ /(\d+\.\d+\.\d*)(\d)\.\d+/) {
43 print "$sysname\t($ip):\tAieeh! IP parsing fuckup!\n";
48 my $url = "http://$ip/Forms/rpip_1";
50 "rpip_RpgDHCP" => "1",
51 "rpip_IptIPAddr" => "$ip",
52 "rpip_IptSubnetMask" => "255.255.255.0",
53 "rpip_IptDefaultGateway" => "$gw",
54 "rpip_IptDNS" => "0.0.0.0",
55 "rpip_IptVID" => "$mgmnt",
56 "rpip_HidBtnNum" => "1"
61 open(NMAP, "nmap -p80 $ip|");
63 if(/^80\/tcp\s+open/) {
68 print "$sysname\t($ip):\tNo reply on port 80\n";
74 print "$sysname\t($ip):\t";
76 my $ua = RequestAgent->new;
77 my $res = $ua->get("http://$ip/rpip.html");
78 if ($res->is_success) {
79 foreach (split("\n", $res->content)) {
80 if (/.*rpip_IptDefaultGateway" .* VALUE="([^"]+)">/) {
81 print "default route $1\n";
85 print $res->status_line, "\n";
91 print "$sysname\t($ip):\t";
93 my $ua = RequestAgent->new;
94 my $res = $ua->post($url, \%shit);
96 print $res->status_line, "\n";