CHips L MINI SHELL

CHips L pro

Current Path : /proc/2/cwd/proc/3/cwd/usr/local/rvglobalsoft/rvsitebuilder7/lib/RVL/
Upload File :
Current File : //proc/2/cwd/proc/3/cwd/usr/local/rvglobalsoft/rvsitebuilder7/lib/RVL/System.pm

#!/usr/bin/perl
package RVL::System;
# WebSite:  http://www.rvglobalsoft.com
# Unauthorized copying is strictly forbidden and may result in severe legal action.
# Copyright (c) 2013 RV Global Soft Co.,Ltd. All rights reserved.
#
# =====YOU MUST KEEP THIS COPYRIGHTS NOTICE INTACT AND CAN NOT BE REMOVE =======
# Copyright (c) 2013 RV Global Soft Co.,Ltd. All rights reserved.
# This Agreement is a legal contract, which specifies the terms of the license
# and warranty limitation between you and RV Global Soft Co.,Ltd. and RV2Factor Product for RV Global Soft.
# You should carefully read the following terms and conditions before
# installing or using this software.  Unless you have a different license
# agreement obtained from RV Global Soft Co.,Ltd., installation or use of this software
# indicates your acceptance of the license and warranty limitation terms
# contained in this Agreement. If you do not agree to the terms of this
# Agreement, promptly delete and destroy all copies of the Software.
#
# =====  Grant of License =======
# The Software may only be installed and used on a single host machine.
#
# =====  Disclaimer of Warranty =======
# THIS SOFTWARE AND ACCOMPANYING DOCUMENTATION ARE PROVIDED "AS IS" AND
# WITHOUT WARRANTIES AS TO PERFORMANCE OF MERCHANTABILITY OR ANY OTHER
# WARRANTIES WHETHER EXPRESSED OR IMPLIED.   BECAUSE OF THE VARIOUS HARDWARE
# AND SOFTWARE ENVIRONMENTS INTO WHICH RV SITE BUILDER MAY BE USED, NO WARRANTY OF
# FITNESS FOR A PARTICULAR PURPOSE IS OFFERED.  THE USER MUST ASSUME THE
# ENTIRE RISK OF USING THIS PROGRAM.  ANY LIABILITY OF RV GLOBAL SOFT CO.,LTD. WILL BE
# LIMITED EXCLUSIVELY TO PRODUCT REPLACEMENT OR REFUND OF PURCHASE PRICE.
# IN NO CASE SHALL RV GLOBAL SOFT CO.,LTD. BE LIABLE FOR ANY INCIDENTAL, SPECIAL OR
# CONSEQUENTIAL DAMAGES OR LOSS, INCLUDING, WITHOUT LIMITATION, LOST PROFITS
# OR THE INABILITY TO USE EQUIPMENT OR ACCESS DATA, WHETHER SUCH DAMAGES ARE
# BASED UPON A BREACH OF EXPRESS OR IMPLIED WARRANTIES, BREACH OF CONTRACT,
# NEGLIGENCE, STRICT TORT, OR ANY OTHER LEGAL THEORY. THIS IS TRUE EVEN IF
# RV GLOBAL SOFT CO.,LTD. IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. IN NO CASE WILL
# RV GLOBAL SOFT CO.,LTD.'S LIABILITY EXCEED THE AMOUNT OF THE LICENSE FEE ACTUALLY PAID
# BY LICENSEE TO RV GLOBAL SOFT CO.,LTD.
# ===============================

use strict;
use warnings;

use File::Path qw(make_path);
use File::Copy;
use File::Basename qw(&basename &dirname);
use Digest::MD5 qw(md5_hex);

use Class::Std::Utils;
{
	sub cp {
		my $source = (defined($_[0]) && $_[0] ne "") ? $_[0] : undef;
		my $dest = (defined($_[1]) && $_[1] ne "") ? $_[1] : undef;
		my $res = 1;
		
		if (defined($source) && defined($dest) && -e $source && $source ne $dest) {
			$res = (copy($source, $dest)) ? 1 : "The existing directory dose not permit to copy file";
		}
		
		return $res;
	}
	
    sub mkdirp {
        my ($dirname) = $_[0];
        my ($mode) = (defined($_[1]) && RVL::String::is_string($_[1]) && $_[1] ne "") ? $_[1] : 0755;
        my ($owner) = (defined($_[2]) && RVL::String::is_string($_[2]) && $_[2] ne "") ? $_[2] : undef;
        my ($group) = (defined($_[3]) && RVL::String::is_string($_[3]) && $_[3] ne "") ? $_[3] : undef;
        my $res = 1;
                                    
                                    
        if (!-d $dirname) {
        	if (defined($owner) && defined($group)) {
        		eval { make_path $dirname, {mode => $mode, owner=> $owner, group=> $group} };
        	} elsif (defined($owner)) {
        		eval { make_path $dirname, {mode => $mode, owner=> $owner} };
        	} elsif (defined($group)) {
                eval { make_path $dirname, {mode => $mode, group=> $group} };
            } else {
            	eval { make_path $dirname, {mode => $mode} };
            }
            
            if ($@) {
                $res = "The existing directory dose not permit to create new directory: $dirname";
            }
        }
        
        return $res; 
    }
    
    sub md5 {
	    my ($data) = $_[0];
	    return md5_hex($data);
	}
	
	sub getUserOwer {
		my $source = shift;
		my $owner = "";
		if (-e $source) {
			my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat($source);
			$owner = getpwuid($uid);
		}
		return $owner;
	}
	
	sub getUserGroup {
        my $source = shift;
        my $group = "";
        if (-e $source) {
            my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat($source);
            $group = getgrgid($gid);
        }
        return $group;
	}
	
	sub getMode {
		my $source = shift;
        my $smode = "";
        if (-e $source) {
        	use Fcntl ':mode';
            my ($dev, $ino, $mode, $nlink, $uid, $gid, $rdev, $size, $atime, $mtime, $ctime, $blksize, $blocks) = stat($source);
            $smode = sprintf "%04o", S_IMODE($mode);
        }
        return $smode;
	}
	
	sub getDiskQuotaPartition {
	   	my $partiition = (defined($_[0]) && $_[0] ne "") ? $_[0] : undef;
	   	my $quota = { block => undef, used  => undef, available => undef };
	   	
	   	if (defined($partiition) && -d $partiition) {
	   		
	   		my $cmd = `df $partiition`;
	   		my @data = split(" ", $cmd);
	   		if (scalar(@data) > 0) {
	   			
	   			if (defined($data[8]) && $data[8] ne "") {
                    $quota->{'block'} = $data[8];
                }
                if (defined($data[9]) && $data[9] ne "") {
                    $quota->{'used'} = $data[9];
                }
	   			if (defined($data[10]) && $data[10] ne "") {
	   				$quota->{'available'} = $data[10];
	   			}
	   			
	   		}
	   		
	   	}
	   	
	   	return $quota;
	}
	
	sub isAlertQuotaPartition {
		my $partiition = (defined($_[0]) && $_[0] ne "") ? $_[0] : undef;
		my $source = (defined($_[1])) ? $_[1] : "";
		my $res = 0;
		
		if (-f $source) {
			my $quota = RVL::System::getDiskQuotaPartition($partiition);
			if (defined($quota->{'available'})) {
				if (RVL::File::filesize($source) > $quota->{'available'}) {
					$res = 1;
				}
			}
		}
		
		return $res;
	}
	
	sub touch {
	    my ($fullFile) = @_;
	    my $path = dirname($fullFile);
	    
	    my $res = 1;
	    if (!-d $path) {
	        $res = RVL::System::mkdirp($path);
	    }
	    
	    if ($res == 1) {
    	    if(!-f $fullFile){
                if (open(my $FILE, '>', $fullFile)) {
                    close($FILE);
                } else {
                    $res = $!." on $fullFile";
                }
            }
	    }
	    
	    return $res;
	}
	
	sub getIPList{
        my ($opt) = $_[0];
        #TODO หา ip list
        if (!defined $opt) {
            return RVL::System::_getMainIPList();
        } elsif ($opt eq 1) {
            #TODO หา all list
            return RVL::System::_getAllIPList();;
        }
    }
    
    sub _getMainIPList{
        my($system, $ethdev,$ips, @IPS);
        $ethdev = '';
        chomp($system = RVL::System::callBackticks("uname -s"));
        if ( -f "/etc/wwwacct.conf") {
            if (open(CONF,"/etc/wwwacct.conf")) {
                while(<CONF>) {
                    s/\n//g;
                    if ($_ !~ /^;/) {
                        if ($_ =~ /ETHDEV/) {
                            (undef,$ethdev) = split(/ /, $_);
                        }
                    }   
                }
                close(CONF);
            }
        }
        
        if ($system =~ /freebsd/i || $ethdev eq "") {
            $ips = RVL::System::callBackticks("/sbin/ifconfig -a");
        } else {
            $ips = RVL::System::callBackticks("/sbin/ifconfig $ethdev");
        }
        @IPS = split(/\n/, $ips);
        foreach my $ip (@IPS) {
            if ($ip =~ /(\d*)\.(\d*)\.(\d*).(\d*)/) {
                if ($1 ne "127") {
                    return "$1.$2.$3.$4";
                }
            }
        }
        return "0.0.0.0";
    }
    
    sub _getAllIPList {
        my $ifconfigs = RVL::System::callBackticks("/sbin/ifconfig -a");
        my @IPS = split(/\n/, $ifconfigs);
        my @allIP = ();
        foreach my $ip (@IPS) {
            if ($ip =~ /(\d*)\.(\d*)\.(\d*).(\d*)/) {
                if ($1 ne "127") {
                    push(@allIP, "$1.$2.$3.$4");
                }
            }
        }
        
        return @allIP;
    }
    
    sub callBackticks{
        my $cmd = join(' ', @_);
    
        if (-f '.rvsBackticks') {
            system('rm -f .rvsBackticks');
        }
        
        my ($TestBackticks) = `echo 'RV Test Backticks'`;
        my ($skipBackticks) = 0;
        if ($TestBackticks !~/RV Test Backticks/) {
            $skipBackticks = 1;
        }
        if (-f '.skipBackticks' || $skipBackticks eq 1) {
            system("$cmd > .rvsBackticks 2>&1");
        }
        my ($resuft);
        if (-f '.rvsBackticks') {
            my ($fd);
            open($fd, '<', '.rvsBackticks');
            $resuft = join('',<$fd>);
            close($fd);
            system('rm -f .rvsBackticks');
        } else {
            $resuft = `$cmd`;
        }
     
        return $resuft;
    }
	
}
1;

