Posted: Tue Jul 19, 2005 4:44 am Post subject: Socket commands
Hey guys,
I'm trying to create an AIM bot using mIRC, and I am stuck. My problem is, after I create a socket and establish a connection with the aim server, I don't know what commands to send to the aim server which will allow me to login using an existing SN and password. And after that, what commands would I send to the server which would allow me to send a message to another user, etc?
So basically I'm just looking for the pure commands that are recognized by the aim server, the pure socket commands. I tried using Windows Packet Editor (WPE) to look at what the aim client does and try to copy it, but it is very hard to tell because it sends a lot of illegible crap, and the packets that the server sends seem to also be slightly different from one connection to another, and also illegible.
But just so I'm as clear as possible, if for example I am to write a bot that will connect to and read a website, I'll use commands that a web server recognizes, commands that are sent by the browser, and so what I send to the web server would look like this:
=========================
GET / HTTP/1.1
Host: www.somewebsite.com
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7. Gecko/20050511 Firefox/1.0.4
Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 300
Connection: keep-alive
=========================
The difference between this and aim server is, when you connect to the web server the client (your browser) has to send these commands right away, and only THEN the server replies. In aim it seems to be the other way around, the aim client won't send anything until it receives some encrypted (or I think it's encrypted anyway) command from the server first, and THEN once it recognizes it, the client replies and logs in etc.
I tested it by opening a socket and listening on port 5190 and having the aim client connect to localhost, and it sent absolutely nothing. And when I try opening a socket to the aim server (login.oscar.aol.com) the server sends 4 characters that seem to be slightly different each time I connect to it, and they look something like this: *èZ and always start with an asterisk (*).
That's as far as I got by myself in terms of figuring out what commands I need to send to the server to login and interact with it, and as you can see, I didn't get very far! Any and all help would be greatly appreciated!
Correct me if I'm wrong, but isn't mIRC an IRC program? You need a coding language to make a bot (I reccomend PERL). If you decide to use PERL. Check out the Net::OSCAR documentation. It allows you to connect to AIM, send IMs, and do almost everything you could normally do on AIM. And to connect to the website, try LWP::Simple, and LWP::UserAgent
In Net::OSCAR, to send an IM you would use something like this:
Code:
$oscar->send_im($client,$reply);
$client would be the person who sent you the IM, and $reply would be a reply set earlier in the code.
Well it's just that I know mIRC very well, and I'd have to learn pearl! mIRC is an irc client yes, but it has a very powerful scripting language which is a combination of unix and c++. I've seen it done before, that is, aim "bot" has been already created for mirc and it worked pretty well, but that was a few years ago and I can't find any trace of it anymore.
But thanks for your advice, if I am unable to find any documentation or help to do this in mirc, I'll prolly switch to what you said and do that instead
And I don't need any help with the mirc scripting, but very specifically with the pure commands that I can send to the aim server that it will recognize and which will make it do what I want, like authenticate my SN/password and message people. Those same commands would even work in telnet, if you were to establish a manual telnet connection to the aim server and type them in there.
The example you gave was an Net::OSCAR-only scripting language command, and when you enter that into Net::OSCAR or pearl (whatever the language/program you're using may be), it then translates it into the pure server commands and sends those commands to the server to make it react and do what you want. My question is, what are those "pure" server calls for the aim servers, would anyone know where to get a list of them or something like that?
Because anyone who wants to make an aim bot from *scratch* would require those commands, and by "from scratch" I mean without utilizing any tools or scripting languages that were designed specificailly for that purpose. Say I just had myself and my c++ compiler to work with, then I'd need those "pure" commands!
AIM has two protocols: OSCAR, and TOC (TOC is an acronym for "Talk to OSCAR"). The OSCAR protocol is the one that AOL Instant Messenger uses, it's the one with buddy icons, typing statuses, and all the other good stuff.
The TOC protocol has support for the basics. It can:
- Sign in/out
- Send and receive IM's
- Set and get AIM profiles
- Manage buddylists with signon/off handlers for buddies
- Use the AIM chat rooms
- Block/unblock and warn
There's mostly it. Basicly, TOC is OSCAR but without the buddy icons and other newer features of AIM.
The point I'm getting at... OSCAR's protocol is the encrypted one. I did some research on the OSCAR protocol, and the server sends a unique identifier for your connection, which is why the messages are different every time. In addition, on the client's side, with each command sent you have to send an incrementing number, starting at 0x0000 up to 0xFFFF and then back to 0x0000 again.
You can search Google for "OSCAR protocol" or continue packet sniffing.
The TOC protocol on the other hand is a lot more simple. Instead of sending garbled up encrypted crap, TOC sends messages to the server like "toc_signon" and "toc_send_im" and "toc_chat_join," etc.
http://www.runabot.com/aim-toc-protocol.html
There's some only slightly outdated TOC documentation. You can also look at the source of Net::AIM, it only has 3 modules altogether as opposed to the 10 or so modules of Net::OSCAR, but Perl is similar to C++ and I think if you have problems with the TOC server you can pick up from the Perl module. _________________ Current Site (2008) http://www.cuvou.com/