APP hardening sample code

Last Updated: Mar 29, 2017

APP hardening

  1. public class DiyShieldTest {
  2. IAcsClient client = null;
  3. @BeforeMethod
  4. public void init() throws ClientException {
  5. // Replace them with the caller's Access Key and Access Key Secret
  6. IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", "your key", "your secret");
  7. // Initialize an IAcsClient object
  8. client = new DefaultAcsClient(profile);
  9. }
  10. @Test
  11. public void testDiyShield() {
  12. // Request the object
  13. DiyShieldRequest request = new DiyShieldRequest();
  14. // Set input parameters
  15. request.setAppInfo(getAppInfo());
  16. request.setChannel(getChannel());
  17. request.setEnhance(getEnhance());
  18. try {
  19. // Obtain the request result
  20. DiyShieldResponse response = client.getAcsResponse(request);
  21. System.out.println("error code : " + response.getErrorCode());
  22. System.out.println("error msg : " + response.getErrorMsg());
  23. Data data = response.getData();
  24. //todo
  25. } catch (ServerException e) {
  26. e.printStackTrace();
  27. } catch (ClientException e) {
  28. e.printStackTrace();
  29. }
  30. }
  31. private String getChannel() {
  32. JSONObject channel = new JSONObject();
  33. channel.put("metaName", "channel");
  34. List<String> values = new ArrayList<>();
  35. values.add("91");
  36. values.add("360");
  37. channel.put("values", values);
  38. return channel.toJSONString();
  39. }
  40. private String getAppInfo() {
  41. JSONObject appInfo = new JSONObject();
  42. appInfo.put("dataType", 1);
  43. appInfo.put("data",
  44. "https://g01.alibaba-inc.com/tfscom/LB1PaMeKXXXXXX8XFXXXXXXXXXX.tfsprivate1446115983140-375");
  45. appInfo.put("md5", "ce86f08da845d0af6d9df2a958de17b0");
  46. appInfo.put("size", 1713656);
  47. appInfo.put("callbackUrl", "https://aaa.com/callback");
  48. appInfo.put("appOsType", 1);
  49. return appInfo.toJSONString();
  50. }
  51. private String getEnhance() {
  52. return "{'enhanceType': -1, 'javaAntiDex2jar': {'percent': 20},'javaConstEncrypt': {'percent': 20},'soEnhance': {'enhanceType': 1,'soFileList': ['lib/armeabi/libbitmaps.so','lib/armeabi/libgifimage.so']}}";
  53. }
  54. }

APP hardening result query

  1. public class GetShieldResultTest {
  2. IAcsClient client = null;
  3. @BeforeMethod
  4. public void init() throws ClientException {
  5. // Replace them with the caller's Access Key and Access Key Secret
  6. IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou", "your key", "your secret");
  7. // Initialize an IAcsClient object
  8. client = new DefaultAcsClient(profile);
  9. }
  10. @Test
  11. public void testGetShieldResult() {
  12. GetShieldResultRequest request = new GetShieldResultRequest();
  13. request.setItemId("366ce1a0-8b71-4409-bfcc-961811805077");
  14. try {
  15. GetShieldResultResponse response = client.getAcsResponse(request);
  16. System.out.println("error code : " + response.getErrorCode());
  17. System.out.println("error msg : " + response.getErrorMsg());
  18. Data data = response.getData();
  19. //todo
  20. } catch (ServerException e) {
  21. e.printStackTrace();
  22. } catch (ClientException e) {
  23. e.printStackTrace();
  24. }
  25. }
  26. }
Thank you! We've received your feedback.