exposing Java private fields with reflection

This commit is contained in:
Luciano Ramalho
2014-10-19 09:00:19 -02:00
parent 926bb370a0
commit 1d48cdbde5
11 changed files with 114 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
from java.lang.reflect import Modifier
import Confidential
message = Confidential('never expose this')
fields = Confidential.getDeclaredFields()
for field in fields:
# list private fields only
if Modifier.isPrivate(field.getModifiers()):
field.setAccessible(True) # break the lock
print 'field:', field
print '\t', field.getName(), '=', field.get(message)