18/09/28-3-bugku-Reverse-easycrack-100 (NJCTF)

Source: Internet
Author: User
Tags ord


Title Link: Https://pan.baidu.com/s/12RGpSCcRVSu-tyreTqecaA
Extract code: 9XYV


Java Layer Analysis

1) The MessageMe method first obtains the package name, and then iterates with 51 or.

1      PublicString MessageMe () {2String v3 = "";3         intV4 = 51;4string[] V1 = This. Getapplicationcontext (). Getpackagename (). split ("\ \");5         Char[] V6 = V1[v1.length-1].tochararray ();6         intV7 =v6.length;7         intv5;8          for(v5 = 0; v5 < V7; + +v5) {9V4 ^=V6[V5];TenV3 = v3 + ((Char) (v4)) ; One         } A  -         returnv3; -}
View Code

2) ParseText is the native layer function, and the passed in parameter is the input string.


Natice Layer Analysis


1V4 = (* (int(__cdecl *) (int,Const Char*)) (* (_dword *) A1 + -)) (A1,"com/njctf/mobile/easycrack/mainactivity");2V5 = (* (int(__cdecl *) (int,int,Const Char*)) (* (_dword *) v3 + the)) (V3, V4,"MessageMe");3V6 = _jnienv::callobjectmethod (A1, A2, V5, (unsignedint)"() ljava/lang/string;");
View Code

The returned string is obtained here for the MessageMe method of the callback Java layer.


The string that is passed into the native layer function is followed or manipulated by the string returned by the MessageMe method.


Then according to multiple%256 can be analyzed is the RC4 encryption, the key is "I_am_the_key", clear text is 2) after the operation of the results, ciphertext for " C8e4ef0e4dcca683088134f8635e970eead9e277f314869f7ef5198a2aa4 ".


Reverse the algorithm, write out the decryption script

1 defre0 ():2     """Reverse Algorithm"""3STR0 ="Easycrack"4STR1 = [Ord (i) forIinchSTR0]5num = 516 7      forIinchRange (len (str1)):8Num ^=Str1[i]9Str1[i] =num;TenSTR1 *= 10 One     returnstr1 A  - defRC4 (data,key): -     """RC4 Algorithm""" thex =0 -box = Range (256) -      forIinchRange (256): -x = (x + box[i] + ord (key[i% len (key)))% 256 +Box[i], box[x] =box[x], Box[i] -x = y =0 +out = [] A      forCharinchData: atx = (x + 1)% 256 -y = (y + box[x])% 256 -BOX[X], box[y] =Box[y], box[x] -Out.append (Ord (char) ^ box[(box[x] + box[y])% 256])) -     return "'. Join (out) -  in """Main algorithm""" -res ='C8E4EF0E4DCCA683088134F8635E970EEAD9E277F314869F7EF5198A2AA4' toKey ='I_am_the_key' +ciphertext = Res.decode ('Hex') -STR0 =re0 () theSTR1 =RC4 (Ciphertext,key) *STR2 = [Ord (i) forIinchSTR1] $Flag ="'Panax Notoginseng  forIinchRange (len (str1)): -Str2[i] ^=Str0[i] theFlag + =chr (Str2[i]) + PrintFlag
View Code

18/09/28-3-bugku-Reverse-easycrack-100 (NJCTF)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.