-
-
Notifications
You must be signed in to change notification settings - Fork 240
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #462 from psiinon/standalone/private
Added standalone script 'PrivateMethodAccess.js'
- Loading branch information
Showing
2 changed files
with
31 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
When writing scripts you may find that you need to access private java methods. | ||
This script shows how you can do this easily. | ||
WARNING: we do not consider private methods to be part of the public API, so they may | ||
be changed or removed at any time. | ||
If you think you have a strong case for making a method public then either: | ||
1. Ask on the ZAP Dev Group: https://groups.google.com/group/zaproxy-develop | ||
2. Submit a pull request making the change (but be prepared for it to be rejected) | ||
*/ | ||
|
||
var ExtensionAlert = Java.type( | ||
"org.zaproxy.zap.extension.alert.ExtensionAlert" | ||
); | ||
var MethodUtils = Java.type("org.apache.commons.lang3.reflect.MethodUtils"); | ||
|
||
extAlert = control.getExtensionLoader().getExtension(ExtensionAlert); | ||
|
||
print(extAlert); | ||
|
||
// Note that there are a lot of other methods in MethodUtils if these are not what you are looking for. | ||
|
||
// Call a private method with no parameters | ||
print(MethodUtils.invokeMethod(extAlert, true, "getAlertPanel")); | ||
|
||
// Call a private method with parameters | ||
print(MethodUtils.invokeMethod(extAlert, true, "applyOverride", "abc", "+def")); |