题目地址:rootme
0x01 题目分析
Source Code:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdio.h>
// g++ -m32 ch20.cpp -o ch20 -z execstack
class formatter
{
public :
virtual int RTTI( ) =0 ;
virtual void displayName( ) =0 ;
virtual void format( const char * ptr ) =0 ;
};
class UpperFormatter: public formatter
{
public :
virtual int RTTI( ) { return 1; };
virtual void displayName( ) { printf ("UpperFormatter"); }
virtual void format( const char * ptr )
{
const char * cptr = ptr;
while (*cptr)
{
printf("%c", toupper(*cptr));
cptr++;
}
}
};
class LowerFormatter: public formatter
{
public :
virtual int RTTI( ) { return 2; };
virtual void displayName( ) { printf ("UpperFormatter"); }
virtual void format( const char * ptr )
{