Simple JAVA application cracking-Class Library Loading in advance

Source: Internet
Author: User

If the jar package Library has the same package path and the same class name when running JAVA, will the JVM report an error?

Of course not! JVM only loads the earliest CLASS

First, the JVM will load its own default package, and then load all the JAR files under the EXT directory to the classpath.

Now there are two JAR packages, kj0213w.jar summer. jar, which both have the package path cn. isto.

If there is a Jcrack. class, the JVM will check which class is used when it is first loaded into the VM! If the path name is the same, it will be discarded!

What do you think of the above loading methods?


First, we design a class


// This is a specially cracked class
Package cn. isto;
Public class Jcrack {
Public Jcrack (){}
Boolean getLogin (String pwd ){
Return true;
}
}
 


There is only one method in it to determine whether the login is successful and returns a true

Package this class as kj021320.jar

Next we will write two more classes.

 

// This is the class for determining login during real running
Package cn. isto;
Public class Jcrack {
Public Jcrack (){
}
Boolean getLogin (String pwd ){
Return "KJ021320". equals (pwd );
}
}
// Call the login verification class
Package cn. isto;
Public class JMain {
Public JMain (){
}
Public static void main (String [] args ){
System. out. println (new Jcrack (). getLogin ("Summer "));
}
}
 


Obviously, we compile the above two classes and run them directly! No need to view the console will print false

However, we will load the above kj021320.jar back and then run the JMain class.


The system will display true. Simply put, the JVM discards the Jcrack class of normal users! The Jcrack class we modified is loaded!

The JAVA application is simply cracked!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.