I. BACKGROUND
For some historical reasons, more than 50% active users in our products are weak accounts. That is, a pseudo-ID generated by the client in accordance with a certain rule exists in keychain, which is a unique identifier for this user, enabling fast login. Under normal circumstances, there will be no problem.
Recently, the company's Apple account needs to be replaced so that our iOS app needs to be migrated from the old account to the new account, and Apple also provides the migration feature. So, the problem is, the Apple account change will lead to teamid transformation, and keychain inside the storage key is associated with Teamid.
Plainly, Teamid changed, you keychain old account storage pseudo-ID is not enrolled, that is equal to 50% of the weak account is lost?
Second, the solution
1. through some activities to guide the player, weak account binding into strong account; (User behavior)
2. Replace the storage mechanism to realize that the pseudo ID will remain the same in different Apple accounts (Teamid) or be able to map the past;
A. Because keychain is associated with Teamid, the transfer cycle, the storage sandbox, the disadvantage of users uninstall, later installation will lose weak accounts;
B. Adhesive plate, considering the long-term transfer process and the characteristics of the adhesive plate itself, and can not solve the problem well;
C. browser cache, as with the pasteboard, too much limit;
3. secretly realize weak account binding into strong account; (User no sense)
4. Discard some players (via customer service)
There are some other small programs are not very suitable, not listed. Finally we chose, 1, 2.a, 3, 4 synchronous, as far as possible to reduce the loss of weak accounts. Let's focus on the 3rd, there's nothing else to say. Note the encryption when storing the sandbox.
Third, "weak account" is bound to "strong account"
Want to secretly realize the "weak account" binding into a "strong account", read the real Apple device number, mobile phone number and so on, can think of, can do before has been blocked by Apple. If it is discovered through some unofficial API, the problem is even greater.
Then you can only retreat and seek third-party assistance. Mobile has launched the "one-click Password-free login" SDK, feel a bit reliable, do not need users to fill in the text message verification code, mobile phone number, you can achieve a key to three-screen password-free login.
They provide an interface to the SDK:
Explicit sign-in + (void) Gettokenexpwithcontroller: (Uiviewcontroller *) VC complete : (void (^) (ID sender)) complete;
Can be obtained through this interface: (Get OpenID and securityphone can achieve strong binding)
{ Capaids = "4,7"; OpenId = "evmqwbpv1ostseq64hbpwwag9wx-hdra7dwkeoph5ug2maarlm1g"; Phonescrip = 968b5c447f12383c0767526c123847b60af29be543d735d0e4eb841ee3988ae1ef67b5dc21978332bc36876c9ff9c9cd8ba1139465419b4d600ff0514 4298fe876ff4a6d3d02c5ada0db9ca94291981f0df882d3671052560cbc031ce9103162e1f22ebee4e539f6a1880ea5201aa27b6cc279e98922df356b b69032dc135250; Privatekey = 83aff2d124ca4133; Securityphone = "173****3919";}
However, the mobile authorization screen must be ejected:
Well, with this step, the user experience will be very bad, we have to find a way to not show this interface, still can get the data we want.
Four, human flesh reverse
1. First I used the class-dump to see if I could get some header files to fail.
Then I want to not pop up their page, still can get the data, it must know their interface name.
2. Because this interface is modal, method swizzling the modal approach:
-(void) Presentviewcontroller: (Uiviewcontroller *) viewcontrollertopresent animated: (BOOL) flag completion: (void (^ __ Nullable) (void)) Completion Ns_available_ios (5_0);
Thus know that their navigation class is uanavigationcontroller;
3. Write a timer delay 10s get the topmost page, and print the VC stack:
Uabufferviewcontroller,uaonekeyviewcontroller (Here are all the properties and methods for printing these 2 classes)
By Uaonekeyviewcontroller's pointer, I accidentally found the parameters I needed in a dictionary Phonenumaccount
, this dictionary stores the
{ Capaids = "4,7"; OpenId = "evmqwbpv1ostseq64hbpwwag9wx-hdra7dwkeoph5ug2maarlm1g"; Phonescrip = 968b5c447f12383c0767526c123847b60af29be543d735d0e4eb841ee3988ae1ef67b5dc21978332bc36876c9ff9c9cd8ba1139465419b4d600ff0514 4298fe876ff4a6d3d02c5ada0db9ca94291981f0df882d3671052560cbc031ce9103162e1f22ebee4e539f6a1880ea5201aa27b6cc279e98922df356b b69032dc135250; Privatekey = 83aff2d124ca4133; Securityphone = "173****3919";}
It's a step further away from what I want.
4. Immediately thereafter, I method swizzling the Phonenumaccount set methods, and in-(void) Qiye_setphonenumaccount: (nsdictionary*) dic; This method has a break point, so I can see the detailed stack of write value phonenumaccount;
I draw the Red Line 2 steps is very critical, one is to skip the mobile API method, another can get all the communication content.
Yes, I don't need to call move + (void) Gettokenexpwithcontroller: (Uiviewcontroller *) VC complete : (void (^) (ID sender)) complete; This method directly bypasses the user consent interface that they force to appear.
And then I just call:
Uiviewcontroller * VC = [[Nsclassfromstring (@ "Uabufferviewcontroller") alloc] init]; [VC performselector:nsselectorfromstring (@ "loginexplicitly")];
Can pass-(void) Qiye_setphonenumaccount: (nsdictionary*) dic; get OpenID and Securityphone;
5. Another, uanetwork this class exposed, we pass method swizzling:
+ (void) Qiye_requestnetworkwithurl: (id) URL params: (ID) Params method: (ID) method completion: (void (^) (id)) completion{ NSLog (@ "qiye_requestnetworkwithurl........%@ %@ %@", Url,params,method); void (^netblock) (id) = ^ (id value) { NSLog (@ "block:%@", value); if (completion) completion (value); }; [Self Qiye_requestnetworkwithurl:url params:params method:method completion:netblock];}
Then their network request parameters, as well as the return of what, have got.
Https://www.cmpassport.com/unisdk/rs/ckRequest block:{capaids = "4,7"; desc = success; Eappid = "6h/km9lzgkjogumpei8nyq=="; Epackage = "y6pktcdwcdjjndxs6pwkbkqr5fo14zygd8lupt+9flc="; esign = "<null>"; Privatekey = 83aff2d124ca4133; ResultCode = 103000; Servertime = 17; SourceID = 800120180112107085;} https://wap.cmpassport.com:8443/log/logreportblock:{config = {crashlog = 1; LIMITM = 50; LIMITN = 3; LIMITX = 100; Norlog = 1; SizeLimit = 1; TimeLimit = 1; }; desc = success; ResultCode = 103000;} Http://www.cmpassport.com/unisdk/rs/getTelecomPhoneNumberNotify?ver=1.0&result=0&state=%7B%22timeStamp %22%3a%2220180115184428437%22%2c%22clienttype%22%3a%221%22%2c%22appid%22%3a%228013416909%22%2c%22format%22%3a% 22json%22%2c%22params%22%3a%22800120180112107085%22%2c%22version%22%3a%221.1%22%7d&msg=success&mobile= 8e482352dbecd75680483db0b4f8ebc5&sign=f43348be1ed50b97b2f2bb392c0de7632c73124eblock:{ResultCode = 103000; Resultdata = {openId = "evmqwbpv1ostseq64hbpwwag9wx-hdra7dwkeoph5ug2maarlm1g"; Phonescrip = 968b5c447f12383c0767526c123847b60af29be543d735d0e4eb841ee3988ae1ef67b5dc21978332bc36876c9ff9c9cd8ba1139465419b4d600ff0514 4298fe876ff4a6d3d02c5ada0db9ca94291981f0df882d3671052560cbc031ce9103162e1f22ebee4e539f6a1880ea5201aa27b6cc279e98922df356b b69032dc135250; Securityphone = "173****3919"; };}
Then, we can secretly implement strong binding, but only if the user has a SIM card, and open 4G network.
Summary: I am not too much, do not recommend people to do so.
IOS "Weak account" Installation "strong account"