简体   繁体   English

Java JAR文件是否可能损坏您的系统?如何检查它正在做什么?

[英]Is it possible for a Java JAR file to damage your system and how can you check what it's doing?

I want to evaluate a software solution where multiple people have submitted JAR files to perform a task on Windows. 我想评估一个软件解决方案,其中有多个人提交了JAR文件以在Windows上执行任务。

Is it possible to check whether the JAR file performs any additional unwanted behaviors besides those it claims to perform on your machine? 是否可以检查JAR文件是否执行除声称在您的计算机上执行的其他不需要的行为?

First, you can use a JVM set with SecurityManager to do run your application in a way that it can have limited access to sensitive functions. 首先,您可以使用带有SecurityManager的JVM集来运行您的应用程序,使其可以有限地访问敏感函数。

You can also set up a "sandbox" so the jar cannot have permissions outside of the sandbox... you could use chroot or a similar tool in a linux/unix environment. 你也可以设置一个“沙箱”,这样jar就不能拥有沙箱之外的权限......你可以在linux / unix环境中使用chroot或类似的工具。

1. You could use software from Sysinternals: http://technet.microsoft.com/en-us/sysinternals/bb842062 1.您可以使用Sysinternals的软件: http//technet.microsoft.com/en-us/sysinternals/bb842062

You can see is program's writing or deleting something from hard drive with HardMon, or monitor any changes with RegMon... Check out their website, they have much programs and you can monitor practically everything! 您可以看到程序正在使用HardMon写入或删除硬盘中的内容,或使用RegMon监控任何更改...查看他们的网站,他们有很多程序,您几乎可以监控所有内容!

2. Or you could install Sandboxie: http://www.sandboxie.com/ 2.或者您可以安装Sandboxie: http//www.sandboxie.com/

and then run you program within sandbox ("virtual filesystem"). 然后在沙箱中运行程序(“虚拟文件系统”)。 When you run a program inside of sandbox, you can see what files did the program make, and the best thing is that any changes that the program did will be undone when it exists, so it can't harm your system. 当您在沙盒中运行程序时,您可以看到程序所执行的文件,最好的是程序执行的任何更改都将在其存在时撤消,因此它不会损害您的系统。 :) :)

3. Also, you could try to decompile JAR file: http://www.google.hr/search?sourceid=chrome&ie=UTF-8&q=java+decompiler 3.此外,您可以尝试反编译JAR文件: http//www.google.hr/search? sourceid = chrome&ie = UTF-8&q = java + codemiler

Yes and No. By default java programs can do the same things any native program on your system can do. 是和否。默认情况下,java程序可以执行系统上任何本机程序可以执行的操作。 This includes deleting and replacing any file it can access, depending on your operating system and your user privileges this may affect system critical files. 这包括删除和替换它可以访问的任何文件,具体取决于您的操作系统和用户权限,这可能会影响系统关键文件。

It is possible to restrict what java applications can do, applets and webstart programs usually are secured this way. 可以限制 Java应用程序可以执行的操作,applet和webstart程序通常以这种方式受到保护。 Alternatively you can run any program as a different/restricted user or in a sandbox to limit the damage it can do. 或者,您可以将任何程序作为不同/受限制的用户或沙箱运行,以限制它可以造成的损害。

If you do not trust the library/program always run it in one of the restricted environments mentioned above. 如果您不相信库/程序总是在上面提到的一个受限环境中运行它。 It may crash if it does something it should not do, but it will be unable to do any damage. 它可能会崩溃,如果它做了它不应该做的事情,但它将无法做任何损害。

Try a decompiler, like Java Decompiler: http://jd.benow.ca/ 尝试一个反编译器,比如Java Decompiler: http//jd.benow.ca/

It decompiles the .jar file, and shows you the source, though keep in mind it might be copyrighted: 它反编译.jar文件,并向您显示源代码,但请记住它可能受版权保护: 替代文字

By the way, why don't you ask for them to submit the source code as well, instead of just the .jar files? 顺便问一下,为什么不要求他们提交源代码,而不仅仅是.jar文件?

Basically, .jar files are like souped-up zip files, and I believe even WinRAR can open .jar files. 基本上,.jar文件就像加强文件的zip文件,我相信即使是WinRAR也可以打开.jar文件。 A quote from their site: 来自他们网站的报价:

Java Archive File (a compressed file for applets and related files) (.JAR) Java Archive File(applet和相关文件的压缩文件)(.JAR)

Short for Java Archive, a file format used to bundle all components required by a Java applet. Java Archive的缩写,用于捆绑Java applet所需的所有组件的文件格式。 JAR files simplify the downloading of applets since all the components (.class files, images, sounds, etc.) can be packaged into a single file. JAR文件简化了applet的下载,因为所有组件(.class文件,图像,声音等)都可以打包到一个文件中。 Additionally, JAR supports data compression, which further decreases download times. 此外,JAR支持数据压缩,这进一步减少了下载时间。

JAR file support is the same as ZIP file support. JAR文件支持与ZIP文件支持相同。 JAR = ZIP + manifest. JAR = ZIP +清单。 The Microsoft VM supports uncompressed and compressed JAR levels 0 and 1, but not signed JAR. Microsoft VM支持未压缩和压缩的JAR级别0和1,但不支持已签名的JAR。

WinRAR provides basic operations for JAR files created by other tools: view contents, extract files, show comments and archive information. WinRAR为其他工具创建的JAR文件提供基本操作:查看内容,提取文件,显示注释和存档信息。

You can use the convert function to convert .jar files into .rar format. 您可以使用convert函数将.jar文件转换为.rar格式。

You do not need to have any external programs to handle these formats. 您不需要任何外部程序来处理这些格式。

After extracting with WinRAR, you can view the source by following this link as an alternate method to JD. 使用WinRAR解压缩后,您可以通过此链接查看源,作为JD的替代方法。

I tried the solution from jensign.com and it looks like it restricts almost everything. 我尝试了jensign.com解决方案,看起来它限制了几乎所有东西。 The .jar application that I used to test wasn't even able to download a website. 我以前测试的.jar应用程序甚至无法下载网站。 However I'm not an expert at this stuff so I can't tell if it is a 100% safe solution. 但是我不是这方面的专家所以我不知道它是否是100%安全的解决方案。

The JAR'd application can be launched under fully restrictive sandbox conditions (very similar to Java applet default security sandboxing): JAR的应用程序可以在完全限制的沙箱条件下启动(非常类似于Java applet默认安全沙箱):

  java -jar -Djava.security.manager PropsFrame.jar 

cite from jensign.com 来自jensign.com

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM