Cooler_

simple payload http injector test

Aug 17th, 2012
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.07 KB | None | 0 0
  1. /*
  2.  
  3. Simple payload injector
  4. to use with GET...
  5.  
  6. test
  7.  
  8. by Cooler_
  9. c00f3r[at]gmail[dot]com
  10.  
  11. */
  12.  
  13. #include <stdio.h>
  14. #include <string.h>
  15. #include <stdlib.h>
  16.  
  17. char *payload_injector(char * ptr,char * payload,int counter)
  18. {
  19.  char *new=(char *)malloc(sizeof(char)*(strlen(ptr)+strlen(payload)+1));
  20.  short i=0,x=1;
  21.  
  22.  while(*ptr != '\0')
  23.  {
  24.   if(*ptr == '!')
  25.   {
  26.    if(counter==x)
  27.    {
  28.     strcat(new,payload);
  29.     i+=strlen(payload);
  30.    }
  31.    x++;
  32.   }
  33.   else
  34.   {
  35.    *(new+i)=*ptr;
  36.    i++;
  37.   }
  38.   ptr++;
  39.  }
  40.  
  41.  return new;
  42. }
  43.  
  44. int char_type_counter(char *string,char type)
  45. {
  46.  short counter=0;
  47.  
  48.  while(*string != '\0')
  49.  {
  50.   if(*string==type)
  51.    counter++;
  52.   string++;
  53.  }
  54.  return counter;
  55. }
  56.  
  57. int main()
  58. {
  59.  char *quote="issteste.php?var=a!&ola=2!&teste=data!";
  60.  int counter=char_type_counter(quote,'!');
  61.  char *test=(char *)malloc(sizeof(char)*(strlen(quote)+8));
  62.  char *payload="PAYLOAD";
  63.  puts(quote);
  64.  
  65.  do{
  66.   test=payload_injector(quote,payload,counter);
  67.   puts(test);
  68.   counter--;
  69.  }while(counter);
  70.  
  71.  
  72.  free(test);
  73.  
  74.  return 0;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment