Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8439249
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:57:32+00:00 2026-06-10T07:57:32+00:00

I have been studying computer vulnerabilities and have been working on this problem for

  • 0

I have been studying computer vulnerabilities and have been working on this problem for countless hours.
I cannot seem to get the heap to overflow correctly. Despite glibc detecting a memory corruption, after disabling MALLOC_CHECK_ my program executes and exits correctly as if overwriting the chunk header didn’t matter. I am running Kubuntu 12.04.

This exercise is from “The Shellcoder’s Handbook, 2nd Edition” and is also featured on Heap Overflow tutorials online. I have followed the instructions to a T multiple times and have received the same result.

Here is the code of my program:

/*basicheap*/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


int main(int argc, char ** argv){

    char *buf;
    char *buf2;

buf=(char*)malloc(1024);
buf2=(char*)malloc(1024);
printf("buf=%p buf2=%p\n", buf, buf2);
strcpy(buf,argv[1]);
free(buf2);
free(buf);
}

when I write past the buffer with glibc on:

xxx@xxx-xxx:~/CProgs$ ./basicheap $(perl -e 'print "A"x1028')
buf=0x9356718 buf2=0x9356b20
*** glibc detected *** ./basicheap: double free or corruption (!prev): 0x09356b20 ***
======= Backtrace: =========
[0x804abff]
[0x8048f4a]
[0x80490d6]
[0x8048e29]
======= Memory map: ========
08048000-080ec000 r-xp 00000000 08:07 6816172    /home/xxx/CProgs/basicheap
080ec000-080ee000 rw-p 000a3000 08:07 6816172    /home/xxx/CProgs/basicheap
080ee000-080f0000 rw-p 00000000 00:00 0 
09355000-09377000 rw-p 00000000 00:00 0          [heap]
b772a000-b772c000 rw-p 00000000 00:00 0 
b772c000-b772d000 r-xp 00000000 00:00 0          [vdso]
bfc14000-bfc36000 rw-p 00000000 00:00 0          [stack]
Aborted (core dumped)
xxx@xxx-xxx:~/CProgs$ 

When I write past the buffer with glibc off:

xxx@xxx-xxx:~/CProgs$ MALLOC_CHECK_=0 ./basicheap $(perl -e 'print "A"x1028')
buf=0xa077718 buf2=0xa077b20
xxx@xxx-xxx:~/CProgs$

GDB of the Chunk header without overwrite:

(gdb) run $(perl -e 'print "A"x1024')
Starting program: /home/xxx/CProgs/basicheap $(perl -e 'print "A"x1024')
buf=0x80f1718 buf2=0x80f1b20

Breakpoint 1, main (argc=2, argv=0xbfffedf4) at basicheap.c:16
16      free(buf2);
(gdb) x/x buf2-4
0x80f1b1c:      0x00000409
(gdb) x/x buf2-8
0x80f1b18:      0x00000000
(gdb) x/x buf2-12
0x80f1b14:      0x41414141
(gdb) 

GDB of the chunk header with overwrite:

(gdb) run $(perl -e 'print "A"x1032')
Starting program: /home/xxx/CProgs/basicheap $(perl -e 'print "A"x1032')
buf=0x80f1718 buf2=0x80f1b20

Breakpoint 1, main (argc=2, argv=0xbfffede4) at basicheap.c:16
16      free(buf2);
(gdb) x/x buf2-4
0x80f1b1c:      0x41414141
(gdb) x/x buf2-8
0x80f1b18:      0x41414141
(gdb) x/x buf2-12
0x80f1b14:      0x41414141
(gdb) 

Both times the program exits normally.
What am I missing? Did they change up how the heap works on the latest versions of Ubuntu?
Any help would be greatly appreciated!

UPDATE: I have stepped through the assembly in gdb and have found that my program enters the function free_check() and the function mem2chunk_check().

In the mem2chunk_check() function, my overwritten value is picked up in the ESI register, and the EDI register points to the address of that value. The only thing I see it doing with my value in ESI is subtracting 1 and then dumping the value.

I have not been able to find any documentation on the mem2chunk_check() function after many google searches.

Are these heap overflows obsolete on modern systems?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:57:33+00:00Added an answer on June 10, 2026 at 7:57 am

    First thing is that nowadays, heap exploitation in Linux is really hard. Well, it is easy to overwrite different buffers if they overflow, but the hard thing is to execute arbitrary code.

    If you want to know the inner workings of heap exploitation you should read the papers I mentioned in this post: Use a heap overflow to write arbitrary data

    Once you understand those concepts, I will warn you saying that most of the methods used/explained in malloc malleficarum were (silently) patched. I don’t know if any of those still works today.

    On the other hand, if you really want to improve your knowledge, I advice you to download the ptmalloc implementation (from http://www.malloc.de/en/) that is the one on which is based the allocator in Linux, compile it (“make shared”, it is also useful to add the “-g” flag) and load it with LD_PRELOAD. This way you will be able to debug the malloc code with gdb, step by step.

    Good luck!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Have been working on this question for a couple hours and have come close
I've been studying this for hours (2 days, actually) and just cannot figure out
I have been studying this code to generate random text: from collections import defaultdict,
Problem I'm fairly new to design patterns, and have been studying the book, Head
I have been programming for a couple of years and am now studying computer-science
I have been studying, playing with and working with ASP.NET MVC since Preview 1
been working on an app and have been studying the questions available here but
Well I have been studying a little C this winter break and in my
I have been working with JQM for a couple of weeks and after studying
Actually I am studying this algorithm and I have been exploring his code (which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.