SwiftIRC
IRC Discussion and Support
 
  Index  •  FAQ  •  Search  

It is currently Mon Jul 28, 2014 8:28 pm




Post new topic Reply to topic  [ 10 posts ] 
 mIRC SASL Authentication Script 
Author Message
 Post subject: mIRC SASL Authentication Script
PostPosted: Mon Sep 07, 2009 5:39 pm 
User
User

Joined: Sun Dec 10, 2006 9:58 pm
Posts: 693
Hello,

I don't often release scripts to the community (Most of my work is supposed to be kept private), but I figured everyone could potentially use this. For those of you who don't know what SASL is, I suggest you read this article.

I have not been able to recreate the crypto to authenticate via dh-blowfish, so only PLAIN authentication is supported presently. I do hope to change this in the relative future, so please check back. Also, I have not written an updater yet, so for all you who will be constantly pushing it, you too should check back periodically for the relative future.

Without further ado...

SASLreadme.txt

Code:
Hello!

Put SASL.dll and SASL.mrc into your $mircdir, load SASL.mrc into your remotes, press "f2", configure
a network using the GUI interface, and connect as you would any server.

Enjoy the added security :D


SASL.mrc

Code:
/*
mSASL Version 1.0 Beta designed by Kyle Travaglini
  * To use this script you must have the proper DLL
  * All I ask is you leave the credit line within the
     main dialog
  * PLEASE read the SASLreadme.txt file before asking
     questions!
*/

alias shname { return SASL }
alias shfile { return SASL.hsh }
alias SASL {
  if ($isid) {
    if ($prop == nlist) { return $hget($shname,NLIST) }
    if ($prop == timeout) { return $hget($shname,$+($1,:TIMEOUT)) }
    if ($prop == user) { return $hget($shname,$+($1,:USER)) }
    if ($prop == passwd) { return $hget($shname,$+($1,:PASSWD)) }
    if ($prop == domain) { return $hget($shname,$+($1,:DOMAIN)) }
    if ($prop == realname) { return $hget($shname,$+($1,:REALNAME)) }
    if ($prop == status) { return $hget($shname,$+($1,:STATUS)) }
    if ($prop == authtype) { return $hget($shname,$+($1,:AUTHTYPE)) }
  }
}
alias sd { hadd -m $shname $+($1,:,$2) $3- }

on *:START:{
  if (!$exists(SASL.hsh)) { hmake $shname 50 }
  else { hload $shname $shfile }
}

on ^*:LOGON:*:{
  if ($network isin $SASL($network).nlist) {
    .quote CAP LS
    .quote NICK $nick
    .quote USER $SASL($network).user $SASL($network).domain 1 : $+ $SASL($network).realname
    sd $network STATUS Connecting
    halt
  }
}

raw CAP:*LS*:{ .quote CAP REQ :multi-prefix sasl }
raw CAP:*ACK*:{ .quote AUTHENTICATE PLAIN }
raw AUTHENTICATE:+:{ .quote AUTHENTICATE $dll(SASL.dll,zencode,$SASL($network).user $SASL($network).user $SASL($network).passwd) }
raw *:*:{
  if ($numeric isnum 903-907) { .quote CAP END }
}

dialog SASL.main {
  title "SASL Manager"
  size -1 -1 150 145
  option dbu
  box "Server List" 1, 5 3 140 113
  text "Created by Kyle Travaglini" 3, 40 135 65 12
  list 4, 10 13 80 104, vsbar, edit
  button "Add" 5, 96 13 43 12
  button "Edit" 6, 96 30 43 12
  button "Delete" 7, 96 47 43 12
  button "OK" 8, 27 120 43 12, ok
  button "Update SASL" 9, 77 120 43 12
}

dialog SASL.edit {
  title "Network Configuration"
  size -1 -1 150 120
  option dbu
  box "Network Settings" 1, 5 3 140 97
  text "Network:" 2, 10 13 36 10, right
  edit "" 3, 48 12 92 10
  text "Username:" 4, 10 25 36 10, right
  edit "" 5, 48 24 92 10
  text "NS Password:" 6, 10 37 36 10, right
  edit "" 7, 48 36 92 10
  text "Domain:" 8, 10 49 36 10, right
  edit "" 9, 48 48 92 10
  text "Real Name:" 10, 10 61 36 10, right
  edit "" 11, 48 60 92 10
  text "Timeout:" 12, 10 73 36 10, right
  edit "" 13, 48 72 92 10
  text "AuthType:" 14, 10 85 36 10, right
  edit "" 15, 48 84 92 10
  button "OK" 16, 27 105 43 12, ok
  button "Cancel" 17, 77 105 43 12, cancel
}

