コード例 #1
0
ファイル: FiSH.c プロジェクト: kelek-/FiSH-irssi
/*
 * Decrypt NOTICE messages (and forward DH1080 key-exchange)
 */
void decrypt_notice(SERVER_REC * server, char *msg, char *nick, char *address,
		    char *target)
{
	GString *decrypted;
	char *DH1024warn;

	if (strncmp(msg, "DH1024_", 7) == 0) {
		DH1024warn =
		    "\002FiSH:\002 Received \002old DH1024\002 public key from you! Please update to latest version: https://github.com/falsovsky/FiSH-irssi";
		signal_stop();
		irc_send_cmdv((IRC_SERVER_REC *) server, "NOTICE %s :%s\n",
			      nick, DH1024warn);
		signal_emit("message irc own_notice", 3, server, DH1024warn,
			    nick);
		return;
	}

	if (strncmp(msg, "DH1080_", 7) == 0) {
		DH1080_received(server, msg, nick, address, target);
		return;
	}
#ifdef FiSH_DECRYPT_ZNC_LOGS
	if (IsZNCtimestamp(msg))
		msg += 11;
#endif

	decrypted = g_string_new("");
	if (FiSH_decrypt(server, msg, ischannel(*target) ? target : nick, decrypted)) {
		signal_continue(5, server, decrypted->str, nick, address, target);
		ZeroMemory(decrypted->str, decrypted->len);
	}
	g_string_free(decrypted, TRUE);
}
コード例 #2
0
ファイル: FiSH.c プロジェクト: hugopeixoto/FiSH-irssi
void raw_handler(SERVER_REC *server, char *data)
{
    char channel[CONTACT_SIZE], *ptr, *ptr_bak;
    int len;

    if (IsNULLorEmpty(data)) return;

    ptr=strchr(data, ' ');	// point to command
    if (ptr==NULL) return;
    ptr++;

    if (strncmp(ptr, "332 ", 4)!=0) return;	// 332 = TOPIC

    ptr_bak=ptr;
    ptr=strchr(ptr, '#');	// point to #channel
    if (ptr==NULL) {
        ptr=strchr(ptr_bak, '&');	// point to &channel
        if (ptr==NULL) {
            ptr=strchr(ptr_bak, '!');	// point to !channel
            if (ptr==NULL) return;
        }
    }

    len=strchr(ptr, ' ')-ptr;
    if (len >= CONTACT_SIZE-2) return;	// channel string too long, something went wrong
    strncpy(channel, ptr, len);
    channel[len]='\0';

    ptr=strchr(ptr, ':');	// point to topic msg start
    if (ptr==NULL) return;
    ptr++;

    FiSH_decrypt(server, ptr, ptr, channel);
}
コード例 #3
0
ファイル: FiSH.c プロジェクト: bcome/FiSH-irssi
void decrypt_action(SERVER_REC * server, char *msg, char *nick, char *address,
		    char *target)
{
	if (target == NULL)
		return;

	FiSH_decrypt(server, msg, msg, ischannel(*target) ? target : nick);
}
コード例 #4
0
ファイル: FiSH.c プロジェクト: kelek-/FiSH-irssi
void decrypt_topic(SERVER_REC * server, char *channel, char *topic, char *nick,
		   char *address)
{
	GString *decrypted;

	decrypted = g_string_new("");
	if (FiSH_decrypt(server, topic, channel, decrypted)) {
		signal_continue(5, server, channel, decrypted->str, nick, address);
		ZeroMemory(decrypted->str, decrypted->len);
	}
	g_string_free(decrypted, TRUE);
}
コード例 #5
0
ファイル: FiSH.c プロジェクト: kelek-/FiSH-irssi
void decrypt_changed_topic(CHANNEL_REC * chan_rec)
{
	GString *decrypted;

	decrypted = g_string_new("");
	if (FiSH_decrypt(chan_rec->server, chan_rec->topic,
		     chan_rec->name, decrypted)) {
		g_free_not_null(chan_rec->topic);
		chan_rec->topic = g_strdup(decrypted->str);
		signal_continue(1, chan_rec);
		ZeroMemory(decrypted->str, decrypted->len);
	}
	g_string_free(decrypted, TRUE);
}
コード例 #6
0
ファイル: FiSH.c プロジェクト: kelek-/FiSH-irssi
void decrypt_action(SERVER_REC * server, char *msg, char *nick, char *address,
		    char *target)
{
	GString *decrypted;
	if (target == NULL)
		return;

	decrypted = g_string_new("");
	if (FiSH_decrypt(server, msg, ischannel(*target) ? target : nick, decrypted)) {
		signal_continue(5, server, decrypted->str, nick, address, target);
		ZeroMemory(decrypted->str, decrypted->len);
	}
	g_string_free(decrypted, TRUE);
}
コード例 #7
0
ファイル: FiSH.c プロジェクト: hugopeixoto/FiSH-irssi
void decrypt_msg(SERVER_REC *server, char *msg, const char *nick, const char *address, const char *target)
{
    const char *contactPtr, *msg_bak=msg;
    char contactName[CONTACT_SIZE]="";


    if (msg==NULL || target==NULL || nick==NULL) return;

#ifdef FiSH_DECRYPT_ZNC_LOGS
    if (IsZNCtimestamp(msg)) msg += 11;
#endif

    //channel?
    if (ischannel(*target)) contactPtr=target;
    else if (strcmp(nick, "-psyBNC")==0) {	// psyBNC log message found		// <-psyBNC> Nw~Thu Mar 29 15:02:45 :([email protected]) +OK e3454451hbadA0

        msg=strstr(msg, " :(")+3;	// points to nick!ident@host in psybnc log
        if (msg==(char *)3) return;
        ExtractRnick(contactName, msg);
        msg=strchr(msg, ' ')+1;
        if (msg==(char *)1) return;
        contactPtr = contactName;
    } else if (strcmp(nick, "-sBNC")==0) {	// sBNC log message found (PRIVMSG)		// <-sBNC> Sun Sep  1 13:37:00 2007 someone ([email protected]): +OK Mp1p8.qYxFN1

        if ((msg=strstr(msg, " ("))==NULL) return;
        else msg--;		// points to the last char of the nick

        while (*msg!='\0' && *msg!=' ' && msg > msg_bak) msg--;

        if (*msg==' ') msg++;	// now points to the first char of the nick
        else return;

        ExtractRnick(contactName, msg);

        if ((msg=strstr(msg, "): "))==NULL) return;	// find metadata end
        msg += 3;	// now points to encrypted message

        contactPtr = contactName;
    } else contactPtr=nick;

    if (FiSH_decrypt(server, msg, msg, contactPtr)) {
        if (strncmp(msg_bak, "\001ACTION ", 8)==0) {
            // ACTION message found
            signal_stop();
            signal_emit("message irc action", 5, server, msg_bak+8, nick, address, target);
        }
    }
}
コード例 #8
0
ファイル: FiSH.c プロジェクト: kelek-/FiSH-irssi
void raw_handler(SERVER_REC * server, char *data)
{
	GString *decrypted;
	char channel[CONTACT_SIZE], *ptr, *ptr_bak;
	int len;

	if (IsNULLorEmpty(data))
		return;

	ptr = strchr(data, ' ');	// point to command
	if (ptr == NULL)
		return;
	ptr++;

	if (strncmp(ptr, "332 ", 4) != 0)
		return;		// 332 = TOPIC

	ptr_bak = ptr;
	ptr = strchr(ptr, '#');	// point to #channel
	if (ptr == NULL) {
		ptr = strchr(ptr_bak, '&');	// point to &channel
		if (ptr == NULL) {
			ptr = strchr(ptr_bak, '!');	// point to !channel
			if (ptr == NULL)
				return;
		}
	}

	len = strchr(ptr, ' ') - ptr;
	if (len >= CONTACT_SIZE - 2)
		return;		// channel string too long, something went wrong
	strncpy(channel, ptr, len);
	channel[len] = '\0';

	ptr = strchr(ptr, ':');	// point to topic msg start
	if (ptr == NULL)
		return;
	ptr++;

	decrypted = g_string_new("");
	if (FiSH_decrypt(server, ptr, channel, decrypted)) {
		g_string_prepend_len(decrypted, data, strlen(data) - strlen(ptr));
		signal_continue(2, server, decrypted->str);
		ZeroMemory(decrypted->str, decrypted->len);
	}
	g_string_free(decrypted, TRUE);
}
コード例 #9
0
ファイル: FiSH.c プロジェクト: hugopeixoto/FiSH-irssi
void decrypt_changed_topic(CHANNEL_REC *chan_rec)
{
    FiSH_decrypt(NULL, chan_rec->topic, chan_rec->topic, chan_rec->name);
}
コード例 #10
0
ファイル: FiSH.c プロジェクト: hugopeixoto/FiSH-irssi
void decrypt_topic(SERVER_REC *server, char *channel, char *topic, char *nick, char *address)
{
    FiSH_decrypt(server, topic, topic, channel);
}