Example #1
0
static  void    do_who(struct Client *sptr,
                       struct Client *acptr,
                       struct Channel *repchan,
                       Link *lp)
{
  char  status[5];
  /* Using a pointer will compile faster than an index */
  char *p = status;

  if (acptr->user->away)
    *p++ = 'G';
  else
    *p++ = 'H';
  if (HasUmode(acptr,UMODE_OPER) 
      && SeesOpers(sptr)
     )
    *p++ = '*';
  if ((repchan != NULL) && (lp == NULL))
    lp = find_user_link(repchan->members, acptr);
  if (lp != NULL)
    {
#ifdef HIDE_OPS
      if(is_chan_op(sptr,repchan))
#endif
	{
	  if (lp->flags & CHFL_CHANOP)
	    *p++ = '@';
	  else if (lp->flags & CHFL_VOICE)
	    *p++ = '+';
	}
    }
  *p = '\0';
  sendto_one(sptr, form_str(RPL_WHOREPLY), me.name, sptr->name,
             (repchan) ? (repchan->chname) : "*",
             acptr->username,
             acptr->host,
#ifdef SERVERHIDE
             HasUmode(sptr,UMODE_AUSPEX) ? acptr->user->server : NETWORK_NAME,
#else
             acptr->user->server,
#endif
             acptr->name,
             status,
             HasUmode(sptr,UMODE_SEEROUTING) ? acptr->hopcount : 0,
             acptr->info);
}
Example #2
0
/*
 * ms_svshost - SVSHOST command handler
 *      parv[0] = sender prefix
 *      parv[1] = remote server
 *      parv[2] = client nick
 *      parv[3] = vhost to spoof
 */
static void ms_svshost(struct Client* client_p, struct Client* source_p,
                      int parc, char* parv[])
{
  char *flag;
  struct Client *victim;
  struct Channel *chptr, *top_chptr, *banchans[100];
  static char comment[] = "Spoofing with vhost...";
  static char urbanned[] = "You are banned";
  char modebuf[MODEBUFLEN], parabuf[MODEBUFLEN];
  int hide_or_not;
  dlink_node *ptr;
  int i, num = 0;
  
  if (ServerInfo.gateway && get_bridge_token(client_p))
  	return;

  if (hunt_server(client_p, source_p, ":%s SVSHOST %s %s :%s", 
		  1, parc, parv) != HUNTED_ISME)
    return;

  if (!find_z_conf(parv[0]))
    return;
    
  victim = find_client(parv[2]);
  if (victim && !IsServer(victim) && MyConnect(victim))
  {
  	extern int introduce_client(struct Client *, struct Client *,
  		struct User *, char *);
  
  	sendto_server(NULL, victim, NULL, NOCAPS, NOCAPS,
		NOFLAGS, ":%s QUIT :%s", victim->name, comment);

/*	sendto_common_channels_local(victim, ":%s!%s@%s QUIT :%s",
		victim->name, victim->username, victim->host, comment);*/
		
/*	++current_serial;	not needed i suppose */

	if (victim->user->channel.head)
	for (ptr = victim->user->channel.head; ptr; ptr = ptr->next) {
		chptr = (struct Channel *)ptr->data;
		
		sendto_channel_local_butone(victim, ALL_MEMBERS, 
			chptr, ":%s!%s@%s QUIT :%s",
			victim->name, victim->username,
			victim->host, comment);
	}
	
	strncpy(victim->host, parv[3], HOSTLEN)[HOSTLEN] = 0;
	
	sendto_one(victim, ":%s NOTICE %s :*** Notice -- Spoofing your host as %s",
		me.name, victim->name, victim->host);
	
	if (victim->user->channel.head)
	for (ptr = victim->user->channel.head; ptr; ptr = ptr->next) {
		chptr = (struct Channel *)ptr->data;
		
#ifdef VCHANS
		top_chptr = RootChan(chptr);
#else
		top_chptr = chptr;
#endif		
		if (is_banned(chptr, victim) & (CHFL_BAN|CHFL_DENY)) {
			sendto_one(victim, ":%s KICK %s %s :%s",
				me.name, top_chptr->chname, victim->name,
				urbanned);
			
			/*remove_user_from_channel(chptr, victim);*/
			banchans[num++] = chptr;
			continue;
		}
		
		if (is_chan_op(chptr, victim)) 
			flag = "+o";
#ifdef HALFOPS			
		else if (is_half_op(chptr, victim)) 
			flag = "+h";
#endif			
		else if (is_voiced(chptr, victim))
			flag = "+v";
		else flag = "";
#ifdef REQUIRE_OANDV
		if (find_user_link(&chptr->chanops_voiced, victim))
			flag = "+ov";
#endif
		sendto_channel_local_butone(victim, ALL_MEMBERS, 
			chptr, ":%s!%s@%s JOIN :%s",
			victim->name, victim->username,
			victim->host, top_chptr->chname);
			
#ifdef ANONOPS
		if (chptr->mode.mode & MODE_HIDEOPS)
			hide_or_not = ONLY_CHANOPS_HALFOPS;
		else
#endif
			hide_or_not = ALL_MEMBERS;
			
		if (flag[0])
		sendto_channel_local_butone(victim, hide_or_not,
			chptr, ":%s MODE %s %s %s %s",
			me.name, top_chptr->chname, flag,
			victim->name, flag[2]? victim->name : "");		
	}
	
	for (i=0; i < num; i++)
		remove_user_from_channel(banchans[i], victim);
	
	introduce_client(NULL, victim, victim->user, victim->name);
	
	victim->lazyLinkClientExists = 0;	/* force introducing to LL servers below... */
	
	if (victim->user->channel.head)
	for (ptr = victim->user->channel.head; ptr; ptr = ptr->next) {
		chptr = (struct Channel *)ptr->data;
		
		if (is_chan_op(chptr, victim)) 
			flag = "@";
#ifdef HALFOPS			
		else if (is_half_op(chptr, victim)) 
			flag = "%";
#endif			
		else if (is_voiced(chptr, victim))
			flag = "+";
		else flag = "";
#ifdef REQUIRE_OANDV
		if (find_user_link(&chptr->chanops_voiced, victim))
			flag = "@+";
#endif
		channel_modes(chptr, victim, modebuf, parabuf);
		sendto_server(NULL, victim, chptr, NOCAPS, NOCAPS,
			LL_ICLIENT|LL_ICHAN, ":%s SJOIN %lu %s %s %s :%s%s",
			me.name, (unsigned long)chptr->channelts,
			chptr->chname, modebuf, parabuf, 
			flag, victim->name);
	}
  }
}