int main(int argc, const char * argv[]) { int counter = 1; while (counter < 3) { int goAgain = 0; int numberOfItems = 0; printIntro(); getRoomChoice(); if (counter == 1) { printf("\nDo you want to try again? Type 0 for NO and 1 for YES."); } else { break; } numberOfItems =scanf("%d", &goAgain); if (goAgain == 1) { counter++; } else { break; } } return 0; }
int main(int argc, char **argv) { srand(time(NULL)); printIntro(); initStats(); processArgs(argc, argv); // Start the packet processor pthread_t packet_processor; pthread_create(&packet_processor, NULL, process_incoming, NULL); // Start the syn flood thread pthread_t syn_sender; pthread_create(&syn_sender, NULL, send_syns, NULL); pthread_t status_update; pthread_create(&status_update, NULL, print_status, NULL); // Wait for the threads to return, which is never. pthread_join(syn_sender, NULL); pthread_join(packet_processor, NULL); pthread_join(status_update, NULL); return 0; }
void startShell() { initShell(); printIntro(); char initialInputChar = '\0'; while (initialInputChar != EOF) { promptPrefix(); initialInputChar = getchar(); // User hits enter if (initialInputChar == '\n') { continue; // End of file symbol reached } else if (initialInputChar == EOF) { break; // User is typing a command } else { // Adding the 'initialInputChar' as the first character of the command int inputCounter = 0; char shellInput[INPUT_SIZE]; shellInput[inputCounter++] = initialInputChar; // Waiting for more user input char tempChar; while (inputCounter < INPUT_SIZE) { tempChar = getchar(); // User has finished typing command if (tempChar == '\n') { // Properly ending the input shellInput[inputCounter] = '\0'; // Performing the command AppCommand appCommand = identifyCommand(shellInput); performCommand(appCommand, shellInput); break; // Forming command } else { shellInput[inputCounter++] = tempChar; } } // Freeing memory for the inputted string memset(shellInput, 0, INPUT_SIZE); } } }
void MsgStream::print(MsgLevel level, const std::string& msg) { if(level <= outputLevel) { printIntro(level); std::cout << msg << std::endl; } if(level <= logLevel) { logIntro(level); logfile << msg << std::endl; } }
int main(void){ HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE); static char string[1000] = ""; char cmd[1000] = ""; int exitCheck = 0; changeSize(); printIntro(string); SetConsoleTextAttribute(hConsole, 0); system("cls"); printMainString(string, 1); printInputField(string); while (!exitCheck){ SetConsoleTextAttribute(hConsole, 14); fgets(cmd, 999, stdin); if ((strcmp(cmd, "") != 0)) exitCheck = executeCmd(cmd, string, 7 + strlen(string) / 74); cleanStr(cmd); } return 0; }
int main() { initscr(); cbreak(); noecho(); keypad(stdscr, TRUE); //open file and write intro data to file FILE *file; file = openFile(); //collect summary data from user and write to file char *title = ""; char *desc = ""; char *loc = ""; char temp[3] = ""; //sprintf(temp,"a"); getSummary(title, desc, loc); //collect data/time data from user and write to file char *startdatetime; char *enddatetime; getDateTime(startdatetime,enddatetime); //!!!!!!remember: [date]T[time]!!!!!!!!!!!!! //clean up getch(); endwin(); //print data to file printIntro(file); printCurrentTime(file); fprintf(file,"ORGANIZER;CN=Derek Redfern:mailto:[email protected]\n\ DESCRIPTION:%s\nSUMMARY;LANGUAGE=en-us:%s\nLOCATION:%s\n",\ desc,title,loc); fprintf(file,"DTSTART;TZID=\"Eastern Standard Time\":%s\n",startdatetime); fprintf(file,"DTEND;TZID=\"Eastern Standard Time\":%s\n",enddatetime); fprintf(file,"END:VEVENT\nEND:VCALENDAR\n"); fclose(file); return 0; }
int kmain(struct multiboot* mboot_ptr) { clearScreen(); init_descriptor_tables(); __asm__ __volatile__("sti"); uint32 initrd_location = findInitrd(mboot_ptr); initialize_paging(); // Initialize the initial ramdisk, and set it as the filesystem root. fs_root = initialize_initrd(initrd_location); printIntro(); println(PRO_TIP, 0x0F); kbHelp(); launchShell(); return 0; }
int main(int argc, char *argv[]) { char *openFile, *destFile; int ret; printIntro("ITG2"); if (argc < 3) { printf("usage: %s <input file> <output file>\n", argv[0]); exit(0); } openFile = argv[1]; destFile = argv[2]; printf("decrypting %s into %s...\n", openFile, destFile); ret = keydump_itg2_decrypt_file(openFile, destFile, KEYDUMP_ITG2_FILE_DATA, NULL); if (ret > -1) { printf("done :D\n"); printf("padMisses: %u\n", ret); } fclose(dfd); fclose(fd); return 0; }
int main(int argc, char *argv[]) { srand(time(NULL)); int fileSize, i, j, subkeySize = 1024, totalBytes = 0; // LOOOOOOOOOL int padMisses = 0; int got, numcrypts; char magic[2], dmagic[2]; uchar *aesKey, backbuffer[16], subkey[1024], verifyBlock[16]; uchar *plaintext = ":Dbyinfamouspat\0"; uchar encbuf[4080], decbuf[4080]; aes_encrypt_ctx ctx[1]; char *openFile, *destFile; FILE *fd, *dfd; printIntro("ITG2"); if (argc < 3) { printf("usage: %s <input file> <output file>\n", argv[0]); exit(0); } openFile = argv[1]; destFile = argv[2]; if ((fd = fopen(openFile, "rb")) == NULL) { fprintf(stderr, "%s: fopen(%s) failed D=\n", argv[0], argv[1]); exit(-1); } for (i = 0; i < subkeySize; i++) subkey[i] = rand() * 255; printf("retrieving key from dongle...\n"); aesKey = (uchar*)malloc(24 * sizeof(uchar)); if (getKey(subkey, aesKey) != 0) { fclose(fd); exit(-1); } aes_encrypt_key(aesKey, 24, ctx); aes_encrypt(plaintext, verifyBlock, ctx); #ifdef KD_DEBUG printKey(aesKey); printbuffer("plaintext",plaintext); printbuffer("verifyBlock",verifyBlock); #endif printf("encrypting into %s...\n", destFile); if ((dfd = fopen(destFile, "wb")) == NULL) { fprintf(stderr, "%s: fopen(%s) failed D=\n", argv[0], destFile); fclose(fd); exit(-1); } fseek(fd, 0, SEEK_END); fileSize = ftell(fd); fseek(fd, 0, SEEK_SET); fwrite(":|", 2, 1, dfd); fwrite(&fileSize, 1, 4, dfd); fwrite(&subkeySize, 1, 4, dfd); fwrite(subkey, 1, subkeySize, dfd); fwrite(verifyBlock, 1, 16, dfd); do { if ((got = fread(decbuf, 1, 4080, fd)) == -1) { fprintf(stderr, "%s: error: fread(%s) returned -1, exiting...\n", argv[0], openFile); fclose(dfd); fclose(dfd); exit(-1); } totalBytes += got; numcrypts = got / 16; if (got % 16 > 0) { numcrypts++; } if (got > 0) { memset(backbuffer, '\0', 16); for (i = 0; i < numcrypts; i++) { for (j = 0; j < 16; j++) { ((uchar*)(decbuf+(16*i)))[j] ^= (((uchar)backbuffer[j]) - j); } aes_encrypt(decbuf+(16*i), encbuf+(16*i), ctx); memcpy(backbuffer, encbuf+(16*i), 16); } fwrite(encbuf, 1, numcrypts*16, dfd); } } while (got > 0); printf("done :D\n"); fclose(dfd); fclose(fd); return 0; }
void me(string args) { if (!hasSetup) { if (streql(splitArg(args, 1), "-H")) { // a super legit help section brought to you by @plankp print("\nMe is here to help you... Believe me...", brown); } else if (streql(splitArg(args, 1), "TEST") && !hasSetup) { hasSetup = true; messageBox("\nYou have skipped the Me setup process."); } else if (!hasSetup) { meHeader(); messageBox("\nWelcome to Me. To start using Me,\n\rpress <RET> to setup Me."); meHeader(); name = messageBox_I("What is your name?"); meHeader(); while (!birthYearValid) { birthYear = messageBox_I("What year were you born in?"); birthYearInt = stoi(birthYear); // need to make this always the current year + 1 if (birthYearInt < getTime("year") && birthYearInt > 1900) { birthYearValid = true; goodAnswer(); } if (!birthYearValid) { badAnswer(); } } meHeader(); while (!birthDateValid) { newline(); birthDate = messageBox_I("What day were you born on"); birthDateInt = stoi(birthDate); if (birthDateInt < 32) { birthDateValid = true; goodAnswer(); } if (!birthDateValid) { badAnswer(); } } meHeader(); while (!birthMonthValid) { newline(); birthMonth = messageBox_I("What month were you born in?"); birthMonth = toUpper(birthMonth); if (findInDictionary("me/setup/month.text",birthMonth)) { birthMonthValid = true; goodAnswer(); } if (!birthMonthValid) { badAnswer(); } } meHeader(); while (!continentValid) { newline(); continent = messageBox_I("What continent do you live in?"); continent = toUpper(continent); if (findInDictionary("me/setup/continent.text",continent)) { continentValid = true; goodAnswer(); } if (!continentValid) { badAnswer(); } } meHeader(); while (!countryValid) { newline(); country = messageBox_I("What country do you live in?"); country = toUpper(country); if (findInDictionary("me/setup/country.text",country)) { countryValid = true; goodAnswer(); } if (!countryValid) { badAnswer(); } } meHeader(); while (!stateValid) { newline(); state = messageBox_I("What state/province do you live in?"); state = toUpper(state); if (findInDictionary("me/setup/state.text",state)) { stateValid = true; goodAnswer(); } if (!stateValid) { badAnswer(); } } meHeader(); newline(); city = messageBox_I("What city/town do you live in?"); clearLine(0,26,0x88); drawFrame(header_background, 20, 8, 60, 11); printAt("Me Setup Process", 0x3D, 21, 9); while (!zipValid) { newline(); zip = messageBox_I("What is your zip/post code?"); zipInt = htoi(zip); if (zipInt > 0) { zipValid = true; goodAnswer(); } else { badAnswer(); } } meHeader(); hasSetup = "true"; messageBox("Me is now ready to use! Type 'me' on\n\rthe command line to begin."); printIntro(); drawBorder(screen_background, 0, 4, 80, sh - 1); actualY = 5; printAt("Q-Kernel> ", light_grey, 1, actualY); } else { print("\nYou have already completed the setup process for Me!",purple); } } else if (streql(splitArg(args, 1),"")) { querying = true; string meArgs = NULL; while (querying) { newline(); //meArgs = ""; print("me> ",green); meArgs = readstr(); print(answer(meArgs,0),red); } } else { answer(args,1); } }
void launchShell() { //allocate some memory for command string buffer. 1kB should be enough for now const int bufSize = 128; char bufStr[bufSize]; while (true) { print("\nQ-Kernel> ", 0x08); typingCmd = true; newCmd = true; readStr(bufStr, bufSize); typingCmd = false; if (strEql(strTrim(bufStr), "")) { print(COMMAND_HELP, 0x0F); } else if(strEql(bufStr, "help")) { kbHelp(); println(PRO_TIP, 0x0F); print(COMMAND_HELP, 0x0F); } else if(strEql(bufStr, "reboot")) { //reboots the computer reboot(); } else if(strEql(bufStr, "skip")) { // It literally does nothing... (Useful at callback) } else if(strEql(bufStr, "hi")) { print("\nHello!", 0x3F); } else if(strEql(bufStr, "files")) { newline(); listTree(); } else if(strEql(bufStr, "cat")) { print("\nFile Name> ", 0x0F); readStr(bufStr, bufSize); ASSERT(strlength(bufStr) < MAX_FNAME_LEN); catFile(finddir_fs(fs_root, bufStr)); } else if(strEql(bufStr,"execute")) { execute(); } else if(strEql(bufStr,"switch")) { print("\nThe specified directory was not found ", 0x0F); } else if(strEql(bufStr,"writer")) { writer(); } else if(strEql(bufStr, "writer -h")) { writerHelp(); } else if(strEql(bufStr, "calc")){ calc(); } else if(strEql(bufStr, "calc -h")){ calcHelp(); } else if(strEql(bufStr, "clear")) { clearScreen(); cursorX = 0; cursorY = 0; updateCursor(); } else if(strEql(bufStr, "clear -i")) { clearScreen(); printIntro(); } else if(strEql(bufStr, "newdir")) { print("\nReserved", 0x0F); } else if(strEql(bufStr, "erase")) { print("\nReserved", 0x0F); } else { print("\nCommand Not Found ", 0x0F); } newline(); } }
int main(int argc, char *argv[]) { srand(time(NULL)); int fileSize, i, j, subkeySize = 1024, totalBytes = 0; // LOOOOOOOOOL int padMisses = 0; int got, numcrypts; char magic[2], dmagic[2]; uchar *aesKey, verifyBlock[22], backbuffer[16], subkey[1024]; uchar *plaintext = "<<'08infamouspat"; uchar *SHAworkspace; uchar salt[16], salted[16], dsalted[16]; uchar encbuf[4080], decbuf[4080]; aes_encrypt_ctx ctx[1]; char *openFile, *destFile; FILE *fd, *dfd; printIntro("Pump It Up Pro"); if (argc < 3) { printf("usage: %s <input file> <output file>\n", argv[0]); exit(0); } openFile = argv[1]; destFile = argv[2]; if ((fd = fopen(openFile, "rb")) == NULL) { fprintf(stderr, "%s: fopen(%s) failed D=\n", argv[0], argv[1]); exit(-1); } for (i = 0; i < subkeySize; i++) subkey[i] = rand() * 255; SHAworkspace = (uchar*)malloc(sizeof(uchar) * (subkeySize+47)); memcpy(SHAworkspace, subkey, subkeySize); memcpy(SHAworkspace+subkeySize, PProSubkeySalt, 47); aesKey = (uchar*)malloc(24 * sizeof(uchar)); memset(aesKey, '\0', 24); gcry_md_hash_buffer(GCRY_MD_SHA1, aesKey, SHAworkspace, subkeySize+47); printKey(aesKey); aes_encrypt_key(aesKey, 24, ctx); for (i = 0; i < 16; i++) salt[i] = rand() * 255; saltHash(salted, salt, 0x123456); aes_encrypt(salted, dsalted, ctx); for (i = 0; i < 16; i++) { verifyBlock[i] = plaintext[i] ^ dsalted[i]; } #ifdef KD_DEBUG printKey(aesKey); printbuffer("salt", salt); printbuffer("salted", salted); printbuffer("dsalted", dsalted); printbuffer("plaintext", plaintext); printbuffer("verifyBlock", verifyBlock); #endif if ((dfd = fopen(destFile, "wb")) == NULL) { fprintf(stderr, "%s: fopen(%s) failed D=\n", argv[0], destFile); fclose(fd); exit(-1); } fwrite("8O", 1, 2, dfd); fwrite(&subkeySize, 1, 4, dfd); fwrite(subkey, 1, subkeySize, dfd); fwrite(salt, 1, 16, dfd); fseek(fd, 0, SEEK_END); fileSize = ftell(fd); fseek(fd, 0, SEEK_SET); printf("file size: %u\n", fileSize); fwrite(&fileSize, 1, 4, dfd); fwrite(verifyBlock, 1, 16, dfd); printf("encrypting into %s...\n", destFile); do { if ((got = fread(decbuf, 1, 4080, fd)) == -1) { fprintf(stderr, "wtf..?\n"); fclose(dfd); fclose(fd); exit(-1); } numcrypts = got / 16; if (got % 16 > 0) { numcrypts++; } if (got > 0) { for (i = 0; i < numcrypts; i++) { //saltHash(salted, salt, numcrypts); //memcpy(salted, salt, 16); //salted[0] += numcrypts; aes_encrypt(salt, dsalted, ctx); // LOLOLOLOLOL // this should cover about a 320GB file, so we should be good... if (salt[0] == 255 && salt[1] == 255 && salt[2] == 255 && salt[3] == 255 && salt[4] == 255) salt[5]++; if (salt[0] == 255 && salt[1] == 255 && salt[2] == 255 && salt[3] == 255) salt[4]++; if (salt[0] == 255 && salt[1] == 255 && salt[2] == 255) salt[3]++; if (salt[0] == 255 && salt[1] == 255) salt[2]++; if (salt[0] == 255) salt[1]++; salt[0]++; for (j = 0; j < 16; j++) { encbuf[(i*16)+j] = dsalted[j] ^ decbuf[(i*16)+j]; } //decbuf[i] = dsalted[i%16] ^ encbuf[i]; } totalBytes += got; if (totalBytes > fileSize) { got -= totalBytes - fileSize; totalBytes -= totalBytes - fileSize; } fwrite(encbuf, 1, numcrypts * 16, dfd); } } while (got > 0); fclose(dfd); fclose(fd); return 0; }