SlideShare a Scribd company logo
H2HC
Hackers to Hackers Conference
R3MF – R3v3rs1ng on
Mach-O File
Ricardo L0gan
Security Specialist with over 15 years of
experience, malware research enthusiastic,
pentest and reverse engineering. I’ve a solid
knowledge on topics like network security,
hardening and tuning across multiple platforms
such as Windows, Linux, OS X and Cisco.
Beginner in programming languages as Python, C
and Assembly.
In Brazil, I contribute with some security
conferences organizations such as SlackShow
Community, bSides SP and Hackers to Hackers
Conference (H2HC).
Member # RTFM 💀 C○||cL/V€ #
### Long live Open Source - Use Linux (Slackware) ###
$Whoami
0x00 Motivation of Research
0x01 The Mach-O Format
0x02 Demo I (crackme)
0x03 Tricks for Reversing
0x04 Demo II (malware)
0x05 Conclusions / Q & (MAYBE 0/) A
Agenda
0x00 Motivation Of Research
For Fun ;) 0/
- Malware
- Crackmes
- Vulnerability Hunting
0x00 Motivation Of Research
0x00 Motivation Of Research
Source: www.virustotal.com 17/11/2016
0x00 Motivation Of Research
.OSA --> ZIP:
 PremierOpinion
 upgrade.xml
Mac.BackDoor.OpinionSpy.3
Names: MacOS_X/OpinionSpy.A (Microsoft),
Mac.BackDoor.OpinionSpy.3 (F-Secure),
Mac.BackDoor.OpinionSpy.3 (Trend)
OSX_KAITEN.A
Names: MacOS_X/Tsunami.A (Microsoft),
OSX/Tsunami (McAfee),
OSX/Tsunami-Gen (Sophos),
OSX/Tsunami.A (F-Secure),
OSX_CARETO.A
Names: MacOS:Appetite-A [Trj] (Avast)
OSX/BackDoor.A (AVG)
Trojan.OSX.Melgato.a (Kaspersky)
OSX/Backdoor-BRE (McAfee)
Backdoor:MacOS_X/Appetite.A (Microsoft)
OSX/Appetite-A (Sophos)
Binary:
/tmp/.z
itunes212.{BLOCKED}pdt.com
0x01 The Mach-o Format
The mach-o is a Universal (fat) binaries (for i386
x86_64 ppc ppc64 armv6 armv7), this format was adopted as
the standard in OS X from version 10.6 on.
We are currently in version 10.11.5 (El Capitan)
10.12 MacOS Sierra
Binary (Linux)
Binary (Windows)
Binary (OS X)
0x01 The Mach-o Format
0x01 The Mach-o Format
Magic Number: File Signatures
0x01 The Mach-o Format
0x01 The Mach-o Format
Structs on File:
- Code is located in __TEXT section.
- Linked libraries in LC_LOAD_DYLIB commands.
- The entrypoint is defined at LC_UNIXTHREAD or LC_THREAD.
0x01 The Mach-o Format HEADER
LOAD_COMMANDS
0x01 The Mach-o Format
SECTIONS
0x01 The Mach-o Format
0x01 The Mach-o Format
Cross Compiling
Building a mach-o file supported
by multiple platforms.
0x01 The Mach-o Format
0x01 The Mach-o Format
0x01 The Mach-o Format
0x01 The Mach-o Format
0x01 The Mach-o Format
0x02 Demo I
Demo 01 Crackme
Binary: cryptorev
Level: easy
Detail: cryptorev is a binary mach-o the goal
is run binary and found the flag.
This demo don’t have protection in this code
just UPX (packer) and DEADBEEF in file ;)
0x03 Tricks for Reversing
When talking about malwares we have a lot of
techniques to make it difficult to analyze
(reversing the sample) like:
- Anti-Disassembly
- Anti-Debugging
- Obfuscation
- Anti-Vm
Good Research about this:
https://www.blackhat.com/docs/us-14/materials/us-14-Branco-Prevalent-
Characteristics-In-Modern-Malware.pdf
0x03 Tricks for Reversing
Static Analysis
file -> determine file type
upx / binwalk -> compress or expand executable files
strings -> find the printable strings in a object, or other binary, file
strip -> remove symbols
hexEdit -> hex editor
Lipo -> create or operate on universal files
otool -> object file displaying tool like a objdump and ldd
nm -> display name list (symbol table)
codesign -> create and manipulate code signatures
machOView -> visual Mach-O file browser
class-dump -> utility for examining the Objective-C runtime information stored in
Mach-O files.
dtrace -> generic front-end to the DTrace facility
fs_usage -> report system calls and page faults related to filesystem activity in
real-time
xattr -> display and manipulate extended attributes
0x03 Tricks for Reversing
0x03 Tricks for Reversing
Dynamic Analysis
Xcode -> xcode is an (IDE) containing a suite of software development.
iDA Pro -> disassembler and debugger.
hopper -> tool used for disassemble, and decompile your 32/64bits mach-o
file.
lldb -> debugger
fseventer -> disk activity tool with a good graphical representation and
solid filter tool.
open snoop -> snoop file opens as they occur. Uses DTrace.
activity Monitor -> tool to help you keep your system in good shape.
procoxp -> It's a simple tool like a top get information accessible
by proc_info
tcpdump -> for dump and analisys traffic on a network
wireshark -> for dump and analisys traffic on a network
lsock -> based on PF_SYSTEM provider, you can get real time notifications
of socket activity like TCPView from SysInternals.
little Snitch -> network traffic monitoring and control.
On March 2016 appear the first Ransomware writing for
mach-o file on OSX System (KeRanger), Distributed by
client BitTorrent Transmission (v.2.90) This threat
has been fixed in version v.2.91 the client.
The latest version Gatekeeper OSX already block this
ransomware since the first sample published 0/!!!
0x04 Demo II
Demo 02 Ransomware Keranger
Hacking is a way of life
Reference
REVERSE Engineering Mac Malware - Defcon 22
https://www.defcon.org/images/defcon-22/dc-22-
presentations/Edwards/DEFCON-22-Sarah-Edwards-Reverse-
Engineering-Mac-Malware.pdf
OS X ABI Mach-O File Format Reference
https://developer.apple.com/library/mac/documentation/DeveloperT
ools/Conceptual/MachORuntime/index.html
Calling Convention
http://www.agner.org/optimize/calling_conventions.pdf
Thanks for my wife and brothers (Rubira, Gabriel Negreiros, C00ler,
Slayer, Ygor-r0gy)
0x05 Conclusions
Question &(MAYBE ;) 0/)Answer
Contact: ricardologanbr@gmail.com
@l0ganbr

More Related Content

Similar to H2HC - R3MF

Nullbyte 6ed. 2019
Nullbyte 6ed. 2019Nullbyte 6ed. 2019
Nullbyte 6ed. 2019
Ricardo L0gan
 
Intrusion Techniques
Intrusion TechniquesIntrusion Techniques
Intrusion Techniques
Festival Software Livre
 
Assingment 5 - ENSA
Assingment 5 - ENSAAssingment 5 - ENSA
Assingment 5 - ENSA
Jeewanthi Fernando
 
Mmw mac malware-mac
Mmw mac malware-macMmw mac malware-mac
Mmw mac malware-mac
Cyphort
 
Tricky sample? Hack it easy! Applying dynamic binary inastrumentation to ligh...
Tricky sample? Hack it easy! Applying dynamic binary inastrumentation to ligh...Tricky sample? Hack it easy! Applying dynamic binary inastrumentation to ligh...
Tricky sample? Hack it easy! Applying dynamic binary inastrumentation to ligh...
Maksim Shudrak
 
Latinoware 2015 Mach-O
Latinoware 2015 Mach-OLatinoware 2015 Mach-O
Latinoware 2015 Mach-O
Ricardo L0gan
 
Bsides Tampa Blue Team’s tool dump.
Bsides Tampa Blue Team’s tool dump.Bsides Tampa Blue Team’s tool dump.
Bsides Tampa Blue Team’s tool dump.
Alexander Kot
 
Malware's Most Wanted: Linux and Internet of Things Malware
Malware's Most Wanted: Linux and Internet of Things MalwareMalware's Most Wanted: Linux and Internet of Things Malware
Malware's Most Wanted: Linux and Internet of Things Malware
Cyphort
 
Threats, Vulnerabilities & Security measures in Linux
Threats, Vulnerabilities & Security measures in LinuxThreats, Vulnerabilities & Security measures in Linux
Threats, Vulnerabilities & Security measures in Linux
Amitesh Bharti
 
Webinar alain-2009-03-04-clamav
Webinar alain-2009-03-04-clamavWebinar alain-2009-03-04-clamav
Webinar alain-2009-03-04-clamav
thc2cat
 
BSides IR in Heterogeneous Environment
BSides IR in Heterogeneous EnvironmentBSides IR in Heterogeneous Environment
BSides IR in Heterogeneous Environment
Stefano Maccaglia
 
The Log4Shell Vulnerability – explained: how to stay secure
The Log4Shell Vulnerability – explained: how to stay secureThe Log4Shell Vulnerability – explained: how to stay secure
The Log4Shell Vulnerability – explained: how to stay secure
Kaspersky
 
DEFCON 27 - ALEXANDRE BORGES - dot net malware threats
DEFCON 27 - ALEXANDRE BORGES - dot net malware threatsDEFCON 27 - ALEXANDRE BORGES - dot net malware threats
DEFCON 27 - ALEXANDRE BORGES - dot net malware threats
Felipe Prado
 
LO-PHI: Low-Observable Physical Host Instrumentation for Malware Analysis
LO-PHI: Low-Observable Physical Host Instrumentation for Malware AnalysisLO-PHI: Low-Observable Physical Host Instrumentation for Malware Analysis
LO-PHI: Low-Observable Physical Host Instrumentation for Malware Analysis
Pietro De Nicolao
 
Strategies to design FUD malware
Strategies to design FUD malwareStrategies to design FUD malware
Strategies to design FUD malware
Pedro Tavares
 
Hacking Exposed: The Mac Attack
Hacking Exposed: The Mac AttackHacking Exposed: The Mac Attack
Hacking Exposed: The Mac Attack
Priyanka Aash
 
Hacking Exposed: The Mac Attack
Hacking Exposed: The Mac AttackHacking Exposed: The Mac Attack
Hacking Exposed: The Mac Attack
Priyanka Aash
 
Ceh v5 module 18 linux hacking
Ceh v5 module 18 linux hackingCeh v5 module 18 linux hacking
Ceh v5 module 18 linux hacking
Vi Tính Hoàng Nam
 
Understanding Malware Lateral Spread Used in High Value Attacks
Understanding Malware Lateral Spread Used in High Value AttacksUnderstanding Malware Lateral Spread Used in High Value Attacks
Understanding Malware Lateral Spread Used in High Value Attacks
Cyphort
 
G3t R00t at IUT
G3t R00t at IUTG3t R00t at IUT
G3t R00t at IUT
Nahidul Kibria
 

Similar to H2HC - R3MF (20)

Nullbyte 6ed. 2019
Nullbyte 6ed. 2019Nullbyte 6ed. 2019
Nullbyte 6ed. 2019
 
Intrusion Techniques
Intrusion TechniquesIntrusion Techniques
Intrusion Techniques
 
Assingment 5 - ENSA
Assingment 5 - ENSAAssingment 5 - ENSA
Assingment 5 - ENSA
 
Mmw mac malware-mac
Mmw mac malware-macMmw mac malware-mac
Mmw mac malware-mac
 
Tricky sample? Hack it easy! Applying dynamic binary inastrumentation to ligh...
Tricky sample? Hack it easy! Applying dynamic binary inastrumentation to ligh...Tricky sample? Hack it easy! Applying dynamic binary inastrumentation to ligh...
Tricky sample? Hack it easy! Applying dynamic binary inastrumentation to ligh...
 
Latinoware 2015 Mach-O
Latinoware 2015 Mach-OLatinoware 2015 Mach-O
Latinoware 2015 Mach-O
 
Bsides Tampa Blue Team’s tool dump.
Bsides Tampa Blue Team’s tool dump.Bsides Tampa Blue Team’s tool dump.
Bsides Tampa Blue Team’s tool dump.
 
