Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shnatsel/d00ca9a1080676897f08b81e461a1abe to your computer and use it in GitHub Desktop.
Save Shnatsel/d00ca9a1080676897f08b81e461a1abe to your computer and use it in GitHub Desktop.
Patch for libdislocate so that it clobbers every buffer allocated with malloc() with a different value. This allows checking for memory disclosure vulnerabilities in arbitrary code simply by running the operation to check twice and comparing the output.
--- libdislocator.so.c.pristine 2018-08-22 04:43:10.970904951 +0300
+++ libdislocator.so.c 2018-08-22 04:46:06.028396381 +0300
@@ -64,7 +64,7 @@
/* Canary & clobber bytes: */
#define ALLOC_CANARY 0xAACCAACC
-#define ALLOC_CLOBBER 0xCC
+int alloc_clobber_counter = 0;
#define PTR_C(_p) (((u32*)(_p))[-1])
#define PTR_L(_p) (((u32*)(_p))[-2])
@@ -187,7 +187,7 @@
DEBUGF("malloc(%zu) = %p [%zu total]", len, ret, total_mem);
- if (ret && len) memset(ret, ALLOC_CLOBBER, len);
+ if (ret && len) memset(ret, alloc_clobber_counter++, len);
return ret;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment