# Csaw 2019 Gibberish Check

Let's take a look at the binary:

```
$    file gibberish_check
gibberish_check: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=248693b90a85745125ac4d8241d53503e822a4c7, stripped
$    pwn checksec gibberish_check
[*] '/Hackery/pod/modules/38-grab_bad/csaw19_gibberishCheck/gibberish_check'
    Arch:     amd64-64-little
    RELRO:    Full RELRO
    Stack:    Canary found
    NX:       NX enabled
    PIE:      PIE enabled
$    ./gibberish_check
Find the Key!
15935728
Wrong D:
```

So we can see that we are dealing with a `x64` bit elf (with `PIE`) that scans in input, and check it. When we take a look at the code in ghidra, we see this:

```

/* WARNING: Globals starting with '_' overlap smaller symbols at the same address */

undefined8 FUN_00101d98(void)

{
  char cVar1;
  int iVar2;
  basic_ostream *this;
  basic_string<char,std--char_traits<char>,std--allocator<char>> *this_00;
  long in_FS_OFFSET;
  allocator<char> local_42d;
  allocator<char> local_42c;
  allocator<char> local_42b;
  allocator<char> local_42a;
  allocator<char> local_429;
  allocator<char> local_428;
  allocator<char> local_427;
  allocator<char> local_426;
  allocator<char> local_425;
  allocator<char> local_424;
  allocator<char> local_423;
  allocator<char> local_422;
  allocator<char> local_421;
  allocator<char> local_420;
  allocator<char> local_41f;
  allocator<char> local_41e;
  allocator<char> local_41d;
  allocator<char> local_41c;
  allocator<char> local_41b;
  allocator<char> local_41a;
  allocator<char> local_419;
  allocator<char> local_418;
  allocator<char> local_417;
  allocator<char> local_416;
  allocator<char> local_415;
  int local_414;
  undefined8 local_410;
  undefined8 local_408;
  undefined *local_400;
  undefined local_3f8 [32];
  basic_string local_3d8 [32];
  basic_string local_3b8 [32];
  basic_string local_398 [32];
  basic_string<char,std--char_traits<char>,std--allocator<char>> local_378 [32];
  char local_358 [32];
  char local_338 [32];
  char local_318 [32];
  char local_2f8 [32];
  char local_2d8 [32];
  char local_2b8 [32];
  char local_298 [32];
  char local_278 [32];
  char local_258 [32];
  char local_238 [32];
  char local_218 [32];
  char local_1f8 [32];
  char local_1d8 [32];
  char local_1b8 [32];
  char local_198 [32];
  char local_178 [32];
  char local_158 [32];
  char local_138 [32];
  char local_118 [32];
  char local_f8 [32];
  char local_d8 [32];
  char local_b8 [32];
  char local_98 [32];
  char local_78 [32];
  char local_58 [32];
  basic_string<char,std--char_traits<char>,std--allocator<char>> abStack56 [8];
  long local_30;
 
  local_30 = *(long *)(in_FS_OFFSET + 0x28);
  FUN_00101be1();
  allocator();
                    /* try { // try from 00101de3 to 00101de7 has its CatchHandler @ 00102950 */
  basic_string((char *)local_378,(allocator *)"dqzkenxmpsdoe_qkihmd");
  allocator();
                    /* try { // try from 00101e16 to 00101e1a has its CatchHandler @ 0010293c */
  basic_string(local_358,(allocator *)"jffglzbo_zghqpnqqfjs");
  allocator();
                    /* try { // try from 00101e49 to 00101e4d has its CatchHandler @ 00102928 */
  basic_string(local_338,(allocator *)"kdwx_vl_rnesamuxugap");
  allocator();
                    /* try { // try from 00101e7c to 00101e80 has its CatchHandler @ 00102914 */
  basic_string(local_318,(allocator *)"ozntzohegxagreedxukr");
  allocator();
                    /* try { // try from 00101eb2 to 00101eb6 has its CatchHandler @ 00102900 */
  basic_string(local_2f8,(allocator *)"xujaowgbjjhydjmmtapo");
  allocator();
                    /* try { // try from 00101ee8 to 00101eec has its CatchHandler @ 001028ec */
  basic_string(local_2d8,(allocator *)"pwbzgymqvpmznoanomzx");
  allocator();
                    /* try { // try from 00101f1e to 00101f22 has its CatchHandler @ 001028d8 */
  basic_string(local_2b8,(allocator *)"qaqhrjofhfiuyt_okwxn");
  allocator();
                    /* try { // try from 00101f54 to 00101f58 has its CatchHandler @ 001028c4 */
  basic_string(local_298,(allocator *)"a_anqkczwbydtdwwbjwi");
  allocator();
                    /* try { // try from 00101f8a to 00101f8e has its CatchHandler @ 001028b0 */
  basic_string(local_278,(allocator *)"zoljafyuxinnvkxsskdu");
  allocator();
                    /* try { // try from 00101fc0 to 00101fc4 has its CatchHandler @ 0010289c */
  basic_string(local_258,(allocator *)"irdlddjjokwtpbrrr_yj");
  allocator();
                    /* try { // try from 00101ff6 to 00101ffa has its CatchHandler @ 00102888 */
  basic_string(local_238,(allocator *)"cecckcvaltzejskg_qrc");
  allocator();
                    /* try { // try from 0010202c to 00102030 has its CatchHandler @ 00102874 */
  basic_string(local_218,(allocator *)"vlpwstrhtcpxxnbbcbhv");
  allocator();
                    /* try { // try from 00102062 to 00102066 has its CatchHandler @ 00102860 */
  basic_string(local_1f8,(allocator *)"spirysagnyujbqfhldsk");
  allocator();
                    /* try { // try from 00102098 to 0010209c has its CatchHandler @ 0010284c */
  basic_string(local_1d8,(allocator *)"bcyqbikpuhlwordznpth");
  allocator();
                    /* try { // try from 001020ce to 001020d2 has its CatchHandler @ 00102838 */
  basic_string(local_1b8,(allocator *)"_xkiiusddvvicipuzyna");
  allocator();
                    /* try { // try from 00102104 to 00102108 has its CatchHandler @ 00102824 */
  basic_string(local_198,(allocator *)"wsxyupdsqatrkzgawzbt");
  allocator();
                    /* try { // try from 0010213a to 0010213e has its CatchHandler @ 00102810 */
  basic_string(local_178,(allocator *)"ybg_wmftbdcvlhhidril");
  allocator();
                    /* try { // try from 00102170 to 00102174 has its CatchHandler @ 001027fc */
  basic_string(local_158,(allocator *)"ryvmngilaqkbsyojgify");
  allocator();
                    /* try { // try from 001021a6 to 001021aa has its CatchHandler @ 001027e8 */
  basic_string(local_138,(allocator *)"mvefjqtxzmxf_vcyhelf");
  allocator();
                    /* try { // try from 001021dc to 001021e0 has its CatchHandler @ 001027d4 */
  basic_string(local_118,(allocator *)"hjhofxwrk_rpwli_mxv_");
  allocator();
                    /* try { // try from 00102212 to 00102216 has its CatchHandler @ 001027c0 */
  basic_string(local_f8,(allocator *)"enupmannieqqzcyevs_w");
  allocator();
                    /* try { // try from 00102248 to 0010224c has its CatchHandler @ 001027ac */
  basic_string(local_d8,(allocator *)"uhmvvb_cfgjkggjpavub");
  allocator();
                    /* try { // try from 0010227e to 00102282 has its CatchHandler @ 00102798 */
  basic_string(local_b8,(allocator *)"gktdphqiswomuwzvjtog");
  allocator();
                    /* try { // try from 001022b4 to 001022b8 has its CatchHandler @ 00102784 */
  basic_string(local_98,(allocator *)"lgoehepwclbaifvtfoeq");