linux – OverTheWire: Piping the password into a vulnerable program does not escalate privilege

I am solving behemoth0 and have successfully reverse engineered and understood how the program works. Here is my exploit for the vulnerable program.

#include <iostream>

#include <string>
#include <cstring>

int main() {
        std::string s = "OK^GSYBEX^Y";
        char pass(200);

        strcpy(pass, s.c_str());

        memfrob(pass, strlen(pass));
        std::cout << pass;

However, the Linux shell command,
$ ./exploit_behemoth0 | /behemoth/behemoth0 where “exploit_behemoth0” is the compiled binary of the exploit above does not escalate privilege to behemoth1.

I learned this “piping” technique from “Hacking the Art of Exploitation by Jeff Erickson” in Chapter 0x300, Section 0x342, pg 161.

How do you fix this “piping” command so that the privilege escalation occurs?