!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/usr/share/webmin/virtual-server/   drwxrwxr-x
Free 25.01 GB of 117.98 GB (21.2%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     list-ports.pl (2.93 KB)      -rwxrwxr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/usr/bin/perl

=head1 list-ports.pl

Lists TCP ports associated with some virtual server

This command lists all TCP ports in use by or allowed to be used by the
virtual server selected with the C<--domain> flag. To output a list of just
port numbers, use the C<--port-only> flag. Or to show the full details of
each port, use C<--multiline>.

=cut

package virtual_server;
if (!$module_name) {
    $main::no_acl_check++;
    $ENV{'WEBMIN_CONFIG'} ||= "/etc/webmin";
    $ENV{'WEBMIN_VAR'} ||= "/var/webmin";
    if ($0 =~ /^(.*)\/[^\/]+$/) {
        chdir($pwd = $1);
        }
    else {
        chop($pwd = `pwd`);
        }
    $0 = "$pwd/list-ports.pl";
    require './virtual-server-lib.pl';
    $< == 0 || die "list-ports.pl must be run as root";
    }

# Parse command-line args
while(@ARGV > 0) {
    local $a = shift(@ARGV);
    if ($a eq "--domain") {
        $domain = shift(@ARGV);
        }
    elsif ($a eq "--multiline") {
        $multi = 1;
        }
    elsif ($a eq "--port-only") {
        $portonly = 1;
        }
    elsif ($a eq "--help") {
        &usage();
        }
    else {
        &usage("Unknown parameter $a");
        }
    }

$domain || &usage("No domain specified");
$d = &get_domain_by("dom", $domain);
$d || usage("Virtual server $domain does not exist");

my @useports = &active_domain_server_ports($d);
my @canports = &allowed_domain_server_ports($d);
my @allports = sort { $a->{'lport'} <=> $b->{'lport'} } (@useports, @canports);

my %done;
if ($multi) {
    # Show full details
    foreach my $p (@allports) {
        next if ($done{$p->{'lport'}}++);
        print $p->{'lport'},"\n";
        my ($use) = grep { $_->{'lport'} eq $p->{'lport'} } @useports;
        my ($can) = grep { $_->{'lport'} eq $p->{'lport'} } @canports;
        print "  In use: ",($use ? "Yes" : "No"),"\n";
        print "  Allowed: ",($can ? "Yes" : "No"),"\n";
        if ($use) {
            print "  Used by PID: ",$use->{'proc'}->{'pid'},"\n";
            print "  Used by command: ",$use->{'proc'}->{'args'},"\n";
            print "  Used by user: ",$use->{'user'}->{'user'},"\n";
            }
        if ($can) {
            print "  Allowed type: ",$can->{'type'},"\n";
            print "  Allowed by: ",$can->{'desc'},"\n";
            }
        }
    }
elsif ($portonly) {
    # Just show port numbers
    foreach my $p (&unique(map { $_->{'lport'} } @allports)) {
        print $p,"\n";
        }
    }
else {
    # Show table of ports
    $fmt = "%-6.6s %-10.10s %-6.6s %-50.50s\n";
    printf $fmt, "Port", "Status", "PID", "Allowed by";
    printf $fmt, ("-" x 6), ("-" x 10), ("-" x 6), ("-" x 50);
    foreach my $p (@allports) {
        next if ($done{$p->{'lport'}}++);
        my ($use) = grep { $_->{'lport'} eq $p->{'lport'} } @useports;
        my ($can) = grep { $_->{'lport'} eq $p->{'lport'} } @canports;
        printf $fmt, $p->{'lport'},
            $use && $can ? "Active" :
            $can ? "Allowed" :
            $use ? "Not allowed" : "",
            $use ? $use->{'proc'}->{'pid'} : "",
            $can ? $can->{'desc'} : "";
        }
    }

sub usage
{
print "$_[0]\n\n" if ($_[0]);
print "Lists TCP ports associated with some virtual server.\n";
print "\n";
print "virtualmin list-ports --domain name\n";
print "                     [--multiline]\n";
print "                     [--port-only]\n";
exit(1);
}


:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0038 ]--