Skip to content

Instantly share code, notes, and snippets.

@marcorentap
marcorentap / perf_cpi.c
Last active February 12, 2024 14:42
calculate CPI with perf_event_open
#include <asm/unistd.h>
#include <linux/perf_event.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
static long perf_event_open(struct perf_event_attr *hw_event, pid_t pid,
int cpu, int group_fd, unsigned long flags) {
int ret;
#include <stdio.h>
typedef struct {
short short1;
short short2;
} some_struct;
int main() {
// In memory: 48 65 6c 6c 6f 00 48 69 00
char *bytes = "\x48\x65\x6c\x6c\x6f\x00\x48\x69\x00";

Overview

The program is a note editor running inside a x86 64-bit unicorn engine instance.

image

The start script is provided (see start.py)

Goal

Overview

The program is a Unicorn Engine x86 64-bit VM that can runs default program or a program that the user uploads. A program is a sequence of x86 64-bit machine language instructions.

image

Goal

Call win which will print out the flag

image

@marcorentap
marcorentap / pwnable.kr_ascii_easy.md
Created January 25, 2023 16:07
pwnable.kr_ascii_easy

Overview

The program reads an input as a command line argument and stores it in a buffer. The argument must only contain ASCII characters. Source code is provided:

#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <string.h>
#include <fcntl.h>

Overview

Initially the program prompts for username then continue with the menu. Users can

image

Options

image

Overview

The C++ source code is provided:

#include <fcntl.h>
#include <iostream> 
#include <cstring>
#include <cstdlib>
#include <unistd.h>
using namespace std;

Overview

Jump jump
The Mac Dad will make you jump jump
Daddy Mac will make you
jump jump
The Daddy makes you J-U-M-P

Menu: