Guest User

Untitled

a guest
Aug 8th, 2018
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. #define FLAG "-----REDACTED-----"
  6.  
  7. int input(char *str, float f) {
  8.  
  9. fgets(str, 16 * f, stdin);
  10.  
  11. if (strlen(str) <= 1) {
  12. puts("No input detected. Registration failed.");
  13. exit(0);
  14. } else if (!strchr(str, 10)) {
  15. while (fgetc(stdin) != 10);
  16. } else {
  17. str[strlen(str) - 1] = 0;
  18. }
  19. }
  20.  
  21. int main() {
  22.  
  23. int admin = 0;
  24.  
  25. char fullname[16];
  26. char username[16];
  27. char password[16];
  28. char recoverypin[4];
  29. char email[16];
  30. char address[16];
  31. char bio[64];
  32.  
  33. gid_t gid = getegid();
  34. setresgid(gid, gid, gid);
  35.  
  36. setbuf(stdout, NULL);
  37.  
  38. puts("******************** Please Register Below ********************");
  39.  
  40. printf("Full Name: ");
  41. input(fullname, 1);
  42.  
  43. printf("Username: ");
  44. input(username, 1);
  45.  
  46. printf("Password: ");
  47. input(password, 1);
  48.  
  49. printf("Recovery Pin: ");
  50. input(recoverypin, 4);
  51.  
  52. printf("Email: ");
  53. input(email, 1);
  54.  
  55. printf("Address: ");
  56. input(address, 1);
  57.  
  58. printf("Biography: ");
  59. input(bio, .25);
  60.  
  61. if (admin) {
  62. printf("Successfully registered '%s' as an administrator account!\n", username);
  63. printf("Here is your flag: %s\n", FLAG);
  64. } else {
  65. printf("Successfully registered '%s' as an user account!\n", username);
  66. }
  67.  
  68. return 0;
  69. }
Add Comment
Please, Sign In to add comment