Malware's Most Wanted: Linux and Internet of Things Malware
Malware's Most Wanted: Linux and Internet of Things MalwareMalware's Most Wanted: Linux and Internet of Things Malware
Malware's Most Wanted: Linux and Internet of Things Malware
 
Threats, Vulnerabilities & Security measures in Linux
Threats, Vulnerabilities & Security measures in LinuxThreats, Vulnerabilities & Security measures in Linux
Threats, Vulnerabilities & Security measures in Linux
 
Webinar alain-2009-03-04-clamav
Webinar alain-2009-03-04-clamavWebinar alain-2009-03-04-clamav
Webinar alain-2009-03-04-clamav
 
BSides IR in Heterogeneous Environment
BSides IR in Heterogeneous EnvironmentBSides IR in Heterogeneous Environment
BSides IR in Heterogeneous Environment
 
The Log4Shell Vulnerability – explained: how to stay secure
The Log4Shell Vulnerability – explained: how to stay secureThe Log4Shell Vulnerability – explained: how to stay secure
The Log4Shell Vulnerability – explained: how to stay secure
 
DEFCON 27 - ALEXANDRE BORGES - dot net malware threats
DEFCON 27 - ALEXANDRE BORGES - dot net malware threatsDEFCON 27 - ALEXANDRE BORGES - dot net malware threats
DEFCON 27 - ALEXANDRE BORGES - dot net malware threats
 
LO-PHI: Low-Observable Physical Host Instrumentation for Malware Analysis
LO-PHI: Low-Observable Physical Host Instrumentation for Malware AnalysisLO-PHI: Low-Observable Physical Host Instrumentation for Malware Analysis
LO-PHI: Low-Observable Physical Host Instrumentation for Malware Analysis
 
Strategies to design FUD malware
Strategies to design FUD malwareStrategies to design FUD malware
Strategies to design FUD malware
 
Hacking Exposed: The Mac Attack
Hacking Exposed: The Mac AttackHacking Exposed: The Mac Attack
Hacking Exposed: The Mac Attack
 
Hacking Exposed: The Mac Attack
Hacking Exposed: The Mac AttackHacking Exposed: The Mac Attack
Hacking Exposed: The Mac Attack
 
Ceh v5 module 18 linux hacking
Ceh v5 module 18 linux hackingCeh v5 module 18 linux hacking
Ceh v5 module 18 linux hacking
 
Understanding Malware Lateral Spread Used in High Value Attacks
Understanding Malware Lateral Spread Used in High Value AttacksUnderstanding Malware Lateral Spread Used in High Value Attacks
Understanding Malware Lateral Spread Used in High Value Attacks
 
G3t R00t at IUT
G3t R00t at IUTG3t R00t at IUT
G3t R00t at IUT
 

Recently uploaded

