2013년 11월 1일 금요일

[Android] smali 디컴파일


.method로 시작하여 .end method

.method private 함수 이름(파라미터 데이터 타입; ; ;) 리턴 값

[ : array[] 의미

[Ljava/lang/String : String[]
Ljava/math/BigInteger : BigInteger


  1. ==== Example 1 ====
  2. .method private isValid([Ljava/lang/String;[Ljava/lang/String;Ljava/math/BigInteger;)Ljava/lang/Boolean;
  3.     .locals 7 // 메소드 내부에서 사용하는 레지스터 수 ex. v1~v7
  4.     .parameter "issuerDN" // 파라미터 이름, 뒤에서부터, p3
  5.     .parameter "subjectDN" // p2
  6.     .parameter "serial" // p1      
  7. .prologue
  8.     const/4 v6, 0x4 // v6 = 0x4
  9.     const/4 v5, 0x3 // v5 = 0x3
  10.     const/4 v4, 0x2 // v4 = 0x2
  11.     const/4 v3, 0x1 // v3 = 0x1
  12.     const/4 v2, 0x0 // v2 = 0x0
  13. .line 103
  14.     aget-object v0, p1v2   // v0 = p1[v2],  v0 = serial[v2]array[] (p1)의 특정 index(v2) 의 값을 v0에 저장
  15.     // p0 는 this 인듯...
  16.     iget-object v1, p0Lops/black/herpderper/TrustModifier$AlwaysTrustManager;->CN1:Ljava/lang/String; // v1 = this.AlwaysTrustManager->C1
  17.     invoke-virtual {v0, v1}Ljava/lang/String;->equals(Ljava/lang/Object;)Z // v0 = String->equals(v0v1);
  18.     move-result v0
  19.     if-eqz v0, :cond_0 // v0가 0 이면 cond_0 로 점프
  20.     aget-object v0, p1v3
  21.     iget-object v1, p0Lops/black/herpderper/TrustModifier$AlwaysTrustManager;->OU:Ljava/lang/String; // AlwaysTrustManager->OU
  22.     invoke-virtual {v0, v1}Ljava/lang/String;->equals(Ljava/lang/Object;)Z
  23.     move-result v0
  24.     if-eqz v0, :cond_0 // if(v0 == 0) goto cond_0;
  25.     ...
  26.     .line 119
  27.     invoke-static {v3}Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean; //  v0 = Boolean->valueOf(v3);
  28.     move-result-object v0
  29.     .line 121
  30.     :goto_0
  31.     return-object v0 // return v0;
  32.     :cond_0
  33.     invoke-static {v2}Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;  // v0 = Boolean->valueOf(v2); // v2=0=false
  34.     move-result-object v0
  35.     goto :goto_0
  36. ==== Result 1 ====
  37. private Boolean isValid(String[] serial, String[] subjectDN, BigInteger issuerDN) {
  38.   v6=4;
  39.   v5=3;
  40.   v4=2;
  41.   v3=1;
  42.   v2=0;
  43.   v0 = serial[v2];
  44.   v1 = AlwaysTrustManager->C1;
  45.   v0 = String->equals(v0v1);
  46.   if(v0 == 0)
  47.      goto cond_0;
  48.   v0 = serial[v3];
  49.   v1 = AlwaysTrustManager->OU;
  50.   v0 = String->equals(v0v1);
  51.   if(v0 == 0)
  52.      goto cond_0;
  53.   ...
  54.   v0 = Boolean->valueOf(v3); // v3=1=true
  55.   :goto_0
  56.   return v0;
  57.   :cond_0
  58.   v0 = Boolean->valueOf(v2); // v2=0=false
  59.   goto: goto_0;
  60. ==== Example 2 ====
  61. # virtual methods
  62. .method protected varargs doInBackground([Ljava/lang/String;)Ljava/lang/String;
  63.     .locals 17
  64.     .parameter "uri"
  65.     .prologue
  66.     .line 28
  67.     invoke-static {}Landroid/os/Debug;->isDebuggerConnected()Z
  68.     move-result v14
  69.     if-eqz v14, :cond_0
  70.     .line 29
  71.     const/16 v14, 0x539
  72.     div-int/lit8 v14, v140x0
  73.     .line 31
  74.     :cond_0
  75.     const/4 v11, 0x0
  76.     .line 34
  77.     .local v11, url:Ljava/net/URL;
  78.     :try_start_0
  79.     new-instance v12, Ljava/net/URL;
  80.     const/4 v14, 0x0
  81.     aget-object v14, p1v14
  82.     invoke-direct {v12, v14}Ljava/net/URL;-><init>(Ljava/lang/String;)V // <init>() 괄호 안에 변수 갯수 = 파라미터 갯수, 즉 v14만 파라미터 v12 는 리턴값 저장
  83.     :try_end_0
  84.     .catch Ljava/net/MalformedURLException{:try_start_0 .. :try_end_0} :catch_1
  85.     .end local v11           #url:Ljava/net/URL; // 이런건 다 코멘트
  86.     .local v12, url:Ljava/net/URL;
  87.     move-object v11, v12
  88.     .line 41
  89.     .end local v12           #url:Ljava/net/URL;
  90.     .restart local v11       #url:Ljava/net/URL;
  91.     :goto_0
  92.     const/4 v13, 0x0
  93.     .line 44
  94.     .local v13, urlConnection:Ljava/net/HttpURLConnection;
  95.     :try_start_1
  96.     invoke-virtual {v11}Ljava/net/URL;->openConnection()Ljava/net/URLConnection;
  97.     move-result-object v14
  98.     move-object v0, v14
  99.     check-cast v0, Ljava/net/HttpURLConnection;
  100.     move-object v13, v0
  101.     .line 47
  102.     const/4 v14, 0x1
  103.     invoke-virtual {v13, v14}Ljava/net/HttpURLConnection;->setDoOutput(Z)V // Z -> 하나의 파라미터 나타냄, v13.HttpURLConnection->setDoOutput(v14);
  104.     .line 48
  105.     const-string v14, "POST"
  106.     invoke-virtual {v13, v14}Ljava/net/HttpURLConnection;->setRequestMethod(Ljava/lang/String;)V
  107.     .line 51
  108.     invoke-static {v13}Lops/black/herpderper/TrustModifier;->relaxHostChecking(Ljava/net/HttpURLConnection;)V
  109.     .line 52
  110.     invoke-virtual {v13}Ljava/net/HttpURLConnection;->getOutputStream()Ljava/io/OutputStream;
  111.     move-result-object v5
  112.     .line 55
  113.     .local v5, out:Ljava/io/OutputStream; // v5 = get_OutputStream();
  114.     const/4 v14, 0x1
  115.     aget-object v14, p1v14
  116.     const-string v15, "UTF-8"
  117.     ...
  118.   :catch_1
  119.     move-exception v1
  120.     .line 38
  121.     .local v1, e1:Ljava/net/MalformedURLException;
  122.     invoke-virtual {v1}Ljava/net/MalformedURLException;->printStackTrace()V
  123.     goto/16 :goto_0
  124. ==== Result 2 ====
  125. protected String doInBackground(String[] uri) {
  126.   v14 = android.os.Debug.isDebuggerConnected();
  127.   if(v14==0)
  128.     goto cond_0;
  129.   v14 = 0x539;
  130.   v14 = v14 / 0;
  131.   :cond_0
  132.   v11 = 0;
  133.   v11 = url:Ljava/net/URL;
  134.   :try_start_0
  135.   v12 = java/net/URL;
  136.   v14 = 0;
  137.   v14 = uri[v14]; // v14 = uri[0];
  138.   v12 = URL->init(v14);
  139.   :try_end_0
  140.   .catch MalformedURLException :catch_1
  141.   v11 = (java/net/URL) v12;
  142.   :goto_0
  143.    v13 = 0;
  144.    v13 = (HttpURLConnection) v13;
  145.   :try_start_1
  146.    v14 = URL->openConnection(v11);
  147.    v0 = v14;
  148.    v0 = (HttpURLConnection) v0;
  149.    v13 = v0;
  150.    v14 = 1;
  151.    v13.setDoOutput(v14);
  152.    v14 = "POST";
  153.    v13.setRequestMethod(v14);
  154.    ops.black.herpderper.TrustModifier.relaxHostChecking(v13);
  155.    v5 = getOutputStream(v13);
  156.    v14 = 1;
  157.    v14 = uri[v14];

댓글 없음:

댓글 쓰기