1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
| <?
error_reporting(E_ALL);
//set_time_limit(0);
class Net_MSN
{
var $_user = '@hotmail.com';
var $_user_real = '';
var $_pass = '';
// var $db;
var $_msn_host = 'messenger.hotmail.com';
var $_msn_port = 1863;
var $_msn_proto = 'MSNP2';
var $_not_serv;
var $_not_port;
var $_hash = 'Q1P7W2E4J9R8U3S5';
var $_enc = 'MD5';
var $_trid = 0;
var $connected = 0;
var $_socket;
var $_AWY = "Away";
var $_NLN = "Online";
var $_IDL = "Idle away";
var $_i = 0;
var $_Contacts = Array();
var $_Contactline = "";
// function Net_MSN()
// {
// $this->msn_dispatch();
// }
function msn_dispatch()
{
echo "Starten msn_dispatch\n";
if ($this->_socket = fsockopen($this->_msn_host, $this->_msn_port))
{
$this->connected = true;
$this->msn_send('VER ' . $this->_trid . ' ' . $this->_msn_proto);
if (eregi('^VER ', $this->msn_recv()))
{
echo "\n\nSuccessfully communicated to " . $this->_msn_host . "\n";
}
$this->msn_send('INF ' . $this->_trid++);
if (eregi('^INF ', $this->msn_recv()))
{
echo "We got the encryption package...\n";
}
$this->msn_send('USR ' . $this->_trid++ . ' ' . $this->_enc . ' I ' . $this->_user);
$inbound = $this->msn_recv();
if (eregi('^XFR ', $inbound))
{
echo "User Passport information sent, awaiting transfer...\n";
@list($cmd, $trid, $type, $info, $etc) = explode(' ', $inbound);
$info = trim($info);
echo "Transfer server recv'd: " . $info . "\n";
@list($srv, $prt) = explode(':', $info);
$this->_not_serv = $srv;
$this->_not_port = $prt;
echo "Notification server + port: $srv, $prt\n";
echo "Closing connection for transfer server...\n";
$this->connected = false;
$this->msn_notification_connect();
}
}
}
function msn_notification_connect()
{
echo "--------------\n\nStart msn_notifcation_connect\n";
if (!$this->connected)
{
if ($this->_socket = fsockopen($this->_not_serv, $this->_not_port))
{
$this->connected = true;
$this->msn_send('VER ' . $this->_trid++ . ' ' . $this->_msn_proto);
if (eregi('^VER ', $this->msn_recv()))
{
echo "\n\nSucessfully communicated to " . $this->_not_serv . "\n";
}
$this->msn_send('INF ' . $this->_trid++);
if (eregi('^INF ', $this->msn_recv()))
{
echo "We got the encryption package...\n";
}
$this->msn_send('USR ' . $this->_trid++ . ' ' . $this->_enc . ' I ' . $this->_user);
$inbound = $this->msn_recv();
if (eregi('^USR ', $inbound))
{
@list($cmd, $trid, $enc, $mode, $digest) = explode(' ', $inbound);
if (trim($mode) == 'S')
{
echo "Encryption mode recv'd...\n";
$encpass = md5(trim($digest) . $this->_pass);
$this->msn_send('USR ' . $this->_trid++ . ' MD5 S ' . $encpass);
echo "Encryped user password sent: " . $encpass . "\n";
}
}
$final = $this->msn_recv();
if (eregi('^USR ', $final))
{
@list($cmd, $trid, $stat, $usr, $sn, $etc) = explode(' ', $final);
if (trim($stat) == 'OK')
{
echo "Server replied OK to signon...\n\n";
$this->msn_send('CHG ' . $this->_trid++ . ' NLN');
$this->msn_send('BLP ' . $this->_trid++ . ' AL');
$this->msn_send('REA ' . $this->_trid++ . ' ' . $this->_user . ' ' . urlencode($this->_user_real));
//zelf:
$this->msn_send('CVR '.$this->_trid++.' 0x0409 win 4.10 i386 MSMSGS 4.6.0082 MSMSGS');
}
}
}
}
}
function msn_recv()
{
if ($this->connected)
{
$d = fgets($this->_socket, 2048);
if($d != "")
{
echo "<font color=blue>Received: $d</font>";
if (eregi('^ILN ',$d))
{
$startpos = 10;
$endpos = strpos($d,' ',10);
$this->_i ++;
$this->_Contacts[$this->_i] = substr($d, $startpos, ($endpos-10));
// echo($this->_i . " : " . $this->_Contacts[$this->_i] . " : " . $endpos);
$this->_Contactline .= $this->_Contacts[$this->_i] . "<br>";
}
echo ("\n");
flush();
return $d;
}
else
return false;
}
}
function msn_send($data,$raw=false)
{
if ($this->connected)
{
echo "<font color=red>Sending: $data</font>\n";flush();
if($raw)
return fputs($this->_socket, $data);
else
return fputs($this->_socket, $data . "\r\n");
}
}
function msn_wait()
{
//Wait for incomming chat requests:
$incomming = $this->msn_recv();
if(eregi('^RNG ', $incomming))
{
$bla = new msn_user($incomming,$this->_user);
}
}
} // end Net_MSN
class msn_user
{
var $_socket,
$_switchip,
$_switchport,
$_id;
function msn_user($incomming,$user)
{
echo "nieuwe\r\n";
$this->_id = 1;
@list($cmd,$sesid,$switchip,$bla,$hash) = explode(" ",$incomming);
@list($this->_switchip,$this->_switchport) = explode(":",$switchip);
$this->_socket = fsockopen($this->_switchip, $this->_switchport) or die("Unable to connect to the switchboard");
//set_file_buffer($this->_socket,0);
//ANS 1 venky_dude@hotmail.com 989495494.750408580 11742066
$this->send("ANS",$user. " ".$hash." ".$sesid);
while(1)
{
$this->get();
}
}
function send($cmd,$data,$raw=false)
{
$data = $cmd . " ". $this->_id++ . " " . $data;
echo "<font color=red>Sending (in msn_user): $data</font>\n";flush();
if(!$raw) $data .= "\r\n";
return fputs($this->_socket, $data);
}
function get()
{
$replies = array( "hallo", "ook hoi.",":)" => ":)","windows" => "linux");
$d = fgets ($this->_socket,1024);
if (eregi('^MSG ', $d))
{
list(,$from,$fromname,$length) = explode(" ",$d);
$msg = fread($this->_socket,$length);
if(ereg("Content-Type: text/x-msmsgscontrol",$msg)) return; //hebben we niet nodig die meuk
//Strip header:
list($header,$msg) = explode("\r\n\r\n",$msg,2);
echo "Bericht: $msg\n";
if($msg == "hallo")
$this->send_msg("ook hoi.");
else
if(isset($replies[$msg]))
{
$this->send_msg($replies[$msg]);
}
}
flush();
return $d;
}
function send_msg($msg)
{
$header = "MIME-Version: 1.0\r\nContent-Type: text/plain; charset=UTF-8\r\nX-MMS-IM-Format: FN=MS%20Shell%20Dlg; EF=; CO=0; CS=0; PF=0\r\n\r\n";
$header .= $msg;
$this->send('MSG', 'N ' . strlen($header) . "\r\n" . $header,true); //send raw data
}
}// end msn_user
//Gooi buffer vol:
//echo "<pre>Starten maar";
//for($i=0;$i<1000;$i++)
//echo " ";
//echo "\n";
//flush();
$msn = new Net_MSN;
while($msn->connected)
{
$msn->msn_wait();
}
?> |