Security_RNRF
0x33. 본문
33. Rooting a CTF server to get all the flags with Dirty COW - CVE-2016-5195
: Searching for Redditts found a new "CTF" for beginners.
: PwnerRank.com
-> useful dirty_cow
-> Change pwn1 to root privilege using dirty_cow
: Let's use our proof of concept exploit and test it to see if it works.
-> Therefore, you can copy and compile this code into a "tmp" file.
-> Test whether you can overwrite a non-critical file without overwriting it.
-> Root ownership file, which logs in as a different challenge user on the system and creates some files.
-> Then return to the first user and run "dirtyc0w" in that file and try to write.
-> And we can see it working when we check.
-> At this point, we write a message informing the author that the server is in "reddit".
-> Now you need an overwritable root file plan to become a root.
-> Our limit is to overwrite something in the file.
-> You can add anything.
-> The first obvious idea would be the "setuid" binary, but the problem is that you have to parse and figure out the Elvin file format to bring back door shells into the binaries.
-> An easier strategy is to overwrite the data in a text file.
-> And it's better to choose "/etc/passwd".
-> Here you can see the user's "ID" and log in as root if "uid" of "pwn1" is set to "0".
-> So the "dirtyC0W" proof of concept is written at the beginning of the file.
-> If so, you must first know the offset inside "/etc/passwd".
-> We use "hexdump" for that and can calculate a little.
-> Thus, the "pwn1" user adds "13" to the hexadecimal "0x4c0" offset.
-> Use Python as a calculator and modify the exploit code to write to a fixed offset.
-> You should be very careful about choosing these offsets and what you should choose.
-> Otherwise, the entire system could be ruined.
-> Therefore, try the desired operation by copying "/etc/passwd" before using the actual binary.
-> Usually, the first attempt is likely to have ruined the system.
-> Therefore, it is finally successful by adjusting the offset slightly and adding a line at the end.
-> And write in the actual "/etc/passwd".
-> Switching to "pwn1" or "ssh" login to "pwn1" now creates a root shell.
-> All flags can then be read.
-> When finished, return "/etc/passwd" to its original state.
: There are a few important points.
-> You should be very careful about what you write over an exploit like this.
-> Only one byte is miscalculated and can destabilize or crash the system.
-> If a server is judged to be vulnerable, it should think about its impact or situation.
-> These small personal "CTF" server projects, or web servers abused by any company, are not recommended to roam around them if they are unauthorized or can cause many causes.
-> But we have to take risks if necessary.