Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <time.h>
- #include <stdlib.h>
- #include <signal.h>
- #include <stdio.h>
- #include <stdbool.h>
- #include <unistd.h>
- volatile sig_atomic_t print_flag = false;
- void handle_alarm( int sig ) {
- printf("Time's up\n"); fflush(stdout);
- exit(0);
- }
- struct creds{
- char* username;
- char* password;
- };
- struct creds* creds1;
- struct creds* creds2;
- char kk[12] = {73,77,69,35,82,87,123,12,101,91};
- char kk2[12] = {25,18,4,4,4,2,18,20,20,6};
- char* hint;
- void takeInput(){
- char user[100]; char pass[100];
- printf("Username: "); fflush(stdout); fgets(user, 100, stdin); fflush(stdin);
- printf("Password: "); fflush(stdout); fgets(pass, 100, stdin); fflush(stdin);
- strcpy(creds1->username, user);
- strcpy(creds1->password, pass);
- }
- void takeInput2(){
- char user[100]; char pass[100];
- printf("Username: "); fflush(stdout); fgets(user, 100, stdin); fflush(stdin);
- printf("Password: "); fflush(stdout); fgets(pass, 100, stdin); fflush(stdin);
- strncpy(creds2->username, user, 100);
- strncpy(creds2->password, pass, 100);
- }
- int checkUser(){
- if(strcmp(creds1->username, "Palash\n")) return 0;
- char a[12] = {4,52,21,66,33,36,12,99,23,63};
- int c=0;
- for(int i=0;i<10;i++){
- c += creds1->password[i]^a[i]^kk[i];
- }
- return c==0;
- }
- int checkUser2(){
- if(strcmp(creds2->username, "Palash2\n")) return 0;
- int a=0,b=0,c=0,d=0,x=0;
- char e[14] = {49, 56, 52, 48, 51, 57, 54, 53, 52, 56, 57, 50, 52};
- for(int i=0;i<10;i++){
- a += e[i]*53;
- b += a %128 + creds2->password[i];
- c = e[b%13];
- d = ((c-48) * 23 + 32)%30;
- x += d^kk2[i];
- }
- return x==0;
- }
- void secretFlag(){
- strcpy(hint, "S3Mqty\n");
- printf("Hint for next pwn: %s", hint); fflush(stdout);
- system("/bin/cat flagBig.txt"); fflush(stdout);
- }
- int main(){
- signal( SIGALRM, handle_alarm ); // Install handler first,
- alarm( 2); // before scheduling it to be called.
- creds2 = malloc(24);
- creds2->username = malloc(16);
- creds2->password = malloc(16);
- creds1 = malloc(24);
- creds1->username = malloc(16);
- creds1->password = malloc(16);
- hint = malloc(48);
- takeInput();
- int c = checkUser();
- if(!c){
- printf("Lets try the other one\n"); fflush(stdout);
- takeInput2();
- c = checkUser2();
- }
- else {
- printf("\n");
- system("/bin/cat flagSmall.txt"); fflush(stdout);
- return 0;
- }
- if(c){
- printf("\n"); fflush(stdout);
- system("/bin/cat flagMedium.txt"); fflush(stdout);
- }else {
- printf("Login failure\n"); fflush(stdout);
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment