Skip to content

Commit 20c525f

Browse files
committed
Add starter files to baby_rev
1 parent dd0f56f commit 20c525f

File tree

4 files changed

+47
-5
lines changed

4 files changed

+47
-5
lines changed

baby_rev/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
CXX=g++
2+
CFLAGS=-I.
3+
4+
baby_rev: baby_rev.c
5+
$(CXX) -o baby_rev baby_rev.cpp
6+
7+
clean:
8+
$(RM) baby_rev

baby_rev/README.md

Whitespace-only changes.

baby_rev/password.cpp

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#include <string>
2+
#include <iostream>
3+
4+
constexpr auto KEY = 42;
5+
6+
bool is_phrase_correct(std::string_view phrase)
7+
{
8+
for (char c : phrase)
9+
{
10+
std::cout << static_cast<char>(c ^ KEY) << std::endl;
11+
}
12+
}
13+
14+
int main()
15+
{
16+
17+
std::string phrase;
18+
std::cout << "What's the secret phrase?" << std::endl;
19+
20+
std::getline(std::cin, phrase);
21+
22+
if (!is_phrase_correct(phrase))
23+
{
24+
std::cerr << "Oops try again..." << std::endl;
25+
return EXIT_FAILURE;
26+
}
27+
28+
std::cout << "Correct!" << std::endl;
29+
30+
return EXIT_SUCCESS;
31+
}

buffer_overflow/buffer_overflow.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
1-
#include <stdio.h> // For puts and fgets
1+
#include <stdio.h> // For puts and fgets
22
#include <unistd.h> // For execve
3+
#include <stdlib.h>
34

4-
void access_vault() {
5+
void access_vault()
6+
{
57
puts("Access granted");
68
execve("/bin/sh", NULL, NULL);
79
}
810

9-
int main() {
11+
int main()
12+
{
1013
char input_buffer[16];
1114
puts("Enter the password to access Santa Ono's secret vault:");
1215

1316
fgets(input_buffer, 32, stdin); // Nothing can go wrong here right?
1417

1518
puts("HAHA you thought! There was no password, you can NEVER get in >:)");
1619

17-
return 0;
18-
}
20+
return EXIT_SUCCESS;
21+
}

0 commit comments

Comments
 (0)