FAQ/dialler.pl

Aus IpcopWiki

< FAQ
Wechseln zu: Navigation, Suche
#!/usr/bin/perl 
$password = "dial_password_here"; 
unless($ARGV[1]) { die "Usage: dialler.pl host action\n\n"; } 
if($ARGV[1] eq "dial") { $action = "Connect"; } 
elsif($ARGV[1] eq "hangup") { $action = "Disconnect"; } 
else { die "Invalid Action... use either dial or hangup\n\n"; } 
$xhost = $ARGV[0]; 
use IO::Socket; 
use MIME::Base64; 
$encoded = encode_base64("dial:$password"); 
chomp($encoded); 
$sock = new IO::Socket::INET ( PeerAddr => $xhost, 
  PeerPort => 81, 
  Proto    => 'tcp' ) || die "Could not connect to host\n\n"; 
$act = "ACTION=".$action; 
$len = length($act); 
print $len; 
print $sock "POST /cgi-bin/dial.cgi HTTP/1.0\n"; 
print $sock "Authorization: Basic $encoded\n"; 
print $sock "Referer: http://$xhost:81/cgi-bin/index.cgi\n"; 
print $sock "Content-Length: $len\n\n"; 
print $sock "ACTION=$action\n\n"; 
undef $/; 
close $sock;
Persönliche Werkzeuge