forked from rcseacord/JavaSCR
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpy.java
More file actions
35 lines (31 loc) · 1.06 KB
/
Copy pathSpy.java
File metadata and controls
35 lines (31 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package obj14j;
import java.lang.reflect.Array;
import java.lang.reflect.Field;
class Spy {
public static void main(String[] args) {
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
System.out.println("Security manager installed."); //$NON-NLS-1$
} else {
System.out.println("No security manager."); //$NON-NLS-1$
}
// Returns an array of Field objects reflecting
// all the fields declared by the class (including private)
final Field fields[] = Leak.class.getDeclaredFields();
// Enumerate fields
for (Field field : fields) {
System.out.println("Field: " + field); //$NON-NLS-1$
if (field.getType().isArray()) {
try {
Object array = field.get("keyBytes".getClass()); //$NON-NLS-1$
int length = Array.getLength(array);
for (int j = 0; j < length; j++) {
System.out.println(Array.get(array, j));
}
} catch (IllegalArgumentException | IllegalAccessException e) {
e.printStackTrace();
}
}
}
} // end main
}