=pod

=head1 System

Lib System.

=head1 HOW IT WORKS

=head2 cp()
@param String $source - File name source
@param String $dest - File name destination
@return Boolean
simple:
            my $res = RVL::System::cp("/home/puttipong/public_html/test.html", "/home/puttipong/public_html/test-5.html");

=head2 mkdirp()
@param String $dirname - Directory name source
@param Integer $mode - Mode
@param String $owner - Owner
@param String $group - Group
@return mix TRUE on success or STRING on error
simple: my $res = RVL::System::mkdirp("/var/rvexploitescanner/conf2/test/", 0644, "puttipong", "puttipong");
           
reference: http://search.cpan.org/~dland/File-Path-2.08/Path.pm
          
=head2 md5()
@param String $data - Data
@return String
simple: my $filename = "/home/puttipong/public_html/test.php";
           my $md5 = RVL::System::md5(RVL::File::file_get_contents($filename));
           
=head2 getUserOwer()
@param String $source - File name source
@return String $owner
simple: my $owner = RVL::System::getUserOwer("/home/puttipong/public_html/test.php");

=head2 getUserGroup
@param String $source - File name source
@return String $group
simple: my $group = RVL::System::getUserGroup("/home/puttipong/public_html/test.php");

=head2  getMode
@param String $source - File name source
@return String $smode          
simple: my $smode = RVL::System::getMode("/home/puttipong/public_html/test.php");
          
=head2 getDiskQuotaPartition
@param String $partiition - Patition
@return HASH $quota
simple: my $quota = RVL::System::getDiskQuotaPartition(__CONSTANT__::EXS_PATH);
    
$VAR1 = {
		          'used' => '67581988',
		          'block' => '234443632',
		          'available' => '154952524'
		       };
		       
=head2 isAlertQuotaPartition
@param String $partiition - Patition
@param String $source - Source file name
@return Boolean 
simple: my $res = RVL::System::isAlertQuotaPartition(__CONSTANT__::EXS_PATH, "/home/puttipong/public_html/test.html");		       
          
=cut

Copyright 2K16 - 2K18 Indonesian Hacker Rulez