level09: source code done
This commit is contained in:
parent
332d382074
commit
1fc850adea
59
level09/source.c
Normal file
59
level09/source.c
Normal file
@ -0,0 +1,59 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
char *set_msg(char *msg, int len);
|
||||
int set_username(char *username);
|
||||
|
||||
int secret_backdoor(void)
|
||||
{
|
||||
char s[128];
|
||||
|
||||
fgets(s, 128, stdin);
|
||||
return system(s);
|
||||
}
|
||||
|
||||
int handle_msg(void)
|
||||
{
|
||||
char msg[140];
|
||||
char username[40];
|
||||
int len = 140;
|
||||
|
||||
set_username(username);
|
||||
set_msg(msg, len);
|
||||
return puts(">: Msg sent!");
|
||||
}
|
||||
|
||||
char *set_msg(char *msg, int len)
|
||||
{
|
||||
char s[1024];
|
||||
|
||||
memset(s, 0, sizeof(s));
|
||||
puts(">: Msg @Unix-Dude");
|
||||
printf(">>: ");
|
||||
fgets(s, 1024, stdin);
|
||||
return strncpy((char *)msg, s, len);
|
||||
}
|
||||
|
||||
int set_username(char *username)
|
||||
{
|
||||
char s[140];
|
||||
|
||||
memset(s, 0, 128);
|
||||
puts(">: Enter your username");
|
||||
printf(">>: ");
|
||||
fgets(s, 128, stdin);
|
||||
for (int i = 0; i <= 40 && s[i]; ++i)
|
||||
username[i] = s[i];
|
||||
return printf(">: Welcome, %s", username);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
puts("--------------------------------------------\n"
|
||||
"| ~Welcome to l33t-m$n ~ v1337 |\n"
|
||||
"--------------------------------------------");
|
||||
handle_msg();
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user