Pages

Showing posts with label java. Show all posts
Showing posts with label java. Show all posts

Thursday, February 7, 2019

Jetty Obfuscation and Reverse Obfuscation


Download Jetty : https://www.eclipse.org/jetty/download.html

For Obfuscation:
Run below command:

java -cp jetty-util-[VERSION_NUMBER].jar org.eclipse.jetty.util.security.Password [PASSWORD]

Example:
$ java -cp lib\jetty-util-9.4.6.v20170531.jar org.eclipse.jetty.util.security.Password SecretPassword123
2017-08-15 18:44:13.036:INFO::main: Logging initialized @148ms to org.eclipse.jetty.util.log.StdErrLog
SecretPassword123
OBF:1fof1j1u1igh1vgt1vn61y101sgo1v1p1ym71v2p1siu1y0q1vnw1vg11idp1iz01fmn
MD5:512d9845442e46f891bafc22f06b171e

For Reverse Obfuscation

Run below command:

java -cp jetty-util-[VERSION_NUMBER].jar org.eclipse.jetty.util.security.Password [OBF:PASSWORD]

Example::
$ java -cp lib\jetty-util-9.4.6.v20170531.jar org.eclipse.jetty.util.security.Password OBF:1fof1j1u1igh1vgt1vn61y101sgo1v1p1ym71v2p1siu1y0q1vnw1vg11idp1iz01fmn
2017-08-15 18:45:48.165:INFO::main: Logging initialized @134ms to org.eclipse.jetty.util.log.StdErrLog
SecretPassword123
OBF:1fof1j1u1igh1vgt1vn61y101sgo1v1p1ym71v2p1siu1y0q1vnw1vg11idp1iz01fmn
MD5:f8ad4d396e4cc2eb2955d3911eb14cb9

Monday, June 4, 2018

Download Oracle 64 bit JDK 1.8 pre installed zip


Click below to download the Oracle JDK 1.8 pre installed zip 64 bit (No installation required)


Click here Oracle JDK 1.8

after download, unzip the pack to a folder

set JAVA_HOME and PATH environment variables

Download Oracle 64 bit JDK 1.7 pre installed zip


Click below to download the Oracle JDK 1.7 pre installed zip 64 bit (No installation required)

Click here Oracle JDK 1.7

after download, unzip the pack to a folder

set JAVA_HOME and PATH environment variables

Tuesday, November 3, 2015

Read Keystore jks file by using Java KeyTool


Below command to read the jks file and display the certificates it contains:

>keytool -list -keystore keystore.jks
Enter keystore password:
Keystore type: JKS
Keystore provider: SUN
Your keystore contains 2 entries
activation, Mar 13, 2013, trustedCertEntry, Certificate fingerprint (SHA1): 85:4B:73:CE:00:86:D6:1B:FE:95:17:3D:BB:E6:BE:02:BB:78:A4:2F
selfsigned, Mar 13, 2013, PrivateKeyEntry, Certificate fingerprint (SHA1): C5:0A:C4:AB:DA:80:03:F7:59:C7:D9:02:C5:D7:9A:97:08:7B:83:A0

Above data says, it has 2 certificate entries,
first one is alias name is "activation"
2nd one is alias name is "selfsigned"

Now we can export the above two entries into Certificates in CRT files as below 

>keytool -exportcert -file keystore.crt -keystore keystore.jks -alias activation 
Enter keystore password: 
Certificate stored in file  <keystore.crt>
>keytool -exportcert -file keystore1.crt -keystore keystore.jks -alias selfsigned
Enter keystore password: 
Certificate stored in file <keystore1.crt>


Thursday, August 13, 2015

Merge Objects using Reflection API

Merging the two objects using Reflection API

For example the class Animal has objects Tiger, Lion, following is show how to merge these objects using Reflection API


1
2
3
4
5
6
7
8
9
class Animal
{
private name;
private age;
private weight;

..setter/getters

}


Main class

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
Class Main {
public static void main(String[] args)
{
    Animal tiger = new Animal();
    tiger.setName("Tiger");
    tiger.setAge("20");
    tiger.setWeight("80");
    Animal lion = new Animal();
    lion.setName("Lion");
    lion.setAge("25");
    lion.setWeight("120");
  
    merge(tiger,lion);
    
    sysout.println(tiger);
}

public static void merge(Object obj, Object update) {
       
        if (!obj.getClass().isAssignableFrom(update.getClass())) {
            return;
        }

        Method[] methods = obj.getClass().getMethods();

        for (Method fromMethod : methods) {
            if (fromMethod.getDeclaringClass().equals(obj.getClass())
                    && fromMethod.getName().startsWith("get")) {

                String fromName = fromMethod.getName();
                String toName = fromName.replace("get", "set");

                try {
                    Method toMetod = obj.getClass().getMethod(toName,
                            fromMethod.getReturnType());
                    Object value = fromMethod.invoke(update, (Object[]) null);
                    if (value != null) {
                        toMetod.invoke(obj, value);
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        }
    }
}


Output:
[Lion, 25, 120]

Tiger objects properties were overriden by Lion object properties.