Post: packet injection........
05-31-2008, 11:38 PM #1
(adsbygoogle = window.adsbygoogle || []).push({}); ok guys seen as though this got removed from ngb here goes......







#define SRC_ETHER_ADDR "aa:aa:aa:aa:aa:aa"
#define DST_ETHER_ADDR "bb:bb:bb:bb:bb:bb"
#define SRC_IP "192.168.0.10"
#define DST_IP "192.168.0.11"

typedef struct EthernetHeader{

unsigned char destination[6];
unsigned char source[6];
unsigned short protocol;

}EthernetHeader;

typedef struct ArpHeader{

unsigned short hardware_type;
unsigned short protocol_type;
unsigned char hard_addr_len;
unsigned char prot_addr_len;
unsigned short opcode;
unsigned char source_hardware[6];
unsigned char source_ip[4];
unsigned char dest_hardware[6];
unsigned char dest_ip[4];
}ArpHeader;


int CreateRawSocket(int protocol_to_sniff)
{
int rawsock;

if((rawsock = socket(PF_PACKET, SOCK_RAW, htons(protocol_to_sniff)))== -1)
{
perror("Error creating raw socket: ");
exit(-1);
}

return rawsock;
}

int BindRawSocketToInterface(char *device, int rawsock, int protocol)
{

struct sockaddr_ll sll;
struct ifreq ifr;

bzero(&sll, sizeof(sll));
bzero(&ifr, sizeof(ifr));

/* First Get the Interface Index */


strncpy((char *)ifr.ifr_name, device, IFNAMSIZ);
if((ioctl(rawsock, SIOCGIFINDEX, &ifr)) == -1)
{
printf("Error getting Interface index !\n");
exit(-1);
}

/* Bind our raw socket to this interface */

sll.sll_family = AF_PACKET;
sll.sll_ifindex = ifr.ifr_ifindex;
sll.sll_protocol = htons(protocol);


if((bind(rawsock, (struct sockaddr *)&sll, sizeof(sll)))== -1)
{
perror("Error binding raw socket to interface\n");
exit(-1);
}

return 1;

}


int SendRawPacket(int rawsock, unsigned char *pkt, int pkt_len)
{
int sent= 0;

/* A simple write on the socket ..thats all it takes ! */

if((sent = write(rawsock, pkt, pkt_len)) != pkt_len)
{
/* Error */
printf("Could only send %d bytes of packet of length %d\n", sent, pkt_len);
return 0;
}

return 1;


}

EthernetHeader* CreateEthernetHeader(char *src_mac, char *dst_mac, int protocol)
{
EthernetHeader *ethernet_header;


ethernet_header = (EthernetHeader *)malloc(sizeof(EthernetHeader));

/* copy the Src mac addr */

memcpy(ethernet_header->source, (void *)ether_aton(src_mac), 6);

/* copy the Dst mac addr */

memcpy(ethernet_header->destination, (void *)ether_aton(dst_mac), 6);

/* copy the protocol */

ethernet_header->protocol = htons(protocol);

/* done ...send the header back */

return (ethernet_header);
}

ArpHeader *CreateArpHeader(void)
{
ArpHeader *arp_header;
in_addr_t temp;

arp_header = (ArpHeader *)malloc(sizeof(struct ArpHeader));

/* Fill the ARP header */
arp_header->hardware_type = htons(ARPHRD_ETHER);
arp_header->protocol_type = htons(ETHERTYPE_IP);
arp_header->hard_addr_len = 6;
arp_header->prot_addr_len = 4;
arp_header->opcode = htons(ARPOP_REPLY);
memcpy(arp_header->source_hardware, (void *)ether_aton(SRC_ETHER_ADDR) , 6);
temp = inet_addr(SRC_IP);
memcpy(&(arp_header->source_ip), &temp, 4);
memcpy(arp_header->dest_hardware, (void *) ether_aton(DST_ETHER_ADDR) , 6);
temp = inet_addr(DST_IP);
memcpy(&(arp_header->dest_ip), &temp, 4);

return arp_header;
}



/* argv[1] is the device e.g. eth0 */

main(int argc, char **argv)
{

int raw;
unsigned char *packet;
EthernetHeader *ethernet_header;
ArpHeader *arp_header;
int pkt_len;

/* Create the raw socket */

raw = CreateRawSocket(ETH_P_ALL);

/* Bind raw socket to interface */

BindRawSocketToInterface(argv[1], raw, ETH_P_ALL);

/* create Ethernet header */

ethernet_header = CreateEthernetHeader(SRC_ETHER_ADDR, DST_ETHER_ADDR, ETHERTYPE_ARP);

/* Create ARP header */

arp_header = CreateArpHeader();

/* Find packet length */

pkt_len = sizeof(EthernetHeader) + sizeof(ArpHeader);

/* Allocate memory to packet */

packet = (unsigned char *)malloc(pkt_len);

/* Copy the Ethernet header first */

memcpy(packet, ethernet_header, sizeof(EthernetHeader));

/* Copy the ARP header - but after the ethernet header */

memcpy((packet + sizeof(EthernetHeader)), arp_header, sizeof(ArpHeader));

/* Send the packet out ! */

if(!SendRawPacket(raw, packet, pkt_len))
{
perror("Error sending packet");
}
else
printf("Packet sent successfully\n");

/* Free the memory back to the heavenly heap */

free(ethernet_header);
free(arp_header);
free(packet);

close(raw);

return 0;
}
(adsbygoogle = window.adsbygoogle || []).push({});
08-10-2008, 03:53 AM #47
lildeg8
im a ps3 hacker
i dont understand i might be retarded.
08-11-2008, 07:49 AM #48
Originally posted by lildeg8 View Post
i dont understand i might be retarded.


That would explain it Happy
08-14-2008, 10:36 PM #49
ccuzzo75
Save Point
what does this do cuz of course i want my hacks back but i dont want to put this in and mess up my game. be more specific !!!, should i put it in my game save...... WHAT!!
08-15-2008, 02:02 AM #50
Originally posted by ccuzzo75 View Post
what does this do cuz of course i want my hacks back but i dont want to put this in and mess up my game. be more specific !!!, should i put it in my game save...... WHAT!!


I direct you into this thread:

You must login or register to view this content.

But unfortunately I wrote on the header that if you think the SOURCE CODE for a RAW SOCKET is supposed to be inside a savefile you should leave the thread.

If you want to hack try not to leech everywhere and ask questions when most of the time they are answered. Everyone wants there hacks back but only people that actually put a little sense into find whats happening and if it's possible to hack Call of duty 4.

For now I wouldn't hack Call of duty 4 as Sony (supposing your hacking on the Playstation 3 version) is laying many bans. Why cheat in this game anyway, it's really easy as it is. I only look into cheats for practice.

Winky Winky
11-29-2008, 10:52 AM #51
and what does raw sockets actually do then? coz this seems pointless atm
12-03-2008, 01:42 AM #52
I'm guessing it's exactly what was already in the gamesave but moddified.
12-08-2008, 04:12 PM #53
I kinda understand whats goin on... but only at the most basic level..... think am gunna do what the god said an do a bit of research..... If anyone else is intrested message me i could use the help as 2 heads are better than one!
12-08-2008, 06:25 PM #54
MEKO112
S.P.E.C.I.A.L
kool it sounds kool to me
01-02-2009, 01:35 AM #55
Default Avatar
Rushnut
Guest
I have some limited C++ coding (From using BYOND) but packet injection isnt new, i know what it is, but i dont know how to use it, e.g i know you must find the packet for when you lay a C4, but i dont know HOW to find it.
Please help?

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo