|
| 1 | +Diapers Simulator |
| 2 | +----------------- |
| 3 | + |
| 4 | +All server side files are in 'service'. |
| 5 | +All files to be distributed to the players are in 'distribute'. Please add the |
| 6 | +server address and port in distribute/description. |
| 7 | + |
| 8 | +# Exploit Details |
| 9 | + |
| 10 | +There is a vulnerability in the line: |
| 11 | + |
| 12 | +`memcpy(diaper_profile.brand, "Bunny Rabbit", 12);` |
| 13 | + |
| 14 | +The struct member length for the brand is 12 so this means that there is no null |
| 15 | +terminator for that member. It looks like it is correct because the member for |
| 16 | +wetness intentionally contains null bytes. |
| 17 | + |
| 18 | +There is also an integer underflow on the wetness. You can decrement wetness |
| 19 | +until it underflows and hits -1. When you do that, all the null bytes in the |
| 20 | +wetness member disappears. |
| 21 | + |
| 22 | +Changing the brand uses strlen to check how much to fread so now, there is a |
| 23 | +possibility of overflowing the brand member into the brand message member. |
| 24 | + |
| 25 | +The brand message member is used in a format string vulnerability here: |
| 26 | + |
| 27 | +`printf(diaper_obj->brand_message);` |
| 28 | + |
| 29 | +Use the format string vulnerability to leak address of printf and calculate libc |
| 30 | +base. Then replace puts in GOT with system. On the next call of puts: |
| 31 | + |
| 32 | +`puts("Shhhhh goodnight sleepy baby... go to b;ed");` |
| 33 | + |
| 34 | +This will spawn an `ed` calculator instance which lets you get shell by doing |
| 35 | +the following statement: |
| 36 | + |
| 37 | +`!sh` |
| 38 | + |
| 39 | +Working exploit is in service/exploit.py |
| 40 | + |
| 41 | +# Deployment Instructions |
| 42 | + |
| 43 | +0. Install docker on the hosting system |
| 44 | +1. Replace the flag in distribute/flag |
| 45 | +2. Build the docker image with: `sh dockerbuild.sh` |
| 46 | +3. Replace the port 1343 with your desired port in dockerrun.sh |
| 47 | +4. Start the docker image: `sh dockerrun.sh` |
| 48 | +5. Test the connectivity with netcat. |
| 49 | + |
| 50 | +libc should have the following hash d58eb4bfe204b6332b9ab3394ea943ef otherwise |
| 51 | +replace the libc in distribute. |
| 52 | + |
| 53 | +Cheers, |
| 54 | +- amon. |
0 commit comments