下载下了apk文件
使用工具jadx-gui-1.2.0打开
public String Xor(String str, String str2) {
char[] cArr = {14, '\r', 17, 23, 2, 'K', 'I', '7', ' ', 30, 20, 'I', '\n', 2, '\f', '>', '(', '@', 11, '\'', 'K', 'Y', 25, 'A', '\r'};
char[] cArr2 = new char[str.length()];
String str3 = str.length() != 25 ? "wrong!!!" : "you win!!!";
for (int i = 0; i < str.length(); i++) {
char charAt = (char) (str.charAt(i) ^ str2.charAt(i % str2.length()));
cArr2[i] = charAt;
if (cArr[i] != charAt) {
return "wrong!!!";
}
}
return str3;
}
/* access modifiers changed from: protected */
@Override // androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, androidx.fragment.app.FragmentActivity
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
ActivityMainBinding inflate = ActivityMainBinding.inflate(getLayoutInflater());
this.binding = inflate;
setContentView(inflate.getRoot());
final EditText editText = (EditText) findViewById(R.id.password);
((Button) findViewById(R.id.button)).setOnClickListener(new View.OnClickListener() {
/* class com.chick.androxor.MainActivity.AnonymousClass1 */
public void onClick(View view) {
String obj = editText.getText().toString();
MainActivity mainActivity = MainActivity.this;
Toast.makeText(mainActivity, mainActivity.Xor(obj, "happyx3"), 1).show();
Log.d("输入", editText.getText().toString());
}
});
}
分析代码
xor函数为我们要逆向的函数,str就是我们要求的flag,str2为"happyx3"
解题代码
str = ''
str2="happyx3"
cArr = [14, '\r', 17, 23, 2, 'K', 'I', '7', ' ', 30, 20, 'I', '\n', 2, '\f', '>', '(', '@', 11, '\'', 'K', 'Y', 25, 'A','\r']
for i in range(25):
for f in range(255):
charAt = chr(f^ord(str2[i % len(str2)]))
if cArr[i] == charAt or cArr[i]== ord(charAt):
str=str+chr(f)
print(str)
print(str)