Linuxhttps.blog.chinaunix.net
viviecho
全部博文(279)
2013年(1)
2012年(39)
2011年(35)
2009年(29)
2008年(131)
2007年(44)
marsgray
abc123zx
lionking
cynthia
格伯纳
Bsolar
浪花小雨
danxingd
shibaola
快乐的小
小石匠_
linxuegu
分类:
2008-04-20 20:20:56
#!/usr/bin/perluse IO::Socket;sub escape { my($toencode) = @_; $toencode=~s/([^a-zA-Z0-9_\-. ])/uc sprintf("%%%02x",ord($1))/eg; $toencode =~ tr/ /+/; # spaces become pluses return $toencode;}if ($#ARGV <= 0) {print STDERR "usage: getright \n\n";print STDERR " : eg. \n";print STDERR ": eg. message.xml\n";exit(0);} else {open(FILE, "<".$ARGV[1]) or die "Cannot open $ARGV[1]: $!";}while ($line=<FILE>){# $line=~s/\n$//; $xml_message .= $line;}close(FILE);#print $xml_message;$xml_message=escape($xml_message);#print $xml_message;if ($ARGV[0] =~ (?:http://)? (.*?) (?:\:([0-9]+))? (/.*)$!x){ ($server,$port,$path) = ($1, $2 || 80, $3); }$socket = IO::Socket::INET->new(PeerAddr => $server,PeerPort => $port,Proto => 'tcp',Type => SOCK_STREAM) or die "Cannot connect: $!";print $socket "GET $path?xml=$xml_message HTTP/1.1\n";print $socket "Host: $server\n\n";while ($data = <$socket>) {# $data=~s/\\//g; print $data;}close($socket);# Example HTTP return header:##HTTP/1.1 200 OK#X-Powered-By: PHP/4.1.2#Connection: close#Transfer-Encoding: chunked#Content-Type: text/html#Date: Fri, 17 Mar 2006 15:44:46 GMT#Server: Apache/1.3.27 (Unix) (Red-Hat/Linux) mod_ssl/2.8.12 OpenSSL/0.9.6b DAV/1.0.3 PHP/4.1.2 mod_perl/1.26#Last-Modified: Fri, 17 Mar 2006 15:44:06 GMT#ETag: "1548-dc-441ad946"#Accept-Ranges: bytes#Content-Length: 220#Connection: close#Content-Type: text/xml# Example Content:#######
上一篇:sysopen
下一篇:port scan(转载IO::Socket::NET应用)
登录 注册