I have seen the online game plug-in production (7)

zhaozj2021-02-16  51

In this chapter, we mainly study the production and sending of the package, and the same method we use is Delphi Winsock2 to make. I have said that only Winsock1 in Delphi, Winsock2 needs to be packaged, and I will not introduce how to encapsulate it.

Let's take a step in our packaging package and send it.

First of all, we should know that the package is divided into two sections. One is IP, one is the agreement (TCP, UDP, other protocols), IP is like a postal code, I lognow your package, where is it, and the agreement? In the format and verification of the package to be used, the agreement in online games is generally defined. To crack the most important thing about the online game is to learn to crack the online game agreement online game agreement, in order not Impact the security of online games that is running, I will introduce the entire process of the package and sending of the network protocol in this regard as an example of the UDP protocol.

Next, we can start to see the whole process of the entire package:

1) We want to start SOCK2, at this time, the WSAStartup function to use, the usage is as follows:

Integer WSAStartup

WVERSIONREQUIRED: WORD,

WSDATA: TWSA_DATA

);

WVersionRequired We are in the program $ 0002, WSData is the structure of TWSA_DATA.

2) Use the socket function to create and get the Socket handle; the usage is as follows:

Integer Socket (AF: Integer,

Struct: Integer,

Protocol: integer

);

Note that in our block package, we have an IP header, so our struct parameter is here to pass, and the parameter value is 2, indicating that the header is included. This function returns the value of the Winsocket just created.

3) Use the SetsockOpt function to set the SOCK option; the usage is as follows:

Integer setsockopt (s: integer,

Level: Integer,

Optname: Integer,

Optval: pchar,

Optlen: Integer

);

The Socket handle is incorporated in s, and the value of the Level input in this program is 0 indicates IP (if it is 6 indicates TCP, 17 means UDP, etc.), and the OptName is written into 2, while the initial value of OptVal fills in 1 Optlen as the size of OptVal.

4) Next, we have to divide several steps to implement build packages:

1. Convert the IP to the SOCK address and convert it with inet_addr.

Longint INET_ADDR

CP: pchar

);

2, the total size of the definition package, the version of IP is IP structure:

The total package size = IP header UDP header size UDP message size,

IP version, defined in this program is 4,

3, fill in the structure of the IP header:

Ip.Ipverlen: = IP version SHL 4;

ip.iptos: = 0; // IP service type

IP.IPTOTIONENGTH: =; // Size

IP.IPID: = 0; // Unique identifier, generally set to 0

ip.Ipoffset: = 0; // Offset field

ip.ipttl: = 128; // Timeout IP.IPPROTOCOL: = $ 11; // Defining Agreement

ip.ipChecksum: = 0; // Total number of inspection

ip.ipsrcaddr: =; // source address

ip.IpdestAddr: =; // destination address

4, fill in the structure of the UDP Baotou:

udp.srcportno: =; // Source port number

UDP.DSTPORTNO: =; // Target port number

Udp.udplength: =; // UDP package size

UDP.UDPCHECKSUM: =; // Total number of inspection

5, put the IP header, UDP header and message, put into the cache.

6, define remote information:

Remote.family: = 2;

Remote.port: =; // Remote port

Remote.addr.addr: =; // Remote address

5) We use Sendto to send a package, usage as follows:

Integer Sendto (S: Integer,

VAR BUF: Integer,

Var Len: integer,

Var flags: integer,

VAR AddRTO: TSOCK_ADDR;

TOLEN: Integer

);

In Socket handle, BUF is a packet that is just built. The total length of the Len passed into the package has just been calculated. Here we have access to Remote, and Tolen is written in the size of the Remote.

6) In the end, don't forget to use CloseSocket (SH) to close Socket and use WSacleanup to shut down Winsock.

The last thing to say is that this transmission method can only send a fully crafted network protocol. If you want to send data in the middle of someone else's program, you can only use APIHOOK or do an intermediate layer in Winsock2. If you have any questions, you need to discuss with me, please send an email to microprogramer@hotmail.com or QQ: 24259132.

转载请注明原文地址:https://www.9cbs.com/read-25304.html

New Post(0)