We provide a usb-key which seems protected by password. you should find a password and find a flag on this device.
You can.. ( of course, you don’t have to do everything.) : ・Connect to Debugger (Hardware Emulator) ・Connect to PC ・Dumping and Analyse a firmware. ・Rewrite a modified firmware. ・Modify the circuit with soldering iron etc..
どうしてこういう問題を作ろうと思ったか。 / What influenced:
ハードウェアに関する問題を作ろうと思っていて、 ハードウェアロック付きの USB メモリを問題にしたら面白そうと思ったのがきっかけです。
My main job is security researcher and developer, and I have recently been investigating of hardware device. So, I thought to try to make mass storage device without an OS and growth up my skills.
ステップ1:ハードウェアを繋ごう Step1 : Let’s connect the device to your machine.
ハードウェアを繋ぐと上記のような2つのデバイスが認識されます。 You will find these devices on your machine when connect the device.
また、マスストレージの方は、それっぽいファイルが保存されているのですが、 “<THIS SECTOR AREA IS PROTECTED BY HARDWARE PROTECTION>” と表示されていて、 内容が読めません。
You can find deleted file that seems would contain a flag data, but it seems protected.
Let’s check the com port. It looks like we need to input correct password via COM port. And if you input wrong password three times, the device going to freeze.
ステップ2:デバッガを繋ごう Step2 : Let’s connect emulator (debugger) to device.
You can find a SWD port that uses for hardware debugging on the other side of USB port. You need insert a cable which we provided at beginning of the game and connect to the emulator (STLink).
But… you may can’t connect the device via emulator if just connect. Most devices disable the debug port (such as SWD, JTAG ICE and so on..) to protect “Intellectual Property” or prevent from illegal use.
Also on this device, I insert a code to disable the SWD port at the beginning of the main program code.
Description of Boot Mode selection (from ST.com, en.CD00164185.pdf)
You can control the boot mode by Jumper switch. If you change the BOOT0 pins ( upper pin ) to 1 (such like the photo), you can connect SWD port because the hardware will not run the challenge binary.
In other way, you can connect it with push and hold the RST button until connect the emulator successfully.
Description of Boot Mode selection (from ST.com, en.CD00225773.pdf)Description of Boot Mode selection (from ST.com, en.CD00225773.pdf)
After connection, you can rip the firmware from hardware with writer tool.
According to the peripheral data sheat, You can find that the main firmware saved on a memory of 0x08000000 (Sector 0) to 0x0800FFFF (Sector 3) area.
I used STM32 ST-Link Utility to rip the challenge program binary on this time. It’s also possible to rip with OpenOCD or similar tools.
if you try to rip with OpenOCD, you can use “mdw” command (i.g. “mdw 0x8000000” ) or “dump_image” command (i.g. “dump_image dump.bin 0x8000000 0xFFFF”)
ステップ3:ファームウェアを解析しよう Step 3 : Let’s analyse the firmware!
普段は IDA 使いなのですが、 無料の範囲でバッチリできることを確認するために、 Ghidra でやってみます。
Looking back at the communication via serial port, the string that “checking ..” was appeared after send a password. At address 0x80001a8, you can find the code.
According the code, you’ll find these rules: * 1st character is “O” * 3rd, 7th and 11th character is “e” * 9th character is “a” * 10th character is “m”
Therefore, the password will “O_e___e_ame!”. ( I filled unknown character with “_”)
…yes, I know why you’re being wired. It’s a my fail. I’m so sorry. I had made a mistake that I wrote an another version firmware. Thus, you would not have found a 2nd, 4th, 5th, 6th and 8th character.
After unlocked, let’s try to find a flag file on the storage with Forensics tool. You can get a flag after by extracting it.
SECCON{YOU_CAN_ANALYSE_HARDWARE_DEVICE}
FAQ / よくある質問
Question: 試してみたいのですが、評価ボードはもらえますか? Can you give me the challenge board?
Answer: ごめんなさい。。でももしお会いできる機会があれば、事前にお持ちすることは可能です。 Sorry. I can’t. but I can show you the board. please feel free to contact me.
Question: どうしてパスワードを解除したあとにファイルが表示されないのですか? Why didn’t show the file after unlocked?
Answer: Windows でテストをした際に、エクスプローラや通常の方法で読み出しに失敗することが何度か確認できており、当該のエラーの解決が間に合わなかったのが理由です。。すみません。。 I’m sorry again. I found a issue that windows system can’t read FAT12 data correctly, and I couldn’t find a solution before the CTF.
I think I could have improved the quality of the challenge If I had more time. Thus, I need to apologize to the CTF Player.
But fortunately, some CTF players told me the challenge was interesting. It made me very happy.
so I think I want to create the “CTF challenge” ( the meaning that it meets the criteria for a general CTF challenge) in the hardware genre if next seccon ctf is to be held.
by the way, could you tell me how to withdraw the money at “Marina Bay Sands Bank” if you know. I think it’s the same way to get points in CTF, but it was very difficult for me…. especially slots….