-
Notifications
You must be signed in to change notification settings - Fork 2
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
Help #1
Comments
Hi @serrapa, Try viewing the raw data with a hex editor and see if the .dex is placed correctly at the beginning of the file. |
Hey thanks for the response! Yes I was wrong, I checked the size of the apk at the end and obviously it’s greater… dont know why I didn’t do it before… anyway, I could not get the shell back, still I dont understand why, I tried it on emulator and on a real device but nothing… have your ever tried to exploit the vuln in this way? |
No, I have never tried it that way. This project came in handy in 2019, as a popular app had not used signature v2 and I needed to keep the original signature. Now I use https://github.com/giacomoferretti/odex-patcher (unmaintaned for now, needs root access). Does the application crash? Check the logcats, and if so send them here. |
Sorry actually I didn’t try it on a real device because I didnt have one with api < 24.. I tried on the emulator and I though there were problems at network level… I set up the metasploit handler on my localhost and I created the shell with the remote host being 10.0.2.2 (the alias for the loopback interface for the emulator, as stated in the android docs)… Dont know if there would be some limitations by doing this way… btw I ll try creating the activity with the textview as you say and I ll let you knew asap! Thank you soo much! |
I tried creating two projects on Android Studio (one benign app and one evil). Both of them are projects based on "Empty Views Activity" template and print a single log line:
The following are the steps I followed:
Don't understand what is wrong.. I just noticed that the evil.dex file is just 20 byte, is it right looking for \x50\x4b\x03\x04 ? here https://github.com/V-E-O/PoC/blob/8c389899e6c4e16b2ddab9ba6d77c2696577366f/CVE-2017-13156/janus.py is different |
You need to extract the correct |
Damn, I coded it really badly... lol |
Aah I see.. anyway I also tried doing:
No ones worked ahaha. Digging deeper I think the problem is also multidexing, so I tried to build my evil apk without multidex (enabled by default on android studio), but I got errors because there are two instances of androidx.startup. InitializationProvider and androidx.profileinstaller.ProfileInstallReceiver... so I tried to remove androidx dependencies from the project, but the com.google.android.material:material:1.10.0 dependency is based on androidx, so fuck all ahaha. Instead if a generate the evil dex with msfvenom this way for example |
Does the injected app have the |
Yes, forgot to mention that I've tested it with only one |
Also, doesn't |
Yes
yeah, I supposed you tested with one dex... btw, also in the reverse order does not change, the app crashes with the same errors logs as above |
Can you share the output file for this? I don't have Metasploit installed, nor Kali Linux. Thank you. |
Ooh yes, I totally forgot, but still not change ahah.. I just tried with the classes.dex inside the output of
It is not much and helpful
|
The |
I needed to convert it as a zip because I cannot upload it as is on github... |
AndroidManifest.xml<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.metasploit.stage" platformBuildVersionCode="10" platformBuildVersionName="2.3.3">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.READ_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_CONTACTS"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_SMS"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<uses-permission android:name="android.permission.READ_CALL_LOG"/>
<uses-permission android:name="android.permission.WRITE_CALL_LOG"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS"/>
<uses-feature android:name="android.hardware.camera"/>
<uses-feature android:name="android.hardware.camera.autofocus"/>
<uses-feature android:name="android.hardware.microphone"/>
<application android:label="@string/app_name">
<activity android:label="@string/app_name" android:name=".MainActivity" android:theme="@android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<intent-filter>
<data android:host="my_host" android:scheme="metasploit"/>
<category android:name="android.intent.category.DEFAULT"/>
<category android:name="android.intent.category.BROWSABLE"/>
<action android:name="android.intent.action.VIEW"/>
</intent-filter>
</activity>
<receiver android:label="MainBroadcastReceiver" android:name=".MainBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
<service android:exported="true" android:name=".MainService"/>
</application>
</manifest> Note: all the permissions, receivers and services added will not be available once injected, because Android parse the correct AndroidManifest.xml inside the original APK. |
You could try to:
|
You're right.. but so how can I get code execution via a bad dex by exploiting the Janus vuln? Because also with the classes dex files from my evil.apk does not work (the app crashes) |
I ll try |
Here you mean with extract_dex.py? Btw, the process looks like that one I did above with the evil and benign app. With less steps because I used the classes dex file from the evil app and not form |
No, just extract it as a normal Zip file |
Yes, it's similar. The thing is that the generated APK file from Metasploit is probably not compatible with the target app (because of receivers, etc), so you want the code from the Metasploit APK, but with the missing stuff from the target app (by using |
@serrapa any updates? |
Hey! I still have to try it, didn't have time these days.. I will notify here as soon as I'm done |
Perfect! |
I tried it on a vulnerable apk. I generated the .dex file with msfvenom than I used this tool to inject my payload.dex. However, if I analyze the generated apk with jadx-gui, I cannot find any references to my evil payload (msfvenom). Do you know why? Am I doing something wrong?
The text was updated successfully, but these errors were encountered: