ldemidov / javasnoop

Automatically exported from code.google.com/p/javasnoop
0 stars 0 forks source link

"Could not initialize agent: Agent JAR loaded but agent failed to initialize" (attaching a java process) #5

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Press button "Attach & Snoop Process..."
2. Choose Java process in the list
3. Press button "Use this as session (and attach)"

What is the expected output? What do you see instead?
Status "SNOOPING". JavaSnoop error: "Could not initialize agent: Agent JAR
                                 loaded but agent failed to initialize"    

What version of the product are you using? On what operating system?
JavaSnoop 1.0.  Windows XP SP3; linux CENTOS 2.6.18-194.3.1.el5

Please provide any additional information below.
Windows Java Arguments process attached:
PID: 9128
Main class: 
Main arguments: null
JVM arguments:
-Xms24m -Xmx1024m -Dnetbeans.logger.console=true -ea -Djdk.home=C:\Archivos de 
programa\Java\jdk1.6.0_23 -splash:C:\Documents and Settings\xxx\Datos de 
programa\.expertlotto\5.0_beta\var\cache\splash.png -Dnetbeans.home=C:\Archivos 
de programa\Expert Lotto 5 BETA\platform -Dnetbeans.user=C:\Documents and 
Settings\xxx\Datos de programa\.expertlotto\5.0_beta 
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=C:\Documents and 
Settings\xxx\Datos de programa\.expertlotto\5.0_beta\var\log\heapdump.hprof 
-Dnetbeans.system_http_proxy=10.12.20.149:80 
-Dnetbeans.system_http_non_proxy_hosts=127.0.0.1 
-Dsun.awt.keepWorkingSetOnMinimize=true -Dnetbeans.dirs=C:\Archivos de 
programa\Expert Lotto 5 BETA\expertlotto
VM version: 19.0-b06

Linux Java Arguments process attached:
PID: 2515
Main class: org.netbeans.Main
Main arguments: --userdir /root/.expertlotto/5.0_beta --branding expertlotto
JVM arguments: -Djdk.home=/usr/lib/jvm/java-1.6.0-openjdk.x86_64 
-Dnetbeans.dirs=/usr/local/expertlotto/bin/../expertlotto: 
-Dnetbeans.home=/usr/local/expertlotto/platform -Xms24m -Xmx1024m 
-Dnetbeans.logger.console=true -ea -XX:+HeapDumpOnOutOfMemoryError 
-XX:HeapDumpPath=/root/.expertlotto/5.0_beta/var/log/heapdump.hprof
VM version: 14.0-b16

Original issue reported on code.google.com by ignacio....@telefonica.net on 27 Sep 2010 at 11:43

Attachments:

GoogleCodeExporter commented 9 years ago
I do have the exact same problem with a JavaWebStart Application

Original comment by meindate...@gmail.com on 26 Oct 2010 at 7:44

GoogleCodeExporter commented 9 years ago
Getting exactly the same error

Original comment by jacques....@gmail.com on 2 Nov 2010 at 9:45

GoogleCodeExporter commented 9 years ago
exact same problem running the same version of javasnoop on OS X

Original comment by vyrus....@gmail.com on 10 Nov 2010 at 2:23

GoogleCodeExporter commented 9 years ago
This can be caused by a number of different things. It's very likely there's a 
stack trace or error messages in the Java console (System.out) of the 
application to which you're attaching.

It's very likely it's a security problem - are you sure you're starting up the 
JavaSnoop startup script before the target program? The startup script turns 
off security, which is needed for the agent to function.

Original comment by arshan.d...@gmail.com on 5 Dec 2010 at 4:07

GoogleCodeExporter commented 9 years ago
If no one comments further in a week or two I'll assume they were Java 
security-related errors and I can close this ticket.

Original comment by arshan.d...@gmail.com on 21 Jan 2011 at 4:09

GoogleCodeExporter commented 9 years ago
Hi, 

I've just has an instance of this issue.  the application I'm looking at is a 
browser-applet based one.

Start javasnoop (using startup.bat) first, then launch the browser and 
authenticate to the application (which leads to the applets being loaded), and 
I get the "agent failed to initialize" message.

I've tried attaching to other java processes running on the system at the same 
time (burp suite) and that works fine, so I don't think it's a general problem 
with Javasnoop but perhaps some issue attaching to applet based programs?

Trying to attach to the process gives the

Original comment by raes...@gmail.com on 26 Jan 2011 at 9:39

GoogleCodeExporter commented 9 years ago
Your message was truncated?

Original comment by arshan.d...@gmail.com on 23 Feb 2011 at 3:33

