# README
dirtycow dot c
Imagine a Playground Game with a Twist
Imagine a playground game where kids are copying each other's moves. One kid is the leader, and the others are trying to perfectly mirror the leader's actions. This code is like a sneaky trick to change the leader without anyone noticing.
What the Code Does
-
Setting Up the Trick:
- The code prepares a secret code (
sc
) that it wants to sneak into the game. This secret code is like a new set of dance moves. - It also makes a copy of the current leader's moves as a backup, just in case things go wrong (
/tmp/bak
).
- The code prepares a secret code (
-
Starting the Game:
- The code starts two kids playing the game:
- One kid keeps distracting the current leader with random actions (
madviseThread
). - The other kid tries to replace the leader's moves with the secret code, over and over again (
procselfmemThread
).
- One kid keeps distracting the current leader with random actions (
- The code starts two kids playing the game:
-
Waiting for the Right Moment:
- A third kid watches the game carefully (
waitForWrite
). - When the two other kids have successfully confused the current leader, the third kid jumps in and takes over, becoming the new leader with the secret code!
- A third kid watches the game carefully (
Important Words
- Functions: These are like the instructions for each kid in the game.
madviseThread
tells one kid how to distract,procselfmemThread
tells the other kid how to replace the moves, andwaitForWrite
tells the third kid when to take over. - Variables: These are like the labels for things in the game.
suid_binary
is the name of the game, andsc
is the secret code. - Threads: Think of these as the individual kids playing the game. Each thread follows a different set of instructions.
In Summary:
This code is a way to exploit a vulnerability in a computer program (the "game"). It does this by tricking the program into running a different set of instructions (the "secret code") that can give the attacker more control over the computer. This kind of trick is dangerous and should only be used by experts in a controlled environment.
main.go
Imagine a Playground Game with a Magical Trick
Imagine a playground game where kids have to follow a set of rules written in a special book. This Go code is like a sneaky magician who wants to change the rules of the game without anyone noticing.
What the Code Does
-
The Magician's Secret Spell:
- The magician has a secret spell (
sc
) that can change the rules of the game. It's like a magic word that can make anything happen. - To be safe, the magician makes a copy of the original rulebook (
/tmp/bak
) before starting the trick.
- The magician has a secret spell (
-
Setting Up the Illusion:
- The magician uses their magic to create two illusions (
madvise
andprocselfmem
).- The first illusion makes it look like they're just playing the game normally.
- The second illusion secretly tries to replace the rules in the rulebook with the secret spell, over and over again.
- The magician uses their magic to create two illusions (
-
Waiting for the Right Moment:
- The magician has a helper (
waitForWrite
) who keeps a close eye on the rulebook. - When the helper sees that the secret spell has successfully replaced the old rules, they give a signal.
- The magician has a helper (
-
The Grand Finale:
- The magician receives the signal and ends the illusions.
- The game continues, but now with the new rules from the secret spell! The magician has successfully changed the game without anyone noticing.
Important Words
- Functions: These are like the different tricks the magician performs.
madvise
,procselfmem
, andwaitForWrite
are all parts of the magician's illusion. - Variables: These are like labels for the magician's tools.
SuidBinary
is the name of the rulebook, andsc
is the secret spell. - Goroutines: Think of these as the magician's helpers. They run different parts of the illusion at the same time.
In Summary
This Go code is a way to exploit a vulnerability in a computer program (the "game"). It does this by tricking the program into running a different set of instructions (the "secret spell") that can give the attacker more control over the computer. This is a very dangerous trick and should only be used by experts in a controlled environment!