import java.io.Serializable;//该类必须实现java.io.Serializablepublic class Employ implements Serializable {public String name;public int age;}
import java.io.FileOutputStream;import java.io.IOException;import java.io.ObjectOutputStream;public class test {public static void main(String[] args) {//将e转化为字节序列存储于/tmp/1.serEmploy e = new Employ();e.name = "zhangyida";e.age = 15;try {FileOutputStream fops = new FileOutputStream("/tmp/1.ser");ObjectOutputStream obos = new ObjectOutputStream(fops);obos.writeObject(e);obos.close();System.out.println("Serialized data is saved in /tmp/1.ser");}catch (IOException i){i.printStackTrace();}}}
import java.io.ObjectInputStream;public class desEmploy {public static void main(String[] args) {Employ e = new Employ();try {FileInputStream fis = new FileInputStream("/tmp/1.ser");ObjectInputStream obis = new ObjectInputStream(fis);e = (Employ) obis.readObject();}catch (IOException i){i.printStackTrace();return;} catch (ClassNotFoundException ex) {System.out.println("Employ class not found!");ex.printStackTrace();return;}System.out.println(e.name);System.out.println(e.age);}}
stream:magic version contents
contentscontentcontents content
contentobjectblockdata
objectnewObjectnewClassnewArraynewStringnewEnumnewClassDescprevObjectnullReferenceexceptionTC_RESET
newObject:TC_OBJECT classDesc newHandle classdata[]
newString:TC_STRING newHandle
newClassDescTC_CLASSDESC className serialVersionUID newHandle classDescInfo*classDescInfoclassDescFlags fields classAnnotation superClassDesc
import java.io.ObjectInputStream;import java.io.Serializable;import java.io.IOException;public class Employ implements Serializable {public String name;//public int age;private void test(String name){System.out.println(name);}private void readObject(ObjectInputStream objin) {try {objin.readObject();Runtime.getRuntime().exec("open /System/Applications/Calculator.app");} catch (IOException e) {e.printStackTrace();} catch (ClassNotFoundException e) {e.printStackTrace();}}}
E
N
D
关
于
我
们
Tide安全团队正式成立于2019年1月,是新潮信息旗下以互联网攻防技术研究为目标的安全团队,团队致力于分享高质量原创文章、开源安全工具、交流安全技术,研究方向覆盖网络攻防、系统安全、Web安全、移动终端、安全开发、物联网/工控安全/AI安全等多个领域。
团队作为“省级等保关键技术实验室”先后与哈工大、齐鲁银行、聊城大学、交通学院等多个高校名企建立联合技术实验室。团队公众号自创建以来,共发布原创文章400余篇,自研平台达到31个,目有18个平台已开源。此外积极参加各类线上、线下CTF比赛并取得了优异的成绩。如有对安全行业感兴趣的小伙伴可以踊跃加入或关注我们。