HTB WP -Redeemer

task1:

1
2
Which TCP port is open on the machine?
机器上哪个 TCP 端口是开放的?

开扫:

1
nmap -sV 10.129.91.201

可惜这1000个端口没扫到(这里不是网络问题,既然能扫1000个端口说明已经连上了)

那就只能扩大端口范围了:

1
nmap -p- 10.129.91.201

其中:

  • -p-:表示扫描全部 TCP 端口,也就是 1-65535,等价于 -p1-65535。

但是效果很慢。

可以尝试等,或者换种更快的。

决定换一个:

1
nmap -Pn -sS -T4 --min-rate 100 -p- 10.129.91.207 
1
2
3
4
5
其中:
-Pn(可选):跳过主机发现(不先 ping),直接假设目标在线。
-sS(可选):SYN 半开放扫描,只发起握手不完成,速度快。
-T4:扫描速度模板,T0~T5:T3 默认,T4 较快,T5 很激进。
--min-rate 100:最低发包速率,每秒至少发送 100 个探测包。

发包频率尽量小点,不然给容器扫炸了。

得到端口6379:

1
2
PORT     STATE SERVICE
6379/tcp open redis

task2:

1
2
Which service is running on the port that is open on the machine?
机器上打开的端口正在运行哪个服务?

回答:

就是上面扫出来那个

1
redis

task3:

1
2
What type of database is Redis? Choose from the following options: (i) In-memory Database, (ii) Traditional Database
Redis是什么类型的数据库?请从以下选项中选择:(i)内存数据库,(ii)传统数据库

回答:

1
2
In-memory Database
与传统数据库(如 MySQL 或 PostgreSQL,主要将数据存在机械硬盘或 SSD 等外存上)不同,Redis 直接将所有数据保存在服务器的主内存(RAM)中。

task4:

1
2
Which command-line utility is used to interact with the Redis server? Enter the program name you would enter into the terminal without any arguments.
哪个命令行工具用于与 Redis 服务器交互?请输入您在终端中输入的程序名称(不带任何参数)。

回答:

1
redis-cli

task5:

1
2
Which flag is used with the Redis command-line utility to specify the hostname?
在 Redis 命令行工具中,使用哪个标志来指定主机名?

回答:

1
-h

task6:

1
2
Once connected to a Redis server, which command is used to obtain the information and statistics about the Redis server?
连接到 Redis 服务器后,使用哪个命令可以获取有关 Redis 服务器的信息和统计信息?

回答:

1
info

task7:

1
2
What is the version of the Redis server being used on the target machine?
目标机器上使用的 Redis 服务器版本是什么?

回答:

根据之前的端口,用-sV 确定版本

1
nmap -Pn -sV -p6379 10.129.91.207

得到版本:

1
2
Redis key-value store 5.0.7
5.0.7就是答案

或者可以连那个服务再确定版本(为后面获得flag做铺垫):

1
redis-cli -h 10.129.91.207 -p 6379

输入info看信息:

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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
10.129.91.207:6379> info
# Server
redis_version:5.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:66bd629f924ac924
redis_mode:standalone
os:Linux 5.4.0-77-generic x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:9.3.0
process_id:750
run_id:e6cc5d448a486bdefa4e65e4acc91a6f46b63d77
tcp_port:6379
uptime_in_seconds:1839
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:5438003
executable:/usr/bin/redis-server
config_file:/etc/redis/redis.conf

# Clients
connected_clients:1
client_recent_max_input_buffer:2
client_recent_max_output_buffer:0
blocked_clients:0

# Memory
used_memory:859624
used_memory_human:839.48K
used_memory_rss:5820416
used_memory_rss_human:5.55M
used_memory_peak:859624
used_memory_peak_human:839.48K
used_memory_peak_perc:100.00%
used_memory_overhead:846142
used_memory_startup:796224
used_memory_dataset:13482
used_memory_dataset_perc:21.26%
allocator_allocated:1584120
allocator_active:1937408
allocator_resident:9158656
total_system_memory:2084024320
total_system_memory_human:1.94G
used_memory_lua:41984
used_memory_lua_human:41.00K
used_memory_scripts:0
used_memory_scripts_human:0B
number_of_cached_scripts:0
maxmemory:0
maxmemory_human:0B
maxmemory_policy:noeviction
allocator_frag_ratio:1.22
allocator_frag_bytes:353288
allocator_rss_ratio:4.73
allocator_rss_bytes:7221248
rss_overhead_ratio:0.64
rss_overhead_bytes:-3338240
mem_fragmentation_ratio:7.12
mem_fragmentation_bytes:5002800
mem_not_counted_for_evict:0
mem_replication_backlog:0
mem_clients_slaves:0
mem_clients_normal:49694
mem_aof_buffer:0
mem_allocator:jemalloc-5.2.1
active_defrag_running:0
lazyfree_pending_objects:0

