Skip to content

Instantly share code, notes, and snippets.

@masbog
Last active October 8, 2024 02:34
Show Gist options
  • Save masbog/d29c779539581defbf542e70ce724ed8 to your computer and use it in GitHub Desktop.
Save masbog/d29c779539581defbf542e70ce724ed8 to your computer and use it in GitHub Desktop.
get dex MD5 of WhatsApp Application and get WhatsApp Version from an APK file
#!/usr/bin/env python3
# tweak up from https://github.com/mgp25/classesMD5-64/blob/master/dexMD5.py
# build AXML library from https://github.com/mikusjelly/axmlparser
# add xml manifest parse for getting WhatsApp Version
# to use this $ python3 dexMD5.py apk/WhatsApp.apk
# Output :
# WhatsApp Version : 2.17.296
# WhatsApp ClassesDEX MD5 : b'YrJNPljM3TuNFPIOZ+jziw=='
#
# @MasBog
import sys
import zipfile
import hashlib
import base64
from xml.dom import minidom
from axmlparser import AXML
try:
apkName = sys.argv[1]
zipFile = zipfile.ZipFile(apkName,'r')
hash = hashlib.md5()
hash.update(zipFile.read('classes.dex'))
axml = AXML(zipFile.read('AndroidManifest.xml'))
xml = minidom.parseString(axml.get_buff())
package = xml.documentElement.getAttribute("package")
print("--> WhatsApp Version : "+xml.documentElement.getAttributeNS('http://schemas.android.com/apk/res/android', "versionName"))
print("--> WhatsApp ClassesDEX MD5 : "+ str(base64.b64encode(hash.digest())));
except:
print("Please enter directory of WhatsApp.apk")
@Tealcmail
Copy link

The code above will not work anymore, try this one:

import sys
import zipfile
import hashlib
import base64
from androguard.core.bytecodes import apk
from xml.dom import minidom
from lxml import etree

apkName = sys.argv[1]
zipFile = zipfile.ZipFile(apkName, 'r')
hash = hashlib.md5()
hash.update(zipFile.read('classes.dex'))

a = apk.APK(apkName)
android_manifest_xml = a.get_android_manifest_xml()

xml = minidom.parseString(etree.tostring(android_manifest_xml, encoding='utf-8').decode('utf-8'))
package = xml.documentElement.getAttribute("package")
print("--> WhatsApp Version : "+xml.documentElement.getAttributeNS('http://schemas.android.com/apk/res/android', "versionName"))
print("--> WhatsApp ClassesDEX MD5 : "+ str(base64.b64encode(hash.digest())));

@KARTHIKMODS
Copy link

axmlparser

How to insta this on termux

@KARTHIKMODS
Copy link

How to install axmlparser this on termux

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment