Skip to content

Instantly share code, notes, and snippets.

@Jinmo
Last active September 16, 2017 06:15
Show Gist options
  • Save Jinmo/f4b2bbd5bb6fe11f0d7d5f5b976b08e6 to your computer and use it in GitHub Desktop.
Save Jinmo/f4b2bbd5bb6fe11f0d7d5f5b976b08e6 to your computer and use it in GitHub Desktop.
munmap by heap (relative address!)
// How to call munmap(0x414141410000, 0x20000)
// : the hard way
// tested on 64bit ubuntu
#define SIZE 0x20000
int main() {
long long chunk[3];
long long target;
target = 0x414141410000LL;
chunk[0] = -target + (long long)(chunk);
chunk[1] = (SIZE | 2) - chunk[0];
printf("%p %p %p\n", chunk[0] + chunk[1], (long long int)chunk - chunk[0], target);
free(chunk + 2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment