Greetings all- I'm working on a program that'll grab the http headers from webservers via requesting a nonexistant file. I'm still in the debugging stage in this, and am having a very odd problem.
The code:
#!/usr/bin/perl
use IO::Socket;
#unless (@ARGV) { die "usage: $0 URL\n" }
die "Usage: $0 <subnet class> ip\n" unless(@ARGV==1);
for ($b=0; $b <= 255; $b++) {
for ($c=0; $c <= 255; $c++) {
for ($d=0; $d <= 255; $d++) {
$url = "http://$ARGV[0].$b.$c.$d/oiuert.tct";
#$url = "http://12.101.189.130/p.tttt";
$EOL = "\015\012";
$BLANK = $EOL x 2;
$sep = ($url > 1) ? "-------------------\n" :
+"";
$host = "$ARGV[0].$b.$c.$d";
#$host = "12.101.189.130";
print "\nConnecting to: $host\n";
$remote = IO::Socket::INET->new( Proto =>
+"tcp",
PeerAddr =>
+$host,
PeerPort =>
+"http(80)",
);
if ($remote ==0) {print "Cannot connect to htt
+p daemon on $host\n" } else {
$remote->autoflush(1);
print $remote "GET $url HTTP/1.0" . $BLANK;
while ( <$remote> ) { print }
print "\n$sep";
close $remote;}
}
}
}
The problem is when I statically assign the host and url values, the program runs- and when I leave it as it is, it doesn't run.
Suggestions?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.