Esempio n. 1
0
#!/usr/bin/env jython
# NOTE: Jython is still Python 2.7 in late2020

import Confidential

message = Confidential('top secret text')
secret_field = Confidential.getDeclaredField('secret')
secret_field.setAccessible(True)  # break the lock!
print 'message.secret =', secret_field.get(message)
Esempio n. 2
0
"""
In the Jython registry file there is this line:

python.security.respectJavaAccessibility = true

Set this to false and Jython provides access to non-public
fields, methods, and constructors of Java objects.
"""

import Confidential

message = Confidential('top secret text')
for name in dir(message):
    attr = getattr(message, name)
    if not callable(attr):  # non-methods only
        print name + '\t=', attr
from java.lang.reflect import Modifier
import Confidential

message = Confidential('top secret text')
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)
#!/usr/bin/env jython
# NOTE: Jython is still Python 2.7 in late2020

from java.lang.reflect import Modifier
import Confidential

message = Confidential('top secret text')
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)
import Confidential

message = Confidential('top secret text')
secret_field = Confidential.getDeclaredField('secret')
secret_field.setAccessible(True)  # break the lock!
print 'message.secret =', secret_field.get(message)