黑客软件编写基础知识集合(4)

时间:2006-10-12 来源: 作者: 点击:
得到计算机的主机名和IP地址 #include 链接库:Wsock32.lib { WORD wVersionRequested; WSADATA wsaData; char name[255]; CString ip; PHOSTENT hostinfo; wVersionRequested = MAKEWORD( 2, 0 ); if ( WSAStartup( wVersionRequested, } } WSACleanup( ); } } ******
  
  得到计算机的主机名和IP地址
  
  #include
  
  链接库:Wsock32.lib
  
  {
  WORD wVersionRequested;
  WSADATA wsaData;
  char name[255];
  CString ip;
  PHOSTENT hostinfo;
  wVersionRequested = MAKEWORD( 2, 0 );
  
  if ( WSAStartup( wVersionRequested, &wsaData ) == 0 )
  {
  
  if( gethostname ( name, sizeof(name)) == 0)
  {
  if((hostinfo = gethostbyname(name)) != NULL)
  {
  ip = inet_ntoa (*(struct in_addr *)*hostinfo->h_addr_list);
  }
  }
  
  WSACleanup( );
  }
  }
  
  
  ***********************************************
  
  用VC++读取网卡MAC地址的程序
  
  运行VC++6.0,选择创建一个Win32 Console程序,然后输入以下代码:
  
  #include "stdafx.h"
  #include
  #include
  #include
  #include
  #include
  
  nb30.h #include < nb30.h >
  typedef struct _ASTAT_
  {
  ADAPTER_STATUS adapt;
  NAME_BUFFER NameBuff [30];
  }ASTAT, * PASTAT;
  
  ASTAT Adapter;
  
  void getmac_one (int lana_num)
  {
  NCB ncb;
  UCHAR uRetCode;
  memset( &ncb, 0, sizeof(ncb) );
  ncb.ncb_command = NCBRESET;
  ncb.ncb_lana_num = lana_num;
  uRetCode = Netbios( &ncb );
  printf( "The NCBRESET return code is:
  0x%x \n", uRetCode );
  memset( &ncb, 0, sizeof(ncb) );
  ncb.ncb_command = NCBASTAT;
  ncb.ncb_lana_num = lana_num;
  strcpy( (char *)ncb.ncb_callname,
  "* " );
  ncb.ncb_buffer = (unsigned char *) &Adapter;
  ncb.ncb_length = sizeof(Adapter);
  uRetCode = Netbios( &ncb );
  printf( "The NCBASTAT
  return code is: 0x%x \n", uRetCode );
  if ( uRetCode == 0 )
  {
  printf( "The Ethernet Number[%d]
  is: %02X%02X-%02X%02X-%02X%02X\n",
  lana_num,
  Adapter.adapt.adapter_address[0],
  Adapter.adapt.adapter_address[1],
  Adapter.adapt.adapter_address[2],
  Adapter.adapt.adapter_address[3],
  Adapter.adapt.adapter_address[4],
  Adapter.adapt.adapter_address[5]);
  }
  }
  int main(int argc, char* argv[])
  {
  NCB ncb;
  UCHAR uRetCode;
  LANA_ENUM lana_enum;
  memset( &ncb, 0, sizeof(ncb) );
  ncb.ncb_command = NCBENUM;
  ncb.ncb_buffer = (unsigned char *) &lana_enum;
  ncb.ncb_length = sizeof(lana_enum);
  uRetCode = Netbios( &ncb );
  printf( "The NCBENUM return
  code is:
  0x%x \n", uRetCode );
  if ( uRetCode == 0 )
  {
  printf( "Ethernet Count is : %d\n\n", lana_enum.length);
  for ( int i=0; i< lana_enum.length; ++i)
  getmac_one( lana_enum.lana);
  }
  return 0;
  }
  
  ----------------------------------------------------------
  
  
  
  ***********************************************
  
  解决VC++语言程序中的2000年问题
  
  PROCTIME.C源程序清单:
  
  #include
  #include
  #include
  
  void goto_ xy(int x,int y)
  {
  union REGS r;
  r.h.ah=2; r.h.bh=0;
  r.h.dh=(char)x;
  r.h.dl=(char)y;
  int86(0x10,&r,&r);
  }
  get_key()
  {
  union REGS r;
  r.h.ah=0;
  return int86(0x16,&r,&r);
  }
  int wherex()
  {int x;
  union REGS r;
  r.h.ah=3; r.h.bh=0;
  int86(0x10,&r,&r);
  (char)x=r.h.dh;
  return x;
  }
  int wherey()
  { int y;
  union REGS r;
  r.h.ah=3; r.h.bh=0;
  int86(0x10,&r,&r);
  (char)y=r.h.dl;
  return y;
  }
  void write_video(int x,int y,char *p,int attrib)
  {
  register int I;
  union REGS r;
  for (I=y;*p;I++) {
  if (*p==\n)
  { goto_ xy(x+1,2);break; }
  goto_ xy(x,I);
  r.h.ah=9; r.h.bh=0;
  r.x.cx=1; r.h.al=*p++;
  r.h.bl=(char)attrib;
  int86(0x10,&r,&r);
  }
  }
  void disptime(int x,int y)
  {
  struct tm *newtime;
  time_t aclock;
  long startsec,currsec;
  int dqx,dqy,YEAR;
  char sj[50],week[3];
  time(&aclock);
  newtime=localtime(&aclock);
  YEAR=newtime->tm_year+1990
  startsec=newtime->tm_sec;
  switch(newtime->tm_wday)
  {
  case 0: strcpy(week,"日"); break;
  case 1: strcpy(week,"一"); break;
  case 2: strcpy(week,"二"); break;
  case 3: strcpy(week,"三"); break;
  case 4: strcpy(week,"四"); break;
  case 5: strcpy(week,"五"); break;
  case 6: strcpy(week,"六"); break;
  }
  while(!kbhit())
  {
  time(&aclock);
  newtime=localtime(&aclock);
  sprintf(sj,"%d.%2d.%2d 星期%s %d:%2d:%2d",YEAR,newtime->tm_mon+1,newtime- >tm_mday,week,newtime->tm_hour,newtime->tm_min,newtime->tm_sec);
  currsec=newtime->tm_sec;
  if(startsec!=currsec)
  {
  dqx=wherex(); dqy=wherey();
  write_video(x,y,sj,0x0a);
  goto_ xy(dqx,dqy);
  return;
  }
  }
  }
  main ()
  {
  union inkey { char ch[2]; int I; }c;
  for(;;) {
  for(;;) {
  if (kbhit()) { c.I=get_key(); break; }
  disptime(0,54);
  if (c.ch[0]==27) exit(0);
  }
  }
  }
------分隔线----------------------------
顶一下
(0)
0%
踩一下
(0)
0%
------分隔线----------------------------
最新评论 查看所有评论
发表评论 查看所有评论
请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
评价:
表情:
用户名: 密码: 验证码:
推荐内容