Guest User

Untitled

a guest
Mar 14th, 2016
151
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. First make a packet
  2. it will be a struct,
  3. struct packet {
  4. struct iphdr ip; //from #include netinet/ip.h
  5. struct udphdr udp; //from #include netinet/udp.h
  6. char payload[BUFSIZE]; //#define BUFSIZE 64 (could be any number)
  7. }
  8. the iphdr struct is declared in the mentioned include, same of the udphdr.
  9.  
  10. Fill in the structs
  11. for example if you have the main function:
  12. main()
  13. {
  14. struct packet pk; //declare a packet of struct earlier defined
  15.  
  16. // Filling in the members of the member ip (which is a struct, structception).
  17. pk.ip.ihl = 5;
  18. pk.ip.version = 4;
  19. ETC. (Lot more members to assign)
  20.  
  21. // Filling in the members of the member udp (same story)
  22. pk.udp.source = htons(6666) //htons to make sure network compatible
  23. pk.udp.dest = samestory with dest port
  24. pk.udp.check = checksum(&ps, &pk) (pointer to pseudo header struct and packet struct) the checksum function, you need to make yourself, make sure it returns the u_int16_t checksum.
  25.  
  26. pk.payload = "lolz am ddosing u, call me maybe";
  27.  
  28. rest of the main function
  29. }
  30.  
  31. Now after you've done this make a while loop using time if you want or just endless
  32. and in the for loop make sure you assign the destination port of all structs that require them,
  33. (struct sockaddr_in daddr, struct packet pk (member udp needs dest port))
  34. after assigning the port to the packet pk you need to assign the pk.udp.check to the return value of calling the function checksum. This because every packet has a different checksum value.
  35. Then finally send the packet.
RAW Paste Data