JRebal(原名JavaRebel)破解小记(4)

  1package temp.jrebel;
  2
  3import java.io.BufferedInputStream;
  4import java.io.BufferedOutputStream;
  5import java.io.ByteArrayInputStream;
  6import java.io.ByteArrayOutputStream;
  7import java.io.File;
  8import java.io.FileInputStream;
  9import java.io.FileOutputStream;
 10import java.io.IOException;
 11import java.io.ObjectInputStream;
 12import java.io.ObjectOutputStream;
 13import java.util.Calendar;
 14import java.util.GregorianCalendar;
 15import java.util.Iterator;
 16import java.util.Map;
 17import junit.framework.Assert;
 18import org.junit.Test;
 19import com.zeroturnaround.licensing.UserLicense;
 20
 21public class ParseLicense {
 22    @Test
 23    public void parseLicenseFile() {
 24        Object localObject1 = null;
 25        try {
 26            System.out.println("start to get lic file.");
 27            File localFile2 = new File("d:\\temp\\jrebel.lic");
 28            Assert.assertNotNull(localFile2);
 29           
 30            System.out.println("start to get objectInputStream.");
 31            localObject1 = new ObjectInputStream(new BufferedInputStream(
 32                    new FileInputStream(localFile2)));
 33            Assert.assertNotNull(localObject1);
 34           
 35            System.out.println("start to get userLicense.");
 36            UserLicense localUserLicense1 = (UserLicense)((ObjectInputStream)localObject1).readObject();
 37            Assert.assertNotNull(localUserLicense1);
 38           
 39            System.out.println("start to get ObjectInputStream2.");
 40            ObjectInputStream localObjectInputStream = new ObjectInputStream(new ByteArrayInputStream(localUserLicense1.getLicense()));
 41            Assert.assertNotNull(localObjectInputStream);
 42           
 43            System.out.println("start to get localMap.");
 44            Map localMap = (Map)localObjectInputStream.readObject();
 45            Assert.assertNotNull(localMap);
 46           
 47            System.out.println("start tot output value.");
 48            for ( Iterator<?> iter = localMap.keySet().iterator(); iter.hasNext(); ) {
 49                String key = (String)iter.next();
 50                System.out.println("key: " + key + ", value: " + localMap.get(key));
 51            }

 52
 53           
 54            System.out.println("start to change date.");
 55            Calendar cal = new GregorianCalendar(20100101);
 56            localMap.put("validUntil", cal.getTime());
 57
 58            System.out.println("start to set a new date to license.");
 59            ByteArrayOutputStream out1 = new ByteArrayOutputStream();
 60            ObjectOutputStream out2 = new ObjectOutputStream(out1);
 61            out2.writeObject(localMap);
 62            out1.toByteArray();
 63            localUserLicense1.setLicense(out1.toByteArray());
 64            out1.close();
 65            out2.close();
 66
 67           
 68            System.out.println("start to get ObjectInputStream2.");
 69            localObjectInputStream = new ObjectInputStream(new ByteArrayInputStream(localUserLicense1.getLicense()));
 70            Assert.assertNotNull(localObjectInputStream);
 71           
 72            System.out.println("start to get localMap.");
 73            localMap = (Map)localObjectInputStream.readObject();
 74            Assert.assertNotNull(localMap);
 75           
 76            for ( Iterator<?> iter = localMap.keySet().iterator(); iter.hasNext(); ) {
 77                String key = (String)iter.next();
 78                System.out.println("key: " + key + ", value: " + localMap.get(key));
 79            }

 80
 81           
 82            String newLicenseFile = "d:\\temp\\new.lic";
 83            ObjectOutputStream out3 = new ObjectOutputStream(new BufferedOutputStream(new FileOutputStream(newLicenseFile)));
 84            out3.writeObject(localUserLicense1);
 85            out3.close();
 86
 87        }
 catch (Exception e) {
 88            e.printStackTrace();
 89            Assert.fail("faile to parse license. ");
 90        }
 finally {
 91            if (localObject1 != null{
 92                try {
 93                    ((ObjectInputStream) localObject1).close();
 94                }
 catch (IOException localIOException12) {
 95                }

 96            }

 97        }

 98
 99    }

100}

101
102 
103

这是我用反编译工具反编译出来的部分源码:

/*     */ package com.zeroturnaround.javarebel;
/*     */ public class jS
/*     */   implements dn

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wwpjdg.html