Hackers and programmers [transferred from Xfocus]

xiaoxiao2021-03-06  22

topic:

Featuring the following C class

Class A

{

Int value;

PUBLIC:

A (int n = 0): value (n) {}

Int getValue ()

{

Return Value;

}

}

Use some way to change the value of the private member A :: Value outside the class.

Possible method of programmers:

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;

A.SetValue (5);

}

Hacker's possible practices:

Void f ()

{

A a a;

* (INT *) & a) = 5;

}

in conclusion:

Programmers are 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-43114.html

New Post(0)