SlideShare una empresa de Scribd logo
1 de 36
Descargar para leer sin conexión
Développement sécurisé Android


Johan Leuenberger
Software Security Engineer


                                 Application Security Forum - 2012
                                                 Western Switzerland

                             7-8 novembre 2012 - Y-Parc / Yverdon-les-Bains
                             https://www.appsec-forum.ch
2




Bio
 Software security engineer chez ELCA
 Spécialisé dans le développement Android
 Réalisation d’elcardm Android
  – Solution d’authentification forte sur smartphone
 « Android Fanboy »
3




Agenda
Android
Menaces
Protections
Conclusion
4




  Android facts
 1 million de nouveaux appareils Android chaque jour.
 1.5 milliard d’applications téléchargées chaque mois
 700’000 applications disponibles




http://developer.android.com/about/index.html
https://www.lookout.com/resources/reports/state-of-mobile-security-2012
5




Applications en tous genres
Jeux




Divers




Finances
6




Applications en tous genres
Jeux




Divers




Finances
7




Applications en tous genres
Jeux




Divers




Finances
8




Applications en tous genres
Jeux




Divers




Finances
9




Agenda
Android
Menaces
Protections
Conclusion
10




Menaces
   Reverse engineering
   Abus du Google Play Store
   Copie de l’application
   Vol d’informations (mot de passe, etc)
11




Scénario
1) Récupération d’une application existante et
   décompilation
2) Ajout de fonctionnalités
3) Packaging de la nouvelle application
4) Publication de l’application sur le Google Play
   Store
12




Reverse engineering - outils

                         APK – Android Application Package File

                      classes.dex               classes compilées
                      resources.arsc + res      resources
                      AndroidManifest.xml  fichier décrivant l’application
                      …

 Outils

     adb  communication avec un appareil Android
     dex2jar  Java Decompiler  ~ .java
     apktool  .smali
13




 Reverse engineering - smali
.class public LHelloWorld;


.super Ljava/lang/Object;


.method public static main([Ljava/lang/String;)V
    .registers 2
    sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream;
    const-string v1, "Hello World!"
    invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V
    return-void
.end method
14




Reverse engineering - Demo
 Modification d’une application afin de récupérer
  le compte et le mot de passe d’un utilisateur
15




Reverse engineering – SMS Receiver
 AndroidManifest.xml
 <uses-permission android:name="android.permission.RECEIVE_SMS" />


 <receiver android:name="ch.elca.appsec.SmsReceiver" android:enabled="true">
     <intent-filter>
         <action android:name="android.provider.Telephony.SMS_RECEIVED" />
     </intent-filter>
 </receiver>
16




Reverse engineering – SMS Receiver
 SmsReceiver
public class SmsReceiver extends BroadcastReceiver {

    @Override
    public void onReceive(Context context, Intent intent) {

        Bundle pudsBundle = intent.getExtras();
        Object[] pdus = (Object[]) pudsBundle.get("pdus");
        SmsMessage messages = SmsMessage.createFromPdu((byte[]) pdus[0]);

        String smsText = messages.getMessageBody();

        forwardToServer(smsText);
    }
17




    Abus du Google Play Store
 Les applications sont «self-signed»
 Publication aisée
 Validation pré-publication
  – Google Bouncer (BH2012 Bypassing Google’s Bouncer)
 Retrait post-publication
  – Remote removal
18




Vol de données
 Pas de keystore
 Application sandbox
  – Faillible au root
 Carte SD
19




Agenda
Android
Menaces
Protections
Conclusion
20




Protections
                 exposition              données
                   Store

     reverse                                          copie de
   engineering                                     l’application




                              module natif            clé
   obfuscation
                               externe             dynamique
21




Reverse engineering
 Pas de solution miracle!
  – Rendons la vie difficile!


 Etape 0 – Activer Proguard
  proguard.config=default_proguard.cfg



                              10 sec
22




Proguard (avec / sans)
23




Module natif
 Android NDK (Native Development Kit)
  – Code natif exécutable sous Android
  – Basé sur JNI (Java Native Interface)
  – Code accessible sous forme binaire uniquement
  – Code binaire peut également être obfusqué
 Comment ca marche?
  – Code écrit en C / C++
  – Compilé via les outils fournis par Google (ndk-build)
     => libMyModule.so
24




Android NDK - Exemple
 Java                   C
                        0110101
25




Android NDK                                                                      C
                                                                            0110101
C
jbyteArray Java_ch_elca_appsec_NativeCaller_decrypt(JNIEnv* env, jobject this,
          jobject context, jbyteArray data) {
     ...
     deviceId = getDeviceId(context);
     ...
     clearData = decrypt(deviceId, data);
     jbyteArray result = (*env)->NewByteArray(env, len);
    (*env)->SetByteArrayRegion(env, result, 0, len, clearData);
     return result;
}

jstring getDeviceId(JNIEnv* env, jobject context) {
     jstring device_id;
     jmethodID mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env,context),
          "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;");
     jobject telephony_manager = (*env)->CallObjectMethod(env, context, mid,
          (*env)->NewStringUTF(env,"phone"));
     mid = (*env)->GetMethodID(env,(*env)->GetObjectClass(env,telephony_manager),
          "getDeviceId", "()Ljava/lang/String;");
     device_id = (jstring)(*env)->CallObjectMethod(env,telephony_manager,mid);
     return device_id;
}
26




Module natif externe
 La librairie est chargée lors de l’exécution
 Elle n’a pas besoin d’être packagée dans
  l’application
 Uniquement disponible aux utilisateurs légitimes
27




Séparation de l’application
                       coquille


                             module externe




 - Publié sur le Store               - Téléchargé durant l’exécution de l’application
 - Contient le minimum de logique    - Compilé à la volée sur un serveur
 - Contient l’UI                     - Unique par utilisateur et par appareil
28




 !(Reverse engineering + copie)

                             Empreinte hardware

                         Mot de passe utilisateur
                                                       Génération du module

                                                            Compilation

                                                            Obfuscation
                             Module (format binaire)


Installation du module
29




Clé dynamique anti-copie
        Client                                      Serveur
                       Secret initial partagé: s0
                                                       r0 = random()
                                     r0, c1            f(r0, s0) = s1
f(r0, s0) = s1                                         encrypt(m1,s1) = c1
decrypt(c1, s1) = m1


r1 = random()
                                      r1, c2
f(r1, s1) = s2
encrypt(m2,s2) = c2
                                                      f(r1, s1) = s2
                                                      decrypt(c2, s2) = m2
30




Clé dynamique anti-copie
   Client
                Serveur    Client copié

    s1           s1



    s2           s2          s1
31




Clé dynamique anti-copie
   Client
                    Serveur   Client copié

    s1               s1         s1



                     s2         s2
    s1




            ERROR
32




Protections
                 exposition              données
                   Store

     reverse                                          copie de
   engineering                                     l’application




                              module natif            clé
   obfuscation
                               externe             dynamique
33




Conclusion
 Beaucoup de possibilités
  – QR Code
  – Push GCM
  – GPS
  – Etc.
 Android évolue constamment
  – Chaque version essaie de corriger certaines
    vulnérabilités
34




Conclusion
 Le port d’une application sur Android n’est
  généralement pas direct (par exemple à partir
  d’une application iPhone)  un certain
  raisonnement est nécessaire

 Le développement d’applications sécurisées
  demande du temps et de l’effort
35




 Questions?




johan.leuenberger@elca.ch
36




Merci/Thank you!

Contact:
   johan.leuenberger@elca.ch
   http://www.secutalk.ch
   Slides:
      http://slideshare.net/ASF-WS/presentations

Más contenido relacionado

Destacado

Les menaces applicatives
Les menaces applicativesLes menaces applicatives
Les menaces applicativesBee_Ware
 
CustomerGauge B2b Net Promoter Score Measurement
CustomerGauge B2b Net Promoter Score MeasurementCustomerGauge B2b Net Promoter Score Measurement
CustomerGauge B2b Net Promoter Score MeasurementCustomerGauge
 
Smart Phones Dumb Apps
Smart Phones Dumb AppsSmart Phones Dumb Apps
Smart Phones Dumb AppsDenim Group
 
Devfest istanbul'14 web app security and framework
Devfest istanbul'14   web app security and framework Devfest istanbul'14   web app security and framework
Devfest istanbul'14 web app security and framework Mehmet Ince
 
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...Ajin Abraham
 
Présentation Identités Actives
Présentation Identités ActivesPrésentation Identités Actives
Présentation Identités ActivesFing
 
StHack 2014 - Ninon Eyrolles Obfuscation 101
StHack 2014 - Ninon Eyrolles Obfuscation 101StHack 2014 - Ninon Eyrolles Obfuscation 101
StHack 2014 - Ninon Eyrolles Obfuscation 101StHack
 
Réduire la taille de son apk
Réduire la taille de son apkRéduire la taille de son apk
Réduire la taille de son apkJacques GIRAUDEL
 
[20-11-2015] Détection des attaques basées sur les librairies tierces dans le...
[20-11-2015] Détection des attaques basées sur les librairies tierces dans le...[20-11-2015] Détection des attaques basées sur les librairies tierces dans le...
[20-11-2015] Détection des attaques basées sur les librairies tierces dans le...Amina WADDIZ
 
Sécurité asterisk web
Sécurité asterisk webSécurité asterisk web
Sécurité asterisk webAgarik
 

Destacado (12)

Les menaces applicatives
Les menaces applicativesLes menaces applicatives
Les menaces applicatives
 
CustomerGauge B2b Net Promoter Score Measurement
CustomerGauge B2b Net Promoter Score MeasurementCustomerGauge B2b Net Promoter Score Measurement
CustomerGauge B2b Net Promoter Score Measurement
 
Smart Phones Dumb Apps
Smart Phones Dumb AppsSmart Phones Dumb Apps
Smart Phones Dumb Apps
 
Devfest istanbul'14 web app security and framework
Devfest istanbul'14   web app security and framework Devfest istanbul'14   web app security and framework
Devfest istanbul'14 web app security and framework
 
Applications mobiles et sécurité
Applications mobiles et sécuritéApplications mobiles et sécurité
Applications mobiles et sécurité
 
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
Nullcon Goa 2016 - Automated Mobile Application Security Testing with Mobile ...
 
Présentation Identités Actives
Présentation Identités ActivesPrésentation Identités Actives
Présentation Identités Actives
 
StHack 2014 - Ninon Eyrolles Obfuscation 101
StHack 2014 - Ninon Eyrolles Obfuscation 101StHack 2014 - Ninon Eyrolles Obfuscation 101
StHack 2014 - Ninon Eyrolles Obfuscation 101
 
Réduire la taille de son apk
Réduire la taille de son apkRéduire la taille de son apk
Réduire la taille de son apk
 
[20-11-2015] Détection des attaques basées sur les librairies tierces dans le...
[20-11-2015] Détection des attaques basées sur les librairies tierces dans le...[20-11-2015] Détection des attaques basées sur les librairies tierces dans le...
[20-11-2015] Détection des attaques basées sur les librairies tierces dans le...
 
Sécurité asterisk web
Sécurité asterisk webSécurité asterisk web
Sécurité asterisk web
 
Introduction à Angular 2
Introduction à Angular 2Introduction à Angular 2
Introduction à Angular 2
 

Similar a ASFWS 2012 - Le développement d’applications sécurisées avec Android par Johan Leuenberger

cours Android.pptx
cours Android.pptxcours Android.pptx
cours Android.pptxYaminaGh1
 
Composants d-une application Android.ppt
Composants d-une application Android.pptComposants d-une application Android.ppt
Composants d-une application Android.pptmahamaalej3
 
Présentation générale de l'offre de solutions TAGES
Présentation générale de l'offre de solutions TAGES Présentation générale de l'offre de solutions TAGES
Présentation générale de l'offre de solutions TAGES Vincent lefebvre
 
Les ateliers android_1_vers2015
Les ateliers android_1_vers2015Les ateliers android_1_vers2015
Les ateliers android_1_vers2015Saber LAJILI
 
Les ateliers android_1_vers2015
Les ateliers android_1_vers2015Les ateliers android_1_vers2015
Les ateliers android_1_vers2015Sabeur LAJILI
 
Les ateliers android_1_vers2015
Les ateliers android_1_vers2015Les ateliers android_1_vers2015
Les ateliers android_1_vers2015Sabeur LAJILI
 
chapitres 3 technologies de communication de l'IoT partie II.pptx
chapitres  3 technologies de communication de l'IoT partie II.pptxchapitres  3 technologies de communication de l'IoT partie II.pptx
chapitres 3 technologies de communication de l'IoT partie II.pptxmerazgaammar2
 
De iOS à bada présentation complète_octobre 2011
De iOS à bada présentation complète_octobre 2011De iOS à bada présentation complète_octobre 2011
De iOS à bada présentation complète_octobre 2011BeMyApp
 
Introduction_Android_-_Complet.pdf
Introduction_Android_-_Complet.pdfIntroduction_Android_-_Complet.pdf
Introduction_Android_-_Complet.pdfmed_univ78
 
Projet de-recherche-Tuteuré
Projet de-recherche-TuteuréProjet de-recherche-Tuteuré
Projet de-recherche-TuteuréRullier Anthony
 
applications-reparties
applications-repartiesapplications-reparties
applications-repartiesmourad50
 
Jug Lausanne Android Janvier2013
Jug Lausanne Android Janvier2013Jug Lausanne Android Janvier2013
Jug Lausanne Android Janvier2013jeromevdl
 
In01 - Programmation Android - 01 - introduction
In01 - Programmation Android - 01 - introductionIn01 - Programmation Android - 01 - introduction
In01 - Programmation Android - 01 - introductionYann Caron
 
Reverse Engineering d'un ransomware
Reverse Engineering d'un ransomwareReverse Engineering d'un ransomware
Reverse Engineering d'un ransomwareNinaSAMMUT
 
Node.js, le pavé dans la mare
Node.js, le pavé dans la mareNode.js, le pavé dans la mare
Node.js, le pavé dans la mareValtech
 

Similar a ASFWS 2012 - Le développement d’applications sécurisées avec Android par Johan Leuenberger (20)

cours Android.pptx
cours Android.pptxcours Android.pptx
cours Android.pptx
 
Composants d-une application Android.ppt
Composants d-une application Android.pptComposants d-une application Android.ppt
Composants d-une application Android.ppt
 
Présentation générale de l'offre de solutions TAGES
Présentation générale de l'offre de solutions TAGES Présentation générale de l'offre de solutions TAGES
Présentation générale de l'offre de solutions TAGES
 
Les ateliers android_1_vers2015
Les ateliers android_1_vers2015Les ateliers android_1_vers2015
Les ateliers android_1_vers2015
 
Les ateliers android_1_vers2015
Les ateliers android_1_vers2015Les ateliers android_1_vers2015
Les ateliers android_1_vers2015
 
Les ateliers android_1_vers2015
Les ateliers android_1_vers2015Les ateliers android_1_vers2015
Les ateliers android_1_vers2015
 
1-android.pdf
1-android.pdf1-android.pdf
1-android.pdf
 
chapitres 3 technologies de communication de l'IoT partie II.pptx
chapitres  3 technologies de communication de l'IoT partie II.pptxchapitres  3 technologies de communication de l'IoT partie II.pptx
chapitres 3 technologies de communication de l'IoT partie II.pptx
 
De iOS à bada présentation complète_octobre 2011
De iOS à bada présentation complète_octobre 2011De iOS à bada présentation complète_octobre 2011
De iOS à bada présentation complète_octobre 2011
 
Introduction_Android_-_Complet.pdf
Introduction_Android_-_Complet.pdfIntroduction_Android_-_Complet.pdf
Introduction_Android_-_Complet.pdf
 
Projet de-recherche-Tuteuré
Projet de-recherche-TuteuréProjet de-recherche-Tuteuré
Projet de-recherche-Tuteuré
 
Rex ionic
Rex ionicRex ionic
Rex ionic
 
applications-reparties
applications-repartiesapplications-reparties
applications-reparties
 
Cours android
Cours androidCours android
Cours android
 
Cours cordova & REST
Cours cordova & RESTCours cordova & REST
Cours cordova & REST
 
Windows Phone 7 et la sécurité
Windows Phone 7 et la sécuritéWindows Phone 7 et la sécurité
Windows Phone 7 et la sécurité
 
Jug Lausanne Android Janvier2013
Jug Lausanne Android Janvier2013Jug Lausanne Android Janvier2013
Jug Lausanne Android Janvier2013
 
In01 - Programmation Android - 01 - introduction
In01 - Programmation Android - 01 - introductionIn01 - Programmation Android - 01 - introduction
In01 - Programmation Android - 01 - introduction
 
Reverse Engineering d'un ransomware
Reverse Engineering d'un ransomwareReverse Engineering d'un ransomware
Reverse Engineering d'un ransomware
 
Node.js, le pavé dans la mare
Node.js, le pavé dans la mareNode.js, le pavé dans la mare
Node.js, le pavé dans la mare
 

Más de Cyber Security Alliance

Robots are among us, but who takes responsibility?
Robots are among us, but who takes responsibility?Robots are among us, but who takes responsibility?
Robots are among us, but who takes responsibility?Cyber Security Alliance
 
iOS malware: what's the risk and how to reduce it
iOS malware: what's the risk and how to reduce itiOS malware: what's the risk and how to reduce it
iOS malware: what's the risk and how to reduce itCyber Security Alliance
 
Why huntung IoC fails at protecting against targeted attacks
Why huntung IoC fails at protecting against targeted attacksWhy huntung IoC fails at protecting against targeted attacks
Why huntung IoC fails at protecting against targeted attacksCyber Security Alliance
 
Corporations - the new victims of targeted ransomware
Corporations - the new victims of targeted ransomwareCorporations - the new victims of targeted ransomware
Corporations - the new victims of targeted ransomwareCyber Security Alliance
 
Introducing Man in the Contacts attack to trick encrypted messaging apps
Introducing Man in the Contacts attack to trick encrypted messaging appsIntroducing Man in the Contacts attack to trick encrypted messaging apps
Introducing Man in the Contacts attack to trick encrypted messaging appsCyber Security Alliance
 
Understanding the fundamentals of attacks
Understanding the fundamentals of attacksUnderstanding the fundamentals of attacks
Understanding the fundamentals of attacksCyber Security Alliance
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemCyber Security Alliance
 
Easy public-private-keys-strong-authentication-using-u2 f
Easy public-private-keys-strong-authentication-using-u2 fEasy public-private-keys-strong-authentication-using-u2 f
Easy public-private-keys-strong-authentication-using-u2 fCyber Security Alliance
 
Create a-strong-two-factors-authentication-device-for-less-than-chf-100
Create a-strong-two-factors-authentication-device-for-less-than-chf-100Create a-strong-two-factors-authentication-device-for-less-than-chf-100
Create a-strong-two-factors-authentication-device-for-less-than-chf-100Cyber Security Alliance
 
Offline bruteforce attack on wi fi protected setup
Offline bruteforce attack on wi fi protected setupOffline bruteforce attack on wi fi protected setup
Offline bruteforce attack on wi fi protected setupCyber Security Alliance
 
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...Cyber Security Alliance
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScriptWarning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScriptCyber Security Alliance
 
Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureCyber Security Alliance
 

Más de Cyber Security Alliance (20)

Bug Bounty @ Swisscom
Bug Bounty @ SwisscomBug Bounty @ Swisscom
Bug Bounty @ Swisscom
 
Robots are among us, but who takes responsibility?
Robots are among us, but who takes responsibility?Robots are among us, but who takes responsibility?
Robots are among us, but who takes responsibility?
 
iOS malware: what's the risk and how to reduce it
iOS malware: what's the risk and how to reduce itiOS malware: what's the risk and how to reduce it
iOS malware: what's the risk and how to reduce it
 
Why huntung IoC fails at protecting against targeted attacks
Why huntung IoC fails at protecting against targeted attacksWhy huntung IoC fails at protecting against targeted attacks
Why huntung IoC fails at protecting against targeted attacks
 
Corporations - the new victims of targeted ransomware
Corporations - the new victims of targeted ransomwareCorporations - the new victims of targeted ransomware
Corporations - the new victims of targeted ransomware
 
Blockchain for Beginners
Blockchain for Beginners Blockchain for Beginners
Blockchain for Beginners
 
Le pentest pour les nuls #cybsec16
Le pentest pour les nuls #cybsec16Le pentest pour les nuls #cybsec16
Le pentest pour les nuls #cybsec16
 
Introducing Man in the Contacts attack to trick encrypted messaging apps
Introducing Man in the Contacts attack to trick encrypted messaging appsIntroducing Man in the Contacts attack to trick encrypted messaging apps
Introducing Man in the Contacts attack to trick encrypted messaging apps
 
Understanding the fundamentals of attacks
Understanding the fundamentals of attacksUnderstanding the fundamentals of attacks
Understanding the fundamentals of attacks
 
Rump : iOS patch diffing
Rump : iOS patch diffingRump : iOS patch diffing
Rump : iOS patch diffing
 
An easy way into your sap systems v3.0
An easy way into your sap systems v3.0An easy way into your sap systems v3.0
An easy way into your sap systems v3.0
 
Reverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande ModemReverse engineering Swisscom's Centro Grande Modem
Reverse engineering Swisscom's Centro Grande Modem
 
Easy public-private-keys-strong-authentication-using-u2 f
Easy public-private-keys-strong-authentication-using-u2 fEasy public-private-keys-strong-authentication-using-u2 f
Easy public-private-keys-strong-authentication-using-u2 f
 
Create a-strong-two-factors-authentication-device-for-less-than-chf-100
Create a-strong-two-factors-authentication-device-for-less-than-chf-100Create a-strong-two-factors-authentication-device-for-less-than-chf-100
Create a-strong-two-factors-authentication-device-for-less-than-chf-100
 
Offline bruteforce attack on wi fi protected setup
Offline bruteforce attack on wi fi protected setupOffline bruteforce attack on wi fi protected setup
Offline bruteforce attack on wi fi protected setup
 
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obf...
 
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScriptWarning Ahead: SecurityStorms are Brewing in Your JavaScript
Warning Ahead: SecurityStorms are Brewing in Your JavaScript
 
Killing any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented featureKilling any security product … using a Mimikatz undocumented feature
Killing any security product … using a Mimikatz undocumented feature
 
Rump attaque usb_caralinda_fabrice
Rump attaque usb_caralinda_fabriceRump attaque usb_caralinda_fabrice
Rump attaque usb_caralinda_fabrice
 
Operation emmental appsec
Operation emmental appsecOperation emmental appsec
Operation emmental appsec
 

ASFWS 2012 - Le développement d’applications sécurisées avec Android par Johan Leuenberger

  • 1. Développement sécurisé Android Johan Leuenberger Software Security Engineer Application Security Forum - 2012 Western Switzerland 7-8 novembre 2012 - Y-Parc / Yverdon-les-Bains https://www.appsec-forum.ch
  • 2. 2 Bio  Software security engineer chez ELCA  Spécialisé dans le développement Android  Réalisation d’elcardm Android – Solution d’authentification forte sur smartphone  « Android Fanboy »
  • 4. 4 Android facts 1 million de nouveaux appareils Android chaque jour. 1.5 milliard d’applications téléchargées chaque mois 700’000 applications disponibles http://developer.android.com/about/index.html https://www.lookout.com/resources/reports/state-of-mobile-security-2012
  • 5. 5 Applications en tous genres Jeux Divers Finances
  • 6. 6 Applications en tous genres Jeux Divers Finances
  • 7. 7 Applications en tous genres Jeux Divers Finances
  • 8. 8 Applications en tous genres Jeux Divers Finances
  • 10. 10 Menaces  Reverse engineering  Abus du Google Play Store  Copie de l’application  Vol d’informations (mot de passe, etc)
  • 11. 11 Scénario 1) Récupération d’une application existante et décompilation 2) Ajout de fonctionnalités 3) Packaging de la nouvelle application 4) Publication de l’application sur le Google Play Store
  • 12. 12 Reverse engineering - outils APK – Android Application Package File  classes.dex  classes compilées  resources.arsc + res  resources  AndroidManifest.xml  fichier décrivant l’application  … Outils  adb  communication avec un appareil Android  dex2jar  Java Decompiler  ~ .java  apktool  .smali
  • 13. 13 Reverse engineering - smali .class public LHelloWorld; .super Ljava/lang/Object; .method public static main([Ljava/lang/String;)V .registers 2 sget-object v0, Ljava/lang/System;->out:Ljava/io/PrintStream; const-string v1, "Hello World!" invoke-virtual {v0, v1}, Ljava/io/PrintStream;->println(Ljava/lang/String;)V return-void .end method
  • 14. 14 Reverse engineering - Demo  Modification d’une application afin de récupérer le compte et le mot de passe d’un utilisateur
  • 15. 15 Reverse engineering – SMS Receiver  AndroidManifest.xml <uses-permission android:name="android.permission.RECEIVE_SMS" /> <receiver android:name="ch.elca.appsec.SmsReceiver" android:enabled="true"> <intent-filter> <action android:name="android.provider.Telephony.SMS_RECEIVED" /> </intent-filter> </receiver>
  • 16. 16 Reverse engineering – SMS Receiver  SmsReceiver public class SmsReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Bundle pudsBundle = intent.getExtras(); Object[] pdus = (Object[]) pudsBundle.get("pdus"); SmsMessage messages = SmsMessage.createFromPdu((byte[]) pdus[0]); String smsText = messages.getMessageBody(); forwardToServer(smsText); }
  • 17. 17 Abus du Google Play Store  Les applications sont «self-signed»  Publication aisée  Validation pré-publication – Google Bouncer (BH2012 Bypassing Google’s Bouncer)  Retrait post-publication – Remote removal
  • 18. 18 Vol de données  Pas de keystore  Application sandbox – Faillible au root  Carte SD
  • 20. 20 Protections exposition données Store reverse copie de engineering l’application module natif clé obfuscation externe dynamique
  • 21. 21 Reverse engineering  Pas de solution miracle! – Rendons la vie difficile!  Etape 0 – Activer Proguard proguard.config=default_proguard.cfg 10 sec
  • 23. 23 Module natif  Android NDK (Native Development Kit) – Code natif exécutable sous Android – Basé sur JNI (Java Native Interface) – Code accessible sous forme binaire uniquement – Code binaire peut également être obfusqué  Comment ca marche? – Code écrit en C / C++ – Compilé via les outils fournis par Google (ndk-build) => libMyModule.so
  • 24. 24 Android NDK - Exemple  Java C 0110101
  • 25. 25 Android NDK C 0110101 C jbyteArray Java_ch_elca_appsec_NativeCaller_decrypt(JNIEnv* env, jobject this, jobject context, jbyteArray data) { ... deviceId = getDeviceId(context); ... clearData = decrypt(deviceId, data); jbyteArray result = (*env)->NewByteArray(env, len); (*env)->SetByteArrayRegion(env, result, 0, len, clearData); return result; } jstring getDeviceId(JNIEnv* env, jobject context) { jstring device_id; jmethodID mid = (*env)->GetMethodID(env, (*env)->GetObjectClass(env,context), "getSystemService", "(Ljava/lang/String;)Ljava/lang/Object;"); jobject telephony_manager = (*env)->CallObjectMethod(env, context, mid, (*env)->NewStringUTF(env,"phone")); mid = (*env)->GetMethodID(env,(*env)->GetObjectClass(env,telephony_manager), "getDeviceId", "()Ljava/lang/String;"); device_id = (jstring)(*env)->CallObjectMethod(env,telephony_manager,mid); return device_id; }
  • 26. 26 Module natif externe  La librairie est chargée lors de l’exécution  Elle n’a pas besoin d’être packagée dans l’application  Uniquement disponible aux utilisateurs légitimes
  • 27. 27 Séparation de l’application coquille module externe - Publié sur le Store - Téléchargé durant l’exécution de l’application - Contient le minimum de logique - Compilé à la volée sur un serveur - Contient l’UI - Unique par utilisateur et par appareil
  • 28. 28 !(Reverse engineering + copie) Empreinte hardware Mot de passe utilisateur Génération du module Compilation Obfuscation Module (format binaire) Installation du module
  • 29. 29 Clé dynamique anti-copie Client Serveur Secret initial partagé: s0 r0 = random() r0, c1 f(r0, s0) = s1 f(r0, s0) = s1 encrypt(m1,s1) = c1 decrypt(c1, s1) = m1 r1 = random() r1, c2 f(r1, s1) = s2 encrypt(m2,s2) = c2 f(r1, s1) = s2 decrypt(c2, s2) = m2
  • 30. 30 Clé dynamique anti-copie Client Serveur Client copié s1 s1 s2 s2 s1
  • 31. 31 Clé dynamique anti-copie Client Serveur Client copié s1 s1 s1 s2 s2 s1 ERROR
  • 32. 32 Protections exposition données Store reverse copie de engineering l’application module natif clé obfuscation externe dynamique
  • 33. 33 Conclusion  Beaucoup de possibilités – QR Code – Push GCM – GPS – Etc.  Android évolue constamment – Chaque version essaie de corriger certaines vulnérabilités
  • 34. 34 Conclusion  Le port d’une application sur Android n’est généralement pas direct (par exemple à partir d’une application iPhone)  un certain raisonnement est nécessaire  Le développement d’applications sécurisées demande du temps et de l’effort
  • 36. 36 Merci/Thank you! Contact: johan.leuenberger@elca.ch http://www.secutalk.ch Slides: http://slideshare.net/ASF-WS/presentations