Advertisement
Xenithz

Bypass Microsoft Feature

Nov 1st, 2011
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.45 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. /*
  5.         Compile : gcc -fno-stack-protector -z execstack microsoft.c -o microsoft
  6.     Reference : http://www.cigital.com/news/index.php?pg=art&artid=70
  7.    
  8.     request_data, in parameter which contains user supplied encoded string like
  9.         "host=dot.net&id=user_id&pw=user_password&cookie=da".
  10.     user_id, out parameter which is used to copy decoded 'user_id'.
  11.     password, out parameter which is used to copy decoded 'password'
  12. */
  13. void decode(char *request_data, char *user_id, char *password){
  14.     char temp_request[64];
  15.     char *p_str;
  16.  
  17.     strcpy(temp_request, request_data);
  18.     p_str = strtok(temp_request, "&");
  19.    
  20.     while(p_str != NULL){
  21.         if (strncmp(p_str, "id=", 3) == 0){
  22.             strcpy(user_id, p_str + 3 );
  23.                 }
  24.     else if (strncmp(p_str, "pw=", 3) == 0){
  25.         strcpy(password, p_str + 3);
  26.     }
  27.            p_str = strtok(NULL, "&");
  28.     }
  29. }
  30.  
  31. /*
  32.     Any combination will fail.
  33. */
  34. int check_password(char *id, char *password){
  35.     return -1;
  36. }
  37. /*
  38.     We use argv[1] to provide request string.
  39. */
  40. int main(int argc, char ** argv)
  41. {
  42.     char user_id[32];
  43.     char password[32];
  44.  
  45.     user_id[0]  = '\0';
  46.     password[0] = '\0';
  47.  
  48.     if ( argc < 2 ) {
  49.         printf("Usage: victim request.\n");
  50.         return 0;
  51.     }
  52.  
  53.     decode( argv[1], user_id, password);
  54.  
  55.     if ( check_password(user_id, password) > 0 ){
  56.         //Dead code.
  57.         printf("Welcome!\n");
  58.     }
  59.     else{
  60.         printf("Invalid password, user:%s password:%s.\n", user_id, password);
  61.     }
  62.  
  63.     return 0;
  64. }
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement