Results 1 to 2 of 2

Thread: The REAL packet injection

  1. #1
    JMC31337
    Guest

    Default

    In this tutorial we will learn a lil programming in C using GCC
    Follow my edits and you'll be able to packet inject Hello World
    ===============================================
    #include<string.h>
    #include<stdio.h>
    #include<stdlib.h>
    #include<sys/socket.h>
    #include<features.h>
    #include<linux/if_packet.h>
    #include<linux/if_ether.h>
    #include<errno.h>
    #include<sys/ioctl.h>
    #include<net/if.h>
    #define PACKET_LENGTH 1024
    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));
    strncpy((char *)ifr.ifr_name, device, IFNAMSIZ);
    if((ioctl(rawsock, SIOCGIFINDEX, &ifr)) == -1)
    {
    printf("Error getting Interface index !\n");
    exit(-1);
    }
    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;
    if((sent = write(rawsock, pkt, pkt_len)) != pkt_len)
    {
    return 0;
    }
    return 1;
    }
    main(int argc, char **argv)
    {
    int raw;
    unsigned char packet[PACKET_LENGTH];
    int num_of_pkts; int x; x = getchar();
    memset(packet, x, PACKET_LENGTH);
    while (x != EOF)
    {
    x = getchar();

    raw = CreateRawSocket(ETH_P_ALL);
    BindRawSocketToInterface(argv[1], raw, ETH_P_ALL);
    num_of_pkts = atoi(argv[2]);
    while((num_of_pkts--)>0)
    { if(!SendRawPacket(raw, packet, PACKET_LENGTH))
    {
    perror("Error sending packet");
    }
    else
    {
    printf("Packet sent successfully\n");
    }
    }
    close(raw);
    memset(packet, x, PACKET_LENGTH);
    }

    return 0;
    }
    =================================
    1) copy to file Pak.c
    2) compile with gcc -o Pak Pak.c
    3) start tcpdump -i "Interface ID"
    4) run Pak with ./Pak "Interface ID" "# of packets"
    i.e: ./Pak rausb0 1
    5) type the packet
    i.e: Hello World
    6) look at TCPDUMP and you should see a bunch of packets

    NOTE: NULL CHARACTER is in C programming so the NULL character will be displayed

    THE TRUE PACKET INJECTION!!!!!!
    MODIFIED BY JMC31337

    the above code + other C codes for packet injection can be found @
    hxxp://security-freak.net/packet-injection/packet-injection.html

    Happy Packet Injection

  2. #2
    JMC31337
    Guest

    Default So lets head on over to the Programming Forum

    We will show an easy C code overflow first to get you acquainted with what overflows are. Do an easy shell code. Then play with JAVA. Now they say JAVA is "IMPOSSIBLE" to overflow, so maybe with our own client server apps, we can find one. At least, we'll have a home-made server to hack attack.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •