Exemplo n.º 1
0
bool OutPacket::fill(unsigned char *buf, int *len) 
{
	int headerLen = 0, bodyLen=0, encryptedLen = 0;
	unsigned char *bodyBuf;
	unsigned char *encrypted;
	bodyBuf   = (unsigned char *)malloc(MAX_PACKET_SIZE* sizeof(unsigned char));
	encrypted = (unsigned char *)malloc(MAX_PACKET_SIZE * sizeof(unsigned char));
	
	headerLen = putHead(buf);	
	bodyLen   = putBody(bodyBuf);
	encryptedLen = bodyLen;
	encryptBody(bodyBuf, bodyLen, encrypted, &encryptedLen);
	
	memcpy(buf+headerLen, encrypted, encryptedLen);
	
	buf[ headerLen + encryptedLen ] = QQ_PACKET_TAIL;
	(*len) = headerLen + encryptedLen + 1;
	
	if(!isUDP()) { 
		short tmp2 = htons(*len);
		memcpy(buf, &tmp2, 2);
	}
	free(bodyBuf);
	free(encrypted);
	return true;
}
Exemplo n.º 2
0
int main()
{
  char *query,*pptr;
  char ftphost[MAX],email[MAX],dnsname[MAX],ipstring[20],genbuf[MAX];
  unsigned char addr[4];
  int ret=0,ipclass=0,inlib=0;

  alarm(CGIALARM);
  query=getenv(QUERYSTRING);
  putHead();
  strcpy(ftphost,"");
  if(query && *query ){
      while(query && *query){
        if(!strncmp(query,"ftp=",4)) {
          query+=4;
          if((pptr=strchr(query,'&'))!=NULL) *pptr='\0'; /* set the NULL at end of string */
          strncpy(ftphost,query,MAX-1);
	*(ftphost+MAX-1)='\0';
        } else if(!strncmp(query,"email=",6)) {
          query+=6;
          if((pptr=strchr(query,'&'))!=NULL) *pptr='\0'; /* set the NULL at end of string */
          strncpy(email,query,MAX-1);
	*(email+MAX-1)='\0';
        }
        query=strchr(query,'&');
        if(query) query++;
      }
    if(strlen(ftphost)){
     ret=getftpname(ftphost,dnsname,addr);
     if(ret>-2){
      sprintf(ipstring,"%d.%d.%d.%d",addr[0],addr[1],addr[2],addr[3]); 
      ipclass=getclass(addr);
      if(ipclass<=2){ /* free IP, can search */
        inlib=addftp(ipstring);
      }
      if(ret<3)/* fail on getting DNS name */
        strcpy(dnsname,ftphost);
    }else{
      ipclass=4; /* out of CERNET */
      strcpy(dnsname,ftphost);
    }
    showthank(dnsname,ipstring,ipclass,inlib);
   }
  }
  putPage();
  putEnd();
  /* log submit */
  sprintf(genbuf,"E-Mail:%s, Submit:'%s',dns:%s,ip:%s,class:%d",email,ftphost,dnsname,ipstring,ipclass);
  Log(SUBMITLOGFILE,genbuf);
  return(0);
}