[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
Jason Yip
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
Fwdays
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
Fwdays
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
Javier Junquera
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
DianaGray10
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
Miro Wengner
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
Safe Software
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
Sease
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
UiPathCommunity
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
Ivo Velitchkov
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
Fwdays
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
christinelarrosa
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Pitangent Analytics & Technology Solutions Pvt. Ltd
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
Neo4j
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
Enterprise Knowledge
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
zjhamm304
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
Chart Kalyan
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
Vadym Kazulkin
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
ScyllaDB
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
FilipTomaszewski5
 

Recently uploaded (20)

[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
[OReilly Superstream] Occupy the Space: A grassroots guide to engineering (an...
 
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba"NATO Hackathon Winner: AI-Powered Drug Search",  Taras Kloba
"NATO Hackathon Winner: AI-Powered Drug Search", Taras Kloba
 
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
"Scaling RAG Applications to serve millions of users",  Kevin Goedecke"Scaling RAG Applications to serve millions of users",  Kevin Goedecke
"Scaling RAG Applications to serve millions of users", Kevin Goedecke
 
GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)GNSS spoofing via SDR (Criptored Talks 2024)
GNSS spoofing via SDR (Criptored Talks 2024)
 
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectorsConnector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
Connector Corner: Seamlessly power UiPath Apps, GenAI with prebuilt connectors
 
JavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green MasterplanJavaLand 2024: Application Development Green Masterplan
JavaLand 2024: Application Development Green Masterplan
 
Essentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation ParametersEssentials of Automations: Exploring Attributes & Automation Parameters
Essentials of Automations: Exploring Attributes & Automation Parameters
 
From Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMsFrom Natural Language to Structured Solr Queries using LLMs
From Natural Language to Structured Solr Queries using LLMs
 
Day 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio FundamentalsDay 2 - Intro to UiPath Studio Fundamentals
Day 2 - Intro to UiPath Studio Fundamentals
 
Apps Break Data
Apps Break DataApps Break Data
Apps Break Data
 
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin..."$10 thousand per minute of downtime: architecture, queues, streaming and fin...
"$10 thousand per minute of downtime: architecture, queues, streaming and fin...
 
Christine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptxChristine's Supplier Sourcing Presentaion.pptx
Christine's Supplier Sourcing Presentaion.pptx
 
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
Crafting Excellence: A Comprehensive Guide to iOS Mobile App Development Serv...
 
Leveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and StandardsLeveraging the Graph for Clinical Trials and Standards
Leveraging the Graph for Clinical Trials and Standards
 
Demystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through StorytellingDemystifying Knowledge Management through Storytelling
Demystifying Knowledge Management through Storytelling
 
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...QA or the Highway - Component Testing: Bridging the gap between frontend appl...
QA or the Highway - Component Testing: Bridging the gap between frontend appl...
 
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdfHow to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
How to Interpret Trends in the Kalyan Rajdhani Mix Chart.pdf
 
High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024High performance Serverless Java on AWS- GoTo Amsterdam 2024
High performance Serverless Java on AWS- GoTo Amsterdam 2024
 
ScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking ReplicationScyllaDB Tablets: Rethinking Replication
ScyllaDB Tablets: Rethinking Replication
 
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeckPoznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
Poznań ACE event - 19.06.2024 Team 24 Wrapup slidedeck
 

H2HC - R3MF

  • 1. H2HC Hackers to Hackers Conference R3MF – R3v3rs1ng on Mach-O File
  • 2. Ricardo L0gan Security Specialist with over 15 years of experience, malware research enthusiastic, pentest and reverse engineering. I’ve a solid knowledge on topics like network security, hardening and tuning across multiple platforms such as Windows, Linux, OS X and Cisco. Beginner in programming languages as Python, C and Assembly. In Brazil, I contribute with some security conferences organizations such as SlackShow Community, bSides SP and Hackers to Hackers Conference (H2HC). Member # RTFM 💀 C○||cL/V€ # ### Long live Open Source - Use Linux (Slackware) ### $Whoami
  • 3. 0x00 Motivation of Research 0x01 The Mach-O Format 0x02 Demo I (crackme) 0x03 Tricks for Reversing 0x04 Demo II (malware) 0x05 Conclusions / Q & (MAYBE 0/) A Agenda
  • 4. 0x00 Motivation Of Research For Fun ;) 0/ - Malware - Crackmes - Vulnerability Hunting
  • 6. 0x00 Motivation Of Research Source: www.virustotal.com 17/11/2016
  • 7. 0x00 Motivation Of Research .OSA --> ZIP:  PremierOpinion  upgrade.xml Mac.BackDoor.OpinionSpy.3 Names: MacOS_X/OpinionSpy.A (Microsoft), Mac.BackDoor.OpinionSpy.3 (F-Secure), Mac.BackDoor.OpinionSpy.3 (Trend) OSX_KAITEN.A Names: MacOS_X/Tsunami.A (Microsoft), OSX/Tsunami (McAfee), OSX/Tsunami-Gen (Sophos), OSX/Tsunami.A (F-Secure), OSX_CARETO.A Names: MacOS:Appetite-A [Trj] (Avast) OSX/BackDoor.A (AVG) Trojan.OSX.Melgato.a (Kaspersky) OSX/Backdoor-BRE (McAfee) Backdoor:MacOS_X/Appetite.A (Microsoft) OSX/Appetite-A (Sophos) Binary: /tmp/.z itunes212.{BLOCKED}pdt.com
  • 8. 0x01 The Mach-o Format The mach-o is a Universal (fat) binaries (for i386 x86_64 ppc ppc64 armv6 armv7), this format was adopted as the standard in OS X from version 10.6 on. We are currently in version 10.11.5 (El Capitan) 10.12 MacOS Sierra
  • 9. Binary (Linux) Binary (Windows) Binary (OS X) 0x01 The Mach-o Format
  • 10. 0x01 The Mach-o Format Magic Number: File Signatures
  • 11. 0x01 The Mach-o Format
  • 12. 0x01 The Mach-o Format Structs on File: - Code is located in __TEXT section. - Linked libraries in LC_LOAD_DYLIB commands. - The entrypoint is defined at LC_UNIXTHREAD or LC_THREAD.
  • 13. 0x01 The Mach-o Format HEADER
  • 16. 0x01 The Mach-o Format Cross Compiling Building a mach-o file supported by multiple platforms.
  • 17. 0x01 The Mach-o Format
  • 18. 0x01 The Mach-o Format
  • 19. 0x01 The Mach-o Format
  • 20. 0x01 The Mach-o Format
  • 21. 0x01 The Mach-o Format
  • 22. 0x02 Demo I Demo 01 Crackme Binary: cryptorev Level: easy Detail: cryptorev is a binary mach-o the goal is run binary and found the flag. This demo don’t have protection in this code just UPX (packer) and DEADBEEF in file ;)
  • 23. 0x03 Tricks for Reversing When talking about malwares we have a lot of techniques to make it difficult to analyze (reversing the sample) like: - Anti-Disassembly - Anti-Debugging - Obfuscation - Anti-Vm Good Research about this: https://www.blackhat.com/docs/us-14/materials/us-14-Branco-Prevalent- Characteristics-In-Modern-Malware.pdf
  • 24. 0x03 Tricks for Reversing
  • 25. Static Analysis file -> determine file type upx / binwalk -> compress or expand executable files strings -> find the printable strings in a object, or other binary, file strip -> remove symbols hexEdit -> hex editor Lipo -> create or operate on universal files otool -> object file displaying tool like a objdump and ldd nm -> display name list (symbol table) codesign -> create and manipulate code signatures machOView -> visual Mach-O file browser class-dump -> utility for examining the Objective-C runtime information stored in Mach-O files. dtrace -> generic front-end to the DTrace facility fs_usage -> report system calls and page faults related to filesystem activity in real-time xattr -> display and manipulate extended attributes 0x03 Tricks for Reversing
  • 26. 0x03 Tricks for Reversing Dynamic Analysis Xcode -> xcode is an (IDE) containing a suite of software development. iDA Pro -> disassembler and debugger. hopper -> tool used for disassemble, and decompile your 32/64bits mach-o file. lldb -> debugger fseventer -> disk activity tool with a good graphical representation and solid filter tool. open snoop -> snoop file opens as they occur. Uses DTrace. activity Monitor -> tool to help you keep your system in good shape. procoxp -> It's a simple tool like a top get information accessible by proc_info tcpdump -> for dump and analisys traffic on a network wireshark -> for dump and analisys traffic on a network lsock -> based on PF_SYSTEM provider, you can get real time notifications of socket activity like TCPView from SysInternals. little Snitch -> network traffic monitoring and control.
  • 27. On March 2016 appear the first Ransomware writing for mach-o file on OSX System (KeRanger), Distributed by client BitTorrent Transmission (v.2.90) This threat has been fixed in version v.2.91 the client. The latest version Gatekeeper OSX already block this ransomware since the first sample published 0/!!! 0x04 Demo II Demo 02 Ransomware Keranger
  • 28. Hacking is a way of life Reference REVERSE Engineering Mac Malware - Defcon 22 https://www.defcon.org/images/defcon-22/dc-22- presentations/Edwards/DEFCON-22-Sarah-Edwards-Reverse- Engineering-Mac-Malware.pdf OS X ABI Mach-O File Format Reference https://developer.apple.com/library/mac/documentation/DeveloperT ools/Conceptual/MachORuntime/index.html Calling Convention http://www.agner.org/optimize/calling_conventions.pdf Thanks for my wife and brothers (Rubira, Gabriel Negreiros, C00ler, Slayer, Ygor-r0gy)
  • 29. 0x05 Conclusions Question &(MAYBE ;) 0/)Answer Contact: ricardologanbr@gmail.com @l0ganbr