Shoutbox

[help] Auth for the site, via msn - Printable Version

-Shoutbox (https://shoutbox.menthix.net)
+-- Forum: MsgHelp Archive (/forumdisplay.php?fid=58)
+--- Forum: Messenger Plus! for Live Messenger (/forumdisplay.php?fid=4)
+---- Forum: Scripting (/forumdisplay.php?fid=39)
+----- Thread: [help] Auth for the site, via msn (/showthread.php?tid=91024)

[help] Auth for the site, via msn by chu4 on 06-11-2009 at 04:18 PM

Immediately to the problem ... :)

For example, have site - www.mysite.com
On the authorization form, the code:

code:
<form name="auth">
    <input type="text" name="user" />
    <input type="password" name="password" />
    <input type="checkbox" name="rem" value="1" />
    <input type="hidden" name="rnd" value="123" />
    <input type="hidden" name="a" value="2" />
    <input type="hidden" name="ajax" value="1" />
    <input type="submit" name="sbm" value="sbm" />
</form>


And...

code:
function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
    if (Message.substr(0,5) === '/auth'){
            botAuth(Message.substr(5,100).split('/')[0], Message.substr(5,100).split('/')[1]);
            return '';
    }
}

function botAuth(acc, pass){
    var webAuth = new ActiveXObject("Microsoft.XMLHTTP");
    with(webAuth){
        open('GET','http://www.mysite.com?' + Math.random(), false); send();
        var x = responseText.indexOf('name="rnd" value="')+'name="rnd" value="'.length;
        rnd_value = responseText.substring(x,responseText.indexOf('"',x));
        open('POST', 'http://www.mysite.com', true);
        send('user=' + acc + '&password=' + pass + '&rem=1&a=2&ajax=1&rnd=' + rnd_value);
    }
}


Auth command:
quote:
/auth account/password

Don't know why, but don't working... :o
Only yesterday, the primary explore scripting in Messenger Plus ... :$
RE: [help] Auth for the site, via msn by MeEtc on 06-11-2009 at 04:52 PM

This might help.
[Tutorial] Communicating with web pages

You need to use the setRequestHeader method


RE: [help] Auth for the site, via msn by chu4 on 06-11-2009 at 05:17 PM

Em... reading... but don't understand anything...

code:
function botAuth(acc, pass){
    var url = "http://xcinema.net";
    var xcinemaAuth = new ActiveXObject("Microsoft.XMLHTTP");
    with(xcinemaAuth){
        open('GET', url, false); send();
        var x = responseText.indexOf('name="rnd" value="')+'name="rnd" value="'.length;
        rnd_value = responseText.substring(x,responseText.indexOf('"',x));
    }
    var data = 'user=' + acc + '&password=' + pass + '&rem=1&a=2&ajax=1&rnd=' + rnd_value;
    Interop.Call("wininet.dll", "DeleteUrlCacheEntryW", url);
    var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    with(xmlhttp){
        open("POST", url, true);
        setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        setRequestHeader("Content-length", data.length);
        setRequestHeader("Connection", "close");

        onreadystatechange = function(){
               if(xmlhttp.readyState == 4 && xmlhttp.responseCode == 200){
                     Messenger.MyPersonalMessage = 'success';
              } else {
                    Messenger.MyPersonalMessage = 'error';
               }
        }

        send(data);
    }
}


PSM: error... :o

Hm... if replace responseCode to status, then PSM: success, but not auth.... :(
RE: [help] Auth for the site, via msn by MeEtc on 06-11-2009 at 05:21 PM

You need to nest the if statement in the onreadystatechange function. reason for this is because the value of readyState changes value from 0 to 4. responseCode will be null until readyState is at least 2. What is happening is your IF statement is triggered many times, and the PSM has flood protection as to how often it can be updated. you want the PSM to be updated only once, but with your code it happens multiple times.Take a look at my tutorial again.

EDIT: ok, yes that was posted below. I would still recommend changing the function though.

When you are saying that you aren't authenticated on the site, what are you doing to test that? Is the script getting more information from the site, or are you opening a web browser? My best guess is that once your browser session ends, the site trashes your authentication status. If you are using the script to fetch more information, keep re-using the same XMLHTTP object, and don't re-declare it. meaning, this line should only appear once in the script:

code:
var webAuth = new ActiveXObject("Microsoft.XMLHTTP");
Post some more details of what you are trying to do.
RE: [help] Auth for the site, via msn by chu4 on 06-11-2009 at 05:41 PM

Full code...

code:
var xcinemaData = new ActiveXObject("Microsoft.XMLHTTP");

function OnEvent_Initialize(MessengerStart){
    command = 'bot'
    bot_name = 'xbot';
    server_url = 'xcinema.net';
    patch = 'mchat';
}

function OnEvent_ChatWndReceiveMessage(ChatWnd, Origin, Message, MessageKind){
    if ( MessageKind == 1 && Message.substr(0,5) == 'chat:' ){
        sendData('[msn] ' + Origin, Message.substr(6,666666));
    }
}

function OnEvent_ChatWndSendMessage(ChatWnd, Message) {
    if (Message.substr(0,9) === '/' + command + ' chat'){
            sendData(bot_name, Message.substr(9,666666));
         return '';
    } else if (Message.substr(0,9) === '/' + command + ' auth'){
            botAuth(Message.substr(9,100).replace(/ /ig, '').split('/')[0], Message.substr(9,100).replace(/ /ig, '').split('/')[1]);
            return '';
    }
}

function sendData(user, mess){
    with(xcinemaData){
        open('GET','http://' + server_url + '/' + patch + '/?' + Math.random(), false); send();
        var input = responseText.indexOf('name="s" value="')+'name="s" value="'.length;
        ssid = responseText.substring(input,responseText.indexOf('"',input));
        open('POST', 'http://' + server_url + '/' + patch + '/', true);
        send('uname='+user+'&message='+mess+'&s='+ssid+'&ajax=1&a=8&numa=0&a=8');
    }
}

function botAuth(acc, pass){
    with(xcinemaData){
        open('GET','http://' + server_url + '/?' + Math.random(), false); send();
        var x = responseText.indexOf('name="rnd" value="')+'name="rnd" value="'.length;
        rnd_value = responseText.substring(x,responseText.indexOf('"',x));
        var data = 'user=' + acc + '&password=' + pass + '&rem=1&a=2&ajax=1&rnd=' + rnd_value;
        open('POST', 'http://' + server_url, true);
        setRequestHeader("Content-type", "application/x-www-form-urlencoded");
        setRequestHeader("Content-length", data.length);
        setRequestHeader("Connection", "close");
        send(data);
    }
}


RE: [help] Auth for the site, via msn by MeEtc on 06-11-2009 at 05:44 PM

ahh, exactly what I thought. You need to take the line for the new object outside of the functions. re-declaring that variable is like closing and re-opening your web browser every time. you need to use the same variable throughout.


RE: [help] Auth for the site, via msn by chu4 on 06-11-2009 at 05:48 PM

MeEtc, u can edit my code? Because i don't understand what u mean... :$


RE: [help] Auth for the site, via msn by MeEtc on 06-11-2009 at 06:20 PM

you already did what I suggested. other than that I'm not sure what part isn't working as I'm not testing it.


RE: [help] Auth for the site, via msn by chu4 on 06-12-2009 at 11:34 AM

Fixed, thanks for help :)