Consult everybody, how should to simulate such an agreement, let he can normal receiving,
Hope experts can tell I should start from which on the one hand, learning and how to simulate the packet, thank you!
I send my own Delphi code
Code can be a bit of a mess, I didn't post the server connection code, is my steps,
Connection bettas chat server, and then send anonymous login packet with a heartbeat packet simulation access (packet by wpe plaintext packet interception down, I will simulate such a clear packet processing login), but I'm so that simulation can only have 10 number of connections, 11 were rejected the connection,
Procedure TForm1. Button4Click (Sender: TObject);
Var
RequestStr BackStr: string;
Username: string;
Password: string;
Time: the string;
RoomID: string;
Salt: string;
Uuid: string;
Vitamin k: string;
P: string;
T1, t2: string;
The begin
Username:=';
Password:=';
Time:=IntToStr (DateTimeToUnix (Now) - 8 * 60 * 60);//timestamp
RoomID:=Edit1. Text;//room number
Salt:='7 oe9npeg9xxv69phu31fycluagkeytsf';//unknown values
Uuid: uuidsetup=();//16 hexadecimal random bytes
Vitamin k:=StrToMD5 (time + salt + vitamin k);//unknown values
='type @={p: loginreq/username @=/password @=/roomid @=' + roomid + '/ct @=2/devid @=' + uuid + '/ver @=20150505/rt @=' + time + '/vitamin k @=' + vitamin k + '/'; }
T1:=hextostring (' B8000000B8000000B1020000 ');
T2:=hextostring (' 00 ');
P:=t1 + 'type @=loginreq/+
'username @=' + username +/password @='+ password +'/roompass @=/roomid @='+
RoomID + + uuid '/devid @=' + '/rt @=' + time + + vitamin k + '/vitamin k @=' '/ver @=20150929/ct @=0/' + t2;
//memo1. Lines. The Add (p); }
If the socket. Connected then
The begin
RequestStr:=p;
Try
Socket. RecvBufferSize
Socket. Write (RequestStr);//send the login packet
Memo1. Lines. The Add (' send data: + RequestStr);
{t1:=hextostring (f0000001f000000b1020000 '1');
RequestStr:=t1 + 'type @=QRL/rid @=' + RoomID + '/' + t2; }
Heartbeat packets for the first time {}
T1:=hextostring (' 5 b0000005b000000b1020000 ');
P:=t1 + 'type @=keeplive/tick @=' + time;
Time:=IntToStr (DateTimeToUnix (Now) - 8 * 60 * 60);
Vitamin k:=StrToMD5 (time + salt + vitamin k);
P:=p + '/VBW @=0/CDN @ @=0/k=' + '/' vitamin k + + t2;
Heartbeat packets for the first time {}
Socket. Write (p);//for the first time heartbeat
BackStr:=socket. ReadLn (', 500);//in fact a timeout is ineffective, indy itself
//bug; At this point if the server end to the die such as
Memo1. Lines. The Add (' return data: + BackStr);
While (True) Do
The begin
T1:=hextostring (' 5 b0000005b000000b1020000 ');
Time:=IntToStr (DateTimeToUnix (Now) - 8 * 60 * 60);
Vitamin k:=StrToMD5 (time + salt + vitamin k);
Sleep (10000);
P:=t1 + 'type @=keeplive/tick @=' + time + '/VBW @=0/CDN @ @=0/k=' + '/' vitamin k + + t2;
Socket. Write (p);
Memo1. Lines. The Add (' send data: '+ p);
BackStr:=socket. ReadLn (', 500);//in fact a timeout is ineffective, indy itself
//bug; At this point if the server end to the die such as
Memo1. Lines. The Add (' return data: + BackStr);
end;
Except,
ShowMessage (' send data failed! ');
end;
End
The else
The begin
Memo1. Lines. The Add (' connection has been broken, can't send! ');
end;
CodePudding user response:
Here is the C/C + + zone, dephi zone left out, please,CodePudding user response: