I'm trying to parse AndroidManifest.xml
from apk using JSZip,
I got an Uint8Array and convert it to string using the following code:
var zip = new JSZip(fileBlobAsByteArray);
var androidCompress = zip.files["AndroidManifest.xml"];
var androidNonCompress = androidCompress._data.getContent();
var androidText = String.fromCharCode.apply(null, androidNonCompress);
var packageName = androidText.toLowerCase().replace(/ /g,'').indexOf('package');
I tried to use toLowerCase and remove all white spaces.
I'm getting a string which I can see it's content in my console but when I'm searching for a word inside the string using indexOf it always returns -1.
I guess the problem is that the output is probably not a regular string and the chrome console doing some manipulation in order to present it as string. the same manipulation I want to do.
I used the following code to convert Uint8Array to searchable string
// Reading to content to a searchable string
var packageNameArray = [];
var textArray = String(androidNonCompress).split(',');
for (var i = 0, len = textArray.length; i < len; i++) {
if (textArray[i] !== 0) {
packageNameArray.push(textArray[i]);
}
}
var searchableText = String.fromCharCode.apply(null, packageNameArray).toString().toLowerCase();