{"id":326,"date":"2018-10-29T20:15:59","date_gmt":"2018-10-30T00:15:59","guid":{"rendered":"http:\/\/www.wispwisp.com\/?p=326"},"modified":"2020-11-09T23:44:58","modified_gmt":"2020-11-09T23:44:58","slug":"raymond-james-ctf","status":"publish","type":"post","link":"https:\/\/www.wispwisp.com\/index.php\/2018\/10\/29\/raymond-james-ctf\/","title":{"rendered":"Raymond James CTF"},"content":{"rendered":"<p><span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">I went to Tampa, Florida last weekend to participate&nbsp;Raymond James CTF. My team got 3rd place with $2500 award.<\/span><\/p>\n<p><span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">The weather in Florida is so0O gO0od: 24 degrees C, meanwhile it&#8217;s like 3 degrees C in Baltimore.<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-333\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/WechatIMG206-1-169x300.jpeg\" alt=\"\" width=\"169\" height=\"300\"><\/span><\/p>\n<p><span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><strong>The team photo:<\/strong><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">My eyes were closed lol.<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-337\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/DqjLkqnWwAApVQm-300x248.jpg\" alt=\"\" width=\"543\" height=\"449\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><strong>The trophy:<\/strong><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-332\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/WechatIMG202-1-225x300.jpeg\" alt=\"\" width=\"260\" height=\"347\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><strong>The coin from gam3z:<\/strong><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-334\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/WechatIMG207-1-286x300.jpeg\" alt=\"\" width=\"286\" height=\"300\"> <img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-335\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/WechatIMG208-1-282x300.jpeg\" alt=\"\" width=\"282\" height=\"300\"><\/span><\/p>\n<p><span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">The onsite-CTF was 70% forensics, 20% binary reverse and 10% Misc. I&#8217;m not good at forensics so I didn&#8217;t contribute much on that. However, I earn 185 out of 215 points from the pre-challenge by solving a binary reverse problem. Those points from the pre-challenge give our team a huge advantage during the on-site CTF.<\/span><\/p>\n<hr>\n<p><span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><strong>Write up for the binary reverse problem from pre-challenge(without IDA):<\/strong><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><strong>Step 1: Understand the program<\/strong><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Use the password in the email from t0k3nz@gam3z-inc.com to extract the binary from the Zip file.<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-342\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/image-300x126.png\" alt=\"\" width=\"663\" height=\"278\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-345\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-9.06.16-PM.png\" alt=\"\" width=\"88\" height=\"89\"><\/span><\/p>\n<blockquote><p><span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">file Ghost_Protocol_Access<\/span><\/p><\/blockquote>\n<p class=\"p1\"><span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code><span class=\"s1\">Ghost_Protocol_Access: ELF 64-bit LSB executable, x86-64, version 1 (GNU\/Linux), statically linked, for GNU\/Linux 3.2.0, BuildID[sha1]=cf8c2aebbde52c274e2f71dc3a83bb63e4a629e3, stripped<\/span><\/code><\/span><\/p>\n<p><span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">I copy the binary to my Ubuntu VM and run the binary:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-347\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-9.08.49-PM-300x153.png\" alt=\"\" width=\"618\" height=\"315\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">The program print out two messages:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>\"This version of bash is terribly out of date....your environment is not secure and this program will not run.\"<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>\"You're not even authorized to use this program!\"<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">I load the binary in Hopper Disassembler(<a href=\"https:\/\/www.hopperapp.com\/\">https:\/\/www.hopperapp.com\/<\/a>) and search for the string: &#8220;<code>This version of bash is terribly out of date....<\/code>&#8220;<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-348\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-9.13.09-PM-300x18.png\" alt=\"\" width=\"1050\" height=\"63\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">The string was used in function: <strong>sub_401c99.&nbsp;<\/strong>I then load the binary in&nbsp;radare2, I prefer reading assembly code in r2 because it looks nicer:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>r2&nbsp;Ghost_Protocol_Access<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>aaa<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>s 0x401c99<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>pdf<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-349\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-9.19.59-PM-300x134.png\" alt=\"\" width=\"759\" height=\"339\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">The program check for things like &#8220;gdb&#8221;, &#8220;r2&#8221;, and &#8220;bash&#8221;. If &#8220;gdb&#8221; or &#8220;r2&#8221; is found, the program will print out the string:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>\"Seriously....you're trying to debug and disassemble me?!?\\n ....ridiculous....I don't even know what to say.....so disappointed....\"<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">If &#8220;bash&#8221;&nbsp; is found, the program will print:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>\"This version of bash is terribly out of date....your environment is not secure and this program will not run.\"<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Now I understand the function &#8220;<strong>sub_401c99<\/strong>&#8221; does some environment check and exit the program. My next step is to find out where this function gets called in the program.<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">I reload the binary in&nbsp;radare2:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>r2&nbsp;Ghost_Protocol_Access<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>aaa<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>pdf<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-363\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-9.34.11-PM-2-300x116.png\" alt=\"\" width=\"631\" height=\"243\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Noticed the function address &#8220;<strong>0x401c99<\/strong>&#8221; was one of the function argument for the next function call(<strong>sub.libc_start_main_40<\/strong>). To display the instruction in function sub.libc_start_main_40 in r2, I used following command:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>s&nbsp;sub.libc_start_main_40<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>pdf<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">I can&#8217;t really understand what the program is doing inside the function &#8220;<code>sub.libc_start_main_40<\/code>&#8221; by reading the assembly code only, I need to run the program in GDB to understand the program flow.<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>gdb .\/Ghost_Protocol_Access<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">The program starts at address&nbsp;0x004015f0:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-353\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-9.45.20-PM-300x83.png\" alt=\"\" width=\"550\" height=\"152\"><\/span><\/p>\n<p><span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">I put break point at the beginning of the program:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>tbreak *0x004015f0<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>run<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Run the program line by line(in assembly) in GDB with &#8220;next&#8221; and &#8220;step&#8221;. Pressing &#8220;n&#8221; in gdb for a while and the program stop at address: 0x402347:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-354\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-9.52.47-PM-300x50.png\" alt=\"\" width=\"528\" height=\"88\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">whats in eax?&nbsp;It&#8217;s the function(<strong>sub_0x401c99<\/strong>) I mentioned before, the function that checks environment and quit the program.<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-355\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-9.53.42-PM-300x162.png\" alt=\"\" width=\"335\" height=\"181\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">At this point I understand after entering the function &#8220;<code>sub.libc_start_main_40<\/code>&#8220;, the program call &#8220;<code>sub_0x401c99<\/code>&#8221; and the program die afterword.<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">I am not sure what to do at this point, I just randomly do a &#8220;<code>strings Ghost_Protocol_Access | grep t0k3n<\/code>&#8221; and got some interesting result:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-356\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-9.59.08-PM-300x32.png\" alt=\"\" width=\"684\" height=\"73\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Since I know one of the token named &#8220;acc3ss&#8221;, I start searching the string &#8220;acc3sst0k3n&#8221; in the program. I&nbsp;search the string in r2 with command <code>\"\/ $string\"<\/code>:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-357\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-10.18.09-PM-300x125.png\" alt=\"\" width=\"403\" height=\"168\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">In hopper, it shows the strings was used in function <strong>sub_401987<\/strong>:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-358\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-10.19.14-PM-300x51.png\" alt=\"\" width=\"571\" height=\"97\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">I notice the function&nbsp;<strong>sub_401987<\/strong> doesn&#8217;t get call in the program:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-360\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-10.21.41-PM-300x40.png\" alt=\"\" width=\"541\" height=\"72\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Hopper has the feature to show where a function get called, if a function get called, it will show something like this in hopper:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-362\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-10.21.33-PM-1-300x21.png\" alt=\"\" width=\"743\" height=\"52\"><\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\">I want to see what function&nbsp;<strong>sub_401987<\/strong> does, my plan is to patch the program and let the function&nbsp;<strong>sub_401987<\/strong> run.<\/span><\/p>\n<hr>\n<p><span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><strong>Step 2: Patch the binary to get the Token(Flag):<\/strong><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><strong>First Patch:<\/strong><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Remember at the beginning of the program, the environment checking function: sub_0x401c99 was moved into the register and get called in &#8220;sub.libc_start_main_40&#8221; function. I first patch the binary to change the value from&nbsp;<strong>sub_0x401c99<\/strong> to&nbsp;<strong>sub_401987<\/strong>, so&nbsp;<strong>sub_401987<\/strong> will be called afterwords.<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-364\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-9.34.11-PM-3-300x116.png\" alt=\"\" width=\"507\" height=\"196\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">The opcode 48c7c7991c40. means 48c7c7991c4000, the small dot, in the end, represent two zero &#8220;00&#8221;. I use this website to convert between opcode and assembly:&nbsp;<a href=\"https:\/\/defuse.ca\/online-x86-assembler.htm#disassembly2\">https:\/\/defuse.ca\/online-x86-assembler.htm#disassembly2<\/a><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">I need the opcode for&nbsp;<code>mov rdi, 0x401987<\/code>:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-365\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-10.44.08-PM-300x241.png\" alt=\"\" width=\"294\" height=\"236\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Patch the binary in r2:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>oo+<\/code>(enable write)<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>s 0x0040160d<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>wx&nbsp;48C7C787194000<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>q<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Run the program again:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-367\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-10.55.53-PM-300x49.png\" alt=\"\" width=\"484\" height=\"79\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">The program ask for a &#8220;Confirmation Code&#8221;, I am not sure what the code is so I enter some random string:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-368\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-10.56.54-PM-300x123.png\" alt=\"\" width=\"488\" height=\"200\"><\/span><\/p>\n<hr>\n<p><span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><strong>Second Patch:<\/strong><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Check the <strong>sub_0x00401987<\/strong> function in r2:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>s&nbsp;0x00401987<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>pdf<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-369\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-11.08.52-PM-300x104.png\" alt=\"\" width=\"696\" height=\"241\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">There are two place call the function &#8220;call sub.You_re_not_even_authorized_to_use_this_program_70d&#8221;. The jump come from <code>CODE XREF from main (0x401b42)<\/code> and <code>CODE XREF from main (0x401b0d)<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Both section does the same thing: call a function, compare the output to a variable, jump if not equal:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-370\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-11.12.01-PM-300x125.png\" alt=\"\" width=\"631\" height=\"263\"><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">I patch the jump instruction to let the program can keep running without doing the jump:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>oo+<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>s&nbsp;0x401b42<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>wx&nbsp;909090909090<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>s&nbsp;0x401b0d<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>wx&nbsp;909090909090<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>q<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Change jne instruction to nop:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-371\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-11.17.34-PM-300x178.png\" alt=\"\" width=\"558\" height=\"331\"><\/span><\/p>\n<p><span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\">Run the program again to get the flag:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-372\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-11.18.25-PM-300x52.png\" alt=\"\" width=\"484\" height=\"84\"><\/span><\/p>\n<hr>\n<p><span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\"><strong>Step 3: Fix the image file:<\/strong><\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\">After the program print our both token, it also outputs a file called: &#8220;acc3sst0k3n&#8221;:<\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-full wp-image-374\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-11.22.05-PM.png\" alt=\"\" width=\"136\" height=\"118\"><\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\">My teammate told me this file can be base64 decode to an image, but the file is somewhere corrupted and they can&#8217;t the flag in the image.<\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\">I did remember there is a super long string in function&nbsp;<strong>sub_0x0401987<\/strong>:<\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-375\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-11.33.56-PM-300x115.png\" alt=\"\" width=\"652\" height=\"250\"><\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\">I am not sure what was this at the beginning, I went to address &#8220;0x00496498&#8221; in r2 and type:<\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>s&nbsp;0x00496498<\/code><\/span><br \/>\n<span style=\"font-size: 14pt; font-family: helvetica, arial, sans-serif;\"><code>ps 100000<\/code><code><\/code><\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\">In r2 it outputs a huge amount of base64 encoded string, the image below shows the end of the string.&nbsp;<\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-376\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-11.36.53-PM-300x63.png\" alt=\"\" width=\"700\" height=\"147\"><\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\">I search for <code>\"XXH+Kk\"<\/code> in &#8220;acc3sst0k3n&#8221; file and found a &#8220;NUL&#8221;.<\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone size-medium wp-image-377\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/Screen-Shot-2018-10-29-at-11.38.39-PM-300x161.png\" alt=\"\" width=\"300\" height=\"161\"><\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\">I delete the <code>\"NUL\"<\/code> and run the following command to convert base64 encoded file to an image:<\/span><\/p>\n<p class=\"p1\"><span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\"><code><span class=\"s1\">base64 -D acc3sst0k3n &gt; a.png<\/span><\/code><\/span><\/p>\n<p><span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\">View the image:<\/span><br \/>\n<span style=\"font-family: helvetica, arial, sans-serif; font-size: 14pt;\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-378\" src=\"https:\/\/www.wispwisp.com\/wp-content\/uploads\/2018\/10\/a-300x130.png\" alt=\"\" width=\"388\" height=\"168\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I went to Tampa, Florida last weekend to participate&nbsp;Raymond James CTF. My team got 3rd place with $2500 award. The weather in Florida is so0O gO0od: 24 degrees C, meanwhile it&#8217;s like 3 degrees C in Baltimore. The team photo: My eyes were closed lol. The trophy: The coin from gam3z: The onsite-CTF was 70% [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":692,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.wispwisp.com\/index.php\/wp-json\/wp\/v2\/posts\/326"}],"collection":[{"href":"https:\/\/www.wispwisp.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wispwisp.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wispwisp.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wispwisp.com\/index.php\/wp-json\/wp\/v2\/comments?post=326"}],"version-history":[{"count":3,"href":"https:\/\/www.wispwisp.com\/index.php\/wp-json\/wp\/v2\/posts\/326\/revisions"}],"predecessor-version":[{"id":750,"href":"https:\/\/www.wispwisp.com\/index.php\/wp-json\/wp\/v2\/posts\/326\/revisions\/750"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wispwisp.com\/index.php\/wp-json\/wp\/v2\/media\/692"}],"wp:attachment":[{"href":"https:\/\/www.wispwisp.com\/index.php\/wp-json\/wp\/v2\/media?parent=326"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wispwisp.com\/index.php\/wp-json\/wp\/v2\/categories?post=326"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wispwisp.com\/index.php\/wp-json\/wp\/v2\/tags?post=326"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}