`

求助: 一个软件注册片段?

J# 
阅读更多

 

  public static boolean checkSerial(String paramString1, String paramString2) 
  { 
    int i = 0; 
    try 
    { 
      i = Integer.valueOf(paramString2).intValue(); 
    } 
    catch (NumberFormatException localNumberFormatException) 
    { 
      return false; 
    } 
    if (paramString2.length() != 12) 
      return false; 
    paramString1 = paramString1 + "abcdefghijklmnopqrstuvwxyz"; 
    int j = 0; 
    for (int k = 0; k < 24; ++k) 
    { 
      j += paramString1.charAt(k); 
      j <<= 2; 
    } 
    j = Math.abs(j); 
    return (j == i); 

  }

 

 paramString1 :用户名   paramString2: 注册码

以上是一个小程序注册 检测有效性的片段,由上可以破解出 反推出一组 用户名 注册码吗?   万分感谢!

 

 

 

答案如下:

 

public class crack {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	String username ="yourname";
    String password = getPassword(username);
    
    if(checkSerial(username,password)) System.out .println("ok");
    System.out .println("username:"+username+"\n"+"password:"+password);
		    

	}
	public static String getPassword(String userName)    
	{ 
	  userName = userName + "abcdefghijklmnopqrstuvwxyz";    
	  int j = 0;    
	  for (int k = 0; k < 24; ++k)    
	  {    
	    j += userName.charAt(k);  
	    j <<= 2;    
	  }    
	  j = Math.abs(j);
	  String passWord="";  
	  String jStr = ""+j;
	  for(int i=0;i<12-jStr.length();i++){
		  passWord+="0";
	  }
	  
	  return passWord+jStr;    
	  
	}  
	
	 public static boolean checkSerial(String paramString1, String paramString2)
	  {
	    int i = 0;
	    try
	    {
	      i = Integer.valueOf(paramString2).intValue();
	    }
	    catch (NumberFormatException localNumberFormatException)
	    {
	      return false;
	    }
	    if (paramString2.length() != 12)
	      return false;
	    paramString1 = paramString1 + "abcdefghijklmnopqrstuvwxyz";
	    int j = 0;
	    for (int k = 0; k < 24; ++k)
	    {
	      j += paramString1.charAt(k);
	      j <<= 2;
	    }
	    j = Math.abs(j);
	    return (j == i);
	  }
}

 

 在此特别感谢 “剑走偏锋2.1” !

 

2
0
分享到:
评论
1 楼 jmu 2009-07-01  
。。。。注册码不就是最后的j吗?
paramString1 = paramString1 + "abcdefghijklmnopqrstuvwxyz";   
   int j = 0;   
  for (int k = 0; k < 24; ++k)   
   {   
     j += paramString1.charAt(k);   
    j <<= 2;   
   }   
 j = Math.abs(j);   

相关推荐

Global site tag (gtag.js) - Google Analytics