Test your malloc protection

Overview

Logo

Test your allocs protections and leaks ! Report Bug · Request Feature

Table of Contents
  1. About The Tool
  2. Getting Started
  3. Usage
  4. Contributing
  5. Contact

About The Tool

screenshot

This tool allows you to test if every allocs in your project are protected. It also checks if an alloc fail: if you free every allocations.

It also check leaks !

(back to top)

Getting Started

Here, you will see how to setup this tool in a example project.

Prerequisites

This is working out of the box on 42's VM

If your are not on the VM you will need those installed on your system.

Your CC must be clang

  • Linux
  • clang
  • llvm

Quickstart

  1. Clone the repo inside your project
    git clone https://github.com/tmatis/ft_mallocator.git
  2. Cd in directory
    cd ./ft_mallocator
  3. Execute script
    bash test.sh
  4. Follow script's instructions...

Demo video

record.mp4

(back to top)

Usage

Here we have an example of not well protected code:

char *malloc_function(void)
{
	return (malloc(1000));
}

int main(void)
{
	void *ptr = malloc_function();
	if (ptr == NULL)
		return (1);
	free(ptr);

	void *array[10];

	for (int i = 0; i < 10; i++)
	{
		array[i] = malloc(1000);
		if (array[i] == NULL)
		{
			printf("it fail %i\n", i);
			return (0);
		}
		memset(array[i], 0, 1000);
	}
	
	for (int i = 0; i < 10; i++)
		free(array[i]);

	ptr = malloc_function();
	memset(ptr, 0, 1000);
	free(ptr);
}

this exemples have many problems, let's run mallocator on it... screenshot

The first allocation is well protected nothing to say. The second alloction if protected but if a malloc crash not everythings is free. (At the second iteration of the for loop) The third allocation is not protected at all, there is no null check.

Let's see a well protected example..

char *malloc_function(void)
{
	return (malloc(1000));
}

int main(void)
{
	void *ptr = malloc_function();
	if (ptr == NULL)
		return (1);
	free(ptr);

	void *array[10];

	int i = 0;
	for (i = 0; i < 10; i++)
	{
		array[i] = malloc(1000);
		if (array[i] == NULL)
		{
			printf("it fail %i\n", i);
			break ;
		}
		memset(array[i], 0, 1000);
	}
	for (int j = 0; j < i; j++)
		free(array[j]);

	ptr = malloc_function();
	if (!ptr)
		return (1);
	memset(ptr, 0, 1000);
	free(ptr);
}

Then we run mallocator on this code ...

screenshot

This code is protected.

You can see how it is working behind the scene here.

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Contact

tmatis's 42 stats

(back to top)

You might also like...
2020-1 KyungHee University information protection project
2020-1 KyungHee University information protection project

PGP Pretty Good Privacy의 약자로, 컴퓨터 파일을 암호화하고 복호화하는 프로그램입니다. Visual Studio 2019 기반으로 코드를 완성했고, PGP 동작 과정을 콘솔에 표현했습니다. PGP Transmission Mode의 Step 3 단계에서

Bypasses for Windows kernel callbacks PatchGuard protection

kernel_callbacks Bypasses for Windows kernel callbacks PatchGuard protection https://www.godeye.club/2021/08/14/001-windows-notification-callbacks.htm

Real Time, High performance BOT detection and protection
Real Time, High performance BOT detection and protection

REAL-TIME BOT PROTECTION CHALLENGE IronFox https://innovera.ir IronFox is a real-time and high performance bot protection, that using Nginx as a reve

An advanced in-memory evasion technique fluctuating shellcode's memory protection between RW/NoAccess & RX and then encrypting/decrypting its contents
An advanced in-memory evasion technique fluctuating shellcode's memory protection between RW/NoAccess & RX and then encrypting/decrypting its contents

Shellcode Fluctuation PoC A PoC implementation for an another in-memory evasion technique that cyclically encrypts and decrypts shellcode's contents t

Blumentals Program Protector v4.x anti protection toolkit
Blumentals Program Protector v4.x anti protection toolkit

VeNoM A Blumentals Program Protector v4.x anti protection toolkit. Reverse engineering proof-of-concept code. Screenshot & demo venomdemo.mp4 Usage Th

Blumentals Program Protector v4.x protection bypass.
Blumentals Program Protector v4.x protection bypass.

cphookLoader64 A Blumentals Program Protector v4.x protection bypass implemented as a memory loader. Screenshot & demo cphookloader64demo.mp4 Overview

TestFrame - This is a test framework that uses Raylib and ImGui together to help test and develop concepts
TestFrame - This is a test framework that uses Raylib and ImGui together to help test and develop concepts

This is a test framework that uses Raylib and ImGui together to help test and develop concepts. It is made using C++ because it uses classes for windows and views.

The Hoard Memory Allocator: A Fast, Scalable, and Memory-efficient Malloc for Linux, Windows, and Mac.

The Hoard Memory Allocator Copyright (C) 1998-2020 by Emery Berger The Hoard memory allocator is a fast, scalable, and memory-efficient memory allocat

jemalloc websitejemalloc - General purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support. [BSD] website

jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support. jemalloc first came

Custom Malloc/Free implementation in C

To run the tests simply compile using "make" and run the executable "memory" with "./memory". The tests run automatically from main(), there are 3 tes

A poggers malloc implementation

pogmalloc(3) A poggers malloc implementation Features Static allocator Real heap allocator (via sbrk(2)) Builtin GC Can also mark static memory Can be

Malloc Lab: simple memory allocator using sorted segregated free list

LAB 6: Malloc Lab Main Files mm.{c,h} - Your solution malloc package. mdriver.c - The malloc driver that tests your mm.c file short{1,2}-bal.rep - T

Custom implementation of C stdlib malloc(), realloc(), and free() functions.

C-Stdlib-Malloc-Implementation NOT INTENDED TO BE COMPILED AND RAN, DRIVER CODE NOT OWNED BY I, ARCINI This is a custom implmentation of the standard

Hardened malloc - Hardened allocator designed for modern systems

Hardened malloc - Hardened allocator designed for modern systems. It has integration into Android's Bionic libc and can be used externally with musl and glibc as a dynamic library for use on other Linux-based platforms. It will gain more portability / integration over time.

Mimalloc-bench - Suite for benchmarking malloc implementations.
Mimalloc-bench - Suite for benchmarking malloc implementations.

Mimalloc-bench Suite for benchmarking malloc implementations, originally developed for benchmarking mimalloc. Collection of various benchmarks from th

Minimal implementation of malloc and free for demo purposes.
Minimal implementation of malloc and free for demo purposes.

Minimal implementation of malloc and free using sbrk() and brk() system calls. Context: How does a process actually request the kernel to allocate/dea

🧼 Cleanly pause and play your YouTube videos while cooking/crafting/doing your makeup by waving your hand over a proximity sensor!

🧼 Cleanly pause and play your YouTube videos while cooking/crafting/doing your makeup by waving your hand over a proximity sensor!

Single header C++ logging library. It is extremely powerful, extendable, light-weight, fast performing, thread and type safe and consists of many built-in features. It provides ability to write logs in your own customized format. It also provide support for logging your classes, third-party libraries, STL and third-party containers etc. Easily view the unexplored korok seeds and locations in your BotW savefile on your Switch
Easily view the unexplored korok seeds and locations in your BotW savefile on your Switch

BotW Unexplored Easily view what hasn't been discovered in your Breath of the Wild savefile, on your Nintendo Switch. The korok seeds that haven't bee

Comments
  • ARGS doesn't not support

    ARGS doesn't not support "

    Hi !

    Thanks a lot for your tool, it's been really useful :)

    I've been trying to test my project pipex and just realised that I cannot put any " inside the ARGS field in config.sh.

    ARGS="file1 "sleep 1" cat file2" just become file1 and cannot fetch any route. Removing the " or switching to ' solve the problem.

    I don't know if you can fix that, but maybe putting a warning would help people with this issue (especially on pipex).

    opened by ThomasRobertson 1
  • Fix some readme typos and update the requirement for using it at home

    Fix some readme typos and update the requirement for using it at home

    Hi !

    This is just a quick PR to fix some typos.

    I also tried to see what was the minimum required packages to run it at home. It doens't need llvm. And with a basic image (debian:stable from Docker), it only requires make and clang to run.

    opened by ThomasRobertson 1
  • error while testing bash

    error while testing bash

    How to reproduce:

    ./mallocator bash
    

    Error

    free(): invalid pointer
    [CRASH] abort
    ┗━━ ?? in ??:0 (0x1391)
    ┗━━ ?? in ??:0 (0x1a31)
    ┗━━ ?? in ??:0 (0x389ff)
    ┗━━ programmable_completions in ??:0 (0x8864b)
    ┗━━ ?? in ??:0 (0x38957)
    ┗━━ shell_is_restricted in ??:0 (0x2253c)
    ┗━━ ?? in ??:0 (0x7c7ed)
    ┗━━ fg_builtin in ??:0 (0x923db)
    ┗━━ history_builtin in ??:0 (0x9422b)
    ┗━━ read_builtin in ??:0 (0x96ba2)
    ┗━━ ?? in ??:0 (0x1999)
    ┗━━ named_function_string in ??:0 (0x358d8)
    ┗━━ ?? in ??:0 (0x33603)
    ┗━━ ?? in ??:0 (0x32fd4)
    ┗━━ ulimit_builtin in ??:0 (0x9c8ae)
    ┗━━ file_error in ??:0 (0x48531)
    ┗━━ shell_execve in ??:0 (0x382f6)
    ┗━━ ?? in ??:0 (0x38c5d)
    ┗━━ execute_command_internal in ??:0 (0x3bf1f)
    ┗━━ execute_command in ??:0 (0x3c559)
    ┗━━ reader_loop in ??:0 (0x22cb7)
    ┗━━ main in ??:0 (0x218e1)
    ┗━━ ?? in ??:0 (0x1adc)
    ┗━━ ?? in ??:0 (0x2328f)
    ┗━━ ?? in ??:0 (0x23349)
    ┗━━ ?? in ??:0 (0x1b6c)
    ┗━━ _start in ??:0 (0x2191d)
    
    
    bug V2 
    opened by tmatis 0
Owner
tmatis
Student
tmatis
jemalloc websitejemalloc - General purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support. [BSD] website

jemalloc is a general purpose malloc(3) implementation that emphasizes fragmentation avoidance and scalable concurrency support. jemalloc first came

jemalloc memory allocator 7.7k Jan 7, 2023
A poggers malloc implementation

pogmalloc(3) A poggers malloc implementation Features Static allocator Real heap allocator (via sbrk(2)) Builtin GC Can also mark static memory Can be

Ariel Simulevski 2 Jun 12, 2022
Malloc Lab: simple memory allocator using sorted segregated free list

LAB 6: Malloc Lab Main Files mm.{c,h} - Your solution malloc package. mdriver.c - The malloc driver that tests your mm.c file short{1,2}-bal.rep - T

null 1 Feb 28, 2022
Custom implementation of C stdlib malloc(), realloc(), and free() functions.

C-Stdlib-Malloc-Implementation NOT INTENDED TO BE COMPILED AND RAN, DRIVER CODE NOT OWNED BY I, ARCINI This is a custom implmentation of the standard

Alex Cini 1 Dec 27, 2021
Hardened malloc - Hardened allocator designed for modern systems

Hardened malloc - Hardened allocator designed for modern systems. It has integration into Android's Bionic libc and can be used externally with musl and glibc as a dynamic library for use on other Linux-based platforms. It will gain more portability / integration over time.

GrapheneOS 893 Jan 3, 2023
Mimalloc-bench - Suite for benchmarking malloc implementations.

Mimalloc-bench Suite for benchmarking malloc implementations, originally developed for benchmarking mimalloc. Collection of various benchmarks from th

Daan 186 Dec 24, 2022
Test cpu and memory speed at linux-vps

Тест скорости процессора и памяти на linux-vps. Занимается бессмысленным перемножением массивов случайных чисел, для определения скорости процессора и

Anton 3 Nov 30, 2021
Alloc-test - Cross-platform benchmarking for memory allocators, aiming to be as close to real world as it is practical

Alloc-test - Cross-platform benchmarking for memory allocators, aiming to be as close to real world as it is practical

null 37 Aug 23, 2022
Test your malloc protection

Test your allocs protections and leaks ! Report Bug · Request Feature Table of Contents About The Tool Getting Started Prerequisites Quickstart Usage

tmatis 49 Dec 7, 2022
Easy to use cryptographic framework for data protection: secure messaging with forward secrecy and secure data storage. Has unified APIs across 14 platforms.

Themis provides strong, usable cryptography for busy people General purpose cryptographic library for storage and messaging for iOS (Swift, Obj-C), An

Cossack Labs 1.6k Jan 6, 2023