SlideShare ist ein Scribd-Unternehmen logo
1 von 49
Downloaden Sie, um offline zu lesen
C+ +11 
METAPROGRAMMING 
A P P L IED 
TO 
SOF TWARE 
OBFUSCAT ION 
SEBAST IEN 
ANDRIVET 
Application Security Forum - 2014 
Western Switzerland 
05-06 November 2014 
Y-Parc / Yverdon-les-Bains 
http://www.appsec-forum.ch 
1
About me 
Senior Security Engineer 
a t SCRT (Swiss) 
Deve l o p e r 
a t ADVTOOLS (Swiss) 
Sebastien ANDRIVET 
Cyberfeminist & hack t i v i s t 
Reverse engineer Intel & ARM 
C + + , C , O b j - C , C # d e ve l o p e r 
Trainer ( iOS & Android appsec) 
2
PROBLEM 
3
Reverse engineering 
• Reverse engineering of an application if often like 
following the “white rabbit” 
• i.e. following string literals 
• Live demo 
• Reverse engineering of an application using IDA 
• Well-known MDM (Mobile Device Management) for 
iOS 
4
A SOLUTION 
OBFUSCATION 
5
What is Obfuscation? 
6
Obfuscator O 
O( ) = 
7
YES! It is also Katy Perry! 
• (almost) same 
semantics 
• obfuscated 
8
“Deliberate act of creating source or machine 
code difficult for humans to understand” 
–WIKIPEDIA, APRIL 2014 
Obfuscation 
9
C++ templates 
• Example: Stack of objects 
OBJECT2 
OBJECT1 
• Push 
• Pop 
10
Without templates 
c l a s s Stack 
{ 
v o i d p u s h (void* o b j e c t ) ; 
void* p o p ( ) ; 
} ; 
Stack singers; 
singers.push(britney); 
Stack apples; 
apples.push(macintosh); 
s i n g e r s apples 
• Reuse the same code (binary) 
• Only 1 instance of Stack class 
11
With C++ templates 
Stack<Singer> singers; 
singers.push(britney); 
Stack<Apple> apples; 
apples.push(macintosh); 
template<typename T> 
c l a s s Stack 
{ 
Stack<Singers> Stack<Apples*> 
v o i d p u s h ( T o b j e c t ) ; 
T p o p ( ) ; 
s i n g e r s apples 
} ; 
12
With C++ templates 
Stack<Singer> singers; 
singers.push(britney); 
Stack<Apple> apples; 
apples.push(macintosh); 
Stack<Singers> Stack<Apples*> 
s i n g e r s apples 
13
C++ templates 
• Two instances of Stack class 
• One per type 
• Does not reuse code 
• By default 
• Permit optimisations based on types 
• For ex. reuse code for all pointers to objects 
• Type safety, verified at compile time 
14
Type safety 
• singers.push(apple); // compilation error 
• apples.push(U2); 
• may or may not work… 
15
Optimisation based on types 
• Generate different code based on types (template 
parameters) 
• Example: enable_if 
template<typename T> 
class MyClass 
{ 
... 
enable_if_t<is_pointer<T>::value, T> 
member_function(T t) { ... }; 
... 
}; 
• member_function is only defined if T is a pointer type 
• (warning: C++14 code, not C++11) 
16
C++ metaprogramming 
• Programs that manipulate or produce programs 
• Subset of C++ 
• Turing-complete (~ full programming language) 
• Close to Functional programming 
• Part of C++ standards 
• Major enhancements in C++11 et C++14 
17
Application 1 - Strings literals obfuscation 
• original string is source code 
• original string in DEBUG builds 
• developer-friendly syntax 
• no trace of original string in compiled code in 
RELEASE builds 
18
1st implementation 
template<int... Indexes> 
struct MetaString1 { 
constexpr MetaString1(const char* str) 
: buffer_ {encrypt(str[Indexes])...} { } 
const char* decrypt(); 
RUNTIME 
private: 
constexpr char encrypt(char c) const { return c ^ 0x55; } 
constexpr char decrypt(char c) const { return encrypt(c); } 
private: 
char buffer_[sizeof...(Indexes) + 1]; 
}; 
19
1st implementation - Usage 
#define OBFUSCATED1(str) (MetaString1<0, 1, 2, 3, 4, 5>(str).decrypt()) 
cout << OBFUSCATED1(“Britney Spears”) << endl; 
20
1st implementation - Problem 
• List of indexes is hard-coded 
• 0, 1, 2, 3, 4, 5 
• As a consequence, strings are truncated! 
21
2nd implementation 
• Generate a list of indexes with metaprogramming 
• C++14 introduces std:index_sequence 
• With C++11, we have to implement our own version 
• Very simplified 
• MakeIndex<N>::type generates: 
• Indexes<0, 1, 2, 3, …, N> 
22
2nd implementation 
• Instead of: 
MetaString1<0, 1, 2, 3, 4, 5>(str) 
• we have: 
MetaString2<Make_Indexes<sizeof(str)-1>::type>(str) 
23
2nd implementation - Usage 
cout << OBFUSCATED2(“Katy Perry”) << endl; 
• No more truncation 
24
3rd implementation 
• In previous implementations, key is hard-coded 
constexpr char encrypt(char c) const { return c ^ 0x55; } 
• New template parameter for Key 
template<int... I, int K> 
struct MetaString3<Indexes<I...>, K> 
25
Generating (pseudo-) random numbers 
• C++11 includes <random>, but for runtime, not compile time 
• MetaRandom<N, M> 
N: Nth generated number 
M: Maximum value (excluded) 
• Linear congruential engine 
• Park-Miller (1988), “minimal standard” 
• Not exactly a uniform distribution (modulo operation) 
• Recursive 
26
Seed 
• template<> 
struct MetaRandomGenerator<0> { 
static const int value = seed; 
}; 
• How to choose an acceptable compile-time seed? 
• Macros (C & C++): 
• __TIME__: compilation time (standard) 
• __COUNTER__: incremented each time it is used 
(non-standard but well supported by compilers) 
27
3rd implementation 
• Different key for each string 
• thanks to __COUNTER__ 
• Different keys for each compilation 
• thanks to __TIME__ 
• Sometimes not desirable: can give hints to attackers 
(differences between versions) 
28
4th implementation 
• Different and random keys, great! 
• Why not go even further? 
• Choose a different encryption algorithm, randomly! 
29
4th implementation 
• Template partial specialization 
• template<int A, int K, typename Indexes> 
struct MetaString4; 
• template<int K, int... I> 
struct MetaString4<0, K, Indexes<I...>> { … c ^ K … }; 
• template<int K, int... I> 
struct MetaString4<1, K, Indexes<I...>> { … c + K … }; 
• #define DEF_OBFUSCATED4(str) 
MetaString4<MetaRandom<__COUNTER__, 2>::value, … 
30
Result 
• Without obfuscation 
cout << "Britney Spears” << endl; 
• With obfuscation 
cout << OBFUSCATED4("Britney Spears") << endl; 
31
Without obfuscation 
32
With obfuscation 
Encrypted 
characters 
(mixed with MOV) 
Decryption 
33
Application 2 - Obfuscate calls 
• How to obfuscate call such as: 
• function_to_protect(); 
• against static analysis (or even dynamic analysis)? 
34
Finite State Machine (simple example) 
35
Boost Meta State Machine (MSM) library 
types 
template parameter 
Compile time entity 
Generates code (FSM) at compile-time 
36
Result 
• Without obfuscation 
function_to_protect(“did”, “again”); 
• With obfuscation 
OBFUSCATED_CALL(function_to_protect, “did”, “again”); 
• Even better 
OBFUSCATED_CALL(function_to_protect, 
OBFUSCATED(“did”), OBFUSCATED(“again”)); 
37
Without obfuscation 
38
With obfuscation 
39
Application 3: FSM + Debugger Detection 
• FSM 
• To fight against static analysis 
• Debugger detection 
• To fight against dynamic analysis 
40
Finite State Machine 
• Follows a different path depending of a predicate 
(Debugged or not Debugged, that is the question) 
41
More obfuscation 
• Obfuscate predicate result 
• Avoid simple “if”, too simple for reverse engineers 
• Make computation instead 
• If the example, counter is odd if predicate is false 
42
More obfuscation 
• Obfuscate function address 
• Otherwise, IDA is smart enough to get it 
• Simply make some computation on address 
• Using MetaRandom (like for strings obfuscation) 
43
Predicate 
• Debugger detection is only an example 
• In the example, implemented only for Mac OS X / 
iOS 
• Virtual environment detection 
• Jailbreak detection 
• Etc 
44
Compilers support 
Compiler Compatible Remark 
Apple LLVM 5.1 Yes Previous versions not tested 
Apple LLVM 6.0 Yes Xcode 6, 6.1 beta 
LLVM 3.4, 3.5 Yes Previous versions not tested 
GCC 4.8.2 or higher Yes Previous versions not tested 
Compile with -std=c++11 
Intel C++ 2013 Yes Version 14.0.3 
(2013 SP1 Update 3) 
Visual Studio 2013 No Lack of constexpr support 
Visual Studio 14 Almost Not far, lack init of arrays 
CTP3 tested 
45
White paper 
46
Credits 
47 
• I take inspiration from 
many sources 
• In particular: 
• Samuel Neves & Filipe 
Araujo 
• LeFF (virus maker)
Infos 
• @AndrivetSeb sebastien@andrivet.com 
• All code presented here is available on GitHub 
• https://github.com/andrivet/ADVobfuscator 
• Contains 
• obfuscator (in source) 
• examples 
• Whitepaper 
• BSD 3-clauses license 
48
Thank you 
Questions? 
49

Weitere ähnliche Inhalte

Was ist angesagt?

Csw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemesCsw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemesCanSecWest
 
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)Gavin Guo
 
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCsw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCanSecWest
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23DefconRussia
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCanSecWest
 
Debugging TV Frame 0x09
Debugging TV Frame 0x09Debugging TV Frame 0x09
Debugging TV Frame 0x09Dmitry Vostokov
 
Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)Giovanni Bechis
 
Migrating KSM page causes the VM lock up as the KSM page merging list is too ...
Migrating KSM page causes the VM lock up as the KSM page merging list is too ...Migrating KSM page causes the VM lock up as the KSM page merging list is too ...
Migrating KSM page causes the VM lock up as the KSM page merging list is too ...Gavin Guo
 
Humantalk Angers 14 Mars
Humantalk Angers 14 MarsHumantalk Angers 14 Mars
Humantalk Angers 14 MarsRĂŠmi Dubois
 
System Calls
System CallsSystem Calls
System CallsDavid Evans
 
44CON London - Attacking VxWorks: from Stone Age to Interstellar
44CON London - Attacking VxWorks: from Stone Age to Interstellar44CON London - Attacking VxWorks: from Stone Age to Interstellar
44CON London - Attacking VxWorks: from Stone Age to Interstellar44CON
 
The true story_of_hello_world
The true story_of_hello_worldThe true story_of_hello_world
The true story_of_hello_worldfantasy zheng
 
CSW2017 Amanda rousseau cansecwest2017_net_hijacking_powershell
CSW2017 Amanda rousseau cansecwest2017_net_hijacking_powershellCSW2017 Amanda rousseau cansecwest2017_net_hijacking_powershell
CSW2017 Amanda rousseau cansecwest2017_net_hijacking_powershellCanSecWest
 
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...Tzung-Bi Shih
 
A little systemtap
A little systemtapA little systemtap
A little systemtapyang bingwu
 
The origin: Init (compact version)
The origin: Init (compact version)The origin: Init (compact version)
The origin: Init (compact version)Tzung-Bi Shih
 
Meltdown & Spectre
Meltdown & Spectre Meltdown & Spectre
Meltdown & Spectre Marco Cipriano
 

Was ist angesagt? (20)

Csw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemesCsw2016 gawlik bypassing_differentdefenseschemes
Csw2016 gawlik bypassing_differentdefenseschemes
 
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
Spectre(v1%2 fv2%2fv4) v.s. meltdown(v3)
 
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerabilityCsw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
Csw2016 gong pwn_a_nexus_device_with_a_single_vulnerability
 
Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23Advanced cfg bypass on adobe flash player 18 defcon russia 23
Advanced cfg bypass on adobe flash player 18 defcon russia 23
 
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacketCsw2016 wheeler barksdale-gruskovnjak-execute_mypacket
Csw2016 wheeler barksdale-gruskovnjak-execute_mypacket
 
Debugging TV Frame 0x09
Debugging TV Frame 0x09Debugging TV Frame 0x09
Debugging TV Frame 0x09
 
Pledge in OpenBSD
Pledge in OpenBSDPledge in OpenBSD
Pledge in OpenBSD
 
Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)Linux seccomp(2) vs OpenBSD pledge(2)
Linux seccomp(2) vs OpenBSD pledge(2)
 
Osol Pgsql
Osol PgsqlOsol Pgsql
Osol Pgsql
 
Migrating KSM page causes the VM lock up as the KSM page merging list is too ...
Migrating KSM page causes the VM lock up as the KSM page merging list is too ...Migrating KSM page causes the VM lock up as the KSM page merging list is too ...
Migrating KSM page causes the VM lock up as the KSM page merging list is too ...
 
Humantalk Angers 14 Mars
Humantalk Angers 14 MarsHumantalk Angers 14 Mars
Humantalk Angers 14 Mars
 
System Calls
System CallsSystem Calls
System Calls
 
44CON London - Attacking VxWorks: from Stone Age to Interstellar
44CON London - Attacking VxWorks: from Stone Age to Interstellar44CON London - Attacking VxWorks: from Stone Age to Interstellar
44CON London - Attacking VxWorks: from Stone Age to Interstellar
 
The true story_of_hello_world
The true story_of_hello_worldThe true story_of_hello_world
The true story_of_hello_world
 
CSW2017 Amanda rousseau cansecwest2017_net_hijacking_powershell
CSW2017 Amanda rousseau cansecwest2017_net_hijacking_powershellCSW2017 Amanda rousseau cansecwest2017_net_hijacking_powershell
CSW2017 Amanda rousseau cansecwest2017_net_hijacking_powershell
 
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
Feldo: Function Event Listing and Dynamic Observing for Detecting and Prevent...
 
Proxy arp
Proxy arpProxy arp
Proxy arp
 
A little systemtap
A little systemtapA little systemtap
A little systemtap
 
The origin: Init (compact version)
The origin: Init (compact version)The origin: Init (compact version)
The origin: Init (compact version)
 
Meltdown & Spectre
Meltdown & Spectre Meltdown & Spectre
Meltdown & Spectre
 

Andere mochten auch

3 d pie chart circular with hole in center 12 stages powerpoint presentation ...
3 d pie chart circular with hole in center 12 stages powerpoint presentation ...3 d pie chart circular with hole in center 12 stages powerpoint presentation ...
3 d pie chart circular with hole in center 12 stages powerpoint presentation ...SlideTeam.net
 
User experience design.
User experience design.User experience design.
User experience design.Mindtree Ltd.
 
ENTREPRENEURIAL OPPORTUNITY E X P L O I T A T I O N A N D T H E F A M I L Y
ENTREPRENEURIAL OPPORTUNITY E X P L O I T A T I O N  A N D  T H E  F A M I L YENTREPRENEURIAL OPPORTUNITY E X P L O I T A T I O N  A N D  T H E  F A M I L Y
ENTREPRENEURIAL OPPORTUNITY E X P L O I T A T I O N A N D T H E F A M I L YFabulyzer
 
創意跟行銷
創意跟行銷創意跟行銷
創意跟行銷bopomo
 
Team Building in Sydney - 7 Important Insights with Beyond the Boardroom
Team Building in Sydney - 7 Important Insights with Beyond the BoardroomTeam Building in Sydney - 7 Important Insights with Beyond the Boardroom
Team Building in Sydney - 7 Important Insights with Beyond the Boardroomsteve dalton
 
Social Learning no dia a dia dos usuĂĄrios
Social Learning no dia a dia dos usuĂĄriosSocial Learning no dia a dia dos usuĂĄrios
Social Learning no dia a dia dos usuĂĄriosBruno de Souza
 
Sebi compliances and penalty 13.11.05 jaipur
Sebi compliances and penalty               13.11.05 jaipurSebi compliances and penalty               13.11.05 jaipur
Sebi compliances and penalty 13.11.05 jaipurPavan Kumar Vijay
 
Insanity: The Chase
Insanity: The ChaseInsanity: The Chase
Insanity: The ChaseDavid Sr.
 
Xero certified Advisor
Xero certified AdvisorXero certified Advisor
Xero certified AdvisorTrish Martino
 
070หลวงพี่เอี้ยงตอนการให้ทานที่ได้บุญมากกว่า
070หลวงพี่เอี้ยงตอนการให้ทานที่ได้บุญมากกว่า070หลวงพี่เอี้ยงตอนการให้ทานที่ได้บุญมากกว่า
070หลวงพี่เอี้ยงตอนการให้ทานที่ได้บุญมากกว่าniralai
 
A Primer - Comparing Japanese, Australian, Dutch and UK RMBS and Mortgage Mar...
A Primer - Comparing Japanese, Australian, Dutch and UK RMBS and Mortgage Mar...A Primer - Comparing Japanese, Australian, Dutch and UK RMBS and Mortgage Mar...
A Primer - Comparing Japanese, Australian, Dutch and UK RMBS and Mortgage Mar...Arthur Karabatsos
 
Ericsson Mobility Report, November 2015 - Regional report North East Asia
Ericsson Mobility Report, November 2015 - Regional report North East AsiaEricsson Mobility Report, November 2015 - Regional report North East Asia
Ericsson Mobility Report, November 2015 - Regional report North East AsiaEricsson
 
iPods & Podcasting for Whole Language Instruction
iPods & Podcasting for Whole Language InstructioniPods & Podcasting for Whole Language Instruction
iPods & Podcasting for Whole Language InstructionUnion City High School
 
Anas Wardi En 12
Anas Wardi En 12Anas Wardi En 12
Anas Wardi En 12Anas Wardi
 
Hiring Hacks For Founders
Hiring Hacks For FoundersHiring Hacks For Founders
Hiring Hacks For Foundersdanarkind
 
Herramientas para crear videotutoriales
Herramientas para crear videotutorialesHerramientas para crear videotutoriales
Herramientas para crear videotutorialesAlexander Guzman
 
фотомонтаж
фотомонтажфотомонтаж
фотомонтажMaysnikov
 
10 Superpowers of the World's Greatest Social Media Marketer
10 Superpowers of the World's Greatest Social Media Marketer10 Superpowers of the World's Greatest Social Media Marketer
10 Superpowers of the World's Greatest Social Media MarketerBarry Feldman
 

Andere mochten auch (20)

VDC-Newsletter 2016-08
VDC-Newsletter 2016-08VDC-Newsletter 2016-08
VDC-Newsletter 2016-08
 
3 d pie chart circular with hole in center 12 stages powerpoint presentation ...
3 d pie chart circular with hole in center 12 stages powerpoint presentation ...3 d pie chart circular with hole in center 12 stages powerpoint presentation ...
3 d pie chart circular with hole in center 12 stages powerpoint presentation ...
 
Your big idea (1)
Your big idea (1)Your big idea (1)
Your big idea (1)
 
User experience design.
User experience design.User experience design.
User experience design.
 
ENTREPRENEURIAL OPPORTUNITY E X P L O I T A T I O N A N D T H E F A M I L Y
ENTREPRENEURIAL OPPORTUNITY E X P L O I T A T I O N  A N D  T H E  F A M I L YENTREPRENEURIAL OPPORTUNITY E X P L O I T A T I O N  A N D  T H E  F A M I L Y
ENTREPRENEURIAL OPPORTUNITY E X P L O I T A T I O N A N D T H E F A M I L Y
 
創意跟行銷
創意跟行銷創意跟行銷
創意跟行銷
 
Team Building in Sydney - 7 Important Insights with Beyond the Boardroom
Team Building in Sydney - 7 Important Insights with Beyond the BoardroomTeam Building in Sydney - 7 Important Insights with Beyond the Boardroom
Team Building in Sydney - 7 Important Insights with Beyond the Boardroom
 
Social Learning no dia a dia dos usuĂĄrios
Social Learning no dia a dia dos usuĂĄriosSocial Learning no dia a dia dos usuĂĄrios
Social Learning no dia a dia dos usuĂĄrios
 
Sebi compliances and penalty 13.11.05 jaipur
Sebi compliances and penalty               13.11.05 jaipurSebi compliances and penalty               13.11.05 jaipur
Sebi compliances and penalty 13.11.05 jaipur
 
Insanity: The Chase
Insanity: The ChaseInsanity: The Chase
Insanity: The Chase
 
Xero certified Advisor
Xero certified AdvisorXero certified Advisor
Xero certified Advisor
 
070หลวงพี่เอี้ยงตอนการให้ทานที่ได้บุญมากกว่า
070หลวงพี่เอี้ยงตอนการให้ทานที่ได้บุญมากกว่า070หลวงพี่เอี้ยงตอนการให้ทานที่ได้บุญมากกว่า
070หลวงพี่เอี้ยงตอนการให้ทานที่ได้บุญมากกว่า
 
A Primer - Comparing Japanese, Australian, Dutch and UK RMBS and Mortgage Mar...
A Primer - Comparing Japanese, Australian, Dutch and UK RMBS and Mortgage Mar...A Primer - Comparing Japanese, Australian, Dutch and UK RMBS and Mortgage Mar...
A Primer - Comparing Japanese, Australian, Dutch and UK RMBS and Mortgage Mar...
 
Ericsson Mobility Report, November 2015 - Regional report North East Asia
Ericsson Mobility Report, November 2015 - Regional report North East AsiaEricsson Mobility Report, November 2015 - Regional report North East Asia
Ericsson Mobility Report, November 2015 - Regional report North East Asia
 
iPods & Podcasting for Whole Language Instruction
iPods & Podcasting for Whole Language InstructioniPods & Podcasting for Whole Language Instruction
iPods & Podcasting for Whole Language Instruction
 
Anas Wardi En 12
Anas Wardi En 12Anas Wardi En 12
Anas Wardi En 12
 
Hiring Hacks For Founders
Hiring Hacks For FoundersHiring Hacks For Founders
Hiring Hacks For Founders
 
Herramientas para crear videotutoriales
Herramientas para crear videotutorialesHerramientas para crear videotutoriales
Herramientas para crear videotutoriales
 
фотомонтаж
фотомонтажфотомонтаж
фотомонтаж
 
