由于58同城在页面上抓取二手房信息的时候,用户的联系电话是图片的,本人水平关系无法进行很好的识别,所以转为抓取其android客户端比较容易,之前都是好好的,最近发现其升级到1.3.0.0后手机号码进行了加密,所以直接反编译其android客户端,查到其用的是des加密,而且加密的key很容易就拿到,下面贴出解密方法。(des加解密比较简单下面贴出来)
很久没写博,上来溜溜,我是firstep
本文转载自:[url=http://hi.baidu.com/alvin4u/blog/item/d2c5ad1b2c7d8938dd5401a5.html]http://hi.baidu.com/alvin4u/blog/item/d2c5ad1b2c7d8938dd5401a5.html[/url]
import java.security.securerandom;import javax.crypto.cipher;import javax.crypto.secretkey;import javax.crypto.secretkeyfactory;import javax.crypto.spec.deskeyspec;public class decode458 { static byte[] key = null; //这个key如果有需要请反编译58客户端获取这里不便贴出 public static void main(string[] args) throws exception { system.out.println(new string(decode458.decode(decode458.converthexstring("002e674657ae8239982087dcb2e6a99b")))); system.out.println(decode458.tohexstring(decode458.encode("13219863008".getbytes()))); } public static byte[] decode(byte[] paramarrayofbyte) { try { securerandom localsecurerandom = new securerandom(); deskeyspec localdeskeyspec = new deskeyspec(key); secretkey localsecretkey = secretkeyfactory.getinstance("des") .generatesecret(localdeskeyspec); cipher localcipher = cipher.getinstance("des"); localcipher.init(2, localsecretkey, localsecurerandom); return localcipher.dofinal(paramarrayofbyte); } catch (exception e) { e.printstacktrace(); return null; } } public static byte[] encode(byte[] paramarrayofbyte) { try { securerandom localsecurerandom = new securerandom(); deskeyspec localdeskeyspec = new deskeyspec(key); secretkey localsecretkey = secretkeyfactory.getinstance("des") .generatesecret(localdeskeyspec); cipher localcipher = cipher.getinstance("des"); localcipher.init(1, localsecretkey, localsecurerandom); return localcipher.dofinal(paramarrayofbyte); } catch (exception e) { e.printstacktrace(); return null; } } public static byte[] converthexstring(string text) { byte digest[] = new byte[text.length() / 2]; for (int i = 0; i < digest.length; i++) { string bytestring = text.substring(2 * i, 2 * i + 2); int bytevalue = integer.parseint(bytestring, 16); digest[i] = (byte) bytevalue; } return digest; } public static string tohexstring(byte b[]) { stringbuffer hexstring = new stringbuffer(); for (int i = 0; i < b.length; i++) { string plaintext = integer.tohexstring(0xff & b[i]); if (plaintext.length() < 2) plaintext = "0" + plaintext; hexstring.append(plaintext); } return hexstring.tostring(); }}
很久没写博,上来溜溜,我是firstep
本文转载自:[url=http://hi.baidu.com/alvin4u/blog/item/d2c5ad1b2c7d8938dd5401a5.html]http://hi.baidu.com/alvin4u/blog/item/d2c5ad1b2c7d8938dd5401a5.html[/url]