马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
x
摘要
在长期运行的应用服务器上,近期的安全漏洞扫描揭示了fastjson组件存在潜伏的安全隐患(FastJSON是一个Java 语言实现的 JSON 解析器和天生器。FastJSON存在长途代码实行漏洞,恶意攻击者可以通过此漏洞长途实行恶意代码来入侵服务器)。为解决这一漏洞,解决方案是对fastjson版本的升级,以增强体系的安全性。为了制止因重新打包整个应用带来的不便与效率损失,我们采取了一种更为灵活的更新计谋——直接在生产环境中升级fastjson至最新稳定版本。
FastJson下载
官方链接:https://mvnrepository.com/artifact/com.alibaba/fastjson
按照如下步骤进行下载FastJson的jar包
下滑找到你要的fastjson包版本,我选择1.2.83。
跳转到具体1.2.83版本页。
跳转到GitHub,点击如下图所示:
点击下载FastJson的jar包
升级Fastjson
1.找到服务器上正在运行的Java的jar包
- # 根据命令能看见正在跑的Java的jar包
- ps -ef|grep java
- # 根据命令找到Java包的位置
- find / -name xx.jar
复制代码
2.备份jar包
- # 切换到jar包目录
- cd /xxx/xxx
- # 复制一份jar包
- cp xx.jar xx.jar_日期.bak
复制代码 举例如下:
3.创建临时文件夹,并将jar移入
注:先备份要进行升级fastjson的jar包
- mkdir temp
- mv xxx.jar temp/
- # 切换到临时目录
- cd temp/
复制代码 4.解压jar包
- jar xvf xxx.jar
- # 一般解压有三个目录:BOOT-INF/ META-INF/ org/
复制代码 通过jar --help 命令查看 jar 的相干命令
- Illegal option: -
- Usage: jar {ctxui}[vfmn0PMe] [jar-file] [manifest-file] [entry-point] [-C dir] files ...
- Options:
- -c create new archive
- -t list table of contents for archive
- -x extract named (or all) files from archive
- -u update existing archive
- -v generate verbose output on standard output
- -f specify archive file name
- -m include manifest information from specified manifest file
- -n perform Pack200 normalization after creating a new archive
- -e specify application entry point for stand-alone application
- bundled into an executable jar file
- -0 store only; use no ZIP compression
- -P preserve leading '/' (absolute path) and ".." (parent directory) components from file names
- -M do not create a manifest file for the entries
- -i generate index information for the specified jar files
- -C change to the specified directory and include the following file
- If any file is a directory then it is processed recursively.
- The manifest file name, the archive file name and the entry point name are
- specified in the same order as the 'm', 'f' and 'e' flags.
- Example 1: to archive two class files into an archive called classes.jar:
- jar cvf classes.jar Foo.class Bar.class
- Example 2: use an existing manifest file 'mymanifest' and archive all the
- files in the foo/ directory into 'classes.jar':
- jar cvfm classes.jar mymanifest -C foo/ .
复制代码 用法:jar {ctxui} [vfmn0PMe] [jar文件] [清单文件] [入口点] [-C目录]文件...
选项:
-c创建新档案
-t列出要归档的目录
-x从存档中提取命名(或所有)文件
-u更新现有档案
-v在标准输出上天生详细输出
-f指定归档文件名
-m包罗来自指定清单文件的清单信息
-n在创建新存档后实行Pack200规范化
-e指定独立应用程序的应用程序入口点
捆绑到可实行的jar文件中
-0只存储;不使用ZIP压缩 (数字0)
-P从文件名生存前导的“ /”(绝对路径)和“ ..”(父目录)组件
-M不为条目创建清单文件
-i为指定的jar文件天生索引信息
-C更改为指定目录并包罗以下文件
如果任何文件是目录,则将对其进行递归处置惩罚。
清单文件名称,归档文件名称和入口点名称为
以与“ m”,“ f”和“ e”标记类似的顺序指定。
5.更新fastjson的jar包
- # 切换到BOOT-INF/lib
- cd BOOT-INF/lib
- # 找到fastjson.jar并替换,可采用文件传输工具或者命令
复制代码 6.重新打成jar包
- #打包时先删除当前目录的xxx.jar包
- rm -rf xxx.jar
- #将所有文件重新压缩成xxx.jar包
- jar -cvfM0 xxx.jar BOOT-INF/ META-INF/ org/
- #将重新打包的xxx.jar放回原来目录,并运行新的jar包。
复制代码 到此,在Linux环境下fastjson升级完成。
参考:jar包的解压和重新打包_jar解压后重新打包-CSDN博客
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。 |