10 Superpowers of the World's Greatest Social Media Marketer
10 Superpowers of the World's Greatest Social Media Marketer10 Superpowers of the World's Greatest Social Media Marketer
10 Superpowers of the World's Greatest Social Media Marketer
 

Ähnlich wie App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obfuscation

The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerAndrey Karpov
 
SPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic librarySPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic libraryAdaCore
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Ali Aminian
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeDmitri Nesteruk
 
Klee and angr
Klee and angrKlee and angr
Klee and angrWei-Bo Chen
 
Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"Yulia Tsisyk
 
State of the .Net Performance
State of the .Net PerformanceState of the .Net Performance
State of the .Net PerformanceCUSTIS
 
Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeKenneth Geisshirt
 
Code Analysis-run time error prediction
Code Analysis-run time error predictionCode Analysis-run time error prediction
Code Analysis-run time error predictionNIKHIL NAWATHE
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)Douglas Chen
 
GCC Summit 2010
GCC Summit 2010GCC Summit 2010
GCC Summit 2010regehr
 
What has to be paid attention when reviewing code of the library you develop
What has to be paid attention when reviewing code of the library you developWhat has to be paid attention when reviewing code of the library you develop
What has to be paid attention when reviewing code of the library you developAndrey Karpov
 
C Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer CentreC Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer Centrejatin batra
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#Hawkman Academy
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?Andrey Karpov
 
Csdfsadf
CsdfsadfCsdfsadf
CsdfsadfAtul Setu
 

Ähnlich wie App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obfuscation (20)

College1
College1College1
College1
 
The operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzerThe operation principles of PVS-Studio static code analyzer
The operation principles of PVS-Studio static code analyzer
 
SPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic librarySPARKNaCl: A verified, fast cryptographic library
SPARKNaCl: A verified, fast cryptographic library
 
Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1Learning C++ - Introduction to c++ programming 1
Learning C++ - Introduction to c++ programming 1
 
Unmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/InvokeUnmanaged Parallelization via P/Invoke
Unmanaged Parallelization via P/Invoke
 
Klee and angr
Klee and angrKlee and angr
Klee and angr
 
report
reportreport
report
 
Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"Adam Sitnik "State of the .NET Performance"
Adam Sitnik "State of the .NET Performance"
 
State of the .Net Performance
State of the .Net PerformanceState of the .Net Performance
State of the .Net Performance
 
Tips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native codeTips and tricks for building high performance android apps using native code
Tips and tricks for building high performance android apps using native code
 
Code Analysis-run time error prediction
Code Analysis-run time error predictionCode Analysis-run time error prediction
Code Analysis-run time error prediction
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)
 
GCC Summit 2010
GCC Summit 2010GCC Summit 2010
GCC Summit 2010
 
What has to be paid attention when reviewing code of the library you develop
What has to be paid attention when reviewing code of the library you developWhat has to be paid attention when reviewing code of the library you develop
What has to be paid attention when reviewing code of the library you develop
 
C Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer CentreC Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer Centre
 
C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#C# 101: Intro to Programming with C#
C# 101: Intro to Programming with C#
 
Static code analysis: what? how? why?
Static code analysis: what? how? why?Static code analysis: what? how? why?
Static code analysis: what? how? why?
 
Csdfsadf
CsdfsadfCsdfsadf
Csdfsadf
 
C
CC
C
 
C
CC
C
 

Mehr von 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
 
Le pentest pour les nuls #cybsec16
Le pentest pour les nuls #cybsec16Le pentest pour les nuls #cybsec16
Le pentest pour les nuls #cybsec16Cyber 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
 
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.0Cyber 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
 
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
 
Rump attaque usb_caralinda_fabrice
Rump attaque usb_caralinda_fabriceRump attaque usb_caralinda_fabrice
Rump attaque usb_caralinda_fabriceCyber Security Alliance
 
Asfws 2014 slides why .net needs ma-cs and other serial(-ization) tales_v2.0
Asfws 2014 slides why .net needs ma-cs and other serial(-ization) tales_v2.0Asfws 2014 slides why .net needs ma-cs and other serial(-ization) tales_v2.0
Asfws 2014 slides why .net needs ma-cs and other serial(-ization) tales_v2.0Cyber Security Alliance
 

Mehr von 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
 
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
 
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
 
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
 
Colt sp sec2014_appsec-nf-vfinal
Colt sp sec2014_appsec-nf-vfinalColt sp sec2014_appsec-nf-vfinal
Colt sp sec2014_appsec-nf-vfinal
 
Asfws2014 tproxy
Asfws2014 tproxyAsfws2014 tproxy
Asfws2014 tproxy
 
