zoukankan      html  css  js  c++  java
  • BUUCTF-RE-JAVA逆向解密

    一、

    .class文件用jd-gui打开

    二、分析

     1 import java.io.PrintStream;
     2 import java.util.ArrayList;
     3 import java.util.Scanner;
     4 
     5 public class Reverse
     6 {
     7   public static void main(String[] args)
     8   {
     9     Scanner s = new Scanner(System.in);
    10     System.out.println("Please input the flag :");
    11     String str = s.next();
    12     System.out.println("Your input is :");
    13     System.out.println(str);
    14     char[] stringArr = str.toCharArray();
    15     Encrypt(stringArr);
    16   }
    17   
    18   public static void Encrypt(char[] arr)
    19   {
    20     ArrayList<Integer> Resultlist = new ArrayList();
    21     for (int i = 0; i < arr.length; i++)
    22     {
    23       int result = arr[i] + '@' ^ 0x20;
    24       Resultlist.add(Integer.valueOf(result));
    25     }
    26     int[] KEY = { 180, 136, 137, 147, 191, 137, 147, 191, 148, 136, 133, 191, 134, 140, 129, 135, 191, 65 };
    27     ArrayList<Integer> KEYList = new ArrayList();
    28     for (int j = 0; j < KEY.length; j++) {
    29       KEYList.add(Integer.valueOf(KEY[j]));
    30     }
    31     System.out.println("Result:");
    32     if (Resultlist.equals(KEYList)) {
    33       System.out.println("Congratulations!");
    34     } else {
    35       System.err.println("Error!");
    36     }
    37   }
    38 }

    第23行flag做了    arr[i]+'@' ^ 0x20;

    第26行可以看到     int[] KEY = { 180, 136, 137, 147, 191, 137, 147, 191, 148, 136, 133, 191, 134, 140, 129, 135, 191, 65 };

    key = [180, 136, 137, 147, 191, 137, 147, 191, 148, 136, 133, 191, 134, 140, 129, 135, 191, 65]
    flag = ''
    for i in key:
         flag+=chr(i-ord('@')^0x20)
    print(flag)

    *    chr是将ascii码转字符  ord是将字符转ascii码

    三、flag

    flag{This_is_the_flag_!}

  • 相关阅读:
    leetcode刷题-73矩阵置零
    leetcode刷题-71简化路径
    leetcode刷题-70爬楼梯
    八、jMeter测试dubbo接口
    六、jMeter测试webservice接口
    python每日一练之mysql.connector
    十一、js常用方法
    九、selenium获取cookie实现免登陆,登录百度云后文件的上传
    python读取配置文件yaml
    测试的职业发展
  • 原文地址:https://www.cnblogs.com/Nickyl07/p/12662486.html
Copyright © 2011-2022 走看看