Protocol 55 of 81Layer 7FrameAssembly v3.1.2
llms-full.txt
ftpFile Transfer Protocol Control Channel

Cleartext USER / PASS & Firewall ALG Headaches (client <-> srv ftp)

Default Port / Protocol
TCP 21
Host Endpoint Rule
Dual-Stack IPv4/IPv6
Wireshark Display Filter
ftp
Standards & Specs
RFC 959, RFC 2428
Wire Stack:Ethernet II[802.1Q / QinQ / MPLS]IPv4 / IPv6TCP 21FTP

What It Does on the Wire

Nothing stresses a stateful firewall’s Application Layer Gateway quite like FTP on TCP 21. Pair code 220 server greetings with cmd "USER" arg "anonymous" and watch your IDS light up.

File Transfer Protocol (ftp, RFC 959) sends human-readable control commands (USER, PASS, SYST, PASV, EPSV, RETR, STOR, QUIT) and 3-digit server status replies (220, 331, 230, 227, 530) over TCP port 21.

In FrameAssembly, specifying code <num> (such as code 220 reply "FTP Server Ready") emits an FTP server reply line (220 FTP Server Ready ), while specifying cmd "<verb>" (with optional arg "<text>") emits a client command line (USER anonymous ) with automatic TCP sequence number tracking.

Anonymous FTP & Cleartext Credential IDS Detection Tests

Test Suricata, Snort, and Zeek ftp.log rules that flag USER anonymous, brute-force 530 Login incorrect loops, or cleartext PASS submissions.

Stateful Firewall FTP ALG / Passive Mode (227 / 229) Debugging

Craft PASV (code 227) or IPv6 EPSV (code 229) negotiations to verify how NGFWs inspect dynamic data-channel ports.

DLP & Exfiltration Filename Alert Validation

Simulate STOR or RETR commands with sensitive dummy filenames (arg "payroll_q4.csv") to test network DLP alerts.

Minimal Quickstart (ftp_quickstart.frasm)

Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.

ftp_quickstart.frasm11 lines
Open in Playground
host client { ip 10.10.4.20 }
host ftp_srv { ip 10.10.4.21 }
compile {
client -> ftp_srv tcp syn srcport 51021 dstport 21 wait 1ms
client <- ftp_srv tcp syn ack wait 1ms
client -> ftp_srv tcp ack wait 1ms
client <- ftp_srv ftp code 220 reply "vsFTPd 3.0.5" wait 2ms
client -> ftp_srv ftp cmd "USER" arg "anonymous" wait 2ms
client <- ftp_srv ftp code 331 reply "Please specify the password."
}

What the Compiler Calculates So You Don't Have To

  • Defaults to TCP destination port 21 (psh ack) and terminates every command or reply with standard CRLF.
  • Formats <code_num> <reply> automatically when code is provided, or <cmd> <arg> for client requests.
  • Keeps bidirectional TCP sequence and acknowledgment numbers synchronized across multi-step login sessions.
Multi-Frame Lab · Ready to Compile

FTP Banner, Failed Brute-Force Login (530) & Successful Passive Retrieval

Completes a TCP 21 handshake, tests a failed 530 Login incorrect attempt, then logs in cleanly and enters PASV mode to retrieve an archive.

ftp_login_and_pasv.frasm22 lines
Open in Playground
host branch_host { ip 172.16.20.35 }
host dmz_ftp { ip 172.16.100.21 }
compile {
branch_host -> dmz_ftp tcp syn srcport 52121 dstport 21 win 65535 mss 1460 wait 1ms
branch_host <- dmz_ftp tcp syn ack win 65535 mss 1460 wait 1ms
branch_host -> dmz_ftp tcp ack wait 1ms
branch_host <- dmz_ftp ftp code 220 reply "DMZ Archive FTP Ready" wait 2ms
// 1. Rejected login attempt -> 530 Login incorrect
branch_host -> dmz_ftp ftp cmd "USER" arg "admin" wait 1ms
branch_host <- dmz_ftp ftp code 331 reply "Password required for admin" wait 2ms
branch_host -> dmz_ftp ftp cmd "PASS" arg "wrongpass" wait 5ms
branch_host <- dmz_ftp ftp code 530 reply "Login incorrect." wait 5ms
// 2. Authorized backup user + PASV + RETR
branch_host -> dmz_ftp ftp cmd "USER" arg "svc_backup" wait 1ms
branch_host <- dmz_ftp ftp code 331 reply "Password required" wait 1ms
branch_host -> dmz_ftp ftp cmd "PASS" arg "LabOnlyToken99" wait 2ms
branch_host <- dmz_ftp ftp code 230 reply "User logged in, proceed." wait 2ms
branch_host -> dmz_ftp ftp cmd "PASV" wait 1ms
branch_host <- dmz_ftp ftp code 227 reply "Entering Passive Mode (172,16,100,21,195,80)." wait 1ms
branch_host -> dmz_ftp ftp cmd "RETR" arg "daily-config.tar.gz"
}
Terminal Commands (FrameAssembly CLI v3.1.2)
# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show ftp_login_and_pasv.frasm

# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly ftp_login_and_pasv.frasm ftp_login_and_pasv.pcap
frameassembly ftp_login_and_pasv.frasm ftp_login_and_pasv.pcapng

# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse ftp_login_and_pasv.pcap ftp_login_and_pasv_edited.frasm

All ftp Keywords & Header Options

Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after ftp:

src_host -> dst_host ftp [cmd "<text>"] [arg "<text>"] [code <100..599>] [reply "<text>"]
Keyword / OptionAccepted ValueDefaultEffect on Packet
cmd "<text>"Quoted FTP command verb ("USER", "PASS", "PASV", "RETR", "STOR", "QUIT")"USER"Writes the FTP client command verb.
arg "<text>"Quoted command argument (username, path, etc.)Omitted unless setAppends a space and argument after cmd before .
code <100..599>3-digit FTP reply code (220, 227, 230, 331, 530)Omitted on client commandsSwitches the packet to an FTP server status response starting with the 3-digit code.
reply "<text>"Quoted server response message"OK" when code is setSets the human-readable text following the 3-digit FTP code.

Cross-Layer Wrappers Valid with ftp

802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol

11 options
OptionRange / FormatDefaultEffect on Packet
wait <number><ns|us|ms|s|m>Time gap (ns, us, ms, s, m)10msAdvances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back).
payload "<text>" | hexpayload "<hex>"Quoted text or hex bytes (choose one)OmittedAppends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums.
srcmac <mac> | dstmac <mac>Colon, hyphen, or Cisco dot MACHost MAC / RFC multicast MACOverrides the 14-byte Ethernet II source or destination MAC address for this single packet.
vlan <0..4095> [pcp <0..7>] [dei <0|1>]VLAN ID 0..4095, PCP 0..7, DEI 0..1UntaggedWraps the packet in an IEEE 802.1Q VLAN tag (0x8100) with optional 802.1p QoS priority.
qinq <0..4095> [innervlan <0..4095>]Outer S-VLAN 0..4095, Inner C-VLAN 0..4095Untagged (innervlan 1 when qinq is set)Double-tags the packet with outer IEEE 802.1ad S-Tag (0x88a8) plus inner IEEE 802.1Q C-Tag (0x8100).
mpls <0..1048575> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>]Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255Unlabeled (at most 1 mpls tag per packet)Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header.
ttl <0..255> [dscp <0..63>] [ecn <0..3>]TTL/Hop Limit 0..255, DSCP 0..63, ECN 0..3ttl 64, dscp 0, ecn 0Sets IPv4 TTL or IPv6 Hop Limit plus DiffServ (DSCP) and ECN QoS markings.
ipid <0..65535> [df] [mf] [fragoffset <0..8191>]IPv4 ID, DF/MF flags, fragment offset 0..8191ipid 1, flags 0, fragoffset 0Sets IPv4 Identification, Do-Not-Fragment (df), More-Fragments (mf), and fragment offset (ignored over IPv6).
flowlabel <0..1048575>20-bit IPv6 Flow Label (0..1048575)0Sets the 20-bit IPv6 Flow Label for ECMP routing tests (ignored when running over IPv4 hosts).
srcport <0..65535> | dstport <0..65535>Port number 0..65535srcport 49152 (remembered), TCP 21Overrides source or destination port and remembers the port pair automatically on <- replies.
seq <number> | acknum <number> | win <0..65535> | syn | ack | psh | fin | rstTCP sequence/ack numbers, window size, flags & RFC 7323 optionspsh ack, win 65535, automatic TCP seq/acknumOverrides automatic TCP sequence tracking, flags, or RFC 7323 options (mss, wscale, sackperm, tsval, tsecr).

Gotchas & Quick Fixes

Use code (Not status) for FTP Server Replies

Avoid
client <- ftp_srv ftp status 220 reply "Ready"
Valid v3.1.2 Syntax
client <- ftp_srv ftp code 220 reply "Ready"

FTP and SMTP use code <num> reply "<text>" (status is used by HTTP, SIP, RTSP, IMAP, and SMB).

Wrap Command Verbs Like "USER" and "PASV" in Double Quotes

Avoid
client -> ftp_srv ftp cmd USER arg anonymous
Valid v3.1.2 Syntax
client -> ftp_srv ftp cmd "USER" arg "anonymous"

Keep cmd and arg values inside double quotes so uppercase FTP verbs and file paths parse cleanly.

Field Guide 03
Poke Stateful Firewalls, Suricata, Zeek & OT Conduits