Train

PDA

توجه ! این یک نسخه آرشیو شده میباشد و در این حالت شما عکسی را مشاهده نمیکنید برای مشاهده کامل متن و عکسها بر روی لینک مقابل کلیک کنید : chmod calculator


HashoR
01-29-2011, 12:53 AM
ما را چه به این حرفــــــــــــــــــــــ ا...!

perl chmod.pl rwxr–r-t ( => 1745 )
perl chmod.pl 1744 ( => -rwxr–r-T )


#!perl
#Chmod rights Calc by HashoR | ashiyane.org

%n2t = (0 => “—”, 1 => “–x”, 2 => “-w-”, 3 => “-wx”, 4 => “r–”, 5 => “r-x”, 6 => “rw-”, 7 => “rwx”);
%t2n = (“-” => 0, “x” => 1, “w” => 2, “r” => 4, “s” => 1, “S” => 0, “t” => 1, “T” => 0);
%sgtt2n = (“t” => 1, “T” => 1, “s” => 2, “S” => 2);
%sot2n = (“s” => 4, “S” => 4);
if($ARGV[0] =~ /^([0-7]?)([0-7])([0-7])([0-7])$/)
**
%rights =
(
“own” => $n2t{$2},
“grp” => $n2t{$3},
“oth” => $n2t{$4}
);
if($1 == 1)
**
substr($rights{‘oth’},2) = “T” if $rights{‘oth’} =~ /..\-/;
substr($rights{‘oth’},2) = “t” if $rights{‘oth’} =~ /..x/;
}
elsif($1 == 2)
**
substr($rights{‘grp’},2) = “S” if $rights{‘grp’} =~ /..\-/;
substr($rights{‘grp’},2) = “s” if $rights{‘grp’} =~ /..x/;
}
elsif($1 == 3)
**
substr($rights{‘oth’},2) = “T” if $rights{‘oth’} =~ /..\-/;
substr($rights{‘grp’},2) = “S” if $rights{‘grp’} =~ /..\-/;
substr($rights{‘oth’},2) = “t” if $rights{‘oth’} =~ /..x/;
substr($rights{‘grp’},2) = “s” if $rights{‘grp’} =~ /..x/;
}
elsif($1 == 4)
**
substr($rights{‘own’},2) = “S” if $rights{‘own’} =~ /..\-/;
substr($rights{‘own’},2) = “s” if $rights{‘own’} =~ /..x/;
}
elsif($1 == 5)
**
substr($rights{‘oth’},2) = “T” if $rights{‘oth’} =~ /..\-/;
substr($rights{‘oth’},2) = “t” if $rights{‘oth’} =~ /..x/;
substr($rights{‘own’},2) = “S” if $rights{‘own’} =~ /..\-/;
substr($rights{‘own’},2) = “s” if $rights{‘own’} =~ /..x/;
}
elsif($1 == 6)
**
substr($rights{‘grp’},2) = “S” if $rights{‘grp’} =~ /..\-/;
substr($rights{‘grp’},2) = “s” if $rights{‘grp’} =~ /..x/;
substr($rights{‘own’},2) = “S” if $rights{‘own’} =~ /..\-/;
substr($rights{‘own’},2) = “s” if $rights{‘own’} =~ /..x/;
}
elsif($1 == 7)
**
substr($rights{‘grp’},2) = “S” if $rights{‘grp’} =~ /..\-/;
substr($rights{‘grp’},2) = “s” if $rights{‘grp’} =~ /..x/;
substr($rights{‘own’},2) = “S” if $rights{‘own’} =~ /..\-/;
substr($rights{‘own’},2) = “s” if $rights{‘own’} =~ /..x/;
substr($rights{‘oth’},2) = “T” if $rights{‘oth’} =~ /..\-/;
substr($rights{‘oth’},2) = “t” if $rights{‘oth’} =~ /..x/;
}
#(!!!11)
print “-”,$rights{‘own’},$rights{‘grp’},$rights{ ‘oth’};
}
elsif ($ARGV[0] =~ /^[-dlcbsp]?([-r])([-w])([-xsS])([-r])([-w])([-xsS])([-r])([-w])([-xtT])$/)
**
%rights =
(
“own” => $t2n{$1}+$t2n{$2}+$t2n{$3},
“grp” => $t2n{$4}+$t2n{$5}+$t2n{$6},
“oth” => $t2n{$7}+$t2n{$8}+$t2n{$9}
);

$sbit = $sot2n{$3}+$sgtt2n{$6}+$sgtt2n{$9};

print $sbit,$rights{‘own’},$rights{‘grp’},$right s{‘oth’};
}
else
**
print “Usage:\n$0 1755\t\t->returns ‘-rwxr-xr-t’\n$0 rwxr-xr-t\t->returns ’1755′\n”;
}



منبع: Ashiyane Digital Security Team

تشــــــــــــــــــکر نشانه رضایت است.