-
-
[原创]2015 移动安全 第一题解题思路
-
发表于: 2015-1-23 13:44 1917
-
第一步 先反编译代码(老生常谈)
第二步 安装apk运行一下,查看日志
Log.i("lil", "table:" + str2);
Log.i("lil", "pw:" + str3);
Log.i("lil", "enPassword:" + str4);
由此可知 这个是查表法
第三步 提取关键代码
private static byte[] aliCodeToBytes(String paramString1, String paramString2)
{
byte[] arrayOfByte = new byte[paramString2.length()];
for (int i = 0; ; i++)
{
if (i >= paramString2.length())
return arrayOfByte;
arrayOfByte[i] = (byte)paramString1.indexOf(paramString2.charAt(i));
}
}
private static String bytesToAliSmsCode(String paramString, byte[] paramArrayOfByte)
{
StringBuilder localStringBuilder = new StringBuilder();
for (int i = 0; ; i++)
{
if (i >= paramArrayOfByte.length)
return localStringBuilder.toString();
localStringBuilder.append(paramString.charAt(0xFF & paramArrayOfByte[i]));
}
}
好。。。。文笔有限 直接贴加解密代码
public static void main(String[] args) {
// pw:义弓么丸广之
String table = ":一乙二十丁厂七卜人入八九几儿了力乃刀又三于干亏士工土才寸下大丈与万上小口巾山千乞川亿个勺久凡及夕丸么广亡门义之尸弓己已子卫也女飞刃习叉马乡丰王井开夫天无元专云扎艺木五支厅不太犬区历尤友匹车巨牙屯比互切瓦止少日中冈贝内水见午牛手毛气升长仁什片仆化仇币仍仅斤爪反介父从今凶分乏公仓月氏勿欠风丹匀乌凤勾文六方火为斗忆订计户认心尺引丑巴孔队办以允予劝双书幻玉刊示末未击打巧正扑扒功扔去甘世古节本术可丙左厉右石布龙平灭轧东卡北占业旧帅归且旦目叶甲申叮电号田由史只央兄叼叫另叨叹四生失禾丘付仗代仙们仪白仔他斥瓜乎丛令用甩印乐";
System.out.println(decryption(table, "义弓么丸广之"));
System.out.println(encryption(table, "581026"));
}
/**
* 加密算法
* @param table //加密表
* @param clear //明文
* @return 密文
*/
private static String encryption(String table,String clear) {
return bytesToAliSmsCode(table, offsize(clear));
}
/**
* 解密算法
*
* @param table
* //加密表
* @param target
* //密文
* @return 明文
*/
private static String decryption(String table, String cipher) {
return new String(aliCodeToBytes(table, cipher));
}
private static byte[] offsize(String s) {
byte[] temp = s.getBytes();
for (int i = 0; i < temp.length; i++) {
temp[i] += 1;
}
return temp;
}
private static byte[] aliCodeToBytes(String paramString1, String paramString2) {
byte[] arrayOfByte = new byte[paramString2.length()];
for (int i = 0;; i++) {
if (i >= paramString2.length())
return arrayOfByte;
arrayOfByte[i] = (byte) ((byte) paramString1.indexOf(paramString2.charAt(i)) - 1);
}
}
private static String bytesToAliSmsCode(String paramString, byte[] paramArrayOfByte) {
StringBuilder localStringBuilder = new StringBuilder();
for (int i = 0;; i++) {
if (i >= paramArrayOfByte.length)
return localStringBuilder.toString();
localStringBuilder.append(paramString.charAt(0xFF & paramArrayOfByte[i]));
}
}
第二步 安装apk运行一下,查看日志
Log.i("lil", "table:" + str2);
Log.i("lil", "pw:" + str3);
Log.i("lil", "enPassword:" + str4);
由此可知 这个是查表法
第三步 提取关键代码
private static byte[] aliCodeToBytes(String paramString1, String paramString2)
{
byte[] arrayOfByte = new byte[paramString2.length()];
for (int i = 0; ; i++)
{
if (i >= paramString2.length())
return arrayOfByte;
arrayOfByte[i] = (byte)paramString1.indexOf(paramString2.charAt(i));
}
}
private static String bytesToAliSmsCode(String paramString, byte[] paramArrayOfByte)
{
StringBuilder localStringBuilder = new StringBuilder();
for (int i = 0; ; i++)
{
if (i >= paramArrayOfByte.length)
return localStringBuilder.toString();
localStringBuilder.append(paramString.charAt(0xFF & paramArrayOfByte[i]));
}
}
好。。。。文笔有限 直接贴加解密代码
public static void main(String[] args) {
// pw:义弓么丸广之
String table = ":一乙二十丁厂七卜人入八九几儿了力乃刀又三于干亏士工土才寸下大丈与万上小口巾山千乞川亿个勺久凡及夕丸么广亡门义之尸弓己已子卫也女飞刃习叉马乡丰王井开夫天无元专云扎艺木五支厅不太犬区历尤友匹车巨牙屯比互切瓦止少日中冈贝内水见午牛手毛气升长仁什片仆化仇币仍仅斤爪反介父从今凶分乏公仓月氏勿欠风丹匀乌凤勾文六方火为斗忆订计户认心尺引丑巴孔队办以允予劝双书幻玉刊示末未击打巧正扑扒功扔去甘世古节本术可丙左厉右石布龙平灭轧东卡北占业旧帅归且旦目叶甲申叮电号田由史只央兄叼叫另叨叹四生失禾丘付仗代仙们仪白仔他斥瓜乎丛令用甩印乐";
System.out.println(decryption(table, "义弓么丸广之"));
System.out.println(encryption(table, "581026"));
}
/**
* 加密算法
* @param table //加密表
* @param clear //明文
* @return 密文
*/
private static String encryption(String table,String clear) {
return bytesToAliSmsCode(table, offsize(clear));
}
/**
* 解密算法
*
* @param table
* //加密表
* @param target
* //密文
* @return 明文
*/
private static String decryption(String table, String cipher) {
return new String(aliCodeToBytes(table, cipher));
}
private static byte[] offsize(String s) {
byte[] temp = s.getBytes();
for (int i = 0; i < temp.length; i++) {
temp[i] += 1;
}
return temp;
}
private static byte[] aliCodeToBytes(String paramString1, String paramString2) {
byte[] arrayOfByte = new byte[paramString2.length()];
for (int i = 0;; i++) {
if (i >= paramString2.length())
return arrayOfByte;
arrayOfByte[i] = (byte) ((byte) paramString1.indexOf(paramString2.charAt(i)) - 1);
}
}
private static String bytesToAliSmsCode(String paramString, byte[] paramArrayOfByte) {
StringBuilder localStringBuilder = new StringBuilder();
for (int i = 0;; i++) {
if (i >= paramArrayOfByte.length)
return localStringBuilder.toString();
localStringBuilder.append(paramString.charAt(0xFF & paramArrayOfByte[i]));
}
}
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!
赞赏
他的文章
看原图
赞赏
雪币:
留言: