How to use dirty cow exploit?


Question

I got Sony m4 aqua with locked bootloader, android 6.01 and july 1 2016 security patch, no DM verity...

I would like to freeze few factory apps via adb's pm disable command (or any other way possible).

I've tried to run "su pm disable package.name" but the su command is not recognized for some reason.
I am Linux noob but I got android studio with SDK and NDK installed on lubuntu machine (got it also on win7 machine).

Can someone explain me the steps to take in order to gain root shell access with DirtyCow exploit (or any other way) to be able to freeze apps?


Answer

The reason the command isn't working for you is because "su" is a binary that gets installed by rooting your device. Without a proper root you have no "su" command.



In order to use the dirtycow exploit you have to compile the binary for your device's architecture.




  • Head over to https://github.com/timwr/CVE-2016-5195 and download or git clone the files.

  • (Optional) If you do not know your device architecture then on the phone install the "Droid Hardware Info" app from Play Store, open it, and swipe left to get to the System tab. Next to the label "Instruction Sets" will be your supported architecture.

  • On your computer open a terminal and navigate to where the dirtycow files are (extract if needed). Then simply type "make (insert architecture here)" without the quotes. This will create two binaries inside the folder at libs/(your_architecture)/ called dirtycow & run-as. Alternatively, if you have USB Debugging enabled then simply attach the device and type "make root" and it will push the binaries into your device at /data/local/tmp, then automate a few ADB commands to exploit and grant you a limited root shell.

  • If you don't see the terminal user icon as # and instead see a $ then the exploit didn't work at some point. Since the files are still on the device I would suggest to then try and manually patch run-as by using adb shell and typing the following...



chmod 777 /data/local/tmp/*



dirtycow /data/local/tmp/run-as /system/bin/run-as



/system/bin/run-as



If this doesn't prompt you as root user (#) then the exploit won't work for your device in this fashion and you'll need to do some digging why not. If this happens try opening an Issue on the Github repo, it's still pretty active so you should have an answer before long.


Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes