{"id":161,"date":"2013-07-27T14:51:49","date_gmt":"2013-07-27T22:51:49","guid":{"rendered":"http:\/\/www.android-decompiler.com\/blog\/?p=161"},"modified":"2018-12-19T13:43:22","modified_gmt":"2018-12-19T21:43:22","slug":"jeb-1-3-how-to-sign-and-match-third-party-library-code","status":"publish","type":"post","link":"https:\/\/www.pnfsoftware.com\/blog\/jeb-1-3-how-to-sign-and-match-third-party-library-code\/","title":{"rendered":"JEB 1.3: How to Sign and Match Third-Party Library Code"},"content":{"rendered":"<p>JEB 1.3 ships with two plugins that allow users to <span style=\"text-decoration: underline;\">create signatures<\/span> for library code, and\u00a0<span style=\"text-decoration: underline;\">apply signatures<\/span> onto DEX files. (Note: we are <strong>not<\/strong> talking about <em>digital signatures<\/em> here, but rather, <em>binary strings that are used to identify a method<\/em> or body of code.)<\/p>\n<p>Combined with the new <strong>navigation bar<\/strong>, portions of a DEX file that contain third-party frameworks (such as those ubiquitous ad libraries) or already analyzed code, can be easily identified: such areas will be marked using a light-green color in the navigation bar.<\/p>\n<h2>Applying signatures<\/h2>\n<p>In practice, applying signatures is extremely easy:<\/p>\n<p>1- Load the file in JEB: as can be seen below,<strong> the navigation bar is mostly blue<\/strong>, which means no library code has been spotted yet. (Note: The orange marks identify public\u00a0constant fields\u00a0&#8211; public static final.)<\/p>\n<p><a href=\"http:\/\/www.android-decompiler.com\/blog\/wp-content\/uploads\/2013\/07\/1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-168\" alt=\"1\" src=\"http:\/\/www.android-decompiler.com\/blog\/wp-content\/uploads\/2013\/07\/1.png\" width=\"720\" height=\"408\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/1.png 1200w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/1-300x170.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/1-1024x580.png 1024w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/1-624x353.png 624w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>2- Fire up the <strong>Library Recognition<\/strong> plugin. (Menu:\u00a0<em>Action \/ Custom Action \/ Library Recognition.<\/em>)<\/p>\n<p><a href=\"http:\/\/www.android-decompiler.com\/blog\/wp-content\/uploads\/2013\/07\/2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-169\" alt=\"2\" src=\"http:\/\/www.android-decompiler.com\/blog\/wp-content\/uploads\/2013\/07\/2.png\" width=\"426\" height=\"280\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/2.png 710w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/2-300x196.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/2-624x409.png 624w\" sizes=\"auto, (max-width: 426px) 100vw, 426px\" \/><\/a><\/p>\n<p>3- By default, the plugin looks for library signature files (<em>*.sig<\/em> extension) stored in the <strong>&#8220;sigs&#8221;<\/strong> sub-directory.<\/p>\n<p>4- The signatures are applied where they can be applied, and the results are visible both in the navigation bar (the <strong>light-green <\/strong>portions) and the console window. Here, many Google AdMob routines were recognized; it appears they make up for more than half of the entire DEX file.<\/p>\n<p><a href=\"http:\/\/www.android-decompiler.com\/blog\/wp-content\/uploads\/2013\/07\/3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-170\" alt=\"3\" src=\"http:\/\/www.android-decompiler.com\/blog\/wp-content\/uploads\/2013\/07\/3.png\" width=\"720\" height=\"408\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/3.png 1200w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/3-300x170.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/3-1024x580.png 1024w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/3-624x353.png 624w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>Close examination of the navigation bar shows that it is divided into two parts:<\/p>\n<ul>\n<li><span style=\"line-height: 1.714285714; font-size: 1rem;\">The upper half concerns methods and fields.<\/span><\/li>\n<li><span style=\"line-height: 1.714285714; font-size: 1rem;\">The lower half concerns classes as a whole.<\/span><\/li>\n<\/ul>\n<p><span style=\"font-size: 1rem; line-height: 1.714285714;\">Due to how the matching algorithm works, an entire class may be marked as library code, when not all corresponding methods and fields may be.<\/span><\/p>\n<h2><strong>Creating signatures<\/strong><\/h2>\n<p>JEB ships with library signatures for popular Google and Android frameworks. But it is also extremely easy to create your own library signatures.<\/p>\n<p>Let&#8217;s take an example. That same APK file contains the Android Support classes; let&#8217;s sign them.<\/p>\n<p>1- Execute the\u00a0<strong>Signature Generator<\/strong>\u00a0plugin. (Menu:\u00a0<em>Action \/ Custom Action \/ Signature Generator.<\/em>) Note that the plugin may also be executed from the command line and take arguments from the command line, in Automation mode. This is particularly useful for bulk signature creation.<\/p>\n<p><a href=\"http:\/\/www.android-decompiler.com\/blog\/wp-content\/uploads\/2013\/07\/4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-174\" alt=\"4\" src=\"http:\/\/www.android-decompiler.com\/blog\/wp-content\/uploads\/2013\/07\/4.png\" width=\"392\" height=\"179\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/4.png 654w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/4-300x136.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/4-624x284.png 624w\" sizes=\"auto, (max-width: 392px) 100vw, 392px\" \/><\/a><\/p>\n<p>2- The plugin asks the user for two pieces of information:<\/p>\n<ul>\n<li><span style=\"line-height: 1.714285714; font-size: 1rem;\">The library name: it is recommended to use the format <em>&#8220;&lt;libraryname&gt;-&lt;version&gt;&#8221;<\/em>. Here, we will go for:\u00a0<strong>android-support-13<\/strong><\/span><\/li>\n<li>The regular expression that identifies which methods should be signed. We want to sign all methods of the android.support.v4 package, so we will input: <strong>Landroid\/support\/v4\/.*<\/strong> (Java internal name convention)<\/li>\n<\/ul>\n<p>After proceeding, the plugin signs the target code. The signing results appears in the Console window:<\/p>\n<p><a href=\"http:\/\/www.android-decompiler.com\/blog\/wp-content\/uploads\/2013\/07\/5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-175\" alt=\"5\" src=\"http:\/\/www.android-decompiler.com\/blog\/wp-content\/uploads\/2013\/07\/5.png\" width=\"451\" height=\"136\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/5.png 752w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/5-300x90.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/5-624x187.png 624w\" sizes=\"auto, (max-width: 451px) 100vw, 451px\" \/><\/a><\/p>\n<p>3- The signature file is created in the &#8220;sigs&#8221; directory. Later on, when you apply signatures to other DEX files, the android-support signatures will be automatically checked and matched against those DEX files.<\/p>\n<p>If you were to re-apply signatures to the currently examined APK file, the android-support methods and classes would obviously be matched, and the navigation bar would reveal that most of this APK is library code:<\/p>\n<p><a href=\"http:\/\/www.android-decompiler.com\/blog\/wp-content\/uploads\/2013\/07\/6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone  wp-image-176\" alt=\"6\" src=\"http:\/\/www.android-decompiler.com\/blog\/wp-content\/uploads\/2013\/07\/6.png\" width=\"720\" height=\"113\" srcset=\"https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/6.png 1200w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/6-300x47.png 300w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/6-1024x160.png 1024w, https:\/\/www.pnfsoftware.com\/blog\/wp-content\/uploads\/2013\/07\/6-624x97.png 624w\" sizes=\"auto, (max-width: 720px) 100vw, 720px\" \/><\/a><\/p>\n<p>In a future blog post, we will spend some time describing how the signing and matching algorithms work. Keep in mind <strong>the library code signing\/matching system is plugins-based, which means it can be customized<\/strong> or tweaked by JEB users. Just have a look at the\u00a0ApplySigs.py and GenSig.py files in the plugins directory if you&#8217;re curious about that.<\/p>\n<p>Stay tuned.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>JEB 1.3 ships with two plugins that allow users to create signatures for library code, and\u00a0apply signatures onto DEX files. (Note: we are not talking about digital signatures here, but rather, binary strings that are used to identify a method or body of code.) Combined with the new navigation bar, portions of a DEX file &hellip; <a href=\"https:\/\/www.pnfsoftware.com\/blog\/jeb-1-3-how-to-sign-and-match-third-party-library-code\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">JEB 1.3: How to Sign and Match Third-Party Library Code<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[15],"tags":[],"class_list":["post-161","post","type-post","status-publish","format-standard","hentry","category-android"],"_links":{"self":[{"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/posts\/161","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/comments?post=161"}],"version-history":[{"count":0,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/posts\/161\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/media?parent=161"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/categories?post=161"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pnfsoftware.com\/blog\/wp-json\/wp\/v2\/tags?post=161"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}