kfor
19.02.2010, 10:49
Народ подскажите как бы мне выполнить команду. Короче уязвимость позволяет выполнять команды в скрипте на перле вот так |ls|. Но использовать в открытом виде ../../../ не получается.
Честно уже как тока не пробовал ничего не получается.
Вот куски из этого скрипта.
#!/usr/bin/perl
# go.pl
BEGIN {
push(@INC,'.');
}
$| = 1;
$datapath = "../../../data/";
$pathname = "../(папка)/";
$pageserver = "http://(тут линк на сайт)";
$baseurl = "http://(тут линк на сайт)/(папка)/";
$domain = "линк";
$path = "/";
########## Print the content header
select(STDOUT);
print "Content-type: text/html\n\n";
########## Read input and assign variables
&ReadParse(*input);
@customerinfo = split('~', get_cookie('customerinfo'));
$loginid = $customerinfo[0];
$customername = $customerinfo[1];
$discount = $customerinfo[2];
######### Get File Name
$filename="";
$pagename=$input{'page'};
$i=length($pagename);
while ($i >= 0)
{
if (substr($pagename, $i, 1) eq '/')
{
$i=-1;
}
else
{
$filename = substr($pagename, $i, 1).$filename;
}
$i--;
}
select(STDOUT);
PrintPage();
exit 0;
sub PrintPage() {
########## Print customer information
open(DATA, $pathname.$filename) || print "Can't open page :".$pathname.$filename."\n\n";
@lines = <DATA>;
foreach $line (@lines)
{
$line =~ s/href="$baseurl/href="$pageserver?page=$baseurl/g;
$line =~ s///g;
$line =~ s///g;
$line =~ s//$customername/g;
if ($line =~ /0.00 {
@s = split(/0.00 $beforestring = $s[0];
$price = $s[1];
$afterstring = $s[2];
$price = sprintf('%1.2f', ($price * (100-$discount))/100);
$line = $beforestring.$price.$afterstring;
}
select(STDOUT);
print $line;
}
close(DATA);
}
sub ReadParse {
local (*in) = @_ if @_;
local ($i, $key, $val);
# Read in text
$in = $ENV{'QUERY_STRING'};
@in = split(/[?&;]/,$in);
foreach $i (0 .. $#in) {
# Convert plus's to spaces
$in[$i] =~ s/\+/ /g;
# Split into key and value.
($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
# Convert %XX from hex numbers to alphanumeric
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$infields = $infields."<input type=hidden name='".$key."' value='".$val."'>\n";
# Associate key and value
$in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator
$in{$key} .= $val;
}
return scalar(@in);
}
Честно уже как тока не пробовал ничего не получается.
Вот куски из этого скрипта.
#!/usr/bin/perl
# go.pl
BEGIN {
push(@INC,'.');
}
$| = 1;
$datapath = "../../../data/";
$pathname = "../(папка)/";
$pageserver = "http://(тут линк на сайт)";
$baseurl = "http://(тут линк на сайт)/(папка)/";
$domain = "линк";
$path = "/";
########## Print the content header
select(STDOUT);
print "Content-type: text/html\n\n";
########## Read input and assign variables
&ReadParse(*input);
@customerinfo = split('~', get_cookie('customerinfo'));
$loginid = $customerinfo[0];
$customername = $customerinfo[1];
$discount = $customerinfo[2];
######### Get File Name
$filename="";
$pagename=$input{'page'};
$i=length($pagename);
while ($i >= 0)
{
if (substr($pagename, $i, 1) eq '/')
{
$i=-1;
}
else
{
$filename = substr($pagename, $i, 1).$filename;
}
$i--;
}
select(STDOUT);
PrintPage();
exit 0;
sub PrintPage() {
########## Print customer information
open(DATA, $pathname.$filename) || print "Can't open page :".$pathname.$filename."\n\n";
@lines = <DATA>;
foreach $line (@lines)
{
$line =~ s/href="$baseurl/href="$pageserver?page=$baseurl/g;
$line =~ s///g;
$line =~ s///g;
$line =~ s//$customername/g;
if ($line =~ /0.00 {
@s = split(/0.00 $beforestring = $s[0];
$price = $s[1];
$afterstring = $s[2];
$price = sprintf('%1.2f', ($price * (100-$discount))/100);
$line = $beforestring.$price.$afterstring;
}
select(STDOUT);
print $line;
}
close(DATA);
}
sub ReadParse {
local (*in) = @_ if @_;
local ($i, $key, $val);
# Read in text
$in = $ENV{'QUERY_STRING'};
@in = split(/[?&;]/,$in);
foreach $i (0 .. $#in) {
# Convert plus's to spaces
$in[$i] =~ s/\+/ /g;
# Split into key and value.
($key, $val) = split(/=/,$in[$i],2); # splits on the first =.
# Convert %XX from hex numbers to alphanumeric
$key =~ s/%(..)/pack("c",hex($1))/ge;
$val =~ s/%(..)/pack("c",hex($1))/ge;
$infields = $infields."<input type=hidden name='".$key."' value='".$val."'>\n";
# Associate key and value
$in{$key} .= "\0" if (defined($in{$key})); # \0 is the multiple separator
$in{$key} .= $val;
}
return scalar(@in);
}