RMI
概述
RMI(Remote Method Invocation)是计算机之间通过网络实现对象调用的一种通讯机制。它允许在Java虚拟机(JVM)之间进行通信,使得在一个JVM中的对象可以调用另一个JVM中的对象的方法,就像这些对象都在同一个JVM中一样。
服务端(Server):
- 服务端创建一个远程对象,并实现一个或多个远程接口。
- 服务端启动 RMI 注册表,并将远程对象绑定到注册表中。
客户端(Client):
- 客户端从 RMI 注册表中查找所需的远程对象。
- 客户端获取远程对象的引用,并调用其方法。
测试环境:JDK8u41
RMIServer.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
| import java.rmi.Naming; import java.rmi.Remote; import java.rmi.RemoteException; import java.rmi.registry.LocateRegistry; import java.rmi.registry.Registry; import java.rmi.server.UnicastRemoteObject;
public class RMIServer { public interface IRemoteObj extends Remote { public String hello(String para) throws RemoteException; } public class RemoteObjImpl extends UnicastRemoteObject implements IRemoteObj { protected RemoteObjImpl() throws RemoteException { super(); } public String hello(String para) throws RemoteException { System.out.println(para); return "over"; } } private void start() throws Exception { RemoteObjImpl h = new RemoteObjImpl(); LocateRegistry.createRegistry(1099); Naming.rebind("rmi://127.0.0.1:1099/Remote", h);
}
public static void main(String[] args) throws Exception { new RMIServer().start(); } }
|
Read More
Python Prototype Pollution
Python原型链污染通常是指通过某种方式非法地修改了对象的原型链,导致对象访问到了不应该访问到的属性或方法,或者对象的属性被非法地修改
Python中,这通常意味着通过修改类的__dict__
或对象的__class__
属性,来实现对类或对象属性的非法修改
基类
1 2 3 4 5 6 7 8 9
| string = "" print(string.__class__) print(string.__class__.__base__)
def function(): pass print(function.__class__) print(function.__class__.__base__)
|
原型链污染
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| class father: secret = "xxxx" class son_a(father): pass class son_b(father): pass
def merge(src, dst): for k, v in src.items(): if hasattr(dst, '__getitem__'): if dst.get(k) and type(v) == dict: merge(v, dst.get(k)) else: dst[k] = v elif hasattr(dst, k) and type(v) == dict: merge(v, getattr(dst, k)) else: setattr(dst, k, v)
instance = son_b() payload = { "__class__": { "__base__": { "secret": "no" } } }
print(son_a.secret) print(instance.secret)
merge(payload, instance) print(son_a.secret) print(instance.secret)
|
无法污染的Object
全局变量获取
Read More