#ifndef NALL_PUBLIC_CAST_HPP1#define NALL_PUBLIC_CAST_HPP23//this is a proof-of-concept-*only* C++ access-privilege elevation exploit.4//this code is 100% legal C++, per C++98 section 14.7.2 paragraph 8:5//"access checking rules do not apply to names in explicit instantiations."6//usage example:78//struct N { typedef void (Class::*)(); };9//template class public_cast<N, &Class::Reference>;10//(class.*public_cast<N>::value);1112//Class::Reference may be public, protected or private13//Class::Reference may be a function, object or variable1415namespace nall {16template<typename T, typename T::type... P> struct public_cast;1718template<typename T> struct public_cast<T> {19static typename T::type value;20};2122template<typename T> typename T::type public_cast<T>::value;2324template<typename T, typename T::type P> struct public_cast<T, P> {25static typename T::type value;26};2728template<typename T, typename T::type P> typename T::type public_cast<T, P>::value = public_cast<T>::value = P;29}3031#endif323334