SlideShare una empresa de Scribd logo
1 de 72
Descargar para leer sin conexión
Yonatan V.Levin
levin.yonatan parahall
Google Developer Expert
CTO & Co Founder
>100 Cities > 30M usersRuby, Go, Python, Microservices
Ooooops...
What Do We Do?
● Android Fundamentals
● Android UI / UX
● Community Hackathon
● Android Advanced
● Mentors Program
● Active community
facebook.com/groups/android.academy.ils/
22.10
Fundamentals
Bang! Bang! You have been hacked.
private boolean isMocLocationsOn() {
return Settings.Secure.getString(getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION)
.equals(ALLOW_MOC_LOCATIONS_ON);
}
public class TimeChangedReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent intent) {
onSystemTimeChanged();
}
}
urlSigner.getUrlSignature(encodedPath, mAuthenticationToken);
Network request signing
First sign
public class NetworkHttpUnauthorizedReceiver extends BroadcastReceiver
{
public void onReceive(Context context, Intent intent) {
int httpCode = intent.getIntExtra(IntentExtras.HTTP_CODE, -1);
if (httpCode == HttpURLConnection.HTTP_UNAUTHORIZED) {
LoginActivity.logOut(context);
}
}
}
Anyone can send “unauthorized”
Possible way to solve it
- Exported = ‘false’ in AndroidManifest.xml
- Custom permissions with
protectionLevel=”signature”
- Dynamic register with LocalBroadcastManager
We lost the battle but not the war
How he did it
Static Analysis
• APKTool, Smali/Baksmali, BytecodeViewer, JEB ($), IDA Pro ($$) …
Network Analysis
• mitmproxy, charles, burpsuite, wireshark
Security is hard.
If it’s not - it’s easy to break
Disclaimer: I’m not security expert.
It’s our journey, and I decided to share it.
It’s a team work
Very easy to reverse-engineer
https://github.com/google/android-classyshark
The first goal:
Protect our code
Code Protection
● Name obfuscation
● String encryption
● Class encryption
● Resources, asset and native library encryption Control flow and
arithmetic obfuscation
● Hide calls through reflection
public String encryptSensitiveMessage() {
String nuclearLaunchCode = "abc123";
String encryptionKey = "secretkey";
return CryptoEngine.encrypt(nuclearLaunchCode, encryptionKey);
}
Example
public String encryptSensitiveMessage() {
String nuclearLaunchCode = "abc123";
String encryptionKey = "secretkey";
Class clazz = Class.forName("CryptoEngine");
Method meth = clazz.getMethod("encrypt", String.class, String.class);
return (String) meth.invoke(null, nuclearLaunchCode, encryptionKey);
}
Reflection
public String encryptSensitiveMessage() {
String nuclearLaunchCode = Base64.decode("YWJjMTIz");
String encryptionKey = Base64.decode("c2VjcmV0a2V5");
Class clazz = Class.forName(Base64.decode("Q3J5cHRvRW5naW5l"));
Method meth = clazz.getMethod(Base64.decode("ZW5jcnlwdA=="), String.class,
String.class);
return (String) meth.invoke(null, nuclearLaunchCode, encryptionKey);
}
String obfuscation
public String a() {
String a = e.f("YWJjMTIz");
String b = e.f("c2VjcmV0a2V5");
Class c = Class.forName(e.f("Q3J5cHRvRW5naW5l"));
Method d = c.getMethod(e.f("ZW5jcnlwdA=="), String.class, String.class);
return (String) d.invoke(null, a, b);
}
Name obfuscation
Automate it:
Proguard
Proguard
release {
minifyEnabled true
shrinkResources true
proguardFile 'proguard-project.pro'
proguardFile 'proguard-crashlytics.pro'
proguardFile 'proguard-gson.pro'
proguardFile 'proguard-okhttp.pro'
proguardFile 'proguard-mixpanel.pro'
proguardFile 'proguard-retrofit.pro'
proguardFile 'proguard-pubnub.pro'
proguardFile 'proguard-logback-android.pro'
proguardFile getDefaultProguardFile('proguard-android.txt')
debuggable false
signingConfig signingConfigs.release
}
-repackageclasses
-allowaccessmodification
-flattenpackagehierarchy
Proguard obfuscation
GSON makes you weak :)
"Order": {
"id": 89684,
"status": "expired",
"payment_type": "cash",
"future_ride": false,
"passenger_comment": "",
"scheduled_at": "2015-12-13T15:13:48+02:00",
"account_ride": false,
"ride_type": "private",
"price_origin": "driver",
"autopay": false...
public class A {
private int b;
private AB c;
private TM d;
private boolean e;
private S f;
private D j;
private D g;
private D k;
private boolean l;
private double m;
private boolean n;
Second goal:
Hide model in network layer
Protocol Buffers
(Wire)
message Person {
// The customer's full name.
required string name = 1;
// The customer's ID number.
required int32 id = 2;
// Email address for the customer.
optional string email = 3;
enum PhoneType {
MOBILE = 0;
HOME = 1;
WORK = 2;
}
message PhoneNumber {
// The user's phone number.
required string number = 1;
// The type of phone stored here.
optional PhoneType type = 2 [default = HOME];
}
// A list of the user's phone numbers.
repeated PhoneNumber phone = 4;
}
public final class Person extends Message {
/** The customer's full name. */
@ProtoField(tag = 1, type = STRING, label = REQUIRED)
public final String name;
/** The customer's ID number. */
@ProtoField(tag = 2, type = INT32, label = REQUIRED)
public final Integer id;
/** Email address for the customer. */
@ProtoField(tag = 3, type = STRING)
public final String email;
/** A list of the user's phone numbers. */
@ProtoField(tag = 4, label = REPEATED)
public final List<PhoneNumber> phone;
byte[] data = person.toByteArray();
Wire wire = new Wire();
Person newPerson = wire.parseFrom(data, Person.class);
Our Network exposing our models
* Ask server guys to have a flag - JSON/ProtoBuff format.
Will make your life easy to debug
Retrofit StarWarsServiceRetrofit = new
Retrofit.Builder().baseUrl(baseUrl)
.client(clientBuilder.build())
.addConverterFactory(WireConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.build();
Third goal:
Challenge the code stripping.
APK Signature check
PackageInfo packageInfo = context.getPackageManager()
.getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES);
for (Signature signature : packageInfo.signatures) {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(signature.toByteArray());
String currentSignature = Base64.encodeToString(md.digest(), Base64.DEFAULT);
//compare signatures
if (EXPECTED_SIGNATURE.equals(currentSignature)) {
return VALID;
}
return INVALID;
Challenge
Connect the code ,key and API.
Goal: every single change in code will generate different key and this
key will be used to sign API request.
Dex
- Custom Class Loading in Dalvik
DexClassLoader cl = new
DexClassLoader(dexInternalStoragePath.getAbsolutePath(),
optimizedDexOutputPath.getAbsolutePath(), null, getClassLoader());
Class libProviderClazz = null;
try {
// Load the library.
libProviderClazz = cl.loadClass("com.example.dex.lib.LibraryProvider");
LibraryInterface lib = (LibraryInterface) libProviderClazz.newInstance();
lib.showAwesomeToast(this, "hello");
} catch (Exception e) {...}
Reflection
Ask application with API - Who are you?
Generate challenge for each user randomly.Load it from server.
What can be challenged?
Resource IDs,
Class fields,
Classes
Method results
NDK possible to reverse-engineer too but really really hard!
https://www.hex-rays.com/products/decompiler/
JNI
- Use bytecode libs
With Help from Google
App Licensing
Google Library to query Google Play
Services if Application was installed from
the play store.
In order to download your expansion files
from Google Play, the user must have
acquired your application from Google
Play.
Combination - Part 1 Authorization
Answer to challenge
Obtain random
challenge for
current session
Application Side
Server Side
Download the
challenge
Using
Reflection
answer
challenge Send as
bytecode data
using
flatbuffer/wire
Compare
&
decide
Combination - Every request
Build
.apk
Extract MD5
from .apk
Store MD5 on server +
hash function (RSA,
AES)
Run-Time
Building Release
Load dex library.
Obtain MD5 from
dex/.so lib
Sign URL with MD5,
Token, TimeStamp and
challenge response Send data using
flatbuffer/wire
Compare url
signature
Compare
signature
and decide
Build
.apk
Extract MD5
from .apk
Store MD5 on
server per built
version
Run-Time
Building Release
Load dex library with
challenge.
Obtain MD5 from
dex/.so lib
Sign API Request with
MD5, Token,
TimeStamp and
challenge response
Answer to challenge
Obtain random
challenge for
current session
Server Side
Generate signature
based on stored MD5,
Challenge Answer,
TimeStamp & Token
Send data using
flatbuffer/wire
Yonatan V.Levin levin.yonatan
parahallGoogle Developer Expert

Más contenido relacionado

La actualidad más candente

드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅재춘 노
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleThierry Wasylczenko
 
The Ring programming language version 1.5.4 book - Part 70 of 185
The Ring programming language version 1.5.4 book - Part 70 of 185The Ring programming language version 1.5.4 book - Part 70 of 185
The Ring programming language version 1.5.4 book - Part 70 of 185Mahmoud Samir Fayed
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTDavid Chandler
 
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)PROIDEA
 
Sustaining Test-Driven Development
Sustaining Test-Driven DevelopmentSustaining Test-Driven Development
Sustaining Test-Driven DevelopmentAgileOnTheBeach
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseSages
 
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebBDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebChristian Baranowski
 
Refactoring for testability c++
Refactoring for testability c++Refactoring for testability c++
Refactoring for testability c++Dimitrios Platis
 
생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트기룡 남
 
Building Your First Data Science Applicatino in MongoDB
Building Your First Data Science Applicatino in MongoDBBuilding Your First Data Science Applicatino in MongoDB
Building Your First Data Science Applicatino in MongoDBMongoDB
 
LISA QooxdooTutorial Slides
LISA QooxdooTutorial SlidesLISA QooxdooTutorial Slides
LISA QooxdooTutorial SlidesTobias Oetiker
 
Работа с реляционными базами данных в C++
Работа с реляционными базами данных в C++Работа с реляционными базами данных в C++
Работа с реляционными базами данных в C++corehard_by
 
Tugas Praktikum Java 2
Tugas Praktikum Java 2Tugas Praktikum Java 2
Tugas Praktikum Java 2azmi007
 
The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84Mahmoud Samir Fayed
 
The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180Mahmoud Samir Fayed
 

La actualidad más candente (20)

드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
드로이드 나이츠 2018: RxJava 적용 팁 및 트러블 슈팅
 
#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG#JavaFX.forReal() - ElsassJUG
#JavaFX.forReal() - ElsassJUG
 
Construire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradleConstruire une application JavaFX 8 avec gradle
Construire une application JavaFX 8 avec gradle
 
The Ring programming language version 1.5.4 book - Part 70 of 185
The Ring programming language version 1.5.4 book - Part 70 of 185The Ring programming language version 1.5.4 book - Part 70 of 185
The Ring programming language version 1.5.4 book - Part 70 of 185
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWT
 
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)
4Developers 2018: Evolution of C++ Class Design (Mariusz Łapiński)
 
Sustaining Test-Driven Development
Sustaining Test-Driven DevelopmentSustaining Test-Driven Development
Sustaining Test-Driven Development
 
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash courseCodepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
Codepot - Pig i Hive: szybkie wprowadzenie / Pig and Hive crash course
 
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und GebBDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
BDD - Behavior Driven Development Webapps mit Groovy Spock und Geb
 
Testing with Node.js
Testing with Node.jsTesting with Node.js
Testing with Node.js
 
Refactoring for testability c++
Refactoring for testability c++Refactoring for testability c++
Refactoring for testability c++
 
생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트생산적인 개발을 위한 지속적인 테스트
생산적인 개발을 위한 지속적인 테스트
 
Building Your First Data Science Applicatino in MongoDB
Building Your First Data Science Applicatino in MongoDBBuilding Your First Data Science Applicatino in MongoDB
Building Your First Data Science Applicatino in MongoDB
 
LISA QooxdooTutorial Slides
LISA QooxdooTutorial SlidesLISA QooxdooTutorial Slides
LISA QooxdooTutorial Slides
 
Spock and Geb in Action
Spock and Geb in ActionSpock and Geb in Action
Spock and Geb in Action
 
Работа с реляционными базами данных в C++
Работа с реляционными базами данных в C++Работа с реляционными базами данных в C++
Работа с реляционными базами данных в C++
 
groovy & grails - lecture 7
groovy & grails - lecture 7groovy & grails - lecture 7
groovy & grails - lecture 7
 
Tugas Praktikum Java 2
Tugas Praktikum Java 2Tugas Praktikum Java 2
Tugas Praktikum Java 2
 
The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84The Ring programming language version 1.2 book - Part 79 of 84
The Ring programming language version 1.2 book - Part 79 of 84
 
The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180The Ring programming language version 1.5.1 book - Part 12 of 180
The Ring programming language version 1.5.1 book - Part 12 of 180
 

Similar a Bang-Bang, you have been hacked - Yonatan Levin, KolGene

Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best PracticesYekmer Simsek
 
Phone gap 12 things you should know
Phone gap 12 things you should knowPhone gap 12 things you should know
Phone gap 12 things you should knowISOCHK
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureC.T.Co
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android InfrastructureAlexey Buzdin
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and FriendsYun Zhi Lin
 
Thomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-finalThomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-finalDroidcon Berlin
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extremeyinonavraham
 
Zone.js 2017
Zone.js 2017Zone.js 2017
Zone.js 2017Jia Li
 
July 2015 Android Taipei - Anti-Decompiler by SUKI
July 2015 Android Taipei - Anti-Decompiler by SUKIJuly 2015 Android Taipei - Anti-Decompiler by SUKI
July 2015 Android Taipei - Anti-Decompiler by SUKISuki Huang
 
Test First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in GrailsTest First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in GrailsTim Berglund
 
Test First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTest First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTim Berglund
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVMSylvain Wallez
 
Fun Teaching MongoDB New Tricks
Fun Teaching MongoDB New TricksFun Teaching MongoDB New Tricks
Fun Teaching MongoDB New TricksMongoDB
 
Android Bootstrap
Android BootstrapAndroid Bootstrap
Android Bootstrapdonnfelker
 
Retrofit
RetrofitRetrofit
Retrofitbresiu
 
HBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to CoprocessorsHBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to CoprocessorsCloudera, Inc.
 
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15Murat Yener
 

Similar a Bang-Bang, you have been hacked - Yonatan Levin, KolGene (20)

Griffon @ Svwjug
Griffon @ SvwjugGriffon @ Svwjug
Griffon @ Svwjug
 
Android Best Practices
Android Best PracticesAndroid Best Practices
Android Best Practices
 
Phone gap 12 things you should know
Phone gap 12 things you should knowPhone gap 12 things you should know
Phone gap 12 things you should know
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Overview of Android Infrastructure
Overview of Android InfrastructureOverview of Android Infrastructure
Overview of Android Infrastructure
 
Dropwizard and Friends
Dropwizard and FriendsDropwizard and Friends
Dropwizard and Friends
 
Thomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-finalThomas braun dependency-injection_with_robo_guice-presentation-final
Thomas braun dependency-injection_with_robo_guice-presentation-final
 
Taking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the ExtremeTaking Jenkins Pipeline to the Extreme
Taking Jenkins Pipeline to the Extreme
 
Zone.js 2017
Zone.js 2017Zone.js 2017
Zone.js 2017
 
Android workshop
Android workshopAndroid workshop
Android workshop
 
July 2015 Android Taipei - Anti-Decompiler by SUKI
July 2015 Android Taipei - Anti-Decompiler by SUKIJuly 2015 Android Taipei - Anti-Decompiler by SUKI
July 2015 Android Taipei - Anti-Decompiler by SUKI
 
Test First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in GrailsTest First Refresh Second: Test-Driven Development in Grails
Test First Refresh Second: Test-Driven Development in Grails
 
Test First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in GrailsTest First, Refresh Second: Web App TDD in Grails
Test First, Refresh Second: Web App TDD in Grails
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Native Java with GraalVM
Native Java with GraalVMNative Java with GraalVM
Native Java with GraalVM
 
Fun Teaching MongoDB New Tricks
Fun Teaching MongoDB New TricksFun Teaching MongoDB New Tricks
Fun Teaching MongoDB New Tricks
 
Android Bootstrap
Android BootstrapAndroid Bootstrap
Android Bootstrap
 
Retrofit
RetrofitRetrofit
Retrofit
 
HBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to CoprocessorsHBaseCon 2013: A Developer’s Guide to Coprocessors
HBaseCon 2013: A Developer’s Guide to Coprocessors
 
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15
 

Más de DroidConTLV

Mobile Development in the Information Age - Yossi Elkrief, Nike
Mobile Development in the Information Age - Yossi Elkrief, NikeMobile Development in the Information Age - Yossi Elkrief, Nike
Mobile Development in the Information Age - Yossi Elkrief, NikeDroidConTLV
 
Doing work in the background - Darryn Campbell, Zebra Technologies
Doing work in the background - Darryn Campbell, Zebra TechnologiesDoing work in the background - Darryn Campbell, Zebra Technologies
Doing work in the background - Darryn Campbell, Zebra TechnologiesDroidConTLV
 
No more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola SolutionsNo more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola SolutionsDroidConTLV
 
Mobile at Scale: from startup to a big company - Dor Samet, Booking.com
Mobile at Scale: from startup to a big company - Dor Samet, Booking.comMobile at Scale: from startup to a big company - Dor Samet, Booking.com
Mobile at Scale: from startup to a big company - Dor Samet, Booking.comDroidConTLV
 
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, ClimacellLiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, ClimacellDroidConTLV
 
MVVM In real life - Lea Cohen Tannoudji, Lightricks
MVVM In real life - Lea Cohen Tannoudji, LightricksMVVM In real life - Lea Cohen Tannoudji, Lightricks
MVVM In real life - Lea Cohen Tannoudji, LightricksDroidConTLV
 
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)DroidConTLV
 
Building Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice NinjaBuilding Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice NinjaDroidConTLV
 
New Android Project: The Most Important Decisions - Vasiliy Zukanov
New Android Project: The Most Important Decisions - Vasiliy ZukanovNew Android Project: The Most Important Decisions - Vasiliy Zukanov
New Android Project: The Most Important Decisions - Vasiliy ZukanovDroidConTLV
 
Designing a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, GettDesigning a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, GettDroidConTLV
 
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, PepperThe Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, PepperDroidConTLV
 
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDevKotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDevDroidConTLV
 
Flutter State Management - Moti Bartov, Tikal
Flutter State Management - Moti Bartov, TikalFlutter State Management - Moti Bartov, Tikal
Flutter State Management - Moti Bartov, TikalDroidConTLV
 
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bisReactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bisDroidConTLV
 
Fun with flutter animations - Divyanshu Bhargava, GoHighLevel
Fun with flutter animations - Divyanshu Bhargava, GoHighLevelFun with flutter animations - Divyanshu Bhargava, GoHighLevel
Fun with flutter animations - Divyanshu Bhargava, GoHighLevelDroidConTLV
 
DroidconTLV 2019
DroidconTLV 2019DroidconTLV 2019
DroidconTLV 2019DroidConTLV
 
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, MondayOk google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, MondayDroidConTLV
 
Introduction to React Native - Lev Vidrak, Wix
Introduction to React Native - Lev Vidrak, WixIntroduction to React Native - Lev Vidrak, Wix
Introduction to React Native - Lev Vidrak, WixDroidConTLV
 
Educating your app – adding ML edge to your apps - Maoz Tamir
Educating your app – adding ML edge to your apps - Maoz TamirEducating your app – adding ML edge to your apps - Maoz Tamir
Educating your app – adding ML edge to your apps - Maoz TamirDroidConTLV
 
Constraint-ly motion - making your app dance - John Hoford, Google
Constraint-ly motion - making your app dance - John Hoford, GoogleConstraint-ly motion - making your app dance - John Hoford, Google
Constraint-ly motion - making your app dance - John Hoford, GoogleDroidConTLV
 

Más de DroidConTLV (20)

Mobile Development in the Information Age - Yossi Elkrief, Nike
Mobile Development in the Information Age - Yossi Elkrief, NikeMobile Development in the Information Age - Yossi Elkrief, Nike
Mobile Development in the Information Age - Yossi Elkrief, Nike
 
Doing work in the background - Darryn Campbell, Zebra Technologies
Doing work in the background - Darryn Campbell, Zebra TechnologiesDoing work in the background - Darryn Campbell, Zebra Technologies
Doing work in the background - Darryn Campbell, Zebra Technologies
 
No more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola SolutionsNo more video loss - Alex Rivkin, Motorola Solutions
No more video loss - Alex Rivkin, Motorola Solutions
 
Mobile at Scale: from startup to a big company - Dor Samet, Booking.com
Mobile at Scale: from startup to a big company - Dor Samet, Booking.comMobile at Scale: from startup to a big company - Dor Samet, Booking.com
Mobile at Scale: from startup to a big company - Dor Samet, Booking.com
 
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, ClimacellLiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
LiveData on Steroids - Giora Shevach + Shahar Ben Moshe, Climacell
 
MVVM In real life - Lea Cohen Tannoudji, Lightricks
MVVM In real life - Lea Cohen Tannoudji, LightricksMVVM In real life - Lea Cohen Tannoudji, Lightricks
MVVM In real life - Lea Cohen Tannoudji, Lightricks
 
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
Best Practices for Using Mobile SDKs - Lilach Wagner, SafeDK (AppLovin)
 
Building Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice NinjaBuilding Apps with Flutter - Hillel Coren, Invoice Ninja
Building Apps with Flutter - Hillel Coren, Invoice Ninja
 
New Android Project: The Most Important Decisions - Vasiliy Zukanov
New Android Project: The Most Important Decisions - Vasiliy ZukanovNew Android Project: The Most Important Decisions - Vasiliy Zukanov
New Android Project: The Most Important Decisions - Vasiliy Zukanov
 
Designing a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, GettDesigning a Design System - Shai Mishali, Gett
Designing a Design System - Shai Mishali, Gett
 
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, PepperThe Mighty Power of the Accessibility Service - Guy Griv, Pepper
The Mighty Power of the Accessibility Service - Guy Griv, Pepper
 
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDevKotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
Kotlin Multiplatform in Action - Alexandr Pogrebnyak - IceRockDev
 
Flutter State Management - Moti Bartov, Tikal
Flutter State Management - Moti Bartov, TikalFlutter State Management - Moti Bartov, Tikal
Flutter State Management - Moti Bartov, Tikal
 
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bisReactive UI in android - Gil Goldzweig Goldbaum, 10bis
Reactive UI in android - Gil Goldzweig Goldbaum, 10bis
 
Fun with flutter animations - Divyanshu Bhargava, GoHighLevel
Fun with flutter animations - Divyanshu Bhargava, GoHighLevelFun with flutter animations - Divyanshu Bhargava, GoHighLevel
Fun with flutter animations - Divyanshu Bhargava, GoHighLevel
 
DroidconTLV 2019
DroidconTLV 2019DroidconTLV 2019
DroidconTLV 2019
 
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, MondayOk google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
Ok google, it's time to bot! - Hadar Franco, Albert + Stav Levi, Monday
 
Introduction to React Native - Lev Vidrak, Wix
Introduction to React Native - Lev Vidrak, WixIntroduction to React Native - Lev Vidrak, Wix
Introduction to React Native - Lev Vidrak, Wix
 
Educating your app – adding ML edge to your apps - Maoz Tamir
Educating your app – adding ML edge to your apps - Maoz TamirEducating your app – adding ML edge to your apps - Maoz Tamir
Educating your app – adding ML edge to your apps - Maoz Tamir
 
Constraint-ly motion - making your app dance - John Hoford, Google
Constraint-ly motion - making your app dance - John Hoford, GoogleConstraint-ly motion - making your app dance - John Hoford, Google
Constraint-ly motion - making your app dance - John Hoford, Google
 

Último

ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...FIDO Alliance
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data SciencePaolo Missier
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?Mark Billinghurst
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераMark Opanasiuk
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxFIDO Alliance
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsLeah Henrickson
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...FIDO Alliance
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!Memoori
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024Stephen Perrenod
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideStefan Dietze
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfSrushith Repakula
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxjbellis
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfFIDO Alliance
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceSamy Fodil
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingScyllaDB
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Paige Cruz
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform EngineeringMarcus Vechiato
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...ScyllaDB
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightSafe Software
 

Último (20)

ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
ASRock Industrial FDO Solutions in Action for Industrial Edge AI _ Kenny at A...
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
The Metaverse: Are We There Yet?
The  Metaverse:    Are   We  There  Yet?The  Metaverse:    Are   We  There  Yet?
The Metaverse: Are We There Yet?
 
Intro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджераIntro in Product Management - Коротко про професію продакт менеджера
Intro in Product Management - Коротко про професію продакт менеджера
 
Introduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptxIntroduction to FIDO Authentication and Passkeys.pptx
Introduction to FIDO Authentication and Passkeys.pptx
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...Hyatt driving innovation and exceptional customer experiences with FIDO passw...
Hyatt driving innovation and exceptional customer experiences with FIDO passw...
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024TopCryptoSupers 12thReport OrionX May2024
TopCryptoSupers 12thReport OrionX May2024
 
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The InsideCollecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
Collecting & Temporal Analysis of Behavioral Web Data - Tales From The Inside
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdfThe Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
The Value of Certifying Products for FDO _ Paul at FIDO Alliance.pdf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Event-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream ProcessingEvent-Driven Architecture Masterclass: Challenges in Stream Processing
Event-Driven Architecture Masterclass: Challenges in Stream Processing
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Working together SRE & Platform Engineering
Working together SRE & Platform EngineeringWorking together SRE & Platform Engineering
Working together SRE & Platform Engineering
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
The Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and InsightThe Zero-ETL Approach: Enhancing Data Agility and Insight
The Zero-ETL Approach: Enhancing Data Agility and Insight
 

Bang-Bang, you have been hacked - Yonatan Levin, KolGene

  • 1. Yonatan V.Levin levin.yonatan parahall Google Developer Expert CTO & Co Founder
  • 2. >100 Cities > 30M usersRuby, Go, Python, Microservices Ooooops...
  • 3.
  • 4. What Do We Do? ● Android Fundamentals ● Android UI / UX ● Community Hackathon ● Android Advanced ● Mentors Program ● Active community
  • 7. Bang! Bang! You have been hacked.
  • 8.
  • 9.
  • 10.
  • 11. private boolean isMocLocationsOn() { return Settings.Secure.getString(getContentResolver(), Settings.Secure.ALLOW_MOCK_LOCATION) .equals(ALLOW_MOC_LOCATIONS_ON); }
  • 12. public class TimeChangedReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { onSystemTimeChanged(); } }
  • 14.
  • 15.
  • 17. public class NetworkHttpUnauthorizedReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { int httpCode = intent.getIntExtra(IntentExtras.HTTP_CODE, -1); if (httpCode == HttpURLConnection.HTTP_UNAUTHORIZED) { LoginActivity.logOut(context); } } } Anyone can send “unauthorized”
  • 18. Possible way to solve it - Exported = ‘false’ in AndroidManifest.xml - Custom permissions with protectionLevel=”signature” - Dynamic register with LocalBroadcastManager
  • 19.
  • 20.
  • 21.
  • 22.
  • 23. We lost the battle but not the war
  • 24. How he did it Static Analysis • APKTool, Smali/Baksmali, BytecodeViewer, JEB ($), IDA Pro ($$) … Network Analysis • mitmproxy, charles, burpsuite, wireshark
  • 25. Security is hard. If it’s not - it’s easy to break
  • 26. Disclaimer: I’m not security expert. It’s our journey, and I decided to share it.
  • 28. Very easy to reverse-engineer https://github.com/google/android-classyshark
  • 30. Code Protection ● Name obfuscation ● String encryption ● Class encryption ● Resources, asset and native library encryption Control flow and arithmetic obfuscation ● Hide calls through reflection
  • 31. public String encryptSensitiveMessage() { String nuclearLaunchCode = "abc123"; String encryptionKey = "secretkey"; return CryptoEngine.encrypt(nuclearLaunchCode, encryptionKey); } Example
  • 32. public String encryptSensitiveMessage() { String nuclearLaunchCode = "abc123"; String encryptionKey = "secretkey"; Class clazz = Class.forName("CryptoEngine"); Method meth = clazz.getMethod("encrypt", String.class, String.class); return (String) meth.invoke(null, nuclearLaunchCode, encryptionKey); } Reflection
  • 33. public String encryptSensitiveMessage() { String nuclearLaunchCode = Base64.decode("YWJjMTIz"); String encryptionKey = Base64.decode("c2VjcmV0a2V5"); Class clazz = Class.forName(Base64.decode("Q3J5cHRvRW5naW5l")); Method meth = clazz.getMethod(Base64.decode("ZW5jcnlwdA=="), String.class, String.class); return (String) meth.invoke(null, nuclearLaunchCode, encryptionKey); } String obfuscation
  • 34. public String a() { String a = e.f("YWJjMTIz"); String b = e.f("c2VjcmV0a2V5"); Class c = Class.forName(e.f("Q3J5cHRvRW5naW5l")); Method d = c.getMethod(e.f("ZW5jcnlwdA=="), String.class, String.class); return (String) d.invoke(null, a, b); } Name obfuscation
  • 36.
  • 37. Proguard release { minifyEnabled true shrinkResources true proguardFile 'proguard-project.pro' proguardFile 'proguard-crashlytics.pro' proguardFile 'proguard-gson.pro' proguardFile 'proguard-okhttp.pro' proguardFile 'proguard-mixpanel.pro' proguardFile 'proguard-retrofit.pro' proguardFile 'proguard-pubnub.pro' proguardFile 'proguard-logback-android.pro' proguardFile getDefaultProguardFile('proguard-android.txt') debuggable false signingConfig signingConfigs.release }
  • 39.
  • 40. GSON makes you weak :)
  • 41. "Order": { "id": 89684, "status": "expired", "payment_type": "cash", "future_ride": false, "passenger_comment": "", "scheduled_at": "2015-12-13T15:13:48+02:00", "account_ride": false, "ride_type": "private", "price_origin": "driver", "autopay": false... public class A { private int b; private AB c; private TM d; private boolean e; private S f; private D j; private D g; private D k; private boolean l; private double m; private boolean n;
  • 42. Second goal: Hide model in network layer
  • 43.
  • 44.
  • 46. message Person { // The customer's full name. required string name = 1; // The customer's ID number. required int32 id = 2; // Email address for the customer. optional string email = 3; enum PhoneType { MOBILE = 0; HOME = 1; WORK = 2; } message PhoneNumber { // The user's phone number. required string number = 1; // The type of phone stored here. optional PhoneType type = 2 [default = HOME]; } // A list of the user's phone numbers. repeated PhoneNumber phone = 4; }
  • 47. public final class Person extends Message { /** The customer's full name. */ @ProtoField(tag = 1, type = STRING, label = REQUIRED) public final String name; /** The customer's ID number. */ @ProtoField(tag = 2, type = INT32, label = REQUIRED) public final Integer id; /** Email address for the customer. */ @ProtoField(tag = 3, type = STRING) public final String email; /** A list of the user's phone numbers. */ @ProtoField(tag = 4, label = REPEATED) public final List<PhoneNumber> phone;
  • 48. byte[] data = person.toByteArray(); Wire wire = new Wire(); Person newPerson = wire.parseFrom(data, Person.class);
  • 49.
  • 50. Our Network exposing our models
  • 51. * Ask server guys to have a flag - JSON/ProtoBuff format. Will make your life easy to debug
  • 52. Retrofit StarWarsServiceRetrofit = new Retrofit.Builder().baseUrl(baseUrl) .client(clientBuilder.build()) .addConverterFactory(WireConverterFactory.create()) .addConverterFactory(GsonConverterFactory.create()) .build();
  • 53. Third goal: Challenge the code stripping.
  • 55. PackageInfo packageInfo = context.getPackageManager() .getPackageInfo(context.getPackageName(), PackageManager.GET_SIGNATURES); for (Signature signature : packageInfo.signatures) { MessageDigest md = MessageDigest.getInstance("SHA"); md.update(signature.toByteArray()); String currentSignature = Base64.encodeToString(md.digest(), Base64.DEFAULT); //compare signatures if (EXPECTED_SIGNATURE.equals(currentSignature)) { return VALID; } return INVALID;
  • 56. Challenge Connect the code ,key and API. Goal: every single change in code will generate different key and this key will be used to sign API request.
  • 57. Dex - Custom Class Loading in Dalvik
  • 58. DexClassLoader cl = new DexClassLoader(dexInternalStoragePath.getAbsolutePath(), optimizedDexOutputPath.getAbsolutePath(), null, getClassLoader()); Class libProviderClazz = null; try { // Load the library. libProviderClazz = cl.loadClass("com.example.dex.lib.LibraryProvider"); LibraryInterface lib = (LibraryInterface) libProviderClazz.newInstance(); lib.showAwesomeToast(this, "hello"); } catch (Exception e) {...}
  • 59. Reflection Ask application with API - Who are you? Generate challenge for each user randomly.Load it from server. What can be challenged? Resource IDs, Class fields, Classes Method results
  • 60. NDK possible to reverse-engineer too but really really hard! https://www.hex-rays.com/products/decompiler/
  • 62. With Help from Google
  • 63. App Licensing Google Library to query Google Play Services if Application was installed from the play store.
  • 64.
  • 65. In order to download your expansion files from Google Play, the user must have acquired your application from Google Play.
  • 66. Combination - Part 1 Authorization Answer to challenge Obtain random challenge for current session Application Side Server Side Download the challenge Using Reflection answer challenge Send as bytecode data using flatbuffer/wire Compare & decide
  • 67. Combination - Every request Build .apk Extract MD5 from .apk Store MD5 on server + hash function (RSA, AES) Run-Time Building Release Load dex library. Obtain MD5 from dex/.so lib Sign URL with MD5, Token, TimeStamp and challenge response Send data using flatbuffer/wire Compare url signature
  • 68. Compare signature and decide Build .apk Extract MD5 from .apk Store MD5 on server per built version Run-Time Building Release Load dex library with challenge. Obtain MD5 from dex/.so lib Sign API Request with MD5, Token, TimeStamp and challenge response Answer to challenge Obtain random challenge for current session Server Side Generate signature based on stored MD5, Challenge Answer, TimeStamp & Token Send data using flatbuffer/wire
  • 69.
  • 70.
  • 71.