CBL 4: Tables in COBOL (110 pts)

Caesar Cipher

Make a program that accepts a line of text and shifts the letters forward by all possible offsets, as shown below.

Hint: use INSPECT.

Flag CBL 4.1: Caesar (10 pts)

Decrypt this text to see the flag:
JXU VBQW YI IYCFBU

Tables

Enter this program into a file named tbl.cbl:
IDENTIFICATION DIVISION.
PROGRAM-ID. TBL.

DATA DIVISION.
WORKING-STORAGE SECTION.
01 TBL.
 05 ROW OCCURS 3 TIMES.
  10 ROW-HDR PIC A(2).
    10 CELL OCCURS 3 TIMES.
     15 CELL-PIC PIC X(1).

PROCEDURE DIVISION.
  MOVE '1 ABC2 DEF3 GHI' TO TBL.
    DISPLAY 'TBL       : ' TBL.
    DISPLAY ' '.
    DISPLAY 'ROW(1)    : ' ROW(1).
    DISPLAY 'ROW(2)    : ' ROW(2).
    DISPLAY 'ROW(3)    : ' ROW(3).
    DISPLAY ' '.
    DISPLAY 'CELL(1,1) : ' CELL(1,1).
    DISPLAY 'CELL(2,2) : ' CELL(2,2).
    DISPLAY 'CELL(3,3) : ' CELL(3,3).

STOP RUN.
Compile and run it. As shown below, this makes a 3 by 3 table.

Tic-Tac-Toe

Create a program that takes a 3x3 table as input and determines whether X has won the game or not, as shown below.

To test your program, here is a winner:

A XXXA OOOA XOX
Here is a loser:
Z OOXZ OOOZ XOX

Flag CBL 4.2: Tic (10 pts)

Find the winners in this list of tables. Concatenate the first letters to form the flag.

For example, if only the first three were winners, the flag would be ABC.

A XOXA OOOA XXX
B XOXB XOOB OOX
C XOXC OXOC XOX
D XOOD XOOD XOX
C XOXB OXOB XXO
B OXXC OOOC XOX
A XXOC OXXC XOO

Flag CBL 4.3: Tics (20 pts)

Execute this command to fetch a longer list of tables:
wget https://samsclass.info/129S/proj/CBL4.3
Find the winners in this list of tables. Concatenate the first letters to find the flag.

Atbash Substitution Cipher

Make a program that accepts a line of text and replaces each letter with an alphabet in reverse order, like this:
A --> Z
B --> Y
C --> X
...
Y --> B
Z --> A
Enciphering text twice with this system recovers the original plaintext, as shown below.

Flag CBL 4.4: Atbash Substitution (10 pts)

Decipher this text to see the flag:
GSV UOZT RH GSRMP_YZXPDZIWH

Keyword Substitution

One way to make an alphabet is to choose a keyword such as ZERO and place it at the start of the alphabet, like this:
Original   : ABCDEFGHIJKLMNOPQRSTUVWXYZ
Replacement: ZEROABCDFGHIJKLMNPQSTUVWXY
Make programs that can encode and decode text with this system, as shown below.

Flag CBL 4.5: Yank (20 pts)

The key is YANK.

Decipher this text to see the flag:

SEB_CIYD_FR_HBXJYRSBQ

Flag CBL 4.6: Power of Three (40 pts)

The key is three letters long.

Decipher this text to see the flag:

Hint: you can guess a word in the plaintext.

SFHR_SHLC_YNTQ_DKWE_HR_AHEINA

Posted 4-8-2020 by Sam Bowne
Ciphertext for 4.5 corrected 4-17-2020