https://github.com/frohoff/ysoserial
Is a proof-of-concept tool for generating payloads that exploit unsafe Java object deserialization. It also works with JMX.
Is there any way to make JMX secure?
I also read https://tersesystems.com/2015/11/08/closing-the-open-door-of-java-object-serialization/. I dont understand how to use NotSoSerial in my project.
You can run NotSoSerial by building the project from githhub, then taking the jar and running the JVM with the following arguments on the command line:
-javaagent:notsoserial.jar -Dnotsoserial.whitelist=empty.txt
as specified in https://github.com/kantega/notsoserial#whitelisting-mode
If you want to use JMX but don't want to use RMI (which uses Java Serialization) then look into jmxtrans or Jolokia and see how you can best lock the JSON messages being passed through there.
Related
I have an executable jar and I was trying to create a Windows Service using sc.exe. I used the below code for creating service:
sc create "TestService" binPath= "C:\Program Files\Java\jdk1.6.0_03\jre\bin\java.exe -jar C:\abc\MainClass.jar"
The service got created but when I was trying to start the service I got the below error:
Error 1053: The service did not respond to the start or control request in a timely fashion.
Later I tried to use Java Service Wrapper (Community Edition), the service starts for some time but is getting stopped everytime. The wrapper log tells something like:
Advice:
The Wrapper consists of a native component as well as a set of classes
which run within the JVM that it launches. The Java component of the
Wrapper must be initialized promptly after the JVM is launched or the
Wrapper will timeout, as just happened. Most likely the main class
specified in the Wrapper configuration file is not correctly initializing
the Wrapper classes:
com.MainClass
While it is possible to do so manually, the Wrapper ships with helper
classes to make this initialization processes automatic.
Please review the integration section of the Wrapper's documentation
for the various methods which can be employed to launch an application
within the Wrapper
Could anyone please tell me how can I run jar as a Windows Service without using external software as I can't use any third party app on Client's prod env.
If not what other configs I need to do in Java Service Wrapper to make the service start.
I tried to find some info related to this on stackoverflow but I did not get anything thing. If any one has anything on stackoverflow please feel free to put this in comment.
I have used this approach before in a productive environment, so I can assure you it is safe to use.
The Jar-File is wrapped in an exe and then it is added to the windows service scheduler (or however you want to call this). If you have a maven project this is also really easy to accomplish.
https://dzone.com/articles/installing-a-java-application-as-a-windows-service
Edit: you said you can’t use external software. With this approach everything that is needed is packed in the exe file. Including a JRE, I hope that that is allowed by your client’s policy.
I have to applications running on a single Wildfly container using single database. Currently they are communicated with each other using JAX-RS and I wonder is there more faster way?
What I have already found:
JAX-RS
Local EJB
Remote EJB
JMS
Seems that the most fastest way is to use Local EJB. But I am not sure about JMS. And what about Websockets?
Ok, one could complain about the question being too broad formulated but providing one possible answer would also be nice ;)
So here is my suggestion:
Simply create a clean API for the communication between the modules and deploy it as a JAR to your server. The module that contains the JAX-RS endpoint could also implement the API to provide the services you need (not only for internal usage but also for your REST service which then would simply delegate the request processing). Now you can simply inject a service using CDI when you need it for internal usage and as far as I know this is the fastest possible way to go for internal communication since it works directly with JAVA objects. Using CDI for the injection of the service implementation has also the benefit of decoupling the modules.
I hope this helps ;)
Have you looked at memory-mapped files? They can offer some very high throughput. Check out the NIO FileChannel class. For a ready-to-run solution, take a look at Jocket.
My application code will run on one box. I have a tool that will be executed on a different box. Here I want to access my application code specific class method in the tool where it will executed on different box. How can I do this?
I don't want to change any existing code on the application side, I only want to add code on tool side to access the application class method. The class that I want to access is a regular java bean class.
We used to have a somehow similar issue.
We end up creating a simple library that allow us to distribute classes over several JVMs and to call methods in remote JVM.
You can have a look on https://github.com/plantuml/remotejvm to see if it can help you.
May be you need to have a look at Remote Method Invocation. Also take care of which version you are using, versions before Java 5.0 required the RMI stubs to be compiled separately.
Java RMI Tutorial
RMI online training
You would want to take a look at remote method invocation(RMI). It is not possible without adding code on the application side since you need to register the application with the RMI registry. The RMI registry is sort of a directory lookup to allow remote applications to access the application.
You could also use RMI-IIOP but it has the same constraints. You need to register the application with tnameserv
Link: https://docs.oracle.com/javase/8/docs/technotes/guides/rmi/index.html
I develop the container-like application which can accept custom JARs and run some classes from these JAR archives. And I wanr to protect my application from this custom code.
I've found SecurityManager and Policy classes there, but I still don't know how to protect my application from stack overflow attacks and so on.
I've found Runtime class, but I cannot use the separate process because I need to have the instance of the custom class in my application.
What instrument should I use? Or, maybe, I should change the architecture of my application?
I think you are trying to achieve what Google did with GAE. It's not a simple subject to be addressed here so I suppose this paper could be of help.
If you have to do this, it seems better to go for a "chroot jail" or the full virtualisation. (Neither of which I no much about.)
I'm developing a system that allows developers to upload custom groovy scripts and freemarker templates.
I can provide a certain level of security at a very high level with the default Java security infrastructure - i.e. prevent code from accessing the filesystem or network, however I have a need to restrict access to specific methods.
My plan was to modify the Groovy and Freemarker runtimes to read Annotations that would either whitelist or blacklist certain methods, however this would force me to maintain a forked version of their code, which is not desirable.
All I essentially need to be able to do is prevent the execution of specific methods when called from Groovy or Freemarker. I've considered a hack that would look at the call stack, but this would be a massive speed hit (and it quite messy).
Does anyone have any other ideas for implementing this?
You can do it by subclassing the GroovyClassLoader and enforcing your constraints within an AST Visitor. THis post explains how to do it: http://hamletdarcy.blogspot.com/2009/01/groovy-compile-time-meta-magic.html
Also, the code referenced there is in the samples folder of Groovy 1.6 installer.
You should have a look at the project groovy-sandbox from kohsuke. Have also a look to his blog post here on this topic and what is solution is addressing: sandboxing, but performance drawback.
OSGi is great for this. You can partition your code into bundles and set exactly what each bundle exposes, and to what other bundles. Would that work for you?
You might also consider the java-sandbox (http://blog.datenwerke.net/p/the-java-sandbox.html) a recently developed library that allows to securely execute untrusted code from within java.
Also see: http://blog.datenwerke.net/2013/06/sandboxing-groovy-with-java-sandbox.html