cscg24-pwn

CSCG 2024 Challenge 'Intro to Pwning 1'
git clone https://git.sinitax.com/sinitax/cscg24-pwn
Log | Files | Refs | sfeed.txt

pwn1.c (1724B)


      1#include <stdio.h>
      2#include <stdlib.h>
      3#include <unistd.h>
      4#include <signal.h>
      5#include <string.h>
      6
      7// pwn1: gcc pwn1.c -o pwn1
      8
      9// --------------------------------------------------- SETUP
     10
     11void ignore_me_init_buffering() {
     12	setvbuf(stdout, NULL, _IONBF, 0);
     13	setvbuf(stdin, NULL, _IONBF, 0);
     14	setvbuf(stderr, NULL, _IONBF, 0);
     15}
     16
     17void kill_on_timeout(int sig) {
     18  if (sig == SIGALRM) {
     19  	printf("[!] Anti DoS Signal. Patch me out for testing.");
     20    _exit(0);
     21  }
     22}
     23
     24void ignore_me_init_signal() {
     25	signal(SIGALRM, kill_on_timeout);
     26	alarm(60);
     27}
     28
     29// --------------------------------------------------- MENU
     30
     31void WINgardium_leviosa() {
     32    printf("┌───────────────────────┐\n");
     33    printf("│ You are a Slytherin.. │\n");
     34    printf("└───────────────────────┘\n");
     35    system("/bin/sh");
     36}
     37
     38void welcome() {
     39    char read_buf[0xff];
     40    printf("Enter your witch name:\n");
     41    gets(read_buf);
     42    printf("┌───────────────────────┐\n");
     43    printf("│ You are a Hufflepuff! │\n");
     44    printf("└───────────────────────┘\n");
     45    printf(read_buf);
     46}
     47
     48void AAAAAAAA() {
     49    char read_buf[0xff];
     50    
     51    printf(" enter your magic spell:\n");
     52    gets(read_buf);
     53    if(strcmp(read_buf, "Expelliarmus") == 0) {
     54        printf("~ Protego!\n");
     55    } else {
     56        printf("-10 Points for Hufflepuff!\n");
     57        _exit(0);
     58    }
     59}
     60// --------------------------------------------------- MAIN
     61
     62void main(int argc, char* argv[]) {
     63	ignore_me_init_buffering();
     64	ignore_me_init_signal();
     65
     66    welcome();
     67    AAAAAAAA();
     68}
     69
     70