Programmer and hackers

zhaozj2021-02-16  47

Topic: There is a C class class a {int value; public: a (int n = 0): value (n) {} int getValue () {return value;}}; please use some way to the outside Change the value of the private member A :: Value.

Programmer's possible practice: class a {int value; public: a (int N = 0): value (n) {} int getValue () {return value;} void setValue (int N) {value = n;}} void f () {a a; a.setValue (5);

Hacker's possible practices: void f () {a a; * (int *) & a) = 5;}

Conclusion: Programmer is accustomed to following existing restrictions to increase existing things. Hackers are used to using existing things to break existing restrictions.

转载请注明原文地址:https://www.9cbs.com/read-22536.html

New Post(0)