HOME       >>       Programming

Sockets Help (mirc)


AlternativeNick

hello, i was wondering if someone would be able to help me out a bit.Im looking to get some info from my forums using sockets and mIRC, however the info i want requires that you be logged in.I know that it would require sockwrite POST something, but im not really sure how to use that :Sanyways, here is the source to the login section (HTML)

<form action="http://forums.xisto.com/no_longer_exists/; method="post" style="margin: 3px 1ex 1px 0pt; text-align: right;"> <input name="user" size="10" type="text"> <input name="passwrd" size="10" type="password"> <select name="cookielength"> <option value="60">1 Hour</option> <option value="1440">1 Day</option> <option value="10080">1 Week</option> <option value="302400">1 Month</option> <option value="-1" selected="selected">Forever</option> </select> <input value="Login" type="submit"><br> Login with username, password and session length </form>


imacul8

Sorta gotta error test this to get it all to work properly but this would be the basic layout of it

alias getforum {sockclose forumsockopen forum 64.69.46.210 80}on *:sockopen:forum: { if ($sockerr) { echo -a Connection failed sockclose forum return }sockwrite -n $sockname POST /forum/index.php?action=login2&user=<user>&passwrd=<pass>&cookielength=-1 HTTP/1.1sockwrite -n $sockname Host: 64.69.46.210sockwrite -n $sockname User-Agent: explorersockwrite -n $sockname Accept: *.*, */*sockwrite -n $sockname Referer: /forum/index.php?action=login2sockwrite -n $sockname Connection: Keep-Alivesockwrite -n $sockname Content-Type: text/htmlsockwrite -n $sockname $crlf}

Hope this helps you, if u need more info i am free to help here

AlternativeNick

hey thanks, but im not really sure how to go back to the page and read the next page from that, if you could PM me with some contact info (irc server, channels, and nickname) i would really appreciate it.otherwise, im available (most of the time) on irc.swiftirc.net in channel #scripting and #mircthanks


imacul8

Well im not sure if your website needs the cookies sent each page you view but if it does it gets a bit more complicated.... if it doesnt then its pretty easy. Since in that last POST it logs in forever (how ever many days it can "max days").

So if it doesnt need cookies sent each time - Once u have done the login part you need to use the sockread event and scan the code for the correct text like "Logged in" or whateva your website says once ur logged in. Once it sees that text u then need to make it open the socket again and grab the next page....

You need to set all the events out better so u can use the same event but have it grab a different page.. i will get to that down a bit further....

something like this would do the job, you can also use it as a debug for the html received from the site to make sure it is working right.


Can use this for the debug

on *:sockread:forum: {window -e @forum sockread %temp if (!$sockbr) { return } if (%temp) { echo @forum %temp }}

And you can add your scan part

on *:sockread:forum: {window -e @forum sockread %temp if (!$sockbr) { return } if (%temp) { echo @forum %temp }if (Logged isin %temp) { echo @forum %temp }}

you will see what that line with that returns, probably even includes a link u can grab out that line... or if u know where u wanna go next just add the commands there (this is where all your events need to be set out better
ie.

alias forumlogin {sockclose forumsockopen forum 64.69.46.210 80set %forum.get POST /forum/index.php?action=login2&user=<user>&passwrd=<pass>&cookielength=-1 HTTP/1.1}alias foruminfo {sockclose forumsockopen forum 64.69.46.210 80set %forum.get GET /pageyouwannagethere.php HTTP/1.1}on *:sockopen:forum: { if ($sockerr) { echo -a Connection failed sockclose forum return }sockwrite -n $sockname %forum.getsockwrite -n $sockname Host: 64.69.46.210sockwrite -n $sockname User-Agent: explorersockwrite -n $sockname Accept: *.*, */*sockwrite -n $sockname Connection: Keep-Alivesockwrite -n $sockname Content-Type: text/htmlsockwrite -n $sockname $crlf}on *:sockread:forum: {window -e @forum sockread %temp if (!$sockbr) { return } if (%temp) { echo @forum %temp }if (Logged isin %temp) { <---- you might need to add/alter this part depending what ur site returnsecho @forum %temp foruminfo}}

Hope this helps you, i will try catch u on that server u mentioned (there now but you arent.. )
If this doesnt work and the foruminfo echos something like "You are not logged in" to the @forums window then you will have to send cookies each time which can be difficult but will cover that if need be...

goodluck

imacul8

Well since i havent been able to get hold of you for the past couple days and you havent replied on here i took it upon myself to get this working correctly and in my studies found you are going to have to save and send the cookies each time u view a page.
I wont cover that at this time since im not even sure if you are continuing with this project...?

But here is the up to date code that will get you logged in correctly to the account

alias forumlogin { sockclose altforum sockopen altforum http://forums.xisto.com/no_longer_exists/ 80 set %forum.get POST /forum/index.php?action=login2&user=<username>&passwrd=<password>&cookielength=-1 HTTP/1.1}alias foruminfo { sockclose altforum sockopen altforum http://forums.xisto.com/no_longer_exists/ 80 set %forum.get POST /forum/index.php?action=profile HTTP/1.1}on *:sockopen:altforum: { if ($sockerr) { echo -a Connection failed sockclose forum return } sockwrite -n $sockname %forum.get sockwrite -n $sockname Host: http://forums.xisto.com/no_longer_exists/ sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; FDM) sockwrite -n $sockname Accept: *.*, */* sockwrite -n $sockname Connection: Keep-Alive sockwrite -n $sockname Content-Type: text/html sockwrite -n $sockname $crlf}on *:sockread:altforum: { window -e @altforum sockread %temp if (!$sockbr) { return } if (%temp) { if (Location: isin %temp) { sockclose altforum sockopen altforum http://forums.xisto.com/no_longer_exists/ 80 set %forum.get POST $+(/,$gettok(%temp,3-,47)) HTTP/1.1 } echo @altforum %temp }}

So if you need help with the next stages after this just let me know

AlternativeNick

ok, so after some work, heres what i have xD
(the dialog is from another script, im just adding this section to it, so ignore the dialog commands)

alias forumlogin { sockclose altforum sockopen altforum http://forums.xisto.com/no_longer_exists/ 80 set %forum.get POST $+(/forum/index.php?action=login2&user=,$user,&passwrd=,$pass,&cookielength=-1) HTTP/1.1}alias foruminfo { sockclose altforum sockopen altforum http://forums.xisto.com/no_longer_exists/ 80 set %forum.get POST /forum/index.php?action=profile HTTP/1.1}on *:sockopen:altforum: { if ($sockerr) { echo -a Connection failed sockclose forum return } sockwrite -n $sockname %forum.get sockwrite -n $sockname Host: http://forums.xisto.com/no_longer_exists/ sockwrite -n $sockname User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; FDM) sockwrite -n $sockname Accept: *.*, */* sockwrite -n $sockname Connection: Keep-Alive sockwrite -n $sockname Content-Type: text/html sockwrite -n $sockname $crlf}on *:sockread:altforum: { window -e @altforum sockread %temp if (!$sockbr) { return } if (%temp) { if (Location: isin %temp) { sockclose altforum sockopen altforum http://forums.xisto.com/no_longer_exists/ 80 set %forum.get POST $+(/,$gettok(%temp,3-,47)) HTTP/1.1 } if (*Hey, <b>AlternativeNick</b>, you have <a* iswm %temp) { var %welcome = Welcome $user $+ , You have $gettok($remove($htmlfree(%temp),$chr(9)),7,32) new messages. var %inbox = $gettok(%temp,2,34) did -a altscripts 22 %welcome } elseif (*Total Time Logged In* iswm %temp) { var %timeonline = You have spent $gettok($remove($htmlfree(%temp),$chr(9),$chr(46)),2,58) on the forums. did -a altscripts 26 %timeonline } elseif (*Show Unread Posts since last visit* iswm %temp) { set %showunreadpostssincelastvisit $gettok(%temp,2,34) } elseif (*Show new replies to your posts.* iswm %temp) { set %shownewrepliestoyourposts $gettok(%temp,2,34) } }}

Anyways, i was also looking at posting a now topic using mirc.

The exact url of that is http://forums.xisto.com/no_longer_exists/forum/ind=post;board=5.0 and will always be the same board. thanks for all the help xD


ps. in this line (you gave to someone in my channel) if ($eval($+(%,$me,.kick),2) == 3) { it wont work, firstly you cant trigger your own on text events, and secondly why would you want to see if youve been swearing, its someone else youre looking for xD

imacul8

ps. in this line (you gave to someone in my channel) if ($eval($+(%,$me,.kick),2) == 3) { it wont work, firstly you cant trigger your own on text events, and secondly why would you want to see if youve been swearing, its someone else youre looking for xD


Oops i was just testing something with $me and must have just pasted that in and not changed it to $nick, my bad. Did that user end up getting it working??

AlternativeNick

yeah, we worked it out... the only problem that was left was that it had $me instead of $nick, took me an hour to see it (at 5 am lol)


tractor

Ok thats good this was a month ago cause your suppose to be the #2 scripter #1 goes to Marius sorry.



VIEW ORIGINAL REGISTER GET FREE HOSTING

Xisto.com offers Free Web Hosting to its Members for their participation in this Community. We moderate all content posted here but we cannot warrant full correctness of all content. While using this site, you agree to have read and accepted our terms of use, cookie and privacy policy. Copyright 2001-2019 by Xisto Corporation. All Rights Reserved.