2005-10-12 15:22:00 -04:00
|
|
|
! All Talk
|
|
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
IN: aim-internals
|
2005-10-16 23:31:30 -04:00
|
|
|
USING: kernel sequences lists stdio prettyprint strings namespaces math unparser threads vectors errors parser interpreter test io crypto words hashtables inspector aim-internals generic queues ;
|
2005-09-18 20:23:06 -04:00
|
|
|
|
|
|
|
|
SYMBOL: username
|
|
|
|
|
SYMBOL: password
|
|
|
|
|
SYMBOL: conn
|
|
|
|
|
SYMBOL: seq-num
|
|
|
|
|
SYMBOL: stage-num
|
|
|
|
|
SYMBOL: login-key
|
|
|
|
|
SYMBOL: aim-chat-ip
|
|
|
|
|
SYMBOL: aim-chat-port
|
|
|
|
|
SYMBOL: auth-code
|
2005-10-16 19:41:35 -04:00
|
|
|
! snac
|
2005-09-19 15:33:06 -04:00
|
|
|
SYMBOL: family
|
|
|
|
|
SYMBOL: opcode
|
2005-10-16 19:41:35 -04:00
|
|
|
SYMBOL: snac-flags
|
|
|
|
|
SYMBOL: snac-request-id
|
|
|
|
|
|
2005-09-20 02:23:59 -04:00
|
|
|
SYMBOL: name
|
|
|
|
|
SYMBOL: message
|
2005-10-13 07:16:41 -04:00
|
|
|
SYMBOL: encoding
|
|
|
|
|
SYMBOL: warning
|
2005-10-16 23:31:30 -04:00
|
|
|
SYMBOL: buddy-hash-name
|
|
|
|
|
SYMBOL: buddy-hash-id
|
|
|
|
|
SYMBOL: group-hash-name
|
|
|
|
|
SYMBOL: group-hash-id
|
|
|
|
|
SYMBOL: banned-hash-name
|
|
|
|
|
SYMBOL: banned-hash-id
|
2005-10-13 07:16:41 -04:00
|
|
|
SYMBOL: channel
|
|
|
|
|
SYMBOL: icbm-cookie
|
|
|
|
|
SYMBOL: message-type
|
|
|
|
|
SYMBOL: my-ip
|
|
|
|
|
SYMBOL: blue-ip
|
|
|
|
|
SYMBOL: file-transfer-cancelled
|
|
|
|
|
SYMBOL: direct-connect-cancelled
|
|
|
|
|
SYMBOL: remote-internal-ip
|
|
|
|
|
SYMBOL: remote-external-ip
|
2005-10-16 19:41:35 -04:00
|
|
|
SYMBOL: ssi-length
|
2005-10-16 23:31:30 -04:00
|
|
|
SYMBOL: modify-queue
|
2005-10-16 19:41:35 -04:00
|
|
|
|
|
|
|
|
TUPLE: group name id ;
|
|
|
|
|
TUPLE: buddy name id gid capabilities buddy-icon online ;
|
2005-09-19 15:33:06 -04:00
|
|
|
|
2005-10-03 23:16:40 -04:00
|
|
|
: aim-login-server "login.oscar.aol.com" ; inline
|
|
|
|
|
: icq-login-server "login.icq.com" ; inline
|
|
|
|
|
: login-port 5190 ; inline
|
|
|
|
|
: client-md5-string "AOL Instant Messenger (SM)" ; inline
|
|
|
|
|
: client-id-string "AOL Instant Messenger, version 5.5 3595/WIN32" ; inline
|
|
|
|
|
: client-id-num HEX: 109 ; inline
|
|
|
|
|
: client-major-ver 5 ; inline
|
|
|
|
|
: client-minor-ver 5 ; inline
|
|
|
|
|
: client-lesser-ver 0 ; inline
|
|
|
|
|
: client-build-num 3595 ; inline
|
|
|
|
|
: client-distro-num 260 ; inline
|
|
|
|
|
: client-language "en" ; inline
|
|
|
|
|
: client-country "us" ; inline
|
|
|
|
|
: client-ssi-flag 1 ; inline
|
|
|
|
|
: client-charset "text/aolrtf; charset=\"us-ascii\"" ; inline
|
2005-10-13 07:16:41 -04:00
|
|
|
: file-transfer-url "http://dynamic.aol.com/cgi/redir?http://www.aol.com/aim/filetransfer/antivirus.html" ; inline
|
|
|
|
|
! : akadns-aol.com "http://www.aol.com.websys.akadns.net" ;
|
|
|
|
|
! 205.188.210.203
|
|
|
|
|
: aim-file-server-port 5190 ; inline
|
|
|
|
|
|
2005-10-12 15:22:00 -04:00
|
|
|
! Family names from ethereal
|
|
|
|
|
: family-names
|
|
|
|
|
{{
|
2005-10-16 19:41:35 -04:00
|
|
|
[[ 1 "Generic" ]] [[ 2 "Location" ]] [[ 3 "Buddylist" ]]
|
|
|
|
|
[[ 4 "Messaging" ]] [[ 6 "Invitation" ]] [[ 8 "Popup" ]]
|
|
|
|
|
[[ 9 "BOS" ]] [[ 10 "User Lookup" ]] [[ 11 "Stats" ]]
|
|
|
|
|
[[ 12 "Translate" ]] [[ 19 "SSI" ]] [[ 21 "ICQ" ]]
|
|
|
|
|
[[ 34 "Unknown Family" ]] }} ;
|
|
|
|
|
|
2005-10-16 23:31:30 -04:00
|
|
|
: ch>lower ( int -- int ) dup LETTER? [ HEX: 20 + ] when ;
|
|
|
|
|
: ch>upper ( int -- int ) dup letter? [ HEX: 20 - ] when ;
|
|
|
|
|
: >lower ( seq -- seq ) [ ch>lower ] map ;
|
|
|
|
|
: >upper ( seq -- seq ) [ ch>upper ] map ;
|
|
|
|
|
|
|
|
|
|
: sanitize-name ( name -- name ) HEX: 20 swap remove >lower ;
|
|
|
|
|
|
2005-10-16 19:41:35 -04:00
|
|
|
: hash-swap ( hash -- hash )
|
|
|
|
|
[ [ unswons cons , ] hash-each ] { } make alist>hash ;
|
|
|
|
|
|
|
|
|
|
: 2list>hash ( keys values -- hash )
|
|
|
|
|
{{ }} clone -rot [ swap pick set-hash ] 2each ;
|
2005-10-12 15:22:00 -04:00
|
|
|
|
|
|
|
|
: capability-names
|
2005-10-13 07:16:41 -04:00
|
|
|
{{
|
|
|
|
|
[[ "Unknown1" HEX: 094601054c7f11d18222444553540000 ]]
|
|
|
|
|
[[ "Games" HEX: 0946134a4c7f11d18222444553540000 ]]
|
|
|
|
|
[[ "Send Buddy List" HEX: 0946134b4c7f11d18222444553540000 ]]
|
|
|
|
|
[[ "Chat" HEX: 748f2420628711d18222444553540000 ]]
|
|
|
|
|
[[ "AIM/ICQ Interoperability" HEX: 0946134d4c7f11d18222444553540000 ]]
|
|
|
|
|
[[ "Voice Chat" HEX: 094613414c7f11d18222444553540000 ]]
|
|
|
|
|
[[ "iChat" HEX: 094600004c7f11d18222444553540000 ]]
|
|
|
|
|
[[ "Send File" HEX: 094613434c7f11d18222444553540000 ]]
|
|
|
|
|
[[ "Unknown2" HEX: 094601ff4c7f11d18222444553540000 ]]
|
|
|
|
|
[[ "Live Video" HEX: 094601014c7f11d18222444553540000 ]]
|
|
|
|
|
[[ "Direct Instant Messaging" HEX: 094613454c7f11d18222444553540000 ]]
|
|
|
|
|
[[ "Unknown3" HEX: 094601034c7f11d18222444553540000 ]]
|
|
|
|
|
[[ "Buddy Icon" HEX: 094613464c7f11d18222444553540000 ]]
|
|
|
|
|
[[ "Add-Ins" HEX: 094613474c7f11d18222444553540000 ]]
|
|
|
|
|
}} ;
|
|
|
|
|
|
2005-10-16 19:41:35 -04:00
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
: capability-values
|
2005-10-16 19:41:35 -04:00
|
|
|
capability-names hash-swap ;
|
|
|
|
|
|
|
|
|
|
: capability-abbrevs
|
2005-10-12 15:22:00 -04:00
|
|
|
{{
|
2005-10-16 19:41:35 -04:00
|
|
|
[[ CHAR: A "Voice" ]]
|
|
|
|
|
[[ CHAR: C "Send File" ]]
|
|
|
|
|
[[ CHAR: E "AIM Direct IM" ]]
|
|
|
|
|
[[ CHAR: F "Buddy Icon" ]]
|
|
|
|
|
[[ CHAR: G "Add-Ins" ]]
|
|
|
|
|
[[ CHAR: H "Get File" ]]
|
|
|
|
|
[[ CHAR: K "Send Buddy List" ]]
|
2005-10-12 15:22:00 -04:00
|
|
|
}} ;
|
|
|
|
|
|
2005-10-16 19:41:35 -04:00
|
|
|
|
2005-10-07 04:31:14 -04:00
|
|
|
: initialize-aim ( username password -- )
|
|
|
|
|
password set username set
|
2005-10-16 23:31:30 -04:00
|
|
|
{{ }} clone buddy-hash-name set
|
|
|
|
|
{{ }} clone buddy-hash-id set
|
|
|
|
|
{{ }} clone group-hash-name set
|
|
|
|
|
{{ }} clone group-hash-id set
|
|
|
|
|
{{ }} clone banned-hash-name set
|
|
|
|
|
{{ }} clone banned-hash-id set
|
|
|
|
|
<queue> modify-queue set
|
2005-10-12 15:22:00 -04:00
|
|
|
! 65535 random-int seq-num set
|
|
|
|
|
0 seq-num set
|
2005-10-07 04:31:14 -04:00
|
|
|
1 stage-num set ;
|
2005-09-18 20:23:06 -04:00
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
: prepend-aim-protocol ( data -- )
|
2005-09-18 20:23:06 -04:00
|
|
|
[
|
|
|
|
|
HEX: 2a >byte
|
|
|
|
|
stage-num get >byte
|
2005-10-03 23:16:40 -04:00
|
|
|
seq-num get >short
|
|
|
|
|
] "" make
|
|
|
|
|
seq-num [ 1+ ] change
|
|
|
|
|
swap dup >r length (>short) r> append append ;
|
2005-09-18 20:23:06 -04:00
|
|
|
|
2005-10-07 04:31:14 -04:00
|
|
|
: (send-aim) ( str -- )
|
2005-10-12 15:22:00 -04:00
|
|
|
"Sending: " print
|
|
|
|
|
dup hexdump
|
2005-10-07 04:31:14 -04:00
|
|
|
conn get [ stream-write ] keep stream-flush ;
|
2005-09-18 20:23:06 -04:00
|
|
|
|
2005-09-22 16:10:20 -04:00
|
|
|
: send-aim ( data -- )
|
2005-10-13 07:16:41 -04:00
|
|
|
make-packet prepend-aim-protocol (send-aim) terpri ;
|
2005-09-22 16:10:20 -04:00
|
|
|
|
2005-09-18 20:23:06 -04:00
|
|
|
: with-aim ( quot -- )
|
2005-09-19 22:58:20 -04:00
|
|
|
conn get swap with-unscoped-stream ;
|
2005-09-19 15:33:06 -04:00
|
|
|
|
2005-09-18 20:23:06 -04:00
|
|
|
: read-aim ( -- bc )
|
2005-10-13 07:16:41 -04:00
|
|
|
[ [
|
2005-09-19 15:33:06 -04:00
|
|
|
head-byte drop
|
|
|
|
|
head-byte drop
|
|
|
|
|
head-short drop
|
|
|
|
|
head-short head-string
|
2005-10-13 07:16:41 -04:00
|
|
|
] with-aim ] catch [ "Socket error" print throw ] when
|
2005-10-12 15:22:00 -04:00
|
|
|
"Received: " write dup hexdump ;
|
2005-09-19 15:33:06 -04:00
|
|
|
|
2005-09-18 20:23:06 -04:00
|
|
|
: make-snac ( fam subtype flags req-id -- )
|
2005-10-03 23:16:40 -04:00
|
|
|
4vector { (>short) (>short) (>short) (>int) } papply % ;
|
2005-09-18 20:23:06 -04:00
|
|
|
|
2005-09-19 15:33:06 -04:00
|
|
|
: parse-snac ( stream -- )
|
|
|
|
|
head-short family set
|
|
|
|
|
head-short opcode set
|
2005-10-16 19:41:35 -04:00
|
|
|
head-short snac-flags set
|
|
|
|
|
head-int snac-request-id set ;
|
2005-09-18 20:23:06 -04:00
|
|
|
|
2005-10-07 04:31:14 -04:00
|
|
|
: (unhandled-opcode) ( str -- )
|
2005-10-10 15:34:07 -04:00
|
|
|
"Family: " write family get unparse write
|
|
|
|
|
", opcode: " write opcode get unparse writeln
|
2005-10-13 07:16:41 -04:00
|
|
|
head-contents hexdump ;
|
2005-09-19 15:33:06 -04:00
|
|
|
|
|
|
|
|
: unhandled-opcode ( -- )
|
|
|
|
|
"Unhandled opcode: " write (unhandled-opcode) ;
|
|
|
|
|
|
|
|
|
|
: incomplete-opcode ( -- )
|
|
|
|
|
"Incomplete handling: " write (unhandled-opcode) ;
|
|
|
|
|
|
|
|
|
|
: unhandled-family-opcode ( -- )
|
2005-10-10 15:34:07 -04:00
|
|
|
"Unhandled family: " write family get unparse writeln
|
2005-09-19 15:33:06 -04:00
|
|
|
unhandled-opcode ;
|
|
|
|
|
|
2005-10-16 23:31:30 -04:00
|
|
|
GENERIC: get-buddy
|
|
|
|
|
M: integer get-buddy ( bid -- <buddy> )
|
|
|
|
|
buddy-hash-id get hash ;
|
|
|
|
|
M: object get-buddy ( name -- <buddy> )
|
|
|
|
|
sanitize-name buddy-hash-name get hash ;
|
|
|
|
|
|
|
|
|
|
GENERIC: get-group
|
|
|
|
|
M: integer get-group ( bid -- <group> )
|
|
|
|
|
group-hash-id get hash ;
|
|
|
|
|
M: object get-group ( name -- <group> )
|
|
|
|
|
sanitize-name group-hash-name get hash ;
|
|
|
|
|
|
|
|
|
|
GENERIC: get-banned
|
|
|
|
|
M: integer get-banned ( bid -- <buddy> )
|
|
|
|
|
banned-hash-id get hash ;
|
|
|
|
|
M: object get-banned ( name -- <buddy> )
|
|
|
|
|
sanitize-name banned-hash-name get hash ;
|
|
|
|
|
|
|
|
|
|
: buddy-name? ( name -- bool )
|
|
|
|
|
get-buddy >boolean ;
|
|
|
|
|
|
|
|
|
|
: group-name? ( name -- bool )
|
|
|
|
|
get-group >boolean ;
|
|
|
|
|
|
|
|
|
|
: banned-name? ( name -- bool )
|
|
|
|
|
get-banned >boolean ;
|
|
|
|
|
|
|
|
|
|
: random-buddy-id ( -- id )
|
|
|
|
|
HEX: fff0 random-int 1+ dup get-buddy [ drop random-buddy-id ] when ;
|
|
|
|
|
|
|
|
|
|
: random-group-id ( -- id )
|
|
|
|
|
HEX: fff0 random-int 1+ dup get-group [ drop random-group-id ] when ;
|
|
|
|
|
|
|
|
|
|
|
2005-10-07 18:45:47 -04:00
|
|
|
! Events
|
|
|
|
|
: buddy-signon ( name -- )
|
2005-10-16 23:31:30 -04:00
|
|
|
get-buddy dup [ t swap set-buddy-online ] [ drop "Can't find buddy in buddylist: " write name get writeln ] if ;
|
2005-10-07 18:45:47 -04:00
|
|
|
|
|
|
|
|
: buddy-signoff ( name -- )
|
2005-10-16 23:31:30 -04:00
|
|
|
get-buddy dup [ f swap set-buddy-online ] [ drop "Can't find buddy in buddylist: " write name get writeln ] if ;
|
2005-10-07 18:45:47 -04:00
|
|
|
|
2005-10-16 23:31:30 -04:00
|
|
|
: print-buddylist
|
|
|
|
|
! group-list get [ [ buddy-name , ] each ] { } make
|
|
|
|
|
! [ buddylist get hash-keys string-sort [ , ] each ] { } make [ drop ] simple-outliner ;
|
2005-10-16 19:41:35 -04:00
|
|
|
;
|
2005-10-07 18:45:47 -04:00
|
|
|
|
2005-10-03 23:16:40 -04:00
|
|
|
: family-table ( -- hash )
|
|
|
|
|
{{ }} ;
|
2005-09-18 20:23:06 -04:00
|
|
|
|
2005-10-03 23:16:40 -04:00
|
|
|
: FAMILY: ( -- fam# )
|
2005-10-10 15:34:07 -04:00
|
|
|
scan 10 base> swons dup car family-table hash dup [
|
2005-10-03 23:16:40 -04:00
|
|
|
drop
|
|
|
|
|
] [
|
|
|
|
|
drop {{ }} clone over car family-table set-hash
|
|
|
|
|
] if ; parsing
|
2005-09-19 22:58:20 -04:00
|
|
|
|
2005-10-03 23:16:40 -04:00
|
|
|
: OPCODE: ( fam# -- )
|
2005-10-10 15:34:07 -04:00
|
|
|
car family-table hash word scan 10 base> rot set-hash f ; parsing
|
|
|
|
|
|
|
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
! Generic, Capabilities
|
|
|
|
|
: send-generic-capabilities
|
2005-10-10 15:34:07 -04:00
|
|
|
[
|
2005-10-13 07:16:41 -04:00
|
|
|
1 HEX: 17 0 HEX: 17 make-snac
|
|
|
|
|
[ 1 4 HEX: 13 3 2 1 3 1 4 1 6 1 8 1 9 1 HEX: a 1 HEX: b 1 ]
|
|
|
|
|
[ >short ] each
|
|
|
|
|
] send-aim ;
|
2005-10-10 15:34:07 -04:00
|
|
|
|
2005-10-10 17:21:38 -04:00
|
|
|
: (handle-supported-families)
|
|
|
|
|
unscoped-stream get empty? [
|
2005-10-12 15:22:00 -04:00
|
|
|
head-short family-names hash .
|
2005-10-10 17:21:38 -04:00
|
|
|
(handle-supported-families)
|
|
|
|
|
] unless ;
|
|
|
|
|
|
|
|
|
|
: handle-supported-families
|
|
|
|
|
"Families: " print
|
2005-10-13 07:16:41 -04:00
|
|
|
(handle-supported-families)
|
|
|
|
|
send-generic-capabilities
|
|
|
|
|
; FAMILY: 1 OPCODE: 3
|
|
|
|
|
|
|
|
|
|
: send-requests ( -- )
|
|
|
|
|
! Self Info Request
|
|
|
|
|
[ 1 HEX: e 0 HEX: e make-snac ] send-aim
|
|
|
|
|
|
|
|
|
|
! Request Rights
|
|
|
|
|
[ HEX: 13 2 0 2 make-snac ] send-aim
|
|
|
|
|
|
|
|
|
|
! Request List
|
|
|
|
|
[ HEX: 13 4 0 HEX: 3efb0004 make-snac ] send-aim
|
2005-10-10 17:21:38 -04:00
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
! Location, Request Rights
|
|
|
|
|
[ 2 2 0 2 make-snac ] send-aim
|
|
|
|
|
|
|
|
|
|
! Buddylist Service, Rights Request
|
|
|
|
|
[ 3 2 0 2 make-snac ] send-aim
|
|
|
|
|
|
|
|
|
|
! Messaging, Request Parameter Info
|
|
|
|
|
[ 4 4 0 4 make-snac ] send-aim
|
|
|
|
|
|
|
|
|
|
! Privacy Management Service, Rights Query
|
|
|
|
|
[ 9 2 0 2 make-snac ] send-aim ;
|
|
|
|
|
|
|
|
|
|
: handle-1-7
|
|
|
|
|
[
|
|
|
|
|
1 8 0 8 make-snac
|
|
|
|
|
head-short dup [
|
|
|
|
|
! "Rate Classes: " write
|
|
|
|
|
head-short >short ! rate class id
|
|
|
|
|
head-int drop ! window size
|
|
|
|
|
head-int drop ! clear level
|
|
|
|
|
head-int drop ! alert level
|
|
|
|
|
head-int drop ! limit level
|
|
|
|
|
head-int drop ! disconnect level
|
|
|
|
|
head-int drop ! current level
|
|
|
|
|
head-int drop ! max level
|
|
|
|
|
head-int drop ! last time
|
|
|
|
|
head-byte drop ! current state
|
|
|
|
|
] repeat
|
|
|
|
|
[
|
|
|
|
|
head-short drop ( rate class id again )
|
|
|
|
|
! Pairs
|
|
|
|
|
head-short [ head-int drop ] repeat
|
|
|
|
|
] repeat
|
|
|
|
|
] send-aim ( BOS, Rights Query )
|
|
|
|
|
send-requests ; FAMILY: 1 OPCODE: 7
|
|
|
|
|
|
|
|
|
|
! : handle-1-15
|
|
|
|
|
! head-byte head-string drop
|
|
|
|
|
! ; FAMILY: 1 OPCODE: 15
|
|
|
|
|
|
|
|
|
|
: (handle-reply-info)
|
|
|
|
|
head-byte head-string name set
|
|
|
|
|
"Warning: " write head-short unparse writeln
|
|
|
|
|
head-short dup unparse print
|
|
|
|
|
[
|
|
|
|
|
head-short
|
|
|
|
|
head-short head-string <string-reader> [
|
|
|
|
|
{
|
|
|
|
|
! { [ 1 = ] [ drop ] }
|
|
|
|
|
{ [ t ] [ " Unhandled tlv 1-15: " write unparse writeln head-contents hexdump ] }
|
|
|
|
|
} cond
|
|
|
|
|
] with-unscoped-stream
|
|
|
|
|
] repeat ;
|
2005-10-10 17:21:38 -04:00
|
|
|
|
2005-10-10 15:34:07 -04:00
|
|
|
! : handle-reply-info
|
|
|
|
|
! "HANDLE REPLY INFO" print
|
|
|
|
|
! 4 [ head-short drop ] repeat
|
|
|
|
|
! (handle-reply-info)
|
|
|
|
|
! ; FAMILY: 1 OPCODE: 15
|
|
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
! message of the day
|
|
|
|
|
: handle-1-19
|
|
|
|
|
7 [ head-short drop ] repeat
|
|
|
|
|
! Generic, Rate Info Request
|
|
|
|
|
[ 1 6 0 6 make-snac ] send-aim ; FAMILY: 1 OPCODE: 19
|
|
|
|
|
|
|
|
|
|
! capabilities ack
|
|
|
|
|
: handle-1-24
|
|
|
|
|
"Unhandled ack: " write head-contents writeln
|
|
|
|
|
; FAMILY: 1 OPCODE: 24
|
|
|
|
|
|
|
|
|
|
! : handle-1-33
|
|
|
|
|
! AIM Email
|
|
|
|
|
! [ 1 4 HEX: 02cc 4 make-snac HEX: 18 >short ] send-aim
|
|
|
|
|
|
|
|
|
|
! AIM Location
|
|
|
|
|
! [ 2 HEX: b HEX: 446d HEX: b make-snac username get length >byte username get % ] send-aim
|
|
|
|
|
! ; FAMILY: 1 OPCODE: 33
|
|
|
|
|
|
2005-10-10 15:34:07 -04:00
|
|
|
|
2005-10-10 17:21:38 -04:00
|
|
|
: handle-2-1
|
|
|
|
|
"2-1: " write head-short unparse writeln
|
|
|
|
|
; FAMILY: 2 OPCODE: 1
|
2005-10-10 15:34:07 -04:00
|
|
|
|
2005-10-10 17:21:38 -04:00
|
|
|
! : handle-
|
|
|
|
|
! ; FAMILY: 2 OPCODE: 3
|
2005-09-19 22:58:20 -04:00
|
|
|
|
2005-10-03 23:16:40 -04:00
|
|
|
! : handle-away-message
|
2005-09-22 16:10:20 -04:00
|
|
|
! head-byte head-string name set
|
2005-10-10 15:34:07 -04:00
|
|
|
! name get write "'s away message: " write
|
|
|
|
|
! ; FAMILY: 2 OPCODE: 6
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
: handle-capabilities
|
|
|
|
|
unscoped-stream get empty? [
|
2005-10-13 07:16:41 -04:00
|
|
|
head-u128 capability-values hash dup [ "Unknown Capability" nip ] unless
|
2005-10-12 15:22:00 -04:00
|
|
|
writeln handle-capabilities
|
2005-10-10 15:34:07 -04:00
|
|
|
] unless ;
|
|
|
|
|
|
|
|
|
|
: handle-29
|
|
|
|
|
"(29)" print
|
|
|
|
|
head-short drop
|
|
|
|
|
head-byte drop
|
|
|
|
|
head-byte head-string drop
|
|
|
|
|
unscoped-stream get empty? [ handle-29 ] unless ;
|
2005-09-22 16:10:20 -04:00
|
|
|
|
2005-10-16 19:41:35 -04:00
|
|
|
: handle-abbrev-capabilities
|
|
|
|
|
unscoped-stream get empty? [
|
|
|
|
|
head-short .h
|
|
|
|
|
handle-abbrev-capabilities
|
|
|
|
|
] unless ;
|
|
|
|
|
|
2005-10-03 23:16:40 -04:00
|
|
|
: handle-buddy-status
|
2005-09-20 02:23:59 -04:00
|
|
|
head-byte head-string name set
|
|
|
|
|
head-short drop
|
|
|
|
|
head-short
|
|
|
|
|
[
|
|
|
|
|
head-short
|
|
|
|
|
head-short head-string <string-reader> [
|
|
|
|
|
{
|
2005-09-29 16:17:28 -04:00
|
|
|
{ [ dup 1 = ] [ drop name get write head-short HEX: 20 bitand 1 > [ " is away." ] [ " is online." ] if writeln ] }
|
2005-10-10 15:34:07 -04:00
|
|
|
{ [ dup 2 = ] [ drop "Member since: " write head-short unparse writeln ] }
|
2005-10-07 18:45:47 -04:00
|
|
|
{ [ dup 3 = ] [ drop name get write " went online at " write head-int unparse writeln name get buddy-signon ] }
|
2005-09-29 16:17:28 -04:00
|
|
|
{ [ dup 4 = ] [ drop name get write " has been idle for " write head-short unparse write " minutes." writeln ] }
|
2005-10-10 15:34:07 -04:00
|
|
|
{ [ dup 6 = ] [ drop name get write ": (6): " write head-short unparse write " " write head-short unparse writeln ] }
|
2005-10-16 19:41:35 -04:00
|
|
|
{ [ dup 13 = ] [ drop "Capabilities3:" print handle-capabilities ] }
|
|
|
|
|
{ [ dup 14 = ] [ drop "Capabilities4:" print handle-capabilities ] }
|
2005-10-10 15:34:07 -04:00
|
|
|
{ [ dup 15 = ] [ drop name get write " has been online for " write head-int unparse write " seconds." writeln ] }
|
2005-10-16 19:41:35 -04:00
|
|
|
{ [ dup 25 = ] [ drop "Abbreviated capabilities: " write handle-abbrev-capabilities ] }
|
2005-10-10 15:34:07 -04:00
|
|
|
{ [ dup 27 = ] [ drop "(27): " write 4 [ head-int unparse write " " write ] repeat terpri ] }
|
|
|
|
|
{ [ dup 29 = ] [ drop handle-29 ] }
|
2005-10-13 07:16:41 -04:00
|
|
|
{ [ t ] [ " Unhandled tlv 3h-bh: " write unparse writeln head-contents hexdump ] }
|
2005-09-20 02:23:59 -04:00
|
|
|
} cond
|
|
|
|
|
] with-unscoped-stream
|
2005-10-10 15:34:07 -04:00
|
|
|
] repeat ; FAMILY: 3 OPCODE: 11
|
2005-09-20 02:23:59 -04:00
|
|
|
|
2005-10-03 23:16:40 -04:00
|
|
|
: handle-buddy-signoff ( -- )
|
2005-09-20 02:23:59 -04:00
|
|
|
head-byte head-string name set
|
|
|
|
|
head-short drop
|
|
|
|
|
head-short
|
|
|
|
|
[
|
|
|
|
|
head-short
|
|
|
|
|
head-short head-string <string-reader> [
|
|
|
|
|
{
|
2005-10-07 18:45:47 -04:00
|
|
|
{ [ dup 1 = ] [ drop name get write " signed off." writeln name get buddy-signoff ] }
|
2005-09-20 02:23:59 -04:00
|
|
|
{ [ dup HEX: 1d = ] [ drop ] }
|
2005-10-13 07:16:41 -04:00
|
|
|
{ [ t ] [ "Unhandled tlv 3h-ch: " write unparse writeln head-contents hexdump ] }
|
2005-09-20 02:23:59 -04:00
|
|
|
} cond
|
|
|
|
|
] with-unscoped-stream
|
2005-10-10 15:34:07 -04:00
|
|
|
] repeat ; FAMILY: 3 OPCODE: 12
|
2005-09-19 22:58:20 -04:00
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
: parse-family-4h-header
|
2005-09-19 15:33:06 -04:00
|
|
|
head-short drop
|
|
|
|
|
head-short drop
|
|
|
|
|
head-short drop
|
|
|
|
|
head-short drop
|
2005-10-13 07:16:41 -04:00
|
|
|
8 head-string drop
|
|
|
|
|
head-short channel set ;
|
2005-09-19 22:58:20 -04:00
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
: parse-message-text ( -- str )
|
|
|
|
|
head-short drop head-short drop head-contents ;
|
2005-09-19 22:58:20 -04:00
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
: parse-message-tlv2
|
2005-09-19 22:58:20 -04:00
|
|
|
unscoped-stream get empty? [
|
|
|
|
|
head-byte
|
|
|
|
|
head-byte drop ! fragVer
|
|
|
|
|
head-short head-string <string-reader>
|
|
|
|
|
[
|
|
|
|
|
{
|
2005-10-13 07:16:41 -04:00
|
|
|
{ [ dup 1 = ] [ drop parse-message-text message set ] }
|
2005-09-19 22:58:20 -04:00
|
|
|
{ [ dup 5 = ] [ drop ] }
|
2005-10-10 15:34:07 -04:00
|
|
|
{ [ t ] [ "Unknown frag: " write unparse writeln unscoped-stream get contents hexdump ] }
|
2005-09-19 22:58:20 -04:00
|
|
|
} cond
|
|
|
|
|
] with-unscoped-stream
|
2005-10-13 07:16:41 -04:00
|
|
|
parse-message-tlv2
|
|
|
|
|
] unless ;
|
|
|
|
|
|
|
|
|
|
: handle-file-transfer-start-tlvs
|
|
|
|
|
unscoped-stream get empty? [
|
|
|
|
|
head-short
|
|
|
|
|
head-short head-string <string-reader> [
|
|
|
|
|
file-transfer-cancelled off
|
|
|
|
|
dup unparse write ": " write
|
|
|
|
|
{
|
|
|
|
|
{ [ dup 2 = ] [ drop head-int int>ip dup my-ip set "my ip: " write write ] }
|
|
|
|
|
{ [ dup 3 = ] [ drop head-int int>ip dup blue-ip set "blue.aol ip: " write write ] }
|
|
|
|
|
{ [ dup 4 = ] [ drop head-int unparse write ] }
|
|
|
|
|
{ [ dup 5 = ] [ drop head-short unparse write ] }
|
|
|
|
|
{ [ dup 10 = ] [ drop head-short unparse write ] }
|
|
|
|
|
{ [ dup 11 = ] [ drop head-short unparse . "Transfer canclled" print file-transfer-cancelled on ] }
|
|
|
|
|
{ [ dup 12 = ] [ drop head-contents message set "Message: " write message get writeln ] }
|
|
|
|
|
{ [ dup 13 = ] [ drop head-contents encoding set ] }
|
|
|
|
|
{ [ dup 14 = ] [ drop head-short unparse write ] }
|
|
|
|
|
{ [ dup 15 = ] [ drop ( do nothing ) ] }
|
|
|
|
|
{ [ dup 22 = ] [ drop head-int unparse write ] }
|
|
|
|
|
{ [ dup 23 = ] [ drop head-short unparse write ] }
|
|
|
|
|
{ [ dup 10001 = ] [ drop head-contents write ] }
|
|
|
|
|
{ [ dup 10002 = ] [ drop head-contents write ] }
|
|
|
|
|
{ [ t ] [ "Unhandled file transfer tlv: " write unparse writeln head-contents hexdump ] }
|
|
|
|
|
} cond terpri
|
|
|
|
|
] with-unscoped-stream
|
|
|
|
|
handle-file-transfer-start-tlvs
|
|
|
|
|
] unless ;
|
|
|
|
|
|
|
|
|
|
: send-file-transfer-start
|
|
|
|
|
"STARTING FILE TRANSFER" print
|
|
|
|
|
[
|
|
|
|
|
4 6 0 HEX: 778f0006 make-snac
|
|
|
|
|
icbm-cookie get >longlong
|
|
|
|
|
2 >short
|
|
|
|
|
name get length >byte
|
|
|
|
|
name get %
|
|
|
|
|
5 >short
|
|
|
|
|
56 >short
|
|
|
|
|
0 >short
|
|
|
|
|
icbm-cookie get >longlong
|
|
|
|
|
"Send File" capability-names hash >u128
|
|
|
|
|
10 >short 2 >short 2 >short
|
|
|
|
|
2 >short 4 >short 0 >int
|
|
|
|
|
22 >short 4 >short HEX: ffffffff >int ! gateway?
|
|
|
|
|
3 >short 4 >short 0 >int
|
|
|
|
|
] send-aim ;
|
|
|
|
|
|
|
|
|
|
: handle-chat-start-tlvs
|
|
|
|
|
unscoped-stream get empty? [
|
|
|
|
|
head-short
|
|
|
|
|
head-short head-string <string-reader> [
|
|
|
|
|
dup unparse write ": " write
|
|
|
|
|
{
|
|
|
|
|
{ [ dup 10 = ] [ drop head-short unparse write ] }
|
|
|
|
|
{ [ dup 12 = ] [ drop head-contents message set ] }
|
|
|
|
|
{ [ dup 13 = ] [ drop head-contents encoding set ] }
|
|
|
|
|
{ [ dup 14 = ] [ drop head-byte unparse write ] }
|
|
|
|
|
{ [ dup 15 = ] [ drop ( do nothing ) ] }
|
|
|
|
|
{ [ dup 10001 = ] [ drop head-contents hexdump ] }
|
|
|
|
|
{ [ t ] [ "Unhandled chat transfer tlv: " write unparse writeln head-contents hexdump ] }
|
|
|
|
|
} cond terpri
|
|
|
|
|
] with-unscoped-stream
|
|
|
|
|
handle-chat-start-tlvs
|
2005-09-19 22:58:20 -04:00
|
|
|
] unless ;
|
|
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
: handle-direct-start-tlvs
|
|
|
|
|
unscoped-stream get empty? [
|
|
|
|
|
head-short
|
|
|
|
|
head-short head-string <string-reader> [
|
|
|
|
|
dup unparse write ": " write
|
|
|
|
|
{
|
|
|
|
|
{ [ dup 2 = ] [ drop head-int int>ip dup remote-internal-ip set "remote internal ip: " write write ] }
|
|
|
|
|
{ [ dup 3 = ] [ drop head-int int>ip dup remote-external-ip set "remote external? ip: " write write ] }
|
|
|
|
|
{ [ dup 4 = ] [ drop head-int int>ip dup my-ip set "my? ip: " write write ] }
|
|
|
|
|
{ [ dup 5 = ] [ drop head-short unparse "port?" write write ] }
|
|
|
|
|
{ [ dup 10 = ] [ drop head-short unparse write ] }
|
|
|
|
|
{ [ dup 11 = ] [ drop head-short unparse write direct-connect-cancelled set ] }
|
|
|
|
|
{ [ dup 15 = ] [ drop ( do nothing ) ] }
|
|
|
|
|
{ [ dup 22 = ] [ drop head-int unparse write ] }
|
|
|
|
|
{ [ dup 23 = ] [ drop head-short unparse "port?" write write ] }
|
|
|
|
|
{ [ t ] [ "Unhandled direct transfer tlv: " write unparse writeln head-contents hexdump ] }
|
|
|
|
|
} cond terpri
|
|
|
|
|
] with-unscoped-stream
|
|
|
|
|
handle-direct-start-tlvs
|
|
|
|
|
] unless ;
|
2005-09-19 22:58:20 -04:00
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
: send-direct-connect-start
|
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
: send-auth-file-transfer
|
|
|
|
|
[
|
|
|
|
|
0 >short
|
|
|
|
|
1 >short
|
|
|
|
|
"Send File" capability-names hash >u128
|
|
|
|
|
0 >short
|
|
|
|
|
] send-aim ;
|
|
|
|
|
|
|
|
|
|
: connect-aim-file-transfer-server
|
|
|
|
|
"205.188.210.203" aim-file-server-port <client> ;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
: handle-file-transfer-start
|
|
|
|
|
head-short message-type set
|
|
|
|
|
head-longlong icbm-cookie set
|
|
|
|
|
head-u128 capability-values hash
|
|
|
|
|
{
|
|
|
|
|
{ [ dup "Send File" = ]
|
|
|
|
|
[ . handle-file-transfer-start-tlvs
|
|
|
|
|
file-transfer-cancelled get [ send-file-transfer-start ] unless
|
|
|
|
|
] }
|
|
|
|
|
{ [ dup "Chat" = ] [ . handle-chat-start-tlvs
|
|
|
|
|
"Chat join message: " write message get writeln ] }
|
2005-10-16 19:41:35 -04:00
|
|
|
{ [ dup "AIM Direct IM" = ] [ . handle-direct-start-tlvs
|
2005-10-13 07:16:41 -04:00
|
|
|
direct-connect-cancelled get [ send-direct-connect-start ] unless
|
|
|
|
|
] }
|
|
|
|
|
{ [ t ] [ "Unsupported capability in channel 2: " write writeln head-contents hexdump ] }
|
|
|
|
|
} cond ;
|
|
|
|
|
|
|
|
|
|
: parse-message-chunks
|
2005-09-19 22:58:20 -04:00
|
|
|
unscoped-stream get empty? [
|
|
|
|
|
head-short
|
|
|
|
|
head-short head-string <string-reader> [
|
|
|
|
|
{
|
2005-10-13 07:16:41 -04:00
|
|
|
{ [ dup 2 = ] [ drop parse-message-tlv2 ] }
|
|
|
|
|
{ [ dup 5 = ] [ drop handle-file-transfer-start ] }
|
|
|
|
|
{ [ dup 11 = ] [ drop ] }
|
|
|
|
|
! { [ dup 13 = ] [ drop ] }
|
|
|
|
|
{ [ t ] [ "Unhandled chunk: " write unparse writeln head-contents hexdump ] }
|
2005-09-19 22:58:20 -04:00
|
|
|
} cond
|
|
|
|
|
] with-unscoped-stream
|
2005-10-13 07:16:41 -04:00
|
|
|
parse-message-chunks
|
2005-09-19 22:58:20 -04:00
|
|
|
] unless ;
|
|
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
: parse-message-tlv ( n -- )
|
2005-09-19 22:58:20 -04:00
|
|
|
[
|
|
|
|
|
head-short
|
|
|
|
|
head-short head-string <string-reader>
|
|
|
|
|
[
|
|
|
|
|
{
|
|
|
|
|
{ [ dup 1 = ] [ drop head-short drop ] }
|
|
|
|
|
{ [ dup 2 = ] [ drop 15 head-string drop ] }
|
|
|
|
|
{ [ dup 3 = ] [ drop ] }
|
|
|
|
|
{ [ dup 15 = ] [ drop ] }
|
|
|
|
|
{ [ dup 29 = ] [ drop ] }
|
2005-10-13 07:16:41 -04:00
|
|
|
{ [ t ] [ "Unknown tlv: " write unparse writeln head-contents hexdump ] }
|
2005-09-19 22:58:20 -04:00
|
|
|
} cond
|
|
|
|
|
] with-unscoped-stream
|
|
|
|
|
] repeat ;
|
|
|
|
|
|
2005-09-19 15:33:06 -04:00
|
|
|
: handle-incoming-message ( -- )
|
2005-10-13 07:16:41 -04:00
|
|
|
parse-family-4h-header
|
|
|
|
|
head-byte head-string name set
|
|
|
|
|
head-short warning set
|
|
|
|
|
head-short parse-message-tlv
|
|
|
|
|
parse-message-chunks
|
|
|
|
|
|
|
|
|
|
channel get 1 = [
|
|
|
|
|
"Incoming msg from " write name get write ": " write
|
|
|
|
|
"Warning: " write warning get 10 /f unparse write "%" writeln
|
|
|
|
|
"Message: " write message get writeln
|
|
|
|
|
] when ; FAMILY: 4 OPCODE: 7
|
2005-09-19 15:33:06 -04:00
|
|
|
|
2005-10-10 17:21:38 -04:00
|
|
|
! : handle-4-12
|
|
|
|
|
! head-short 2 / [ head-short drop ] repeat
|
|
|
|
|
! head-cstring drop
|
|
|
|
|
! head-short drop
|
|
|
|
|
! head-byte head-string
|
|
|
|
|
! ; FAMILY: 4 OPCODE: 12
|
|
|
|
|
|
2005-09-19 15:33:06 -04:00
|
|
|
: handle-typing-message ( -- )
|
2005-10-13 07:16:41 -04:00
|
|
|
parse-family-4h-header
|
2005-09-19 15:33:06 -04:00
|
|
|
head-byte head-string write
|
|
|
|
|
head-short
|
|
|
|
|
{
|
2005-09-19 22:58:20 -04:00
|
|
|
{ [ dup 0 = ] [ drop " has an empty textbox." writeln ] }
|
|
|
|
|
{ [ dup 1 = ] [ drop " has entered text." writeln ] }
|
|
|
|
|
{ [ dup 2 = ] [ drop " is typing..." writeln ] }
|
|
|
|
|
{ [ t ] [ " does 4h.14h unknown: " write unparse writeln ] }
|
2005-10-10 15:34:07 -04:00
|
|
|
} cond ; FAMILY: 4 OPCODE: 20
|
2005-09-19 15:33:06 -04:00
|
|
|
|
2005-10-10 17:21:38 -04:00
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
: handle-19-3
|
|
|
|
|
; FAMILY: 19 OPCODE: 3
|
|
|
|
|
|
2005-10-16 19:41:35 -04:00
|
|
|
|
|
|
|
|
! : handle-19-6-tlv ( str-reader -- )
|
|
|
|
|
! empty? [ (handle-19-6-tlv) handle-19-6-tlv ] unless ;
|
|
|
|
|
|
2005-10-17 02:28:11 -04:00
|
|
|
SYMBOL: gid ! group id
|
|
|
|
|
SYMBOL: bid ! buddy id
|
2005-10-16 19:41:35 -04:00
|
|
|
SYMBOL: type
|
2005-10-13 07:16:41 -04:00
|
|
|
: handle-19-6
|
2005-10-16 19:41:35 -04:00
|
|
|
head-byte drop ! ssi version, probably 0
|
|
|
|
|
head-short [
|
|
|
|
|
head-short head-string name set name get .
|
2005-10-17 02:28:11 -04:00
|
|
|
head-short gid set gid get .
|
|
|
|
|
head-short bid set bid get .
|
2005-10-16 19:41:35 -04:00
|
|
|
head-short type set type get . ! type 0 is a buddy, 1 is a group
|
|
|
|
|
"TLV CHAIN DATA: " print
|
|
|
|
|
head-short head-string hexdump ! short short data
|
|
|
|
|
|
|
|
|
|
type get
|
|
|
|
|
{
|
2005-10-17 02:28:11 -04:00
|
|
|
{ [ dup 0 = ] [ drop name get bid get gid get { } clone f f <buddy>
|
|
|
|
|
dup name get sanitize-name buddy-hash-name get set-hash bid get buddy-hash-id get set-hash ] }
|
|
|
|
|
{ [ dup 1 = ] [ drop name get dup length 0 = [ drop ] [ gid get <group>
|
|
|
|
|
dup name get sanitize-name group-hash-name get set-hash gid get group-hash-id get set-hash ] if ] }
|
|
|
|
|
{ [ dup 3 = ] [ drop name get bid get gid get { } clone f f <buddy>
|
|
|
|
|
dup name get sanitize-name banned-hash-name get set-hash bid get banned-hash-id get set-hash ] }
|
2005-10-16 19:41:35 -04:00
|
|
|
{ [ t ] [ drop "Unknown 19-6 type" print ] }
|
|
|
|
|
} cond
|
|
|
|
|
] repeat
|
|
|
|
|
head-short drop ! timestamp
|
2005-10-10 17:21:38 -04:00
|
|
|
|
2005-10-16 23:31:30 -04:00
|
|
|
snac-flags get 0 = [
|
2005-10-16 19:41:35 -04:00
|
|
|
! SSI, Activate
|
|
|
|
|
[ HEX: 13 7 0 7 make-snac ] send-aim
|
|
|
|
|
! Set User Info. Capabilities!
|
|
|
|
|
! if you send this packet correctly you get capabilities
|
|
|
|
|
! and others' capabilities turn into letters instead of u128s
|
|
|
|
|
[
|
|
|
|
|
2 4 0 4 make-snac
|
|
|
|
|
5 >short
|
|
|
|
|
capability-values hash-keys length 16 * >short ! size
|
|
|
|
|
capability-values hash-keys [ >u128 ] each
|
|
|
|
|
6 >short 6 >short 4 >short 2 >short 2 >short
|
|
|
|
|
] send-aim
|
|
|
|
|
|
|
|
|
|
! Set ICBM Parameter
|
|
|
|
|
[
|
|
|
|
|
4 2 0 2 make-snac
|
|
|
|
|
0 >int
|
|
|
|
|
HEX: b >short
|
|
|
|
|
HEX: 1f40 >short
|
|
|
|
|
HEX: 03e7 >short
|
|
|
|
|
HEX: 03e7 >short
|
|
|
|
|
0 >int
|
|
|
|
|
] send-aim
|
|
|
|
|
|
|
|
|
|
! Client Ready
|
|
|
|
|
[
|
|
|
|
|
1 2 0 2 make-snac
|
|
|
|
|
[
|
|
|
|
|
HEX: 1 HEX: 4 HEX: 110 HEX: 8f1
|
|
|
|
|
HEX: 13 HEX: 3 HEX: 110 HEX: 8f1
|
|
|
|
|
HEX: 2 HEX: 1 HEX: 110 HEX: 8f1
|
|
|
|
|
HEX: 3 HEX: 1 HEX: 110 HEX: 8f1
|
|
|
|
|
HEX: 4 HEX: 4 HEX: 110 HEX: 8f1
|
|
|
|
|
HEX: 6 HEX: 1 HEX: 110 HEX: 8f1
|
|
|
|
|
HEX: 8 HEX: 1 HEX: 104 HEX: 8f1
|
|
|
|
|
HEX: 9 HEX: 1 HEX: 110 HEX: 8f1
|
|
|
|
|
HEX: a HEX: 1 HEX: 110 HEX: 8f1
|
|
|
|
|
HEX: b HEX: 1 HEX: 110 HEX: 8f1
|
|
|
|
|
] [ >short ] each
|
|
|
|
|
] send-aim
|
|
|
|
|
|
|
|
|
|
! Process
|
2005-10-16 23:31:30 -04:00
|
|
|
] when ; FAMILY: 19 OPCODE: 6
|
|
|
|
|
|
2005-09-19 15:33:06 -04:00
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
: parse-server ( ip:port -- )
|
2005-09-19 15:33:06 -04:00
|
|
|
":" split [ first ] keep second string>number aim-chat-port set aim-chat-ip set ;
|
|
|
|
|
|
2005-10-07 04:31:14 -04:00
|
|
|
: process-login-chunks ( stream -- )
|
2005-09-19 22:58:20 -04:00
|
|
|
unscoped-stream get empty? [
|
2005-09-19 15:33:06 -04:00
|
|
|
head-short
|
|
|
|
|
head-short
|
|
|
|
|
swap
|
|
|
|
|
{
|
2005-10-13 07:16:41 -04:00
|
|
|
{ [ dup 5 = ] [ drop head-string parse-server ] }
|
2005-09-22 16:10:20 -04:00
|
|
|
{ [ dup 6 = ] [ drop head-string auth-code set ] }
|
|
|
|
|
{ [ t ] [ drop head-string drop ] }
|
2005-09-19 15:33:06 -04:00
|
|
|
} cond
|
2005-10-07 04:31:14 -04:00
|
|
|
process-login-chunks
|
2005-09-19 15:33:06 -04:00
|
|
|
] unless ;
|
|
|
|
|
|
|
|
|
|
: handle-login-packet ( -- )
|
2005-10-10 15:34:07 -04:00
|
|
|
process-login-chunks ; FAMILY: 23 OPCODE: 3
|
2005-09-19 15:33:06 -04:00
|
|
|
|
2005-10-07 04:31:14 -04:00
|
|
|
: password-md5 ( password -- md5 )
|
2005-09-19 15:33:06 -04:00
|
|
|
login-key get
|
|
|
|
|
password get string>md5 append
|
2005-10-03 23:16:40 -04:00
|
|
|
client-md5-string append
|
2005-09-19 15:33:06 -04:00
|
|
|
string>md5 >string ;
|
|
|
|
|
|
|
|
|
|
: respond-login-key-packet ( -- )
|
2005-09-18 20:23:06 -04:00
|
|
|
[
|
|
|
|
|
HEX: 17 HEX: 2 0 0 make-snac
|
|
|
|
|
1 >short
|
|
|
|
|
username get length >short
|
2005-10-03 23:16:40 -04:00
|
|
|
username get %
|
2005-09-18 20:23:06 -04:00
|
|
|
|
|
|
|
|
! password hash chunk
|
2005-09-19 15:33:06 -04:00
|
|
|
HEX: 25 >short
|
|
|
|
|
HEX: 10 >short
|
2005-10-07 04:31:14 -04:00
|
|
|
password-md5 %
|
2005-09-18 20:23:06 -04:00
|
|
|
|
|
|
|
|
HEX: 4c >short
|
|
|
|
|
HEX: 00 >short
|
2005-10-03 23:16:40 -04:00
|
|
|
HEX: 03 >short client-id-string length >short client-id-string %
|
|
|
|
|
HEX: 16 >short HEX: 02 >short client-id-num >short
|
|
|
|
|
HEX: 17 >short HEX: 02 >short client-major-ver >short
|
|
|
|
|
HEX: 18 >short HEX: 02 >short client-minor-ver >short
|
|
|
|
|
HEX: 19 >short HEX: 02 >short client-lesser-ver >short
|
|
|
|
|
HEX: 1a >short HEX: 02 >short client-build-num >short
|
|
|
|
|
HEX: 14 >short HEX: 04 >short client-distro-num >int
|
|
|
|
|
HEX: 0f >short client-language length >short client-language %
|
|
|
|
|
HEX: 0e >short client-country length >short client-country %
|
|
|
|
|
HEX: 4a >short HEX: 01 >short client-ssi-flag >byte
|
2005-09-18 20:23:06 -04:00
|
|
|
] send-aim ;
|
|
|
|
|
|
2005-09-19 15:33:06 -04:00
|
|
|
: handle-login-key-packet ( -- )
|
|
|
|
|
head-short head-string login-key set
|
2005-10-10 15:34:07 -04:00
|
|
|
respond-login-key-packet ; FAMILY: 23 OPCODE: 7
|
2005-09-19 22:58:20 -04:00
|
|
|
|
2005-09-19 15:33:06 -04:00
|
|
|
: handle-packet ( packet -- )
|
|
|
|
|
<string-reader>
|
|
|
|
|
[
|
|
|
|
|
parse-snac
|
2005-10-03 23:16:40 -04:00
|
|
|
family get family-table hash dup [
|
|
|
|
|
opcode get swap hash dup [
|
|
|
|
|
execute
|
|
|
|
|
] [
|
2005-09-19 15:33:06 -04:00
|
|
|
unhandled-opcode drop
|
2005-09-25 02:15:29 -04:00
|
|
|
] if
|
2005-09-19 15:33:06 -04:00
|
|
|
] [
|
2005-10-03 23:16:40 -04:00
|
|
|
unhandled-family-opcode
|
|
|
|
|
drop
|
2005-09-25 02:15:29 -04:00
|
|
|
] if
|
2005-09-19 22:58:20 -04:00
|
|
|
unscoped-stream get empty? [ incomplete-opcode ] unless
|
|
|
|
|
] with-unscoped-stream ;
|
2005-09-19 15:33:06 -04:00
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
! Login
|
|
|
|
|
: send-first-login ( -- )
|
|
|
|
|
[ 1 >int ] send-aim ;
|
2005-10-10 15:34:07 -04:00
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
: send-first-request-auth ( -- )
|
|
|
|
|
2 stage-num set
|
|
|
|
|
[
|
|
|
|
|
HEX: 17 HEX: 6 0 0 make-snac
|
|
|
|
|
1 >short
|
|
|
|
|
username get length >short
|
|
|
|
|
username get %
|
|
|
|
|
HEX: 4b >short
|
|
|
|
|
HEX: 00 >short
|
|
|
|
|
HEX: 5a >short
|
|
|
|
|
HEX: 00 >short
|
|
|
|
|
] send-aim ;
|
2005-10-10 15:34:07 -04:00
|
|
|
|
2005-10-13 07:16:41 -04:00
|
|
|
! AIM Chat Server
|
|
|
|
|
: send-second-login
|
|
|
|
|
[
|
|
|
|
|
1 >int
|
|
|
|
|
6 >short
|
|
|
|
|
auth-code get length >short
|
|
|
|
|
auth-code get %
|
|
|
|
|
] send-aim ;
|
|
|
|
|
|
|
|
|
|
: first-server
|
|
|
|
|
! first server
|
|
|
|
|
1 stage-num set
|
|
|
|
|
aim-login-server login-port <client> conn set
|
|
|
|
|
|
|
|
|
|
send-first-login read-aim drop
|
|
|
|
|
|
|
|
|
|
! normal transmission stage
|
|
|
|
|
send-first-request-auth read-aim handle-packet
|
|
|
|
|
read-aim handle-packet
|
|
|
|
|
read-aim drop
|
|
|
|
|
conn get stream-close ;
|
|
|
|
|
|
|
|
|
|
: second-server
|
|
|
|
|
aim-chat-ip get aim-chat-port get <client> conn set
|
|
|
|
|
1 stage-num set
|
|
|
|
|
65535 random-int seq-num set
|
|
|
|
|
send-second-login read-aim drop
|
|
|
|
|
2 stage-num set ;
|
|
|
|
|
|
|
|
|
|
: handle-loop ( -- )
|
|
|
|
|
read-aim handle-packet terpri handle-loop ;
|
|
|
|
|
|
|
|
|
|
: connect-aim ( -- )
|
|
|
|
|
first-server
|
|
|
|
|
aim-chat-ip get
|
|
|
|
|
[ "No aim server received (too many logins, try again later)" throw ] unless
|
|
|
|
|
second-server [ handle-loop ] in-thread ;
|
|
|
|
|
|
|
|
|
|
IN: aim
|
2005-10-10 15:34:07 -04:00
|
|
|
|
2005-10-03 23:16:40 -04:00
|
|
|
! Commands
|
|
|
|
|
: send-im ( name message -- )
|
2005-09-20 02:23:59 -04:00
|
|
|
message set
|
|
|
|
|
name set
|
|
|
|
|
[
|
|
|
|
|
4 6 0 HEX: 7c3a0006 make-snac
|
|
|
|
|
"1973973" >cstring
|
|
|
|
|
1 >short
|
|
|
|
|
name get length >byte
|
2005-10-03 23:16:40 -04:00
|
|
|
name get %
|
2005-09-20 02:23:59 -04:00
|
|
|
2 >short
|
|
|
|
|
|
|
|
|
|
[
|
|
|
|
|
5 >byte 1 >byte 3 >short 1 >byte 1 >byte 2 >byte
|
|
|
|
|
HEX: 101 >short
|
|
|
|
|
message get length 4 + >short
|
|
|
|
|
0 >short
|
|
|
|
|
HEX: ffff >short
|
2005-10-03 23:16:40 -04:00
|
|
|
message get %
|
|
|
|
|
] make-packet
|
|
|
|
|
dup length >short %
|
2005-09-20 02:23:59 -04:00
|
|
|
3 >short 0 >short 6 >short 0 >short
|
|
|
|
|
] send-aim ;
|
|
|
|
|
|
2005-09-22 16:10:20 -04:00
|
|
|
: query-info ( name -- )
|
|
|
|
|
name set
|
|
|
|
|
[
|
|
|
|
|
2 HEX: 15 0 HEX: 29cb0015 make-snac
|
|
|
|
|
1 >int
|
|
|
|
|
name get length >byte
|
2005-10-03 23:16:40 -04:00
|
|
|
name get %
|
2005-09-22 16:10:20 -04:00
|
|
|
] send-aim ;
|
|
|
|
|
|
|
|
|
|
: query-away ( name -- )
|
|
|
|
|
name set
|
|
|
|
|
[
|
|
|
|
|
2 HEX: 15 0 HEX: 29cb0015 make-snac
|
|
|
|
|
2 >int
|
|
|
|
|
name get length >byte
|
2005-10-03 23:16:40 -04:00
|
|
|
name get %
|
2005-09-22 16:10:20 -04:00
|
|
|
] send-aim ;
|
|
|
|
|
|
|
|
|
|
: set-away ( message -- )
|
|
|
|
|
message set
|
|
|
|
|
[
|
|
|
|
|
2 4 0 4 make-snac
|
|
|
|
|
3 >short
|
2005-10-03 23:16:40 -04:00
|
|
|
client-charset length >short
|
|
|
|
|
client-charset %
|
2005-09-22 16:10:20 -04:00
|
|
|
4 >short
|
|
|
|
|
message get length >short
|
2005-10-03 23:16:40 -04:00
|
|
|
message get %
|
2005-09-22 16:10:20 -04:00
|
|
|
] send-aim ;
|
|
|
|
|
|
|
|
|
|
: return-from-away ( -- )
|
|
|
|
|
[
|
|
|
|
|
2 4 0 4 make-snac
|
|
|
|
|
4 >short
|
|
|
|
|
0 >short
|
|
|
|
|
] send-aim ;
|
|
|
|
|
|
|
|
|
|
: set-info ( message -- )
|
|
|
|
|
message set
|
|
|
|
|
! [ 2 9 0 HEX: 63e40000 ] send-aim
|
|
|
|
|
[
|
|
|
|
|
2 4 0 4 make-snac
|
|
|
|
|
1 >short
|
2005-10-03 23:16:40 -04:00
|
|
|
client-charset length >short
|
|
|
|
|
client-charset %
|
2005-09-22 16:10:20 -04:00
|
|
|
2 >short
|
|
|
|
|
message get length >short
|
2005-10-03 23:16:40 -04:00
|
|
|
message get %
|
2005-09-22 16:10:20 -04:00
|
|
|
] send-aim ;
|
|
|
|
|
|
2005-10-16 23:31:30 -04:00
|
|
|
: buddylist-edit-start
|
|
|
|
|
[ HEX: 13 HEX: 11 0 HEX: 11 make-snac ] send-aim ;
|
2005-09-22 16:10:20 -04:00
|
|
|
|
2005-10-16 23:31:30 -04:00
|
|
|
: buddylist-edit-stop
|
|
|
|
|
[ HEX: 13 HEX: 12 0 HEX: 12 make-snac ] send-aim ;
|
2005-09-22 16:10:20 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
! add, delete groups, move buddies from group to group
|
|
|
|
|
! parse buddy list
|
|
|
|
|
|
2005-10-16 23:31:30 -04:00
|
|
|
: add-group ( name -- )
|
|
|
|
|
dup name set modify-queue get enque
|
|
|
|
|
buddylist-edit-start
|
|
|
|
|
[
|
|
|
|
|
HEX: 13 8 0 HEX: 4fb20008 make-snac
|
|
|
|
|
name get length >short
|
|
|
|
|
name get %
|
|
|
|
|
random-group-id >short
|
|
|
|
|
0 >short ! buddy id
|
|
|
|
|
1 >short ! buddy type
|
|
|
|
|
0 >short ! tlv len
|
|
|
|
|
] send-aim ;
|
|
|
|
|
|
|
|
|
|
: delete-group ( name -- )
|
|
|
|
|
dup name set modify-queue get enque
|
|
|
|
|
buddylist-edit-start
|
|
|
|
|
[
|
2005-10-17 02:28:11 -04:00
|
|
|
HEX: 13 HEX: a 0 HEX: 5086000a make-snac
|
|
|
|
|
name get length >short
|
|
|
|
|
name get %
|
|
|
|
|
name get get-group group-id >short
|
|
|
|
|
0 >short
|
|
|
|
|
1 >short
|
|
|
|
|
0 >short
|
|
|
|
|
] send-aim ;
|
2005-10-16 23:31:30 -04:00
|
|
|
|
|
|
|
|
! TODO: make sure buddy doesnt already exist, makd sure group exists
|
2005-09-22 16:10:20 -04:00
|
|
|
: add-buddy ( name group -- )
|
2005-10-16 23:31:30 -04:00
|
|
|
group set
|
|
|
|
|
dup name set modify-queue get enque
|
|
|
|
|
buddylist-edit-start
|
2005-09-22 16:10:20 -04:00
|
|
|
[
|
2005-10-17 02:28:11 -04:00
|
|
|
HEX: 13 8 0 HEX: 5b2f0008 make-snac
|
2005-09-22 16:10:20 -04:00
|
|
|
name get length >short
|
2005-10-03 23:16:40 -04:00
|
|
|
name get %
|
2005-10-17 02:28:11 -04:00
|
|
|
group get get-group group-id >short
|
|
|
|
|
random-buddy-id >short
|
2005-10-13 07:16:41 -04:00
|
|
|
0 >short ! buddy type
|
|
|
|
|
0 >short ! tlv len
|
2005-10-16 23:31:30 -04:00
|
|
|
] send-aim ;
|
2005-09-22 16:10:20 -04:00
|
|
|
|
2005-10-16 23:31:30 -04:00
|
|
|
: delete-buddy ( name -- )
|
|
|
|
|
dup name set modify-queue enque
|
|
|
|
|
buddylist-edit-start
|
2005-09-22 16:10:20 -04:00
|
|
|
[
|
2005-10-17 02:28:11 -04:00
|
|
|
HEX: 13 HEX: a 0 HEX: 5086000a make-snac
|
2005-09-22 16:10:20 -04:00
|
|
|
name get length >short
|
2005-10-03 23:16:40 -04:00
|
|
|
name get %
|
2005-10-16 23:31:30 -04:00
|
|
|
name get get-buddy dup buddy-gid >short
|
|
|
|
|
buddy-id >short
|
2005-09-22 16:10:20 -04:00
|
|
|
0 >short
|
|
|
|
|
0 >short
|
2005-10-16 23:31:30 -04:00
|
|
|
] send-aim ;
|
2005-09-22 16:10:20 -04:00
|
|
|
|
2005-10-16 23:31:30 -04:00
|
|
|
: modify-buddylist ( name -- )
|
2005-10-17 02:28:11 -04:00
|
|
|
! dup buddy-name? [ dup name set dup buddy-id bid set buddy-gid gid set ] when
|
|
|
|
|
! dup group-name? [ dup name set dup group-id gid set 0 bid set ] when
|
|
|
|
|
! dup banned-name? [ dup name set dup buddy-id bid set buddy-gid gid set ] when
|
|
|
|
|
! [
|
|
|
|
|
! HEX: 13 9 0 HEX: 6e190009 make-snac
|
|
|
|
|
! name get dup length >short %
|
|
|
|
|
! gid get >short
|
|
|
|
|
! 0 >short
|
|
|
|
|
! 1 >short ! group type = 1
|
|
|
|
|
|
2005-10-16 23:31:30 -04:00
|
|
|
! "members of this group" tlv
|
|
|
|
|
! 8 >short
|
|
|
|
|
! HEX: c8 >short
|
|
|
|
|
! 4 >short
|
|
|
|
|
! HEX: 4e833ea8 >int
|
2005-10-17 02:28:11 -04:00
|
|
|
! ] send-aim ;
|
|
|
|
|
drop ;
|
2005-10-16 23:31:30 -04:00
|
|
|
|
|
|
|
|
IN: aim-internals
|
|
|
|
|
: buddylist-ack
|
|
|
|
|
modify-queue get deque modify-buddylist
|
|
|
|
|
buddylist-edit-stop ; FAMILY: 19 OPCODE: 14
|
|
|
|
|
|
|
|
|
|
IN: aim
|
2005-10-10 15:34:07 -04:00
|
|
|
|
2005-09-19 15:33:06 -04:00
|
|
|
: run ( username password -- )
|
2005-10-07 04:31:14 -04:00
|
|
|
initialize-aim connect-aim ;
|
|
|
|
|
! [ initialize-aim connect-aim ] with-scope ;
|
2005-09-19 15:33:06 -04:00
|
|
|
|
|
|
|
|
! my aim test account. you can use it.
|
|
|
|
|
: run-test-account
|
|
|
|
|
"FactorTest" "factoraim" run ;
|
2005-09-18 20:23:06 -04:00
|
|
|
|