Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optionally allow WEBIRC blocks to spoof ident responses #344

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion extensions/m_webirc.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ DECLARE_MODULE_AV2(webirc, NULL, NULL, webirc_clist, NULL, webirc_hfnlist, NULL,
/*
* mr_webirc - webirc message handler
* parv[1] = password
* parv[2] = fake username (we ignore this)
* parv[2] = fake username
* parv[3] = fake hostname
* parv[4] = fake ip
*/
Expand Down Expand Up @@ -171,6 +171,13 @@ mr_webirc(struct MsgBuf *msgbuf_p, struct Client *client_p, struct Client *sourc
else
rb_strlcpy(source_p->host, source_p->sockhost, sizeof(source_p->host));

if (aconf->flags & CONF_FLAGS_SPOOF_IDENT)
{
if (parv[2][0] != '~')
SetGotId(source_p);
rb_strlcpy(source_p->username, parv[2], sizeof(source_p->username));
}

/* Check dlines now, klines will be checked on registration */
if((aconf = find_dline((struct sockaddr *)&source_p->localClient->ip,
GET_SS_FAMILY(&source_p->localClient->ip))))
Expand Down
3 changes: 3 additions & 0 deletions include/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,7 @@ struct ListClient
#define FLAGS_EXEMPTSHIDE 0x04000000
#define FLAGS_EXEMPTJUPE 0x08000000
#define FLAGS_IDENTIFIED 0x10000000 /* owns their current nick */
#define FLAGS_USER_SPOOFING 0x00000080 /* username has already been set, so ignore it in USER */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Collides with FLAGS_GOTID



/* flags for local clients, this needs stuff moved from above to here at some point */
Expand Down Expand Up @@ -545,6 +546,8 @@ struct ListClient
#define SetExemptResv(x) ((x)->flags |= FLAGS_EXEMPTRESV)
#define IsIPSpoof(x) ((x)->flags & FLAGS_IP_SPOOFING)
#define SetIPSpoof(x) ((x)->flags |= FLAGS_IP_SPOOFING)
#define IsUserSpoof(x) ((x)->flags & FLAGS_USER_SPOOFING)
#define SetUserSpoof(x) ((x)->flags |= FLAGS_USER_SPOOFING)
#define IsExtendChans(x) ((x)->flags & FLAGS_EXTENDCHANS)
#define SetExtendChans(x) ((x)->flags |= FLAGS_EXTENDCHANS)

Expand Down
1 change: 1 addition & 0 deletions include/s_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ struct ConfItem
#define CONF_FLAGS_NEED_IDENTD 0x00000008
#define CONF_FLAGS_EXEMPTKLINE 0x00000040
#define CONF_FLAGS_NOLIMIT 0x00000080
#define CONF_FLAGS_SPOOF_IDENT 0x00000100
#define CONF_FLAGS_SPOOF_IP 0x00000200
#define CONF_FLAGS_SPOOF_NOTICE 0x00000400
#define CONF_FLAGS_REDIR 0x00000800
Expand Down
2 changes: 1 addition & 1 deletion ircd/authproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ authd_decide_client(struct Client *client_p, const char *ident, const char *host
if(client_p->preClient == NULL || client_p->preClient->auth.cid == 0)
return;

if(*ident != '*')
if(*ident != '*' && !IsGotId(client_p))
{
rb_strlcpy(client_p->username, ident, sizeof(client_p->username));
SetGotId(client_p);
Expand Down
1 change: 1 addition & 0 deletions ircd/newconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ static struct mode_table auth_table[] = {
{"extend_chans", CONF_FLAGS_EXTEND_CHANS },
{"allow_sctp", CONF_FLAGS_ALLOW_SCTP },
{"kline_spoof_ip", CONF_FLAGS_KLINE_SPOOF },
{"spoof_ident", CONF_FLAGS_SPOOF_IDENT },
{NULL, 0}
};

Expand Down
2 changes: 2 additions & 0 deletions ircd/s_conf.c
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,8 @@ verify_access(struct Client *client_p, const char *username)
/* user@host spoof */
if((p = strchr(aconf->info.name, '@')) != NULL)
{
SetUserSpoof(client_p);

char *host = p+1;
*p = '\0';

Expand Down
2 changes: 1 addition & 1 deletion ircd/s_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ register_local_user(struct Client *client_p, struct Client *source_p)
}

/* dont replace username if its supposed to be spoofed --fl */
if(!IsConfDoSpoofIp(aconf) || !strchr(aconf->info.name, '@'))
if(!IsUserSpoof(source_p))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The above-mentioned collision means that this if is always true

{
p = myusername;

Expand Down