• [buuctf]简单注册器


    简单注册器

    分析

    这是一个apk文件,所以我用jadx来解题,把apk拖入到其中。
    进入主函数MainActivity中

    package com.example.flag;
    
    import android.os.Bundle;
    import android.support.v4.app.Fragment;
    import android.support.v7.app.ActionBarActivity;
    import android.view.LayoutInflater;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.view.View;
    import android.view.ViewGroup;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;
    
    /* loaded from: classes.dex */
    public class MainActivity extends ActionBarActivity {
        /* JADX INFO: Access modifiers changed from: protected */
        @Override // android.support.v7.app.ActionBarActivity, android.support.v4.app.FragmentActivity, android.app.Activity
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            if (savedInstanceState == null) {
                getSupportFragmentManager().beginTransaction().add(R.id.container, new PlaceholderFragment()).commit();
            }
            Button button = (Button) findViewById(R.id.button1);
            final TextView textview = (TextView) findViewById(R.id.textView1);
            final EditText editview = (EditText) findViewById(R.id.editText1);
            button.setOnClickListener(new View.OnClickListener() { // from class: com.example.flag.MainActivity.1
                @Override // android.view.View.OnClickListener
                public void onClick(View v) {
                    int flag = 1;
                    String xx = editview.getText().toString();
                    if (xx.length() != 32 || xx.charAt(31) != 'a' || xx.charAt(1) != 'b' || (xx.charAt(0) + xx.charAt(2)) - 48 != 56) {
                        flag = 0;
                    }
                    if (flag == 1) {
                        char[] x = "dd2940c04462b4dd7c450528835cca15".toCharArray();
                        x[2] = (char) ((x[2] + x[3]) - 50);
                        x[4] = (char) ((x[2] + x[5]) - 48);
                        x[30] = (char) ((x[31] + x[9]) - 48);
                        x[14] = (char) ((x[27] + x[28]) - 97);
                        for (int i = 0; i < 16; i++) {
                            char a = x[31 - i];
                            x[31 - i] = x[i];
                            x[i] = a;
                        }
                        String bbb = String.valueOf(x);
                        textview.setText("flag{" + bbb + "}");
                        return;
                    }
                    textview.setText("输入注册码错误");
                }
            });
        }
    
        @Override // android.app.Activity
        public boolean onCreateOptionsMenu(Menu menu) {
            getMenuInflater().inflate(R.menu.main, menu);
            return true;
        }
    
        @Override // android.app.Activity
        public boolean onOptionsItemSelected(MenuItem item) {
            int id = item.getItemId();
            if (id == R.id.action_settings) {
                return true;
            }
            return super.onOptionsItemSelected(item);
        }
    
        /* loaded from: classes.dex */
        public static class PlaceholderFragment extends Fragment {
            @Override // android.support.v4.app.Fragment
            public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
                View rootView = inflater.inflate(R.layout.fragment_main, container, false);
                return rootView;
            }
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79

    其中主要的位置是。

     if (flag == 1) {
                        char[] x = "dd2940c04462b4dd7c450528835cca15".toCharArray();
                        x[2] = (char) ((x[2] + x[3]) - 50);
                        x[4] = (char) ((x[2] + x[5]) - 48);
                        x[30] = (char) ((x[31] + x[9]) - 48);
                        x[14] = (char) ((x[27] + x[28]) - 97);
                        for (int i = 0; i < 16; i++) {
                            char a = x[31 - i];
                            x[31 - i] = x[i];
                            x[i] = a;
                        }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    之后针对这里进行改写,flag即可出来

    #include
    #include
    int main() {
    	char x[]= "dd2940c04462b4dd7c450528835cca15";
    	x[2] = ((x[2] + x[3]) - 50);
    	x[4] = ((x[2] + x[5]) - 48);
    	x[30] = (char)((x[31] + x[9]) - 48);
    	x[14] = (char)((x[27] + x[28]) - 97);
    	for (int i = 0; i < 16; i++) {
    		char a = x[31 - i];
    		x[31 - i] = x[i];
    		x[i] = a;
    	}
    	printf("flag{%s}", x);
    	return 0;
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

    运行获得flag
    flag{59acc538825054c7de4b26440c0999dd}

  • 相关阅读:
    pandas中read_csv和to_csv、read_hdf和to_hdf、read_json和to_json函数及其他各类文件的读取与存储
    JS 封装节流(后期优化)
    情侣纪念日网站html5源码教程
    <stack和queue>——《C++初阶》
    声明 Array List 的3种方式 ArrayList、Collection、List 的区别
    计算机视觉40例之案例16KNN英文字母识别
    typeScript--[类的实例方法与静态方法]
    Kaldi 入门使用教程
    经济专业技术资格考试-经济专业技术资格分为初级、中级、高级三个级别
    HTML期末大学生网页设计作业——奇恩动漫HTML (1页面) HTML+CSS+JS网页设计期末课程大作业
  • 原文地址:https://blog.csdn.net/m0_71081503/article/details/126284075