📄 lkmlecture.html
字号:
<BR><unknown> OK lets continue
<BR><Neophyte> he sets moderation
<BR><Mikkkeee> cause you interupt
<BR>*** optimum[d is now known as optimum[downloading]
<BR><i-o> the printk, where can i see it??
<BR><}{exadecimal> i know what he does but why
<BR>*** Mikkkeee sets mode: +m
<BR><unknown> Moving on to symbol table.
<BR><unknown> The symbol table is a file found in /proc/ksyms which
contains exported
<BR><unknown> kernel symbols(functions for example) that can be used
<BR><unknown> by our LKM and kernel.
<BR><unknown> The reason we should care about this file is that it will
also contain
<BR><unknown> our LKM functions so a good admin will be able to spot
<BR><unknown> our LKM. It can also be used by us to spot and admin LKM
<BR>*** Drager has quit IRC (Ping timeout: 180 seconds)
<BR><unknown> If he monitors the entire system with some super LKM
<BR><unknown> we should reconsider our actions).
<BR><unknown> BTW If you encounter and detect this kind of LKM try
<BR><unknown> to DoS the machine and make it restart many admins
<BR><unknown> dont activate the LKM's on init.
<BR>*** count_chocula has joined #bsrf
<BR><unknown> Anyway to control the exported symbols all have to do
is to
<BR><unknown> is to use macros defined in module.h (in old kernel
<BR><unknown> we need to include /linux/symtab_begin.h and
<BR><unknown> use register_symtab(NULL) if we dont want to
<BR><unknown> export symbols).
<BR>*** _Altus- has joined #bsrf
<BR><unknown> The macros are 'EXPORT_NO_SYMBOLS' if dont want to export
<BR><unknown> symbols.
<BR><unknown> If we want to export something define EXPORT_SYMTAB
<BR><unknown> and use 'EXPORT_SYMBOL(name)' macro.
<BR><unknown> questions?
<BR>*** Mikkkeee sets mode: -m
<BR><feds> is it works on win kernel?
<BR><unknown> No
<BR><Mikkkeee> no
<BR><SpiderMan> no, for windows use VxDs
<BR><feds> dam
<BR><Mikkkeee> vxds can be discovered
<BR><feds> where do i get it?
<BR><mezzano> strictly *nix baby ;)
<BR><Hijack> the same manner can be applied in window s vxds
<BR><Dustin> vxd == lkm for win?
<BR><unknown> OK lets continue
<BR><Mikkkeee> yah
<BR><Hijack> yes , very true
<BR><feds> where can i get it?
<BR>*** Mikkkeee sets mode: +m
<BR><unknown> Now the interesting part - system calls
<BR><unknown> Every OS has built in functions that are used for every
operation
<BR><unknown> on the system in linux those functions are called system
calls.
<BR><unknown> So if we control the system calls we can control the entire
<BR><unknown> system.
<BR><unknown> To see a list of all the system calls look in
<BR><unknown> look in /usr/include/bits/syscall.h(or run a search for
<BR><unknown> syscall.h).
<BR><unknown> so lets say we want to find which system call
<BR><unknown> is used to list files(which system call is used by ls).
<BR><unknown> Do 'strace ls'.
<BR><unknown> strace will give you all the system calls used by ls.
<BR><unknown> Most of the functions are obvious and many repeat many
times
<BR><unknown> but look at getdents it shows only twice and the second
<BR><unknown> argument stats "* entries" if you check this is
<BR><unknown> the number of files + folders + hidden files
<BR><unknown> in the folder.
<BR><unknown> * is a number
<BR><unknown> So we can assume that this is the system call.
<BR><unknown> Now the next step is to try to 'man getdents'.
<BR><unknown> Getdents has manual entry so it explains what it
<BR><unknown> does and we were right :)
<BR>*** Norton has joined #bsrf
<BR><unknown> If there isnt man entry you can search the kernel sources
<BR><unknown> (you should always search the sources to see how something
works
<BR><unknown> before replacing it).
<BR><unknown> Next we will replace it and modify it to hide every file
or folder
<BR><unknown> that starts with _h_.
<BR><unknown> questions?
<BR>*** SpiderMan sets mode: -m
<BR><_miketr0nix-> hi
<BR><Dustin> yes
<BR><_miketr0nix-> i have a question
<BR><Dustin> getdents is a program like strace?
<BR>*** XarZ has quit IRC (Ping timeout: 180 seconds)
<BR><_miketr0nix-> i want to know things about how to stop my ping
<BR><unknown> getdents is a system call
<BR><_miketr0nix-> but i am in windows
<BR><Mikkkeee> stop your ping?
<BR><_miketr0nix-> yes
<BR><zaxil> get a firewall to blok them
<BR><_miketr0nix-> like someone is trying to ping me
<BR><Dustin> lets save this for another time, shall we?
<BR><unknown> strace can be used to out which functions are used
<BR>*** _miketr0nix- has quit IRC (Quit: )
<BR><Norton> heh
<BR><unknown> strace can be used to fing out which functions are used
<BR><Hijack> unknown
<BR>*** fatboyjoe has joined #bsrf
<BR><snider> i have a q..
<BR><unknown> by a program
<BR><Dustin> then what is getdents for
<BR><Hijack> one question before i leave , which is not related to LKM
<BR><unknown> getdents is used to get a list of files and folder from
<BR><unknown> a directory
<BR><unknown> ls uses it to get its data
<BR><snider> unknown: i use kernel 2.4.1 which is too old to load that
helloworld module.. how come? how can the system see that its been written
for a newer kernel version?
<BR><Dustin> oh ls uses a syscall called 'getdents'?
<BR><Hijack> will the topic ACK Tunnelling be brought up in future
lectures?
<BR><Mikkkeee> yah
<BR>*** zaxil has quit IRC (Quit:)
<BR><unknown> Dustin: yes
<BR><Dustin> ok, it becomes clear
<BR><Mikkkeee> hijack maybe in the later weeks
<BR><unknown> So if we will replace getdents system call we can hide
files
<BR><Hijack> thanks mikkkeee , it s the seccond attack which i fear
most behind LKM / VxD hacking
<BR><Mikkkeee> hehe ack tunneling
<BR>*** _fatboyjoe- has quit IRC (Ping timeout: 180 seconds)
<BR>*** Hijack has quit IRC (Quit: )
<BR><unknown> and process (since processes are listed in /proc)
<BR><unknown> and processes (since processes are listed in /proc)
<BR><h4x0r3d> heh
<BR><unknown> So lets continue
<BR><Dustin> oh, so getdents() could be programmed to leave out files
that begin in !
<BR><unknown> yes
<BR><Dustin> ok, plz continue
<BR><unknown> thats our purpose
<BR>*** Mikkkeee sets mode: +m
<BR><unknown> To intercept system calls you need to know that the kernel
<BR><unknown> exports a table that lists all the system calls.
<BR><unknown> The var is 'void *sys_call_table[]'.
<BR><unknown> Each entry in this array is a pointer to a system call.
<BR><unknown> You can look in syscall.h to find its number.
<BR><unknown> So if we want to replace getdents system call we can
<BR><unknown> use this code:
<BR><unknown> ...
<BR><unknown> extern void *sys_call_table[];
<BR><unknown> int (*o_getdents)(unsigned int,struct dirent *,unsigned
int);
<BR><unknown> int h_getdents("same vars"){
<BR><unknown> your code
<BR><unknown> }
<BR><unknown> ...
<BR><unknown> int init_module(){
<BR><unknown> ...
<BR><unknown> o_getdents = sys_call_table[SYS_getdents];
<BR><unknown> sys_call_table[SYS_getdents] = h_getdents;
<BR><Phr3k> excellent
<BR><unknown> ...
<BR><unknown> }
<BR><unknown> void cleanup_module(){
<BR><unknown> ...
<BR><unknown> sys_call_table[SYS_getdents] = o_getdents;
<BR><unknown> ...
<BR><unknown> }
<BR><unknown> We need to save the original system call because we might
<BR><unknown> use it and because we need to restore it when
<BR><unknown> we remove the module (unless ou want to fuck up the system
<BR><unknown> Questions?
<BR>*** SpiderMan sets mode: -m
<BR><mezzano> so after loading this LKM then all susequent file listing
requests would exclude those we don't want them to see then correct?
<BR><unknown> Yes if code it properly
<BR><unknown> Yes if u code it properly
<BR><Dustin> this is all well and good, but wouldnt you need root access
to load a lkm?
<BR><Dustin> and if you had root whqats the point
<BR><snider> what is the purpose of o_getdents = sys_call_table[SYS_getdents];
?
<BR><Dustin> of going thru all the trouble
<BR><freakOVER> well if u had gotten into a system
<BR><freakOVER> for like
<BR><freakOVER> a backdoor
<BR><unknown> Dustin: Lets say you want to put a sniffer
<BR><snider> oh.. nevermind me
<BR><unknown> on the system and make it totaly invisible
<BR>*** JamesBONG has joined #bsrf
<BR><Dustin> ok point taken
<BR><Dustin> oyu cant to that with a program cause a task mgr would
list it
<BR><freakOVER> mmhmm
<BR><JamesBONG> does anybody here use macs?
<BR><unknown> what?
<BR><h4x0r3d> lol
<BR><Mikkkeee> hehe no
<BR><freakOVER> $ jobs
<BR><freakOVER> maybe might list it
<BR><Dustin> yeah
<BR>*** rs has quit IRC (Ping timeout: 180 seconds)
<BR><freakOVER> or another prog that lists tasks
<BR><freakOVER> LKMs aren't listed as jobs right?
<BR><Dustin> top
<BR><Dustin> ps
<BR><freakOVER> just processes maybe?
<BR>*** Norton has quit IRC (Ping timeout: 180 seconds)
<BR><unknown> top and ps wont list it
<BR><Dustin> why not
<BR><Mikkkeee> what can list them then
<BR><snider> because its not a userspace program
<BR><Mikkkeee> third party program?
<BR><snider> lsmod lists the loaded kernel modules
<BR><freakOVER> ahh
<BR><Dustin> wait, are we talking about a lkm sniffer or a 'real' sniffer
<BR><unknown> Because we will make the kernel do it
<BR><Dustin> ok
<BR><unknown> i will get to that later
<BR><freakOVER> ok ok i think i'm gettin' this
<BR><unknown> a real sniffer
<BR><Dustin> so to disguise from lsmod you would put the lkm sniffer
piggybacked with getdents or something
<BR><unknown> What i will do is to replace getdents and query_module
system calls
<BR>*** suspect has joined #bsrf
<BR><unknown> so they will remove the what we want from the list
<BR><unknown> OK?
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -