#include #include #include #include #include #include #include /// Prints usage message void usage(char* filename) { printf("\tNSA - yet another CIA network installer for FBI 2.0 or" "greater.\n" "\tUsage: %s ip-address 1st.cia [2nd.cia 3rd.cia ...]\n", filename); } int main(int argc, char* argv[]) { // Print usage message if too few args are given. if(argc < 3) { usage(argv[0]); return EXIT_FAILURE; } // Check the files first. // Keep each file name with its size, which we'll need when sending the // file. struct file_w_size { char * file; unsigned long int size; }; struct file_w_size filelist[argc-2]; for( int i=2; i> 32; filelist[i].size = (filelist[i].size & 0x0000FFFF0000FFFF) << 16 | (filelist[i].size & 0xFFFF0000FFFF0000) >> 16; filelist[i].size = (filelist[i].size & 0x00FF00FF00FF00FF) << 8 | (filelist[i].size & 0xFF00FF00FF00FF00) >> 8; printf("Sending size of %s...\n", filelist[i].file); send(sock, &filelist[i].size, sizeof(unsigned long int), 0); // Open and send the file printf("Sending %s...\n", filelist[i].file); FILE *fp = fopen(filelist[i].file, "r"); size_t bytes_read; do { bytes_read = fread(buf, 1, 16000000, fp); send(sock, buf, bytes_read, 0); }while(bytes_read); printf("Sent %s!\n", filelist[i].file); fclose(fp); } free(buf); close(sock); return EXIT_SUCCESS; }