Asfws 2014 slides why .net needs ma-cs and other serial(-ization) tales_v2.0
Asfws 2014 slides why .net needs ma-cs and other serial(-ization) tales_v2.0Asfws 2014 slides why .net needs ma-cs and other serial(-ization) tales_v2.0
Asfws 2014 slides why .net needs ma-cs and other serial(-ization) tales_v2.0
 

KĂźrzlich hochgeladen

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 

KĂźrzlich hochgeladen (20)

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 

App secforum2014 andrivet-cplusplus11-metaprogramming_applied_to_software_obfuscation

  • 1. C+ +11 METAPROGRAMMING A P P L IED TO SOF TWARE OBFUSCAT ION SEBAST IEN ANDRIVET Application Security Forum - 2014 Western Switzerland 05-06 November 2014 Y-Parc / Yverdon-les-Bains http://www.appsec-forum.ch 1
  • 2. About me Senior Security Engineer a t SCRT (Swiss) Deve l o p e r a t ADVTOOLS (Swiss) Sebastien ANDRIVET Cyberfeminist & hack t i v i s t Reverse engineer Intel & ARM C + + , C , O b j - C , C # d e ve l o p e r Trainer ( iOS & Android appsec) 2
  • 4. Reverse engineering • Reverse engineering of an application if often like following the “white rabbit” • i.e. following string literals • Live demo • Reverse engineering of an application using IDA • Well-known MDM (Mobile Device Management) for iOS 4
  • 8. YES! It is also Katy Perry! • (almost) same semantics • obfuscated 8
  • 9. “Deliberate act of creating source or machine code difficult for humans to understand” –WIKIPEDIA, APRIL 2014 Obfuscation 9
  • 10. C++ templates • Example: Stack of objects OBJECT2 OBJECT1 • Push • Pop 10
  • 11. Without templates c l a s s Stack { v o i d p u s h (void* o b j e c t ) ; void* p o p ( ) ; } ; Stack singers; singers.push(britney); Stack apples; apples.push(macintosh); s i n g e r s apples • Reuse the same code (binary) • Only 1 instance of Stack class 11
  • 12. With C++ templates Stack<Singer> singers; singers.push(britney); Stack<Apple> apples; apples.push(macintosh); template<typename T> c l a s s Stack { Stack<Singers> Stack<Apples*> v o i d p u s h ( T o b j e c t ) ; T p o p ( ) ; s i n g e r s apples } ; 12
  • 13. With C++ templates Stack<Singer> singers; singers.push(britney); Stack<Apple> apples; apples.push(macintosh); Stack<Singers> Stack<Apples*> s i n g e r s apples 13
  • 14. C++ templates • Two instances of Stack class • One per type • Does not reuse code • By default • Permit optimisations based on types • For ex. reuse code for all pointers to objects • Type safety, verified at compile time 14
  • 15. Type safety • singers.push(apple); // compilation error • apples.push(U2); • may or may not work… 15
  • 16. Optimisation based on types • Generate different code based on types (template parameters) • Example: enable_if template<typename T> class MyClass { ... enable_if_t<is_pointer<T>::value, T> member_function(T t) { ... }; ... }; • member_function is only defined if T is a pointer type • (warning: C++14 code, not C++11) 16
  • 17. C++ metaprogramming • Programs that manipulate or produce programs • Subset of C++ • Turing-complete (~ full programming language) • Close to Functional programming • Part of C++ standards • Major enhancements in C++11 et C++14 17
  • 18. Application 1 - Strings literals obfuscation • original string is source code • original string in DEBUG builds • developer-friendly syntax • no trace of original string in compiled code in RELEASE builds 18
  • 19. 1st implementation template<int... Indexes> struct MetaString1 { constexpr MetaString1(const char* str) : buffer_ {encrypt(str[Indexes])...} { } const char* decrypt(); RUNTIME private: constexpr char encrypt(char c) const { return c ^ 0x55; } constexpr char decrypt(char c) const { return encrypt(c); } private: char buffer_[sizeof...(Indexes) + 1]; }; 19
  • 20. 1st implementation - Usage #define OBFUSCATED1(str) (MetaString1<0, 1, 2, 3, 4, 5>(str).decrypt()) cout << OBFUSCATED1(“Britney Spears”) << endl; 20
  • 21. 1st implementation - Problem • List of indexes is hard-coded • 0, 1, 2, 3, 4, 5 • As a consequence, strings are truncated! 21
  • 22. 2nd implementation • Generate a list of indexes with metaprogramming • C++14 introduces std:index_sequence • With C++11, we have to implement our own version • Very simplified • MakeIndex<N>::type generates: • Indexes<0, 1, 2, 3, …, N> 22
  • 23. 2nd implementation • Instead of: MetaString1<0, 1, 2, 3, 4, 5>(str) • we have: MetaString2<Make_Indexes<sizeof(str)-1>::type>(str) 23
  • 24. 2nd implementation - Usage cout << OBFUSCATED2(“Katy Perry”) << endl; • No more truncation 24
  • 25. 3rd implementation • In previous implementations, key is hard-coded constexpr char encrypt(char c) const { return c ^ 0x55; } • New template parameter for Key template<int... I, int K> struct MetaString3<Indexes<I...>, K> 25
  • 26. Generating (pseudo-) random numbers • C++11 includes <random>, but for runtime, not compile time • MetaRandom<N, M> N: Nth generated number M: Maximum value (excluded) • Linear congruential engine • Park-Miller (1988), “minimal standard” • Not exactly a uniform distribution (modulo operation) • Recursive 26
  • 27. Seed • template<> struct MetaRandomGenerator<0> { static const int value = seed; }; • How to choose an acceptable compile-time seed? • Macros (C & C++): • __TIME__: compilation time (standard) • __COUNTER__: incremented each time it is used (non-standard but well supported by compilers) 27
  • 28. 3rd implementation • Different key for each string • thanks to __COUNTER__ • Different keys for each compilation • thanks to __TIME__ • Sometimes not desirable: can give hints to attackers (differences between versions) 28
  • 29. 4th implementation • Different and random keys, great! • Why not go even further? • Choose a different encryption algorithm, randomly! 29
  • 30. 4th implementation • Template partial specialization • template<int A, int K, typename Indexes> struct MetaString4; • template<int K, int... I> struct MetaString4<0, K, Indexes<I...>> { … c ^ K … }; • template<int K, int... I> struct MetaString4<1, K, Indexes<I...>> { … c + K … }; • #define DEF_OBFUSCATED4(str) MetaString4<MetaRandom<__COUNTER__, 2>::value, … 30
  • 31. Result • Without obfuscation cout << "Britney Spears” << endl; • With obfuscation cout << OBFUSCATED4("Britney Spears") << endl; 31
  • 33. With obfuscation Encrypted characters (mixed with MOV) Decryption 33
  • 34. Application 2 - Obfuscate calls • How to obfuscate call such as: • function_to_protect(); • against static analysis (or even dynamic analysis)? 34
  • 35. Finite State Machine (simple example) 35
  • 36. Boost Meta State Machine (MSM) library types template parameter Compile time entity Generates code (FSM) at compile-time 36
  • 37. Result • Without obfuscation function_to_protect(“did”, “again”); • With obfuscation OBFUSCATED_CALL(function_to_protect, “did”, “again”); • Even better OBFUSCATED_CALL(function_to_protect, OBFUSCATED(“did”), OBFUSCATED(“again”)); 37
  • 40. Application 3: FSM + Debugger Detection • FSM • To fight against static analysis • Debugger detection • To fight against dynamic analysis 40
  • 41. Finite State Machine • Follows a different path depending of a predicate (Debugged or not Debugged, that is the question) 41
  • 42. More obfuscation • Obfuscate predicate result • Avoid simple “if”, too simple for reverse engineers • Make computation instead • If the example, counter is odd if predicate is false 42
  • 43. More obfuscation • Obfuscate function address • Otherwise, IDA is smart enough to get it • Simply make some computation on address • Using MetaRandom (like for strings obfuscation) 43
  • 44. Predicate • Debugger detection is only an example • In the example, implemented only for Mac OS X / iOS • Virtual environment detection • Jailbreak detection • Etc 44
  • 45. Compilers support Compiler Compatible Remark Apple LLVM 5.1 Yes Previous versions not tested Apple LLVM 6.0 Yes Xcode 6, 6.1 beta LLVM 3.4, 3.5 Yes Previous versions not tested GCC 4.8.2 or higher Yes Previous versions not tested Compile with -std=c++11 Intel C++ 2013 Yes Version 14.0.3 (2013 SP1 Update 3) Visual Studio 2013 No Lack of constexpr support Visual Studio 14 Almost Not far, lack init of arrays CTP3 tested 45
  • 47. Credits 47 • I take inspiration from many sources • In particular: • Samuel Neves & Filipe Araujo • LeFF (virus maker)
  • 48. Infos • @AndrivetSeb sebastien@andrivet.com • All code presented here is available on GitHub • https://github.com/andrivet/ADVobfuscator • Contains • obfuscator (in source) • examples • Whitepaper • BSD 3-clauses license 48