- switch (state->mode)
- {
- case KNOCK:
- {
- const char *blocks[] = {
- "Wake up, Neo...",
- "The Matrix has you...",
- "Follow the white rabbit.",
- " ",
- "Knock, knock, Neo."
- };
- int nblocks = countof(blocks);
- int j;
- typing_delay = True;
- transmit_delay = False;
- long_delay = False;
- visible_cursor = True;
- for (j = 0; j < nblocks; j++)
- {
- int x = 3;
- int y = 2;
- const char *s = blocks[j];
- if (!s[0] || !s[1]) typing_delay = False;
- zero_cells (state);
- hack_text_1 (state, &x, &y, s,
- typing_delay, transmit_delay, -1,
- visible_cursor, True);
- matrix_usleep (state, 2000000);
- }
- }
- break;
-
- case TRACEA1: case TRACEB1:
- {
- const char *blocks[10];
- int j, n = 0;
-
- if (state->mode == TRACEA1)
- blocks[n++] =
- (state->grid_width >= 52
- ? "Call trans opt: received. 2-19-98 13:24:18 REC:Log>"
- : "Call trans opt: received.\n2-19-98 13:24:18 REC:Log>");
- else
- blocks[n++] =
- (state->grid_width >= 52
- ? "Call trans opt: received. 9-18-99 14:32:21 REC:Log>"
- : "Call trans opt: received.\n9-18-99 14:32:21 REC:Log>");
-
- if (state->mode == TRACEB1)
- blocks[n++] = "WARNING: carrier anomaly";
- blocks[n++] = "Trace program: running";
-
- typing_delay = False;
- transmit_delay = True;
- long_delay = True;
- visible_cursor = True;
- for (j = 0; j < n; j++)
- {
- const char *s = blocks[j];
- int x = 0;
- int y = 0;
- zero_cells (state);
- hack_text_1 (state, &x, &y, s,
- typing_delay, transmit_delay, long_delay,
- visible_cursor, True);
- }
- matrix_usleep (state, 1000000);
- }
- break;
-
- case SYSTEMFAILURE:
- {
- const char *s = "SYSTEM FAILURE";
- int i;
- float cx = ((int)state->grid_width - (int)strlen(s)) / 2 - 0.5;
- float cy = (state->grid_height / 2) - 1.3;
- int x, y;
-
- if (cy < 0) cy = 0;
- if (cx < 0) cx = 0;
-
- XFillRectangle (state->dpy, state->window, state->erase_gc,
- cx * state->char_width,
- cy * state->char_height,
- (strlen(s) + 1) * state->char_width,
- state->char_height * 1.6);
-
- for (i = -2; i < 3; i++)
- {
- XGCValues gcv;
- gcv.foreground = state->colors[i + 2];
- XChangeGC (state->dpy, state->scratch_gc, GCForeground, &gcv);
- XDrawRectangle (state->dpy, state->window, state->scratch_gc,
- cx * state->char_width - i,
- cy * state->char_height - i,
- (strlen(s) + 1) * state->char_width + (2 * i),
- (state->char_height * 1.6) + (2 * i));
- }
-
- /* If we don't clear these out, part of the box may get overwritten */
- for (i = 0; i < state->grid_height * state->grid_width; i++)
- {
- m_cell *cell = &state->cells[i];
- cell->changed = 0;
- }
-
- x = ((int)state->grid_width - (int)strlen(s)) / 2;
- y = (state->grid_height / 2) - 1;
- if (y < 0) y = 0;
- if (x < 0) x = 0;
- hack_text_1 (state, &x, &y, s,
- typing_delay, transmit_delay, long_delay,
- visible_cursor, False);
- }
- break;
-
- case NMAP:
- {
- /* Note that what Trinity is using here is moderately accurate:
- She runs nmap (http://www.insecure.org/nmap/) then breaks in
- with a (hypothetical) program called "sshnuke" that exploits
- the (very real) SSHv1 CRC32 compensation attack detector bug
- (http://staff.washington.edu/dittrich/misc/ssh-analysis.txt).
-
- The command syntax of the power grid control software looks a
- lot like Cisco IOS to me. (IOS is a descendant of VMS.)
- */
- const char *blocks[] = {
- "# ",
-
- "\001nmap 10.2.2.2\n",
- "Starting nmap V. 2.54BETA25\n"
-
- "\010", "\010", "\010",
-
- "Insufficient responses for TCP sequencing (3), OS detection "
- "may be less accurate\n"
- "Interesting ports on 10.2.2.2:\n"
- "(The 1538 ports scanned but not shown below are in state: "
- "filtered)\n"
- "Port state service\n"
- "22/tcp open ssh\n"
- "\n"
- "No exact OS matches for host\n"
- "\n"
- "Nmap run completed -- 1 IP address (1 host up) scanned\n"
- "# ",
-
- "\001sshnuke 10.2.2.2 -rootpw=\"Z1ON0101\"\n",
-
- "Connecting to 10.2.2.2:ssh ... ",
-
- "successful.\n"
- "Attempting to exploit SSHv1 CRC32 ... ",
-
- "successful.\n"
- "Resetting root password to \"Z1ON0101\".\n",
-
- "System open: Access Level <9>\n"
- "# ",
-
- "\001ssh 10.2.2.2 -l root\n",
-
- "root@10.2.2.2's password: ",
-
- "\001\010\010\010\010\010\010\010\010\n",
-
- "\n"
- "RRF-CONTROL> ",
-
- "\001disable grid nodes 21 - 40\n",
-
- "\002Warning: Disabling nodes 21-40 will disconnect sector 11 "
- "(27 nodes)\n"
- "\n"
- "\002 ARE YOU SURE? (y/n) ",
-
- "\001\010\010y\n",
- "\n"
- };
-
- int nblocks = countof(blocks);
- int y = state->grid_height - 2;
- int x, j;
-
- visible_cursor = True;
- x = 0;
- zero_cells (state);
- for (j = 0; j < nblocks; j++)
- {
- const char *s = blocks[j];
- typing_delay = (*s == '\001');
- if (typing_delay) s++;
-
- long_delay = False;
- hack_text_1 (state, &x, &y, s,
- typing_delay, transmit_delay, long_delay,
- visible_cursor, True);
- }
-
- typing_delay = False;
- long_delay = False;
- for (j = 21; j <= 40; j++)
- {
- char buf[100];
- sprintf (buf, "\002Grid Node %d offline...\n", j);
- hack_text_1 (state, &x, &y, buf,
- typing_delay, transmit_delay, -1,
- visible_cursor, True);
-
- }
- long_delay = True;
- hack_text_1 (state, &x, &y, "\nRRF-CONTROL> ",
- typing_delay, transmit_delay, long_delay,
- visible_cursor, True);
-
- /* De-glow all cells before draining them... */
- for (j = 0; j < state->grid_height * state->grid_width; j++)
- {
- m_cell *cell = &state->cells[j];
- cell->changed = (cell->glow != 0);
- cell->glow = 0;
- }
- }
- break;
-
- default:
- abort();
- break;
- }
-}
-
-
-static void
-drain_matrix (m_state *state)
-{
- int delay = get_integer_resource ("delay", "Integer");
- int i;
-
- /* Fill the top row with empty top-feeders, to clear the screen. */
- for (i = 0; i < state->grid_width; i++)
- {
- m_feeder *f = &state->feeders[i];
- f->y = -1;
- f->remaining = 0;
- f->throttle = 0;
- }
-
- /* Turn off all the spinners, else they never go away. */
- for (i = 0; i < state->grid_width * state->grid_height; i++)
- if (state->cells[i].spinner)
- {
- state->cells[i].spinner = 0;
- state->cells[i].changed = 1;
- }
-
- /* Run the machine until there are no live cells left. */
- while (1)
- {
- Bool any_cells_p = False;
- for (i = 0; i < state->grid_width * state->grid_height; i++)
- if (state->cells[i].glyph)
- {
- any_cells_p = True;
- goto FOUND;
- }
- FOUND:
- if (! any_cells_p)
- return;
-
- feed_matrix (state);
- redraw_cells (state, True);
- XSync (state->dpy, False);
- handle_events (state);
- if (delay) usleep (delay);
- }
-}