Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extracting XML with the strings decoded #105

Open
videostormdev opened this issue Sep 6, 2022 · 2 comments
Open

Extracting XML with the strings decoded #105

videostormdev opened this issue Sep 6, 2022 · 2 comments

Comments

@videostormdev
Copy link

videostormdev commented Sep 6, 2022

I am trying to extract the APP_RESTRICTIONS from an APK

These are listed in the manifest as meta-data, pointing to an XML file (typically res/xml/app_restrictions.xml)

The following code is how I get the XML file using php-apk-parser (awesome tool btw)
However, the XML file still has the resource IDs instead of the corresponding strings for most fields (name, description, etc)

$metaconf = $manifest->getMetaData('android.content.APP_RESTRICTIONS');
if (($metaconf != null)&&(strlen($metaconf)>1)){
	// metaconf is the resource id for the xml file
	$managedconfig = 1;
	if ($getresource){
		$mcarr = $apk->getResources($metaconf);
		//error_log("Supports managedconfig, values = " . count($mcarr));
		$managedconfigxmlfile = $mcarr[0];
		//$managedconfigxml = stream_get_contents($apk->getStream($managedconfigxmlfile));
										
		// below works, but extracted xml has resource ids in it (not decoded)
		$mcstr = new \ApkParser\Stream($apk->getStream($managedconfigxmlfile));
		$mcxml = new \ApkParser\XmlParser($mcstr);
		$managedconfigxml = $mcxml->getXmlString();
         }
}

Is there a straightforward way to get the XML text with all resource strings decoded?

@tufanbarisyildirim
Copy link
Owner

hi @videostormdev can I have an example APK somehow?

@videostormdev
Copy link
Author

Yes, please see https://www.lumi-tv.com/help/splashtiles_v2p3p0.apk

The description field in the app_restrictions.xml will always contain the resource id, not the decoded version. Of course this is to allow for localization of the strings, but it would be handy to have an easy way to set your localization and get the corresponded decoded string directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants