Tags: fat32 fatcat bash
Rating: 4.7
Unlike other participants, I could not just make `find` work for me, so I had to find another way.
Fortunately, there's a very nice tool called `fatcat `. It can show directory listing without mounting an image, and it also shows "real" inodes:
```
% fatcat -l / strcmp.fat32 
Listing path /
Directory cluster: 2
d 1/1/1980 00:00:00  SPACE/                         c=758
d 1/1/1980 00:00:00  !/                             c=1406
d 1/1/1980 00:00:00  #/                             c=1618
d 1/1/1980 00:00:00  $/                             c=1254
d 1/1/1980 00:00:00  %/                             c=1406
d 1/1/1980 00:00:00  &/                             c=1618
...
```
So the procedure was:
* Create a blacklist of "invalid" inodes. It's very easy, because we know that flag starts with "PCTF{"
* Just go level down until the flag is complete ignoring directories that link to blacklisted inodes.
Creating a blacklist of inodes (also had to add some manually):
```
for symbool in $(cat all-symbols); do fatcat strcmp.fat32 -l "/$symbol" | awk '{print $5}' | cut -d= -f2 | grep -v '^$'; done | sort | uniq  >> bad-inodes
```
Creating regexp list:
```
cat bad-inodes | sort | uniq | while read s; do echo 'c='$s'$'; done > r
```
Final iterating looked like this:
```
% fatcat strcmp.fat32 -l '/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/' | grep -vf r
Listing path /P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/
Directory cluster: 950
d 1/1/1980 00:00:00  P/                             c=1110
d 1/1/1980 00:00:00  S/                             c=1454
f 1/1/1980 00:00:00  TOOBAD                         c=1842 s=0 (0B)
% fatcat strcmp.fat32 -l '/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/' | grep -vf r
Listing path /P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/
Directory cluster: 1454
d 1/1/1980 00:00:00  P/                             c=1110
d 1/1/1980 00:00:00  Y/                             c=622
f 1/1/1980 00:00:00  NOMATCH                        c=1842 s=0 (0B)
....
% fatcat strcmp.fat32 -l '/P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/' | grep -vf r
Listing path /P/C/T/F/{/W/H/A/T/_/I/N/_/T/A/R/N/A/T/I/O/N/_/I/S/_/T/H/1/S/_/F/I/L/E/S/Y/S/T/E/M/!/}/
Directory cluster: 1638
```
The challenge was generated with this tool: https://github.com/8051Enthusiast/regex2fat