Search
Search
Search
Search
Information
Information
Light
Dark
Open actions menu
Basic upload method
Bypass upload method
Tips!
If you encounter an error (by firewall) while uploading using both methods,
try changing extension of the file before uploading it and rename it right after.
This uploader supports multiple file upload.
Submit
~
scripts
File Content:
daemonserver.c
/* Artificial Intelligence Support Assistant - (AISA) */ #include<stdio.h> #include<string.h> //strlen #include<stdlib.h> //strlen #include<sys/socket.h> #include<arpa/inet.h> //inet_addr #include<unistd.h> //write #include<pthread.h> //for threading , link with lpthread #include <errno.h> //the thread function void *connection_handler(void *); char *execute_command (char *command, int len); char *get_domain_info_from_server (char *command) ; char* find_and_change_permission (char *command) ; char* call_to_system (char *command) ; int main(int argc , char *argv[]) { int socket_desc , client_sock , c , *new_sock; struct sockaddr_in server , client; socklen_t len; struct sockaddr_storage addr; char ipstr[INET6_ADDRSTRLEN]; int enable = 1; //Create socket socket_desc = socket(AF_INET , SOCK_STREAM , 0); if (socket_desc == -1) { printf("Could not create socket"); } puts("Socket created"); //Prepare the sockaddr_in structure server.sin_family = AF_INET; server.sin_addr.s_addr = INADDR_ANY; server.sin_port = htons(4445); if (setsockopt(socket_desc, SOL_SOCKET, SO_REUSEADDR, &enable, sizeof(int)) < 0) perror("setsockopt(SO_REUSEADDR) failed"); //Bind if( bind(socket_desc,(struct sockaddr *)&server , sizeof(server)) < 0) { //print the error message perror("bind failed. Error"); return 1; } puts("bind done"); //Listen listen(socket_desc , 3); //Accept and incoming connection puts("Waiting for incoming connections..."); c = sizeof(struct sockaddr_in); while( (client_sock = accept(socket_desc, (struct sockaddr *)&client, (socklen_t*)&c)) ) { puts("Connection accepted"); len = sizeof addr; getpeername(client_sock, (struct sockaddr*)&addr, &len); // deal with both IPv4 and IPv6: if (addr.ss_family == AF_INET) { struct sockaddr_in *s = (struct sockaddr_in *)&addr; inet_ntop(AF_INET, &s->sin_addr, ipstr, sizeof ipstr); } else { // AF_INET6 struct sockaddr_in6 *s = (struct sockaddr_in6 *)&addr; inet_ntop(AF_INET6, &s->sin6_addr, ipstr, sizeof ipstr); } printf("Peer IP address: %s\n", ipstr); if (strcmp(ipstr, "127.0.0.1") == 0) { puts("New Client connected from our server"); } else { puts ("Other IP address, Disconnecting") ; close (client_sock) ; continue ; } pthread_t sniffer_thread; new_sock = malloc(1); *new_sock = client_sock; if( pthread_create( &sniffer_thread , NULL , connection_handler , (void*) new_sock) < 0) { perror("could not create thread"); return 1; } //Now join the thread , so that we dont terminate before the thread //pthread_join( sniffer_thread , NULL); } if (client_sock < 0) { perror("accept failed"); return 1; } return 0; } /* * This will handle connection for each client * */ void *connection_handler(void *socket_desc) { //Get the socket descriptor int sock = *(int*)socket_desc; char command_to_exe [900024] ; char client_message [900024] ; char *tmp_fname ; char tmp_fname_res [100] ; char tmp_a [100] ; int read_size ; FILE *fp; tmp_fname = tmpnam (NULL) ; fp = fopen(tmp_fname , "w" ); read_size = recv(sock , client_message , 900024 , 0) ; fwrite(client_message , 1 , read_size , fp ); fclose(fp); sprintf (command_to_exe, "/usr/bin/php -c /etc/sentora/panel/etc/apps/filemanager/php.ini /etc/sentora/panel/modules/server/php-multithreaded-socket-server-master/handle-server.php %s", tmp_fname) ; puts (command_to_exe) ; system (command_to_exe) ; strcpy (tmp_fname_res, tmp_fname) ; strcat (tmp_fname_res, ".res") ; fp = fopen(tmp_fname_res, "r" ); if (fp == NULL) { puts ("file open failled") ; write(sock , "failed_to_open_response_file", strlen("Failed")) ; remove (tmp_fname) ; return NULL; } memset(client_message,0, 900024); fread(client_message, 1, 900024, fp); fclose(fp); write(sock , client_message, strlen(client_message)) ; free(socket_desc); close(sock); remove (tmp_fname) ; remove (tmp_fname_res) ; return 0; }
Edit
Download
Unzip
Chmod
Delete