GoogleCodeExporter commented 9 years ago
Guys,

Thanks for sharing your idea. 

When I'm trying to attach a process. I'm getting the same error as you "Could 
not initialize agent: Agent JAR loaded but agent failed to initialize".

I have copied the console error message, but could not figure out how to solve 
this. Can you please help me. Thanks.

RegisterWebUtil - Loading WebUtil Version 10.1.2.3
proxyHost=null
proxyPort=0
connectMode=HTTP, native.
Forms Applet version is : 10.1.2.3
java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source)
    at sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(Unknown Source)
Caused by: java.security.AccessControlException: access denied 
(java.util.PropertyPermission package.restrict.access.sun read)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
    at java.lang.System.getProperty(Unknown Source)
    at com.aspect.snoop.agent.SnoopAgent.turnOffSecurity(SnoopAgent.java:62)
    at com.aspect.snoop.agent.SnoopAgent.agentmain(SnoopAgent.java:47)
    ... 6 more

From your experience, have you came across on performing pen-test in an Oracle 
Application that uses jinitiator. Can this software work. Please let me know. 
Thanks for your help.

Original comment by rastab...@gmail.com on 23 Mar 2011 at 10:41

GoogleCodeExporter commented 9 years ago
Just would like to add in more. This software works on paros. I was able to 
attach the process in JavaSnoop. But not working in Oracle Apps kind of web 
applications.

Please share your ideas. I really need it urgently. Thanks again.

Original comment by rastab...@gmail.com on 23 Mar 2011 at 10:43

GoogleCodeExporter commented 9 years ago
I experienced this same issue when attempting to attach to a Java Web Start 
based app under Windows 7 Professional 32bit using Java 1.6.0_24. I double 
checked the java policy settings that the startup.bat file sets and it all 
looked fine. But I was starting the java app via Firefox 4, and when I switched 
to starting the app via IE9 I was able to attach javasnoop successfully. I 
haven't had a chance to investigate any differences in the way the browsers 
invoke java differently but for thse havin this problem with applets or web 
start etc. this might be a quick fix if it works for others too.

Original comment by jpc0...@yahoo.com on 13 Apr 2011 at 10:25

GoogleCodeExporter commented 9 years ago
It seems the reason that I was getting this error was due to the fact that 
script.bat file was trying to place the java.policy file in c:\documents and 
settings\<unmae> however the real file needed to be placed in "C:\Documents and 
Settings\<uname>\Application Data\Sun\Java\Deployment\security" on my machine. 
When I took the unsafe.policy file  from resources/unsafe.policy and placed it 
in that folder and renamed it to java.policy I stopped getting that error. 
Please use the README.txt file in Javasnoop and figure out how ti turn the 
console on for java apps. That tells you if you have any security exception. If 
you see that then most likely what I did should solve your issue. I did this on 
Windows XP/SP3.

Original comment by mandar.s...@gmail.com on 7 Oct 2011 at 6:04

GoogleCodeExporter commented 9 years ago
Thanks for the solution Mandar.

I modified my batch file line as follows and tested it and it resolve the 
issue.  Perhaps this change should be implemented into the source Arshan?  Note 
there were two things that needed to be fixed.  1) the location itself and 2) 
Windows needs quotes around a full path like this.

-set user_policy=%USERPROFILE%\.java.policy
+set user_policy="%USERPROFILE%\Application 
Data\Sun\Java\Deployment\security\java.policy"

I also commented out the second to last line which copies the safe user policy 
into place.  I didn't have a policy by default and I don't know enough about 
Java security policies to be comfortable changing it.

Thanks for your work on this Arshan!

Original comment by alex.lau...@gmail.com on 30 Nov 2011 at 9:48

GoogleCodeExporter commented 9 years ago
I should have mentioned this was with 1.0.  It doesn't look like I was getting 
the same error with 1.1RC1, but the java.policy file wasn't successfully 
copying either using the default batch file. I'm pretty sure you at least need 
quotes around any path that contains a drive letter.  I'm on XP by the way.  
May not be different in W7.

Original comment by alex.lau...@gmail.com on 1 Dec 2011 at 7:59

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Some of this is copy+pasted from a previous post but this is a new bug report 
as far as I know.

I am also experiencing the error message:

"Could not initialize agent: Agent JAR loaded but failed to initialize"

What steps will reproduce the problem?
1. Press button "Attach & Snoop Process..."
2. Choose Java process in the list
3. Press button "Attach" (Attach and clobber lookandfeel also results in the 
same)

What is the expected output? What do you see instead?
Status "SNOOPING". JavaSnoop error: "Could not initialize agent: Agent JAR
loaded but agent failed to initialize"    

What version of the product are you using? On what operating system?
JavaSnoop 1.1-RC1.  Windows XP SP3;

Please provide any additional information below.

PID: 1288
Main class: sun.plugin2.main.client.PluginMain
Main arguments: 
write_pipe_name=jpi2_pid3348_pipe2,read_pipe_name=jpi2_pid3348_pipe1
JVM arguments: -D__jvm_launched=88099939 
-Xbootclasspath/a:C:\PROGRA~1\Java\jre6\lib\deploy.jar;C:\PROGRA~1\Java\jre6\lib
\javaws.jar;C:\PROGRA~1\Java\jre6\lib\plugin.jar -Dsun.awt.warmup=true 
-Djnlp.packEnabled=true
VM version: 20.5-b03

C:\JavaSnoop>set
ALLUSERSPROFILE=C:\Documents and Settings\All Users
APPDATA=C:\Documents and Settings\testing\Application Data
CLIENTNAME=Console
CommonProgramFiles=C:\Program Files\Common Files
COMPUTERNAME=REMOVED-5955DBB
ComSpec=C:\WINDOWS\system32\cmd.exe
FP_NO_HOST_CHECK=NO
HOMEDRIVE=C:
HOMEPATH=\Documents and Settings\testing
JAVA_HOME=C:\Program Files\Java\jdk1.6.0_25
LOGONSERVER=\\REMOVED-xxxxxxx
NUMBER_OF_PROCESSORS=2
OS=Windows_NT
Path=C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\jruby-1.6.5.1\bi
n;C:\Program Files\Nmap;C:\Program Files\w3af;C:\Python25;
PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH
PROCESSOR_ARCHITECTURE=x86
PROCESSOR_IDENTIFIER=x86 Family 6 Model 42 Stepping 7, GenuineIntel
PROCESSOR_LEVEL=6
PROCESSOR_REVISION=2a07
ProgramFiles=C:\Program Files
PROMPT=$P$G
SESSIONNAME=Console
SystemDrive=C:
SystemRoot=C:\WINDOWS
TEMP=C:\DOCUME~1\TEST~1\LOCALS~1\Temp
TMP=C:\DOCUME~1\TEST~1\LOCALS~1\Temp
USERDOMAIN=REMOVED-xxxxxxxx
USERNAME=testing
USERPROFILE=C:\Documents and Settings\testing
VS100COMNTOOLS=C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\
windir=C:\WINDOWS

From js.log
2012-01-11 09:40:40,504 SwingWorker-pool-3-thread-2 INFO  snoop.StartupView - 
Attaching to process ID 1288 with generated agent at 
C:\JavaSnoop\working\JavaSnoop.jar
2012-01-11 09:40:40,538 SwingWorker-pool-3-thread-2 ERROR snoop.StartupView - 
com.sun.tools.attach.AgentInitializationException: Agent JAR loaded but agent 
failed to initialize

I think this may have to do with the JVM arguments using JRE and not JDK, but I 
can't find any information on how to modify that behavior.

Original comment by Andrew.B...@gmail.com on 11 Jan 2012 at 8:15

GoogleCodeExporter commented 9 years ago
Change the %USERPROFILE%\.java.policy file to reflect the contents of the 
resource\unsafe.policy file supplied with the JavaSnoop installation to fix 
this issue.  Remember, that all instances of the JVM must be closed and 
restarted for this to take effect (e.g., if you have a browser window with an 
applet started before you changed the policy file, the new policy will not be 
reflected to that applet).

Original comment by raj...@gmail.com on 11 May 2012 at 4:25

GoogleCodeExporter commented 9 years ago
I am also getting this problem. I have changed all my java.policy files to the 
unsafe one, and I am also providing the -Djava.security.policy attribute to the 
browser so I can specifically point at a java policy file. I can list the ePIDS 
of all running java apps then it fails on attaching with the same error. I only 
get this problem on applets by the way, works fine on fat clients.

Original comment by myleshos...@gmail.com on 24 Oct 2013 at 2:41

GoogleCodeExporter commented 9 years ago
I am also getting this problem on a Windows 7 machine.  It is with a JavaFX 
app.  I have used procmon to check to see what policy files it is 
loading/reading and have made sure that all of the policy files it touches have 
been modified to the unsafe version.

Original comment by mbo...@gmail.com on 20 Nov 2013 at 4:47

GoogleCodeExporter commented 9 years ago
This looks like a problem with the latest version of jdk 1.7.  I removed 1.7 
and installed the last version of 1.6 and JavaSnoop worked.

Original comment by mbo...@gmail.com on 2 Dec 2013 at 4:42