# Persistence
loading:0
rdb_changes_since_last_save:0
rdb_bgsave_in_progress:0
rdb_last_save_time:1783821961
rdb_last_bgsave_status:ok
rdb_last_bgsave_time_sec:0
rdb_current_bgsave_time_sec:-1
rdb_last_cow_size:413696
aof_enabled:0
aof_rewrite_in_progress:0
aof_rewrite_scheduled:0
aof_last_rewrite_time_sec:-1
aof_current_rewrite_time_sec:-1
aof_last_bgrewrite_status:ok
aof_last_write_status:ok
aof_last_cow_size:0

# Stats
total_connections_received:6
total_commands_processed:8
instantaneous_ops_per_sec:0
total_net_input_bytes:358
total_net_output_bytes:15418
instantaneous_input_kbps:0.00
instantaneous_output_kbps:0.00
rejected_connections:0
sync_full:0
sync_partial_ok:0
sync_partial_err:0
expired_keys:0
expired_stale_perc:0.00
expired_time_cap_reached_count:0
evicted_keys:0
keyspace_hits:0
keyspace_misses:0
pubsub_channels:0
pubsub_patterns:0
latest_fork_usec:222
migrate_cached_sockets:0
slave_expires_tracked_keys:0
active_defrag_hits:0
active_defrag_misses:0
active_defrag_key_hits:0
active_defrag_key_misses:0

# Replication
role:master
connected_slaves:0
master_replid:fffd8b6b99a1c05e55a31a6ec8e95819c798c4f5
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0

# CPU
used_cpu_sys:1.113860
used_cpu_user:0.990695
used_cpu_sys_children:0.000000
used_cpu_user_children:0.001001

# Cluster
cluster_enabled:0

# Keyspace
db0:keys=4,expires=0,avg_ttl=0
(0.77s)

可以看到:

1
redis_version:5.0.7

或者直接输入:

1
info server

得到:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
10.129.91.207:6379> info server
# Server
redis_version:5.0.7
redis_git_sha1:00000000
redis_git_dirty:0
redis_build_id:66bd629f924ac924
redis_mode:standalone
os:Linux 5.4.0-77-generic x86_64
arch_bits:64
multiplexing_api:epoll
atomicvar_api:atomic-builtin
gcc_version:9.3.0
process_id:750
run_id:e6cc5d448a486bdefa4e65e4acc91a6f46b63d77
tcp_port:6379
uptime_in_seconds:1949
uptime_in_days:0
hz:10
configured_hz:10
lru_clock:5438113
executable:/usr/bin/redis-server
config_file:/etc/redis/redis.conf

task8:

1
2
Which command is used to select the desired database in Redis?
在 Redis 中,使用哪个命令来选择所需的数据库?

回答:

1
select

和SQl数据库的选择命令一样

task9:

1
2
How many keys are present inside the database with index 0?
数据库中索引为 0 的键有多少个?

回答:

前面info里有

1
2
3
# Keyspace
db0:keys=4,expires=0,avg_ttl=0
(0.77s)

键就是keyspace,所以有4个

或者直接输入:

1
info keyspace

得到:

1
2
3
4
10.129.91.207:6379> info keyspace
# Keyspace
db0:keys=4,expires=0,avg_ttl=0
(1.46s)

或者输入:

1
select 0

切换至 0 号库(但其实默认连接索引为 0 的数据库):

1
dbsize

task10:

1
2
Which command is used to obtain all the keys in a database?
哪个命令可以用来获取数据库中的所有键?

回答:

1
keys *

task11:

1
Submit root flag

回答:

先连到服务:

1
redis-cli -h 10.129.91.207 -p 6379

这个命令里没有ls,而redis是数据库,所以依照ls的思想,把这个数据库里的所有键列出来:

1
keys *

看到flag键了,先用 type 命令确定 flag 的类型:

1
type flag

接着直接用 get 命令获取指定键(Key)的字符串(String)值。:

1
get flag

得到flag:

这些命令啥的多积累,要用的时候拿出来看即可