SlideShare a Scribd company logo
Object Oriented Code RE with
HexRaysCodeXplorer
Eugene Rodionov
@vxradius
Alex Matrosov
@matrosov
Agenda
* Object Oriented Code Reversing Challenges
-- virtual methods
-- templates
* Reversing Object Oriented Malware
-- Flamer
-- Sednit
* HexRaysCodeXplorer in use
Modern C++ Malware for Targeted Attacks
Why reversing C++ code
is a hard problem?
Virtual Methods & Templates
Virtual Methods
class Cat {
private:
int _weight;
public:
Cat(int weight) : _weight(weight) {};
int eat(int food) {
return _weight += food;
};
};
int _tmain(int argc, _TCHAR* argv[])
{
Cat* cat = new Cat(130);
int newWeigth = cat->eat(20);
}
class Animal {
protected:
int _weight;
public:
Animal(int weight) : _weight(weight) {};
virtual int eat(int food) = 0;
};
class Cat : Animal {
public:
Cat(int weight) : Animal(weight) {};
virtual int eat(int food) {
return _weight += food;
};
};
int _tmain(int argc, _TCHAR* argv[])
{
Animal* cat = new Cat(130);
int newWeight = cat->eat(20);
}
vs
Virtual Methods
class Cat {
private:
int _weight;
public:
Cat(int weight) : _weight(weight) {};
int eat(int food) {
return _weight += food;
};
};
int _tmain(int argc, _TCHAR* argv[])
{
Cat* cat = new Cat(130);
int newWeigth = cat->eat(20);
}
class Animal {
protected:
int _weight;
public:
Animal(int weight) : _weight(weight) {};
virtual int eat(int food) = 0;
};
class Cat : Animal {
public:
Cat(int weight) : Animal(weight) {};
virtual int eat(int food) {
return _weight += food;
};
};
int _tmain(int argc, _TCHAR* argv[])
{
Animal* cat = new Cat(130);
int newWeight = cat->eat(20);
}
vs
Virtual Function Tables
Class A
vfPtr
attr_1
attr_2
A::vfTable
A::a1()
A::a2()
A::a3()
RTTI Object
Locator
signature
pTypeDescriptor
pClassDescriptor
meta
Virtual Function Tables
Class A
vfPtr
attr_1
attr_2
A::vfTable
A::a1()
A::a2()
A::a3()
RTTI Object
Locator
signature
pTypeDescriptor
pClassDescriptor
meta
Virtual Function Tables
* lead to indirect method calls
-- difficult to analyze statically
* initialized in constructors
-- need to track back object creation
C++ Templates
* extra code to analyze
-- another way to create polymorphic types
* problematic to recognize standard library
code (FLIRT)
-- playing with compiler optimization
options
std::vector<int> std::vector<char>
std::vector<std::string> std::vector<custom_type>
C++ Code Reconstruction Problems
* Object identification
-- type reconstruction
* Class layout reconstruction
-- Identify constructors/destructors
-- Identify class members
-- Local/global type reconstruction
-- Associate object with exact method calls
* RTTI reconstruction
-- vftable reconstruction
-- Associate vftable object with exact object
-- class hierarchy reconstruction
Reversing Object
Oriented Malware
Practical Approaches: REconstructing Flamer Framework
REconstructing Flamer Framework
Vector<Command Executor>
DB_Query ClanCmd
Vector<Task>
IDLER CmdExec
Vector<DelayedTasks>
Euphoria
Share
Supplier
Vector<Consumer>
Mobile
Consumer
Cmd
Consumer
MunchSniffer FileFinder
FileCollect Driller GetConfig
LSS
Sender
Frog Beetlejuice
Lua
Consumer
Media
Consumer
http://www.welivesecurity.com/2012/08/02/flamer-analysis-framework-reconstruction/
REconstructing Flamer Framework
Vector<Command Executor>
DB_Query ClanCmd
Vector<Task>
IDLER CmdExec
Vector<DelayedTasks>
Euphoria
Share
Supplier
Vector<Consumer>
Mobile
Consumer
Cmd
Consumer
MunchSniffer FileFinder
FileCollect Driller GetConfig
LSS
Sender
Frog Beetlejuice
Lua
Consumer
Media
Consumer
http://www.welivesecurity.com/2012/08/02/flamer-analysis-framework-reconstruction/
Identifying Used Types
* Smart pointers
* Strings
* Vectors to maintain objects
* Custom data types:
-- tasks
-- triggers
-- and etc.
Data Types Being Used: Smart pointers
struct SMART_PTR
{
void *pObject; // pointer to the object
int *RefNo; // reference counter
};
Data Types Being Used: Smart pointers
Data Types Being Used: Vectors
struct VECTOR
{
void *vTable; // pointer to the virtual table
int NumberOfItems; // self-explanatory
int MaxSize; // self-explanatory
void *vector; // pointer to buffer with elements
};
* Used for handling objects:
-- tasks
-- triggers
Data Types Being Used: Strings
struct USTRING_STRUCT
{
void *vTable; // pointer to the table
int RefNo; // reference counter
int Initialized;
wchar_t *UnicodeBuffer; // pointer to unicode string
char *AsciiBuffer; // pointer to ASCII string
int AsciiLength; // length of the ASCII string
int Reserved;
int Length; // Length of unicode string
int LengthMax; // Size of UnicodeBuffer
};
Approaching Flamer
* Identify Object Constructors
* Reconstruct Object
Attributes
* Reconstruct Object Methods
Type
reconstruction
Control Flow Graph
Reconstruction
Identifying Object Constructors
REconstructing Object’s Attributes
REconstructing Object’s Attributes
REconstructing Object’s Methods
REconstructing Object’s Methods
REconstructing Object’s Methods
Reversing Object
Oriented Malware
Practical Approaches: REconstructing XAgent Framework
XAgent Framework
Communication Channels
Vector<IAgentChannel>
AgentKernel
Local
Storage
Cryptor
Agent Modules
Vector<IAgentModule>
AgentKernel
Module
FileSystem
Channel
Controller
DNameNode
Module
Remote
KeyLogger
Process
Retranslator
Module
WinHttp
http://www.welivesecurity.com/2014/10/08/sednit-espionage-group-now-using-custom-exploit-kit/
Object Interconnection: IAgentModule
struct IAgentModule {
LPVOID receiveMessage;
LPVOID sendMessage;
LPVOID getModuleId;
LPVOID setModuleId;
LPVOID executeModule;
};
AgentKernel
Module
FileSystem
Module
Remote
Keylogger
Process
Retranslator
Module
IAgentModule
Exploring RTTI*
* recover type names
* reconstruct class hierarchy
* identify object virtual function tables
* IDA ClassInformer plugin
Exploring RTTI*
* recover type names
* reconstruct class hierarchy
* identify object virtual function tables
* IDA ClassInformer plugin
XAgent: LocalDataStorage
Local
DataStorage
Registry
reader/writer
File
reader/writer
XAgent: Cryptor
XAgent: Cryptor
encrypted message
salt
(4 bytes)
RC4key
plain text
XAgent: IReservedApi
XAgent: Identifying Used Types
* Strings: std::string
* Containers to maintain objects:
-- std::vector
-- std::list
XAgent: Identifying Used Types
* Strings: std::string
* Containers to maintain objects:
-- std::vector
-- std::list
HexRaysCodeXplorer
HexRaysCodeXplorer since 2013
* CodeXplorer V1.0 released
on REcon’2013
* First third-party plugin
for Hex-Rays Decompiler
* v1.0 supports IDA v6.4 and
Decompiler for x86 v1.8
HexRaysCodeXplorer Features
* Hex-Rays decompiler plugin x86/x64
* The plugin was designed to facilitate static analysis of:
-- object oriented code
-- position independent code
* The plugin allows to:
-- partially reconstruct object type
-- navigate through decompiled virtual methods
Hex-Rays Decompiler Plugin SDK
* At the heart of the decompiler lies ctree structure:
-- syntax tree structure
-- consists of citem_t objects
-- there are 9 maturity levels of the ctree structure
* Type citem_t is a base class for:
-- cexpr_t – expression type
-- cinsn_t – statement type
* Expressions have attached type information
* Statements include:
-- block, if, for, while, do, switch, return, goto, asm
* Hex-Rays provides iterators for traversing the citem_t objects within
ctree structure:
-- ctree_visitor_t, ctree_parentee_t
Hex-Rays Decompiler Plugin SDK
citem_t
cexpr_t cinsn_t
* Type citem_t is a base class for:
-- cexpr_t – expression type
-- cinsn_t – statement type
* Expressions have attached type information
* Statements include:
-- block, if, for, while, do, switch, return, goto, asm
* Hex-Rays provides iterators for traversing the citem_t objects within
ctree structure:
-- ctree_visitor_t, ctree_parentee_t
Hex-Rays Decompiler Plugin SDK
citem_t
cexpr_t cinsn_t
DEMO time :)
HexRaysCodeXplorer: Gapz Position Independent Code
HexRaysCodeXplorer: Virtual Methods
IDA’s ‘Local Types’ is used to represent
object type
HexRaysCodeXplorer: Virtual Methods
IDA’s ‘Local Types’ is used to represent
object type
HexRaysCodeXplorer: Virtual Methods
* Hex-Rays decompiler plugin is used to navigate through the
virtual methods
HexRaysCodeXplorer: Object Type REconstruction
* Hex-Rays’s ctree structure may be used to partially
reconstruct object type
* Input:
-- pointer to the object instance
-- object initialization routine entry point
* Output:
-- C structure-like object representation
HexRaysCodeXplorer: Object Type REconstruction
* citem_t objects:
-- memptr, idx, memref
-- call, ptr, asg
HexRaysCodeXplorer: Object Type REconstruction
* citem_t objects:
-- memptr, idx, memref
-- call, ptr, asg
HexRaysCodeXplorer: Object Type REconstruction
// reference of DWORD at offset 12 in buffer a1
*(DWORD *)(a1 + 12) = 0xEFCDAB89;
HexRaysCodeXplorer: v1.7 [NSEC Edition]
Automatic virtual table identification
+
Type reconstruction
HexRaysCodeXplorer: v1.7 [NSEC Edition]
* Automatic virtual table identification
HexRaysCodeXplorer: v1.7 [NSEC Edition]
* Automatic virtual table identification
HexRaysCodeXplorer: v1.7 [NSEC Edition]
* Automatic virtual table identification
* Support for IDA Pro x64
* Bugfixes
DEMO time :)
HexRaysCodeXplorer: Next plans
* Switch to IdaPython
Why python?
HexRaysCodeXplorer: Next plans
* Switch to IdaPython
* Further research & development:
-- find cross-references to
object attributes
-- handling nested structures
-- code similarity based on data
flow analysis
Thank you for your attention!
http://REhints.com
@Rehints
https://github.com/REhints/HexRaysCodeXplorer