dialog SASL.deletewarn {
  title "SASL"
  size -1 -1 120 40
  option dbu
  text "You must specify a network to delete." 1, 13 5 100 10
  button "OK" 2, 40 20 43 12, ok
}

dialog SASL.editwarn {
  title "SASL"
  size -1 -1 120 40
  option dbu
  text "You must specify a network to edit." 1, 13 5 100 10
  button "OK" 2, 40 20 43 12, ok
}

on *:DIALOG:SASL.*:*:*:{
  if ($dname == SASL.main) {
    if ($devent == init) {
      did -r $dname 3
      did -a $dname 3 $decode(Q3JlYXRlZCBieSBLeWxlIFRyYXZhZ2xpbmk=,m)
      var %net_iter = 1
      while (%net_iter <= $numtok($SASL().nlist,44)) {
        did -a $dname 4 $gettok($SASL().nlist,%net_iter,44)
        inc %net_iter 1     
      }
    }
    if ($devent == sclick) {
      if ($did == 5) { dialog -m SASL.edit SASL.edit }
      elseif ($did == 6) {
        if ($did($dname,4).seltext) {
          hadd -m $shname EDIT True
          dialog -m SASL.edit SASL.edit
        }
        else { dialog -m SASL.deletewarn SASL.deletewarn }
      }
      elseif ($did == 7) {
        if ($did($dname,4).sel) {
          if ($?!="Are you certain you wish to delete $did($dname,4).seltext $+ ?") {
            hdel -w $shname $+($did($dname,4).seltext,:*)
            hadd -m $shname NLIST $remtok($SASL().nlist,$did($dname,4).seltext,1,44)
            did -d $dname 4 $did($dname,4).sel
          }
        }
        else { dialog -m SASL.deletewarn SASL.deletewarn }
      }
      elseif ($did == 9) { usasl }
    }
  }
  elseif ($dname == SASL.edit) {
    if ($devent == init) {
      if ($hget($shname,EDIT) == True) {
        var %network = $did(SASL.main,4).seltext
        did -a $dname 3 %network
        did -a $dname 5 $SASL(%network).user
        did -a $dname 7 $SASL(%network).passwd
        did -a $dname 9 $SASL(%network).domain
        did -a $dname 11 $SASL(%network).realname
        did -a $dname 13 $SASL(%network).timeout
        did -a $dname 15 $SASL(%network).authtype
      }
    }
    if ($devent == sclick) {
      if ($did == 16) {
        var %network = $did($dname,3)
        if ($hget($shname,EDIT) == True) { hadd -m $shname NLIST $remtok($SASL().nlist,%network,1,44) }
        else {
          if ($findtok($SASL().nlist,%network,1,44)) {
            if ($?!=" $+ %network already exists; overwrite?") {
              hadd -m $shname NLIST $remtok($SASL().nlist,%network,1,44)
            }
            else { halt }
          }
        }
        hdel $shname EDIT
        hadd -m $shname NLIST $+($SASL().nlist,$chr(44),%network)
        sd %network USER $did($dname,5)
        sd %network PASSWD $did($dname,7)
        sd %network DOMAIN $did($dname,9)
        sd %network REALNAME $did($dname,11)
        sd %network TIMEOUT $did($dname,13)
        sd %network AUTHTYPE $did($dname,15)
        var %net_iter = 1
        did -r SASL.main 4
        while (%net_iter <= $numtok($SASL().nlist,44)) {
          did -a SASL.main 4 $gettok($SASL().nlist,%net_iter,44)
          inc %net_iter 1     
        }
      }
    }
  }
}
;;


SASL.cpp

Code:
/*
Modified Encoding Function Copyright (c) 2009 Kyle Travaglini
Base64 Function Copyright (c) mr_man

Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.

Other tools besides base64_encode have been provided as
well; mainly base64_decode :P

*/

#include <windows.h>

#define BASE64_VALUE_SZ 256
#define BASE64_RESULT_SZ 8192

static void base64_init(void);
static int base64_initialized = 0;
int base64_value[BASE64_VALUE_SZ];
const char base64_code[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";


static void
base64_init(void)
{
    int i;

    for (i = 0; i < BASE64_VALUE_SZ; i++)
   base64_value[i] = -1;

    for (i = 0; i < 64; i++)
   base64_value[(int) base64_code[i]] = i;
    base64_value['='] = 0;

    base64_initialized = 1;
}

char *
base64_decode(const char *p)
{
    static char result[BASE64_RESULT_SZ];
    int j;
    int c;
    long val;
    if (!p)
   return NULL;
    if (!base64_initialized)
   base64_init();
    val = c = 0;
    for (j = 0; *p && j + 4 < BASE64_RESULT_SZ; p++) {
   unsigned int k = ((unsigned char) *p) % BASE64_VALUE_SZ;
   if (base64_value[k] < 0)
       continue;
   val <<= 6;
   val += base64_value[k];
   if (++c < 4)
       continue;
   result[j++] = (val >> 16) & 0xff;
   result[j++] = (val >> 8) & 0xff;
   result[j++] = val & 0xff;
   val = c = 0;
    }
    result[j] = 0;
    return result;
}

const char *
base64_encode(const char *decoded_str)
{
    static char result[BASE64_RESULT_SZ];
    int bits = 0;
    int char_count = 0;
    int out_cnt = 0;
    int c;

    if (!decoded_str)
   return decoded_str;

    if (!base64_initialized)
   base64_init();

    while ((c = (unsigned char) *decoded_str++) && out_cnt < sizeof(result) - 5) {
   bits += c;
   char_count++;
   if (char_count == 3) {
       result[out_cnt++] = base64_code[bits >> 18];
       result[out_cnt++] = base64_code[(bits >> 12) & 0x3f];
       result[out_cnt++] = base64_code[(bits >> 6) & 0x3f];
       result[out_cnt++] = base64_code[bits & 0x3f];
       bits = 0;
       char_count = 0;
   } else {
       bits <<= 8;
   }
    }
    if (char_count != 0) {
   bits <<= 16 - (8 * char_count);
   result[out_cnt++] = base64_code[bits >> 18];
   result[out_cnt++] = base64_code[(bits >> 12) & 0x3f];
   if (char_count == 1) {
       result[out_cnt++] = '=';
       result[out_cnt++] = '=';
   } else {
       result[out_cnt++] = base64_code[(bits >> 6) & 0x3f];
       result[out_cnt++] = '=';
   }
    }
    result[out_cnt] = '\0';
    return result;
}

const char *
base64_encode_bin(const char *data, int len)
{
    static char result[BASE64_RESULT_SZ];
    int bits = 0;
    int char_count = 0;
    int out_cnt = 0;

    if (!data)
   return data;

    if (!base64_initialized)
   base64_init();

    while (len-- && out_cnt < sizeof(result) - 5) {
   int c = (unsigned char) *data++;
   bits += c;
   char_count++;
   if (char_count == 3) {
       result[out_cnt++] = base64_code[bits >> 18];
       result[out_cnt++] = base64_code[(bits >> 12) & 0x3f];
       result[out_cnt++] = base64_code[(bits >> 6) & 0x3f];
       result[out_cnt++] = base64_code[bits & 0x3f];
       bits = 0;
       char_count = 0;
   } else {
       bits <<= 8;
   }
    }
    if (char_count != 0) {
   bits <<= 16 - (8 * char_count);
   result[out_cnt++] = base64_code[bits >> 18];
   result[out_cnt++] = base64_code[(bits >> 12) & 0x3f];
   if (char_count == 1) {
       result[out_cnt++] = '=';
       result[out_cnt++] = '=';
   } else {
       result[out_cnt++] = base64_code[(bits >> 6) & 0x3f];
       result[out_cnt++] = '=';
   }
    }
    result[out_cnt] = '\0';
    return result;
}


//Base SixtyFour (64) DLL

extern "C" __declspec(dllexport) int __stdcall zencode(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause);
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*) { return 1; }

int __stdcall zencode(HWND mWnd, HWND aWnd, char *data, char *parms, BOOL show, BOOL nopause)
{
    char *toEncode = data;
    int i;
    size_t len = strlen(data);
    for (i = 0; i < len; i++) if (toEncode[i] == ' ') toEncode[i] = '\0';
   strcpy(data,base64_encode_bin(toEncode, len));
   return 3;
}


Alternatively, you may download any file (Including a compiled DLL) from http://ZetaScript.org/sasl4mirc

Cheers

_________________
Image

Image


Last edited by Kyle on Tue Sep 08, 2009 3:13 am, edited 1 time in total.

Offline
 Profile  
 
 Post subject: Re: mIRC SASL Authentication Script
PostPosted: Mon Sep 07, 2009 9:55 pm 
User
User

Joined: Sun Jul 27, 2008 7:26 pm
Posts: 122
Location: New York
Add the f2 alias *cough*
Code:
f2 { dialog -m SASL.main SASL.main }


I doubt I would have any use for this but it looks well coded and very clean. I do not know anything about C so I can't really comment on the .dll :(

_________________
#xmrfunny1x


Offline
 Profile  
 
 Post subject: Re: mIRC SASL Authentication Script
PostPosted: Tue Sep 08, 2009 2:37 am 
User
User

Joined: Sat May 13, 2006 9:41 pm
Posts: 225
Your encoding/decoding code sure looks a lot like http://www.mircscripts.org/comments.php?cid=3634 ...
I was wondering why you sometimes had 3, and sometimes had 4 spaces as indentation. But that's just the conversion of tabs from the original document (where tabs have been replacing by 3 spaces in "your" code).
Please, if you use someone else's code, include their name.

Other than that, nice work at the rest, I guess. I would've tackled it myself if I hadn't been so busy lately.

_________________
Image


Offline
 Profile  
 
 Post subject: Re: mIRC SASL Authentication Script
PostPosted: Tue Sep 08, 2009 2:53 am 
Newbie
Newbie

Joined: Tue Aug 05, 2008 9:37 am
Posts: 4
Please take my name off this monstrosity.


Offline
 Profile  
 
 Post subject: Re: mIRC SASL Authentication Script
PostPosted: Tue Sep 08, 2009 3:14 am 
User
User

Joined: Sun Dec 10, 2006 9:58 pm
Posts: 693
Done Hatty.

Thank you for providing that link Timmy, that is indeed the source. I have had that code lying around for a bit and I forgot where it was from :oops:. Now that I know the author, they have been properly cited.


Offline
 Profile  
 
 Post subject: Re: mIRC SASL Authentication Script
PostPosted: Tue Sep 08, 2009 7:47 am 
User
User

Joined: Sun Dec 28, 2008 11:55 pm
Posts: 28
Good job, but just a note: mr_man is not the author, he just reviewed the DLL. The author is codemastr_


Offline
 Profile  
 
 Post subject: Re: mIRC SASL Authentication Script
PostPosted: Wed Jun 23, 2010 11:37 pm 
Newbie
Newbie

Joined: Fri Nov 20, 2009 4:02 pm
Posts: 6
Unfortunately I could not overcome the message :

* $dll: unable to open 'C:\Path\to\mirc\SASL.dll'

Do you have similar experience?

Thanks in advance.


Offline
 Profile  
 
 Post subject: Re: mIRC SASL Authentication Script
PostPosted: Thu Nov 11, 2010 10:42 pm 
Newbie
Newbie

Joined: Thu Nov 11, 2010 10:39 pm
Posts: 1
probably your build is faulty, try e.g. http://honk-honk.org/SASL/SASL.dll . but it is not working for me either .


Offline
 Profile  
 
 Post subject: Re: mIRC SASL Authentication Script
PostPosted: Mon Dec 13, 2010 2:57 pm 
Newbie
Newbie

Joined: Mon Dec 13, 2010 2:51 pm
Posts: 1
I am writing to report that the script in the first post has problems when used in mIRC running in portable mode. Configured networks do not get stored. I solved my problem by searching out another SASL authentication script for mIRC which I am using in mIRC 7.15 to successfully connect to Freenode. It is available here in the mIRC forum.

_________________
:)


Offline
 Profile  
 
 Post subject: Re: mIRC SASL Authentication Script
PostPosted: Mon Oct 24, 2011 7:52 am 
Newbie
Newbie

Joined: Mon Oct 24, 2011 7:50 am
Posts: 1
Thanks))That is exactly the link I was looking for!I'm sure someone else will find this useful


Offline
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 


 Who is online 

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 
Index  |  FAQ  |  Search

phpBB skin developed by: John Olson
Protected by Anti-Spam ACP
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group