#include #include #include #include using namespace std; /** g++ -m32 -o vptrShellcode vptrShellcode.cpp -z execstack **/ class Person{ public: virtual void talk(const char *name) = 0; }; class NiceGirl: public Person{ public: void talk(const char* name){ cout << "My name is " << name << ",and all girls are beautiful" << endl; } }; class TheManWhoSoldTheWorld:public Person{ public: void talk(const char* name){ cout << "And his name is " << name << " !!" << endl; cout << "We passed upon the stair, we spoke of was and when" << endl; } }; void displayMessage(int); int main(int argc, char ** argv){ if(argc < 2){ cout << "Usage : ./vptrShellcode " << endl; return 1; } displayMessage(atoi(argv[1])); return 0; } void displayMessage(int gender){ Person* person; if(gender){ person = new TheManWhoSoldTheWorld; } else{ person = new NiceGirl; } char name[32]; gets(name); person->talk(name); delete person; }