More Related Content

PDF
25 años de conciertos de rock en albox.doc
PPTX
Frases Motivacionais
PDF
Introduction-to-Jib-Cranes.pdf
PPTX
Lição 2 - Promessas de Deus para Israel.pptx
PPTX
Win32/Duqu: involution of Stuxnet
PDF
Reconstructing Gapz: Position-Independent Code Analysis Problem
PDF
Festi botnet analysis and investigation
PDF
Defeating x64: The Evolution of the TDL Rootkit
25 años de conciertos de rock en albox.doc
Frases Motivacionais
Introduction-to-Jib-Cranes.pdf
Lição 2 - Promessas de Deus para Israel.pptx
Win32/Duqu: involution of Stuxnet
Reconstructing Gapz: Position-Independent Code Analysis Problem
Festi botnet analysis and investigation
Defeating x64: The Evolution of the TDL Rootkit

Viewers also liked (20)

PPTX
Modern malware techniques for attacking RBS systems in Russia
PDF
HexRaysCodeXplorer: make object-oriented RE easier
PDF
Modern Bootkit Trends: Bypassing Kernel-Mode Signing Policy
PDF
Advanced Evasion Techniques by Win32/Gapz
PPTX
Проведение криминалистической экспертизы и анализа руткит-программ на примере...
PDF
Carberp Evolution and BlackHole: Investigation Beyond the Event Horizon
PDF
BERserk: New RSA Signature Forgery Attack
DOCX
42054960
PDF
Smartcard vulnerabilities in modern banking malware
PDF
インテルMEの秘密 - チップセットに隠されたコードと、それが一体何をするかを見出す方法 - by イゴール・スコチンスキー - Igor Skochinsky
PPTX
Defeating x64: Modern Trends of Kernel-Mode Rootkits
PDF
Bootkits: past, present & future
PDF
Win32/Flamer: Reverse Engineering and Framework Reconstruction
PDF
Cybercrime in Russia: Trends and Issues
PDF
HexRaysCodeXplorer: object oriented RE for fun and profit
PDF
BIOS and Secure Boot Attacks Uncovered
PPTX
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
PDF
Visiting the Bear Den
PDF
CSW2017 Yuhao song+Huimingliu cyber_wmd_vulnerable_IoT
PDF
Моделирование угроз для BIOS и UEFI
Modern malware techniques for attacking RBS systems in Russia
HexRaysCodeXplorer: make object-oriented RE easier
Modern Bootkit Trends: Bypassing Kernel-Mode Signing Policy
Advanced Evasion Techniques by Win32/Gapz
Проведение криминалистической экспертизы и анализа руткит-программ на примере...
Carberp Evolution and BlackHole: Investigation Beyond the Event Horizon
BERserk: New RSA Signature Forgery Attack
42054960
Smartcard vulnerabilities in modern banking malware
インテルMEの秘密 - チップセットに隠されたコードと、それが一体何をするかを見出す方法 - by イゴール・スコチンスキー - Igor Skochinsky
Defeating x64: Modern Trends of Kernel-Mode Rootkits
Bootkits: past, present & future
Win32/Flamer: Reverse Engineering and Framework Reconstruction
Cybercrime in Russia: Trends and Issues
HexRaysCodeXplorer: object oriented RE for fun and profit
BIOS and Secure Boot Attacks Uncovered
AMSI: How Windows 10 Plans to Stop Script-Based Attacks and How Well It Does It
Visiting the Bear Den
CSW2017 Yuhao song+Huimingliu cyber_wmd_vulnerable_IoT
Моделирование угроз для BIOS и UEFI
Ad

Similar to Object Oriented Code RE with HexraysCodeXplorer (20)

PDF
Aleksandr Matrosov, Eugene Rodionov - HexRaysCodeXplorer make object-oriented...
PDF
Matrosov, rodionov win32 flamer. reverse engineering and framework reconstr...
PDF
Half-automatic Compilable Source Code Recovery
PPTX
The Great and Mighty C++
PDF
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
PDF
Effective Object Oriented Design in Cpp
PDF
Bjarne essencegn13
PDF
C++ Training
PDF
[E-Dev-Day 2014][5/16] C++ and JavaScript bindings for EFL and Elementary
PDF
How to make a large C++-code base manageable
PDF
C++ Interview Questions and Answers PDF By ScholarHat
PPT
PPTX
C++ language
PDF
Virtual Machines
PDF
Std c notes_03
PDF
Pharo: a reflective language A first systematic analysis of reflective APIs
PDF
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
PDF
Антон Бикинеев, Reflection in C++Next
PDF
L10
PDF
OOP LAB MANUAL BTECH 3RD SEMESTER2023-24.pdf
Aleksandr Matrosov, Eugene Rodionov - HexRaysCodeXplorer make object-oriented...
Matrosov, rodionov win32 flamer. reverse engineering and framework reconstr...
Half-automatic Compilable Source Code Recovery
The Great and Mighty C++
C++ CoreHard Autumn 2018. Debug C++ Without Running - Anastasia Kazakova
Effective Object Oriented Design in Cpp
Bjarne essencegn13
C++ Training
[E-Dev-Day 2014][5/16] C++ and JavaScript bindings for EFL and Elementary
How to make a large C++-code base manageable
C++ Interview Questions and Answers PDF By ScholarHat
C++ language
Virtual Machines
Std c notes_03
Pharo: a reflective language A first systematic analysis of reflective APIs
Kernel Recipes 2019 - Hunting and fixing bugs all over the Linux kernel
Антон Бикинеев, Reflection in C++Next
L10
OOP LAB MANUAL BTECH 3RD SEMESTER2023-24.pdf
Ad

Recently uploaded (20)

PPTX
OOP with Java - Java Introduction (Basics)
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
PPTX
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
PPTX
Welding lecture in detail for understanding
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PPTX
web development for engineering and engineering
PDF
PPT on Performance Review to get promotions
PPTX
Geodesy 1.pptx...............................................
PPTX
Strings in CPP - Strings in C++ are sequences of characters used to store and...
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Arduino robotics embedded978-1-4302-3184-4.pdf
PDF
Structs to JSON How Go Powers REST APIs.pdf
PPT
Project quality management in manufacturing
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
Construction Project Organization Group 2.pptx
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
OOP with Java - Java Introduction (Basics)
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
Recipes for Real Time Voice AI WebRTC, SLMs and Open Source Software.pptx
Welding lecture in detail for understanding
Embodied AI: Ushering in the Next Era of Intelligent Systems
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
web development for engineering and engineering
PPT on Performance Review to get promotions
Geodesy 1.pptx...............................................
Strings in CPP - Strings in C++ are sequences of characters used to store and...
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
bas. eng. economics group 4 presentation 1.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Arduino robotics embedded978-1-4302-3184-4.pdf
Structs to JSON How Go Powers REST APIs.pdf
Project quality management in manufacturing
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Construction Project Organization Group 2.pptx
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx

Object Oriented Code RE with HexraysCodeXplorer

  • 1. Object Oriented Code RE with HexRaysCodeXplorer Eugene Rodionov @vxradius Alex Matrosov @matrosov
  • 2. Agenda * Object Oriented Code Reversing Challenges -- virtual methods -- templates * Reversing Object Oriented Malware -- Flamer -- Sednit * HexRaysCodeXplorer in use
  • 3. Modern C++ Malware for Targeted Attacks
  • 4. Why reversing C++ code is a hard problem? Virtual Methods & Templates
  • 5. Virtual Methods class Cat { private: int _weight; public: Cat(int weight) : _weight(weight) {}; int eat(int food) { return _weight += food; }; }; int _tmain(int argc, _TCHAR* argv[]) { Cat* cat = new Cat(130); int newWeigth = cat->eat(20); } class Animal { protected: int _weight; public: Animal(int weight) : _weight(weight) {}; virtual int eat(int food) = 0; }; class Cat : Animal { public: Cat(int weight) : Animal(weight) {}; virtual int eat(int food) { return _weight += food; }; }; int _tmain(int argc, _TCHAR* argv[]) { Animal* cat = new Cat(130); int newWeight = cat->eat(20); } vs
  • 6. Virtual Methods class Cat { private: int _weight; public: Cat(int weight) : _weight(weight) {}; int eat(int food) { return _weight += food; }; }; int _tmain(int argc, _TCHAR* argv[]) { Cat* cat = new Cat(130); int newWeigth = cat->eat(20); } class Animal { protected: int _weight; public: Animal(int weight) : _weight(weight) {}; virtual int eat(int food) = 0; }; class Cat : Animal { public: Cat(int weight) : Animal(weight) {}; virtual int eat(int food) { return _weight += food; }; }; int _tmain(int argc, _TCHAR* argv[]) { Animal* cat = new Cat(130); int newWeight = cat->eat(20); } vs
  • 7. Virtual Function Tables Class A vfPtr attr_1 attr_2 A::vfTable A::a1() A::a2() A::a3() RTTI Object Locator signature pTypeDescriptor pClassDescriptor meta
  • 8. Virtual Function Tables Class A vfPtr attr_1 attr_2 A::vfTable A::a1() A::a2() A::a3() RTTI Object Locator signature pTypeDescriptor pClassDescriptor meta
  • 9. Virtual Function Tables * lead to indirect method calls -- difficult to analyze statically * initialized in constructors -- need to track back object creation
  • 10. C++ Templates * extra code to analyze -- another way to create polymorphic types * problematic to recognize standard library code (FLIRT) -- playing with compiler optimization options std::vector<int> std::vector<char> std::vector<std::string> std::vector<custom_type>
  • 11. C++ Code Reconstruction Problems * Object identification -- type reconstruction * Class layout reconstruction -- Identify constructors/destructors -- Identify class members -- Local/global type reconstruction -- Associate object with exact method calls * RTTI reconstruction -- vftable reconstruction -- Associate vftable object with exact object -- class hierarchy reconstruction
  • 12. Reversing Object Oriented Malware Practical Approaches: REconstructing Flamer Framework
  • 13. REconstructing Flamer Framework Vector<Command Executor> DB_Query ClanCmd Vector<Task> IDLER CmdExec Vector<DelayedTasks> Euphoria Share Supplier Vector<Consumer> Mobile Consumer Cmd Consumer MunchSniffer FileFinder FileCollect Driller GetConfig LSS Sender Frog Beetlejuice Lua Consumer Media Consumer http://www.welivesecurity.com/2012/08/02/flamer-analysis-framework-reconstruction/
  • 14. REconstructing Flamer Framework Vector<Command Executor> DB_Query ClanCmd Vector<Task> IDLER CmdExec Vector<DelayedTasks> Euphoria Share Supplier Vector<Consumer> Mobile Consumer Cmd Consumer MunchSniffer FileFinder FileCollect Driller GetConfig LSS Sender Frog Beetlejuice Lua Consumer Media Consumer http://www.welivesecurity.com/2012/08/02/flamer-analysis-framework-reconstruction/
  • 15. Identifying Used Types * Smart pointers * Strings * Vectors to maintain objects * Custom data types: -- tasks -- triggers -- and etc.
  • 16. Data Types Being Used: Smart pointers struct SMART_PTR { void *pObject; // pointer to the object int *RefNo; // reference counter };
  • 17. Data Types Being Used: Smart pointers
  • 18. Data Types Being Used: Vectors struct VECTOR { void *vTable; // pointer to the virtual table int NumberOfItems; // self-explanatory int MaxSize; // self-explanatory void *vector; // pointer to buffer with elements }; * Used for handling objects: -- tasks -- triggers
  • 19. Data Types Being Used: Strings struct USTRING_STRUCT { void *vTable; // pointer to the table int RefNo; // reference counter int Initialized; wchar_t *UnicodeBuffer; // pointer to unicode string char *AsciiBuffer; // pointer to ASCII string int AsciiLength; // length of the ASCII string int Reserved; int Length; // Length of unicode string int LengthMax; // Size of UnicodeBuffer };
  • 20. Approaching Flamer * Identify Object Constructors * Reconstruct Object Attributes * Reconstruct Object Methods Type reconstruction Control Flow Graph Reconstruction
  • 27. Reversing Object Oriented Malware Practical Approaches: REconstructing XAgent Framework
  • 28. XAgent Framework Communication Channels Vector<IAgentChannel> AgentKernel Local Storage Cryptor Agent Modules Vector<IAgentModule> AgentKernel Module FileSystem Channel Controller DNameNode Module Remote KeyLogger Process Retranslator Module WinHttp http://www.welivesecurity.com/2014/10/08/sednit-espionage-group-now-using-custom-exploit-kit/
  • 29. Object Interconnection: IAgentModule struct IAgentModule { LPVOID receiveMessage; LPVOID sendMessage; LPVOID getModuleId; LPVOID setModuleId; LPVOID executeModule; }; AgentKernel Module FileSystem Module Remote Keylogger Process Retranslator Module IAgentModule
  • 30. Exploring RTTI* * recover type names * reconstruct class hierarchy * identify object virtual function tables * IDA ClassInformer plugin
  • 31. Exploring RTTI* * recover type names * reconstruct class hierarchy * identify object virtual function tables * IDA ClassInformer plugin
  • 34. XAgent: Cryptor encrypted message salt (4 bytes) RC4key plain text
  • 36. XAgent: Identifying Used Types * Strings: std::string * Containers to maintain objects: -- std::vector -- std::list
  • 37. XAgent: Identifying Used Types * Strings: std::string * Containers to maintain objects: -- std::vector -- std::list
  • 39. HexRaysCodeXplorer since 2013 * CodeXplorer V1.0 released on REcon’2013 * First third-party plugin for Hex-Rays Decompiler * v1.0 supports IDA v6.4 and Decompiler for x86 v1.8
  • 40. HexRaysCodeXplorer Features * Hex-Rays decompiler plugin x86/x64 * The plugin was designed to facilitate static analysis of: -- object oriented code -- position independent code * The plugin allows to: -- partially reconstruct object type -- navigate through decompiled virtual methods
  • 41. Hex-Rays Decompiler Plugin SDK * At the heart of the decompiler lies ctree structure: -- syntax tree structure -- consists of citem_t objects -- there are 9 maturity levels of the ctree structure
  • 42. * Type citem_t is a base class for: -- cexpr_t – expression type -- cinsn_t – statement type * Expressions have attached type information * Statements include: -- block, if, for, while, do, switch, return, goto, asm * Hex-Rays provides iterators for traversing the citem_t objects within ctree structure: -- ctree_visitor_t, ctree_parentee_t Hex-Rays Decompiler Plugin SDK citem_t cexpr_t cinsn_t
  • 43. * Type citem_t is a base class for: -- cexpr_t – expression type -- cinsn_t – statement type * Expressions have attached type information * Statements include: -- block, if, for, while, do, switch, return, goto, asm * Hex-Rays provides iterators for traversing the citem_t objects within ctree structure: -- ctree_visitor_t, ctree_parentee_t Hex-Rays Decompiler Plugin SDK citem_t cexpr_t cinsn_t
  • 46. HexRaysCodeXplorer: Virtual Methods IDA’s ‘Local Types’ is used to represent object type
  • 47. HexRaysCodeXplorer: Virtual Methods IDA’s ‘Local Types’ is used to represent object type
  • 48. HexRaysCodeXplorer: Virtual Methods * Hex-Rays decompiler plugin is used to navigate through the virtual methods
  • 49. HexRaysCodeXplorer: Object Type REconstruction * Hex-Rays’s ctree structure may be used to partially reconstruct object type * Input: -- pointer to the object instance -- object initialization routine entry point * Output: -- C structure-like object representation
  • 50. HexRaysCodeXplorer: Object Type REconstruction * citem_t objects: -- memptr, idx, memref -- call, ptr, asg
  • 51. HexRaysCodeXplorer: Object Type REconstruction * citem_t objects: -- memptr, idx, memref -- call, ptr, asg
  • 52. HexRaysCodeXplorer: Object Type REconstruction // reference of DWORD at offset 12 in buffer a1 *(DWORD *)(a1 + 12) = 0xEFCDAB89;
  • 53. HexRaysCodeXplorer: v1.7 [NSEC Edition] Automatic virtual table identification + Type reconstruction
  • 54. HexRaysCodeXplorer: v1.7 [NSEC Edition] * Automatic virtual table identification
  • 55. HexRaysCodeXplorer: v1.7 [NSEC Edition] * Automatic virtual table identification
  • 56. HexRaysCodeXplorer: v1.7 [NSEC Edition] * Automatic virtual table identification * Support for IDA Pro x64 * Bugfixes
  • 58. HexRaysCodeXplorer: Next plans * Switch to IdaPython
  • 60. HexRaysCodeXplorer: Next plans * Switch to IdaPython * Further research & development: -- find cross-references to object attributes -- handling nested structures -- code similarity based on data flow analysis
  • 61. Thank you for your attention! http://REhints.com @Rehints https://github.com/REhints/HexRaysCodeXplorer