Ejemplo n.º 1
0
int getserver(int srvnr, int usernum)
{
   char fnmuser[20];
   char buf[100];
   int ern;
   ap_snprintf(fnmuser,sizeof(fnmuser),lngtxt(373),usernum);
   ap_snprintf(buf,sizeof(buf),lngtxt(374),srvnr);
   ern = getini(lngtxt(375),buf,fnmuser);
   if (ern != 0) { return ern; }
   ap_snprintf(user(usernum)->server,sizeof(user(usernum)->server),"%s",value);
   ap_snprintf(buf,sizeof(buf),lngtxt(376),srvnr);
   ern = getini(lngtxt(377),buf,fnmuser);
   if (ern != 0) { user(usernum)->port = 6667; } else { user(usernum)->port = atoi(value); }
   ap_snprintf(buf,sizeof(buf),lngtxt(378),srvnr);
   ern = getini(lngtxt(379),buf,fnmuser);
   if (ern != 0) { *user(usernum)->spass=0; return 0; }
   ap_snprintf(user(usernum)->spass,sizeof(user(usernum)->spass),"%s",value);
   return 0;
}
Ejemplo n.º 2
0
/* getting the new datas*/
int getthenewpiece()
{
	int sd, i;
	char *xml, query[256], *post, *post2;

	if (firstrun)
	{
		splitserver(gijohnserver, &gijohnport);
		if ((xmlxml.newhashes = malloc(sizeof(char))) == NULL)
		{
			fprintf(stderr, "Malloc error...\n");
			exit(1);
		}
		*xmlxml.newhashes = 0;
		if ((xmlxml.delhashes = malloc(sizeof(char))) == NULL)
		{
			fprintf(stderr, "Malloc error...\n");
			exit(1);
		}
		*xmlxml.newhashes = 0;
		memset(xmlxml.format, '\0', 64);
		memset(xmlxml.keymap.firstword, '\0', 64);
		memset(xmlxml.keymap.lastword, '\0', 64);
		memset(xmlxml.keymap.charset, '\0', 256);
		memset(xmlxml.error, '\0', 1024);
		memset(xmlxml.sessionid, '\0', 33);
	}

	if (getnewsid)
	{		
		getini(username, password);		
		makeformatandperformancexml(&post, username, password);
		if ((post2 = malloc(sizeof(char)*strlen(post)*3+1)) == NULL)
		{
			fprintf(stderr, "Malloc error...\n");
			exit(1);
		}
		urlencode(post, post2);
		free(post);
		post = post2;
		setbuf(stdout, NULL);
		if (options.flags & FLG_VERBOSE) printf("[+] Getting new session\n");

		if (gijohnsmp > 1) {
			for (i = 1; i < gijohnsmp; i++) {
				if (!fork()) {
					sessionname = malloc(sizeof(char)*30);
					memset(sessionname, 0, 30);
					sprintf(sessionname, "gijohnfork_%d", i);
					rec_name = sessionname;
					break;
				}
			}
		}

		sprintf(query, "/newsession.php");

		do
		{
			*xmlxml.error = 0;
			host_entry = getthehostname(gijohnserver);
			if ((sd = getconnection(host_entry, gijohnport)) < 0)
			{
				strncpy(xmlxml.error, "connection error",
				    strlen("connection error"));
				printf("[-] Connection error\n[+]"
				" Sleeping for %dsec... and reconnection\n", SLEEP_TIME);
				sleep(SLEEP_TIME);
			}
			else
			{
				postxml(sd, &xml, query, gijohnserver, gijohnport, post);
				close(sd);
				parsexml(xml);
				free(xml);
				if (*xmlxml.error)
				{
					printf("[-] Error (new sessionid): %s\n[+]"
					" Sleeping for %dsec... and resending\n", xmlxml.error, SLEEP_TIME);
					sleep(SLEEP_TIME);
				}
			}

		}
		while (*xmlxml.error);
		free(post);
		getnewsid = 0;
		if (options.flags & FLG_VERBOSE) printf("[+] New session is: %s\n", xmlxml.sessionid);
	}
	if (xmlxml.upgrade)
	{
		printf("[!] You have to upgrade your gijohn, because it's too old to use! Exiting...\n");
		destroysession();
		exit(1);
	}

	sprintf(query, "/getpieces.php?sessionid=%s", xmlxml.sessionid);
	do
	{
		*xmlxml.error = 0;
		if ((sd = getconnection(host_entry, gijohnport)) < 0)
		{
			strncpy(xmlxml.error, "connection error",
			    strlen("connection error"));
			printf("[-] Connection error\n[+]"
			" Sleeping for %dsec... and reconnection\n", SLEEP_TIME);
			sleep(SLEEP_TIME);
		}
		else
		{
			getxml(sd, &xml, query, gijohnserver, gijohnport, options.flags & FLG_VERBOSE);
			close(sd);
			parsexml(xml);
			free(xml);
			if (*xmlxml.error)
			{
				printf("[-] Error (new keyspace): %s\n[+] "
				"Sleeping for %dsec... and resending\n", xmlxml.error, SLEEP_TIME);
				sleep(SLEEP_TIME);
			}
		}
	}
	while (*xmlxml.error);

	if (firstrun)
	{
		ldr_init_database(&database, &options.loader);
	}

	if (xmlxml.clearhashes)
	{
		memset(&database, '\0', sizeof(struct db_main));
		ldr_init_database(&database, &options.loader);
	}

	if (*xmlxml.error == 0)
	{
		if (*xmlxml.newhashes) ldr_load_xml_array(&database, xmlxml.newhashes, xmlxml.format);
		if (*xmlxml.delhashes) ldr_load_xml_delarray(&database, xmlxml.delhashes);
		if (*xmlxml.newhashes || *xmlxml.delhashes) ldr_fix_xmldatabase(&database, xmlxml.clearhashes | firstrun);
	}
	else
	{
		printf("[-] Error: %s\n", xmlxml.error); exit(1);
	}

	if ((options.flags & FLG_VERBOSE) || firstrun)
	{
		log_event("Remaining %s", john_loaded_counts());
		printf("[+] Loaded %s (%s [%s])\n",	john_loaded_counts(),
		database.format->params.format_name,
		database.format->params.algorithm_name);
	}

	if (firstrun)
	{
		printf("[+] Server: %s\n[+] Charset: %s\n[+] Charset length: %d\n", gijohnserver, xmlxml.keymap.charset, (int)strlen(xmlxml.keymap.charset));
	}

	return 0;
}
Ejemplo n.º 3
0
int
main (int argc, char **argv)
{
  int rc;
  char *pt;
  char *bversion;
  FILE *pidfile,*conffile;
  if(argc==2)
  {
      strmncpy(configfile,argv[1],sizeof(configfile));
  } else {
      strcpy(configfile,"psybnc.conf");  /* rcsid */
  }
  conffile=fopen(configfile,"r");
  if(conffile==NULL)
  {
     printf("Configuration File %s not found, aborting\nRun 'make menuconfig' for creating a configuration or create the file manually.\n",configfile); /* rcsid */
     exit (0x0);
  }
  fclose(conffile);
  readconfig();
  rc = getini("SYSTEM","LANGUAGE",INIFILE);  /* rcsid */
  if(rc!=0)
  {
      rc=loadlanguage("english");  /* rcsid */
  } else {
      rc=loadlanguage(value);  
      if(rc<0)
          rc=loadlanguage("english");  /* rcsid */
  }
  if(rc<0)
  {
      printf("Could not load language file, aborting.\n");  /* rcsid */
      exit(0x0);	  
  }
  printbanner();
  printf(lngtxt(991),configfile);
  printf(lngtxt(992),langname);
  ap_snprintf(logfile,sizeof(logfile),lngtxt(993));
  rc = getini(lngtxt(994),lngtxt(995),INIFILE);
  if (rc != 0) {
     printf("%s", lngtxt(996));
     exit (0x0);
  }
  listenport = atoi(value);
  rc = getini(lngtxt(997),"ME",INIFILE);
  if (rc < 0) {
     memset(value,0x0,sizeof(value));       
  }
  pt=strchr(value,' '); /* shortening bouncername to no spaces */
  if(pt)
      *pt=0;
  ap_snprintf(me,sizeof(me),"%s",value);
  rc = getini(lngtxt(998),lngtxt(999),INIFILE);
  if (rc < 0) {
     printf("%s", lngtxt(1000));
     ap_snprintf(value,sizeof(value),lngtxt(1001));
  }
  ap_snprintf(logfile,sizeof(logfile),"%s",value);
  oldfile(logfile);
  /* creating the socket-root */
  socketnode=(struct socketnodes *) pmalloc(sizeof(struct usernodes));
  socketnode->sock=NULL;
  socketnode->next=NULL;

  #ifdef IPV6
  /* set the default ipv6 preference for users without a PREFERIPV6 setting */
  rc = getini("SYSTEM", "DEFAULTIPV6", INIFILE);
  if (rc == 0)
  {
     defaultipv6 = atoi(value);
  }
  #endif

  /* creating the demon socket */
  rc = createlisteners();
  if (rc == 0) {
    printf("%s", lngtxt(1002));
    exit (0x0);
  }
  /* creating background */
  pidfile = fopen(lngtxt(1003),"w");
  if(pidfile==NULL)
  {
      printf("%s", lngtxt(1004));
      exit(0x0);
  }
  if(mainlog!=NULL)
  {
      fclose(mainlog);
      mainlog=NULL;
  }
  fflush(stdout);
  

  pid = fork();
  //pid = 0;
  if (pid < 0) {
  
  }
  if (pid == 0) {
     rc= errorhandling();
     makesalt();

#ifdef HAVE_SSL
     initSSL();
     pcontext;
#endif
     U_CREATE=0;
#ifdef PARTYCHANNEL
     /* partychannel setup */
     strmncpy(partytopic,lngtxt(1005),sizeof(partytopic));
     partyusers=NULL;
#endif
     /* creating the usernode-root */
     usernode=(struct usernodes *) pmalloc(sizeof(struct usernodes));
     usernode->uid=0;
     usernode->user=NULL;
     usernode->next=NULL;
     /* creating the newpeer-root */
     peernode=(struct peernodes *) pmalloc(sizeof(struct peernodes));
     peernode->uid=0;
     peernode->peer=NULL;
     peernode->next=NULL;
     /* creating the datalink-root */
     linknode=(struct linknodes *) pmalloc(sizeof(struct linknodes));
     linknode->uid=0;
     linknode->link=NULL;
     linknode->next=NULL;
     /* loading the users */
     loadusers();
     loadlinks();
     pcontext;
     /* loading the hostallows */
     hostallows=loadlist(lngtxt(1006),hostallows);
  }
  pcontext;
  if (pid) {
     bversion=buildversion();
     printf(lngtxt(1007),bversion,pid);
     p_log(LOG_INFO,-1,lngtxt(1008),bversion,pid);
     fprintf( pidfile,"%d\n",pid);
     fclose(pidfile);
     exit (0x0);
  }  
  pcontext;
//#ifndef BLOCKDNS
//  if(init_dns_core()==0)
//  {
//     dns_err(0,1);
//  }
//#endif

  p_dns_init();
  bncmain();
  return 0x0;
}