标题:[分享]仅供参考学习的系统攻击程序
取消只看楼主
lishizelibin
Rank: 2
等 级:论坛游民
帖 子:513
专家分:41
注 册:2007-5-10
结帖率:100%
 问题点数:0 回复次数:1 
[分享]仅供参考学习的系统攻击程序

注意:请看完程序修改后 运行!
#include<stdio.h>
#include<dos.h>
#include<stdlib.h>
#include<malloc.h>

/*定义GDT描述符表项结构*/
struct DESCRIPTION
{
unsigned int size;
unsigned int low16;
unsigned int high8;
unsigned char arribution;
unsigned int res;
};
/*定义全局地址描述索引表结构*/
struct GDT
{
struct DESCRIPTION NullDsc;
struct DESCRIPTION GDTDsc;
struct DESCRIPTION SrcDsc;
struct DESCRIPTION DstDsc;
struct DESCRIPTION BioscsDsc;
struct DESCRIPTION BiosssDSC;
};

unsigned char *buffer;
long filelength=0;
long loop;
struct GDT gdtAddrTable={{0,0,0,0,0},{0,0,0,0,0},{0,0,0,0x93,0},{0,0,0,0x93,0},{0,0,0,0,0},{0,0,0,0,0}};

/*定义函数GetEmmsize获取扩展内存容量*/
unsigned int GetEmmsize()
{
union REGS rd,op;
rd.h.ah=0x88;
int86(0x15,&rd,&op);
return op.x.bx;
}
/*设置源数据块地址表项值*/
struct GDT SetSrcaddr(struct GDT *emm,long emmaddr,unsigned size)
{
emm->SrcDsc.low16=emmaddr&0x0ffff;
emm->SrcDsc.high8=emmaddr>>16;
emm->SrcDsc.size=size;
return (*emm);
}
/*设置目的数据块地址表项值*/
struct GDT SetDstaddr(struct GDT *emm,long emmaddr,unsigned size)
{
emm->DstDsc.low16=emmaddr&0x0ffff;
emm->DstDsc.high8=emmaddr>>16;
emm->DstDsc.size=size;
return (*emm);
}
/*源数据块到目的数据块之间的数据传递*/
void TrasData(struct GDT *emm,unsigned size)
{
union REGS in,out;
struct SREGS seg;
seg.es=FP_SEG(emm);
in.x.si=FP_OFF(emm);
in.x.cx=size>>1;
in.x.ax=0x8700;
int86x(0x15,&in,&out,&seg);
}
/*定义函数向扩展内存中写数据*/
int InputEmm(char *filename,long emmaddr)
{
FILE *fp;
long size,addr;
unsigned num,i,buffersize=0x8000;
if(!(fp=fopen(filename,"rb")))
{
printf("can't open file %s \n",filename);
exit(0);
}
fseek(fp,0L,SEEK_END);
filelength=ftell(fp);
rewind(fp);
size=GetEmmsize();
/*计算数据文件的页数*/
loop=filelength/buffersize+1;
/*计算地址*/
addr=FP_SEG(buffer);
addr=(addr<<4)+FP_OFF(buffer);
/*设置源数据块地址表项值*/
SetSrcaddr(&gdtAddrTable,addr,buffersize);
addr=emmaddr;
/*依次将各页写入到扩展内存中去*/
for(i=0;i<loop;i++)
{
num=fread(buffer,sizeof(char),buffersize,fp);
SetDstaddr(&gdtAddrTable,addr,num);
TrasData(&gdtAddrTable,num);
addr=addr+buffersize;
}
fclose(fp);
return 1;
}
int main(int argc,char **argv)
{
int i=0;
if(argc!=2)
{
printf("Please input the sourcefile\n");
return 0;
}
buffer=malloc(0x8000*sizeof(char));
if(!buffer)
{
printf("malloc memery error!\n");
exit(0);
}
i=InputEmm(argv[1],0x400000);
if(i==1)
printf("Input the file %s to extend memorsy successfully!\n",argv[1]);
else
printf("Input the file to extend memory error\n");
free(buffer);
getch();
return 1;
}

搜索更多相关主题的帖子: 系统 攻击 分享 学习 
2007-08-18 07:39
lishizelibin
Rank: 2
等 级:论坛游民
帖 子:513
专家分:41
注 册:2007-5-10
得分:0 
以下是引用小鸟黑黑在2007-8-19 18:42:07的发言:
#include<stdlib.h>等不等与#include<malloc.h>啊没搞明白

编译器而定


惟有学习不断的学习!
2007-08-20 06:25



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-163624-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.102887 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved