 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Fri Nov 21, 2008 10:45 pm Post subject: Sending Packets |
|
|
I know you can send packets with the send/sendto function. But if you wanted to send a "custom" packet (Like, you went low level and did all the hex stuff).....example:
| Code: |
33 0C 85 49 19 84 C4 CF CC F3 C3 06 28 5F 56 D4 C4 9F 41 18 EA E1 24 7C 6D 83 D2 66 AC AF 33 6F A2 A6 DA 41 78 0F F3 29 09 A2 7B D3 D0 68 40 06 EE 4C 1A 5A DA 4D 43 83 49 39 63 89 A0 44 B8 BF 59 B8 27 66 C0 F4 8C 02 CF 83 F4 18 5F C0 56 9A
|
Would you just store it in a string and use that string as your buffer for the send/sendto function? And, if you do this, do you have to create the packet header, or only the payload?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Fri Nov 21, 2008 11:14 pm Post subject: |
|
|
Store it in an array of bytes/chars.
You have to include the header.
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Nov 22, 2008 12:50 am Post subject: |
|
|
So I would do something like:
| Code: |
char buf[255] = "33 0C 85 49 19 84 C4 CF CC F3 C3 06 28 5F 56 D4 C4 9F 41 18 EA E1 24 7C 6D 83 D2 66 AC AF 33 6F A2 A6 DA 41 78 0F F3 29 09 A2 7B D3 D0 68 40 06 EE 4C 1A 5A DA 4D 43 83 49 39 63 89 A0 44 B8 BF 59 B8 27 66 C0 F4 8C 02 CF 83 F4 18 5F C0 56 9A";
send(socket, buf, strlen(buf), NULL);
|
?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
pkedpker Master Cheater
Reputation: 1
Joined: 11 Oct 2006 Posts: 412
|
Posted: Sat Nov 22, 2008 3:34 am Post subject: |
|
|
| oib111 wrote: | So I would do something like:
| Code: |
char buf[255] = "33 0C 85 49 19 84 C4 CF CC F3 C3 06 28 5F 56 D4 C4 9F 41 18 EA E1 24 7C 6D 83 D2 66 AC AF 33 6F A2 A6 DA 41 78 0F F3 29 09 A2 7B D3 D0 68 40 06 EE 4C 1A 5A DA 4D 43 83 49 39 63 89 A0 44 B8 BF 59 B8 27 66 C0 F4 8C 02 CF 83 F4 18 5F C0 56 9A";
send(socket, buf, strlen(buf), NULL);
|
? |
close but taht won't work cuz C++ doesn't know those are hexademials you have to use \x in front of all and you have to remove all spaces..
just replace all spaces with \x and it will work..
i'll give you a little example to get u started
\x33\x0C\x85\x49\x19\x84\xC4\xCF\xCC
etc..
store em in unsigned char buff[255]; after all they are unsigned
_________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Nov 22, 2008 5:11 am Post subject: |
|
|
You could also simply do:
| Code: | | char Buffer[] = { 0x33, 0x0C, 0x85, ... }; |
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Nov 22, 2008 10:57 am Post subject: |
|
|
Yea, I was going to ask if I had to do \x. So, it would be something like:
| Code: |
char buffer[] = "33\x0C\x85\x49\x19\x84\xC4\xCF\xCC\xF3\xC3\x06\x28\x5F\x56\xD4\xC4\x9F\x41\x18\xEA\xE1\x24\x7C\x6D\x83\xD2\x66\xAC\xAF\x33\x6F\xA2\xA6\xDA\x41\x78\x0F\xF3\x29\x09\xA2\x7B\xD3\xD0\x68\x40\x06\xEE\x4C\x1A\x5A\xDA\x4D\x43\x83\x49\x39\x63\x89\xA0\x44\xB8\xBF\x59\xB8\x27\x66\xC0\xF4\x8C\x02\xCF\x83\xF4\x18\x5F\xC0\x56\x9Aa";
send(socket, buffer, strlen(buffer), NULL);
|
And since, I gotta do the header, I have to do all this lol?
| Quote: |
IP packets are composed of a header and Payload. The IPv4 packet header consists of:
1. 4 bits that contain the version, that specifies if it's an IPv4 or IPv6 packet,
2. 4 bits that contain the Internet Header Length which is the length of the header in multiples of 4 bytes. Ex. 5 is equal to 20 bytes.
3. 8 bits that contain the Type of Service, also referred to as Quality of Service (QoS), which describes what priority the packet should have,
4. 16 bits that contain the length of the packet in bytes,
5. 16 bits that contain an identification tag to help reconstruct the packet from several fragments,
6. 3 bits that contain a zero, a flag that says whether the packet is allowed to be fragmented or not (DF: Don't fragment), and a flag to state whether more fragments of a packet follow (MF: More Fragments)
7. 13 bits that contain the fragment offset, a field to identify which fragment this packet is attached to,
8. 8 bits that contain the Time to live (TTL) which is the number of hops (router, computer or device along a network) the packet is allowed to pass before it dies (for example, a packet with a TTL of 16 will be allowed to go across 16 routers to get to its destination before it is discarded),
9. 8 bits that contain the protocol (TCP, UDP, ICMP, etc...)
10. 16 bits that contain the Header Checksum, a number used in error detection,
11. 32 bits that contain the source IP address,
12. 32 bits that contain the destination address.
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
Posted: Sat Nov 22, 2008 2:29 pm Post subject: |
|
|
| Quote: | | char buffer[] = "33\x0C\x85\x49\x19\x84\xC4\xCF\xCC\xF3\xC3\x06\x28\x5F\x56\xD4\xC4\x9F\x41\x18\xEA\xE1\x24\x7C\x6D\x83\xD2\x66\xAC\xAF\x33\x6F\xA2\xA6\xDA\x41\x78\x0F\xF3\x29\x09\xA2\x7B\xD3\xD0\x68\x40\x06\xEE\x4C\x1A\x5A\xDA\x4D\x43\x83\x49\x39\x63\x89\xA0\x44\xB8\xBF\x59\xB8\x27\x66\xC0\xF4\x8C\x02\xCF\x83\xF4\x18\x5F\xC0\x56\x9Aa"; |
"33.....a"
Add \x.
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Nov 22, 2008 7:04 pm Post subject: |
|
|
The a is a typo lol. Btw, does any1 have an example of an ARP Packet? I'm looking on wikipedia and got this (http://en.wikipedia.org/wiki/Address_Resolution_Protocol#Example_reply):
| Quote: |
Given the scenario laid out in the request section, if the host 10.10.10.140 is running and available, then it would receive the ARP request and send a reply packet as shown below. (This reply assumes that the host 10.10.10.140 has a MAC address of 00:09:58:D8:33:AA.) Note that the sender and target address blocks have been swapped (the sender of the reply is the target of the request; the target of the reply is the sender of the request). Furthermore, the host 10.10.10.140 has filled in its MAC address in the sender hardware address.
Any hosts on the same network as these two hosts would also see the request (since it is a broadcast) so they are able to cache information about the source of the request. The ARP reply (if any) is directed only to the originator of the request so information in the ARP reply is not available to other hosts on the same network.
+ Bits 0 - 7 8 - 15 16 - 31
0 Hardware type = 1 Protocol type = 0x0800
32 Hardware length = 6 Protocol length = 4 Operation = 2 (reply)
64 SHA (first 32 bits - Sender MAC) = 0x000958D8
96 SHA (last 16 bits - Sender MAC) = 0x33AA SPA (first 16 bits - Sender IP) = 0x0A0A
128 SPA (last 16 bits - Sender IP) = 0x0A8C THA (first 16 bits - Target MAC) = 0x0009
160 THA (last 32 bits - Target MAC) = 0x58D81122
192 TPA (32 bits - Target IP) = 0x0A0A0A7B
|
And I got this as the code, someone correct me if I'm wrong (which I'm pretty sure I am haha):
| Code: |
WSADATA wsaData;
SOCKET SendSocket;
sockaddr_in RecvAddr;
int Port = 27015;
WSAStartup(MAKEWORD(2,2), &wsaData);
RecvAddr.sin_family = AF_INET;
RecvAddr.sin_port = htons(Port);
RecvAddr.sin_addr.s_addr = inet_addr("10.10.10.123");
char buffer[] = "\x01\x08\x00\x06\x04\x02\x00\x09\x58\xD8\x33\xAA\x0A\x0A\x0A\x8C\x00\x09\x58\xD8\x11\x22\x0A\x0A\x0A\x7B";
sendto(SendSocket, buffer, strlen(buffer), NULL, (SOCKADDR*)&RecvAddr, sizeof(RecvAddr));
|
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
killersamurai Expert Cheater
Reputation: 0
Joined: 10 Sep 2007 Posts: 197 Location: Colorado
|
Posted: Sat Nov 22, 2008 8:26 pm Post subject: |
|
|
| I would use a structure instead of an array if I created the packet. That is assuming I know what every byte/s represents. It will be a lot easier to just create a structure and fill it instead of creating an array and setting every byte. If you wrote a program that creates the packet with user specified information, it will be easier to put it in the structure. If you are just going to use one set of information and not change it, then the array would be fine.
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Nov 22, 2008 8:49 pm Post subject: |
|
|
It's not going to be user defined. And how exactly would you use a structure for creating a packet? Like have a member of the structure for each part? And can anyone verify that the packet I constructed is correct...based off this link: http://en.wikipedia.org/wiki/Address_resolution_protocol#Example_reply
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Sat Nov 22, 2008 9:20 pm Post subject: |
|
|
struct packett{
char * header;
char *packet;...
|
|
| Back to top |
|
 |
killersamurai Expert Cheater
Reputation: 0
Joined: 10 Sep 2007 Posts: 197 Location: Colorado
|
Posted: Sat Nov 22, 2008 9:28 pm Post subject: |
|
|
If you want to use a structure you would fill it out before sending
[example]
typedef struct _A
{
int a;
int b;
}A;
A a;
a.a = 0xffffffff;
a.b = 0xffffffff;
[/example]
After that, you would send it.
[example]
sendto(socket, &a, sizeof(A), flags, to, tolen);
[/example]
a is just an address, so it will point to the beginning of a. With the sizeof(A), you specify that the structure contains 8 bytes (two int's) and it will send 8 bytes from the structure.
You can confirm it by doing something like this.
| Code: |
#include <stdio.h>
typedef struct _A
{
int a;
int b;
}A;
int main(void)
{
A a;
unsigned char * c = &a;
a.a = 0x01020304;
a.b = 0x05060708;
printf("Address of a: %p\n", &a);
printf("c is pointing to: %p\n", c);
printf("Value of a.a: %x\n", a.a);
printf("Value of a.b: %x\n", a.b);
printf("c first byte: %x\n", *c);
c++;
printf("c second byte: %x\n", *c);
c++;
printf("c third byte: %x\n", *c);
c++;
printf("c fourth byte: %x\n", *c);
c++;
printf("c fifth byte: %x\n", *c);
c++;
printf("c sixth byte: %x\n", *c);
c++;
printf("c seventh byte: %x\n", *c);
c++;
printf("c eighth byte: %x\n", *c);
return 0;
}
|
|
|
| Back to top |
|
 |
oib111 I post too much
Reputation: 0
Joined: 02 Apr 2007 Posts: 2947 Location: you wanna know why?
|
Posted: Sat Nov 22, 2008 11:04 pm Post subject: |
|
|
Ok, I see. But still, can anyone confirm I correctly constructed the packet?
_________________
| 8D wrote: |
cigs dont make people high, which weed does, which causes them to do bad stuff. like killing |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|