Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
91 views
in Technique[技术] by (71.8m points)

python - Is it possible to analyze dex file directly with mobsf?

I have several dex files that needs to be statically analyzed by mobsf after unpacking the apk file because core code are inaccessible prior to unpacking.

What I've tried: Adding Line 3 and changing line 4 from glob_pattern = app_dir + *.dex' to glob_pattern = ddex_dir

def get_dex_files(app_dir):
    """Get all Dex Files for analysis."""
    ddex_dir = "C:/path/Sample/dexfilepath/"
    glob_pattern = app_dir + '*.dex'
    return glob.glob(glob_pattern)

I know it's na?ve approach but I'm really new into pentesting.

A portion of the error code:

[INFO] 08/Jan/2021 11:49:08 - Decompiling to Java with jadx
[INFO] 08/Jan/2021 11:49:30 - DEX -> SMALI
[INFO] 08/Jan/2021 11:49:30 - Converting 10046944_dexfile_execute.dex to Smali Code
[INFO] 08/Jan/2021 11:49:30 - Converting 10152568_dexfile_execute.dex to Smali Code
[INFO] 08/Jan/2021 11:49:30 - Converting 10247328_dexfile_execute.dex to Smali Code
[INFO] 08/Jan/2021 11:49:30 - Converting 10286360_dexfile_execute.dex to Smali Code
[INFO] 08/Jan/2021 11:49:30 - Converting 10453796_dexfile_execute.dex to Smali Code
[INFO] 08/Jan/2021 11:49:30 - Converting 1272952_dexfile_execute.dex to Smali Code
[INFO] 08/Jan/2021 11:49:30 - Converting 1349780_dexfile_execute.dex to Smali Code
[INFO] 08/Jan/2021 11:49:30 - Converting 13539468_dexfile_execute.dex to Smali Code
[INFO] 08/Jan/2021 11:49:30 - Converting 3046356_dexfile_execute.dex to Smali Code
[INFO] 08/Jan/2021 11:49:31 - Converting 3261832_dexfile.dex to Smali Code
[INFO] 08/Jan/2021 11:49:31 - Converting 3261832_dexfile_execute.dex to Smali Code
[INFO] 08/Jan/2021 11:49:31 - Converting 359592_dexfile_execute.dex to Smali Code
[INFO] 08/Jan/2021 11:49:31 - Converting 5068284_dexfile_execute.dex to Smali Code
[INFO] 08/Jan/2021 11:49:31 - Converting 8294920_dexfile.dex to Smali Code
Lcom/qinggan/ftp/library/ftp/QGFTPServer$MyFtplet;->onConnect(Lorg/apache/ftpserver/ftplet/FtpSession;)Lorg/apache/ftpserver/ftplet/FtpletResult;: Invalid debug offset
Lcom/qinggan/ftp/library/socket/message/QGP2PMessageBase;->obtainHead(I)Ljava/lang/String;: Invalid debug offset
Lcom/qinggan/ftp/library/socket/message/QGP2PMessageServer$1;->run()V: Invalid debug offset
Lcom/qinggan/ftp/library/socket/message/QGP2PMessageClient$1;->run()V: Invalid debug offset
Lcom/qinggan/keepalive/GuardService;->getServiceIntent()Landroid/content/Intent;: Invalid debug offset
Lcom/qinggan/ftp/library/socket/message/QGP2PMessageClient;->closeSelf()V: Invalid debug offset
[INFO] 08/Jan/2021 11:49:32 - Converting 8294920_dexfile_execute.dex to Smali CodeLcom/qinggan/app/arielapp/ArielApplication$16;->insert(Ljava/util/List;)V: Invalid debug offset
Lcom/qinggan/ftp/library/ftp/QGFTPClient$2;->run()V: Invalid debug offset
Lcom/qinggan/app/arielapp/ArielApplication$11;->clearUserCache()V: Invalid debug offset
Lcom/qinggan/ftp/library/socket/message/QGP2PMessageServer;->dispatchMessage(Lcom/qinggan/ftp/library/socket/message/QGP2PMessage;)V: Invalid debug offset

Lcom/hp/hpl/sparta/DefaultLog;->error(Ljava/lang/String;Ljava/lang/String;I)V: Invalid debug offset
Lcom/qinggan/app/arielapp/ArielApplication$17;->onConnectStatusChange(Z)V: Invalid debug offset
question from:https://stackoverflow.com/questions/65623227/is-it-possible-to-analyze-dex-file-directly-with-mobsf

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I would try to use dex2jar tool for this purpose. Convert your apk to jar and then analyze it with MobSF. MobSF should work with jar files since this is an archive. I am not sure if it will show the stable behavior, but it can be an option.

As far as I know MobSF also have this package within it's source code, so did you try to load this APK directly to MobSF without changing anything? I think it might work.

Also you can use JADX tool for manual source code analyzing. It should restore the source code from the DEX binaries.

Also observe this issue. MobSF developer suggests to use enjarify instead of dex2jar (2nd answer) and sends the link which explains how to do it.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...