Web、サーバ、ソフトウェア、バグ・脆弱性 などの情報を何人かで集まって書いていく IT/Web情報系ブログ

Psychson(BadUSB)のPS2251-07(2307)用パッチを公開

投稿日:   最終更新日:2017/04/01  投稿者:xx2zz


2017年04月01日 追記
以下の記事を参照してください。
【完全版】PS2251-07(2307)用Psychson(BadUSB)パッチの適用方法
Please refer to the following article.
【Complete version】How to apply PS2251-07(2307) patch for Psychson(BadUSB)

Phison 2251-07 (2307)でPsychsonのファームウェアを動かすことができたこと、
最新のバーナーを使うことで新しいバージョンの2307チップでもカスタムファームウェアを書き込めたことを報告してきましたが、
今回は、Psychsonを2307で動かすためのコードレベルでの詳細な情報を公開します。

スポンサーリンク

差分ファイル

このファイルには以下の変更が含まれています。

注意: このファイルはPS2251-07(2307)でPsychsonのカスタムファームウェアを動かす実験を目的とした研究資料です。動作の保証をするものではありません。差分適用後のプログラムを動作させたりカスタムファームウェアを書き込むことでデバイスやPCが使えなくなったり壊れても責任を負えません。自己責任で利用してください。

“Psychson2307_diff” をダウンロード

Psychson2307_diff_20160710.zip – 4587 回のダウンロード – 4.23 KB

2016年07月10日 追記
クロック関連の処理(FA60~FA6B)を元コード(2303)に合わせて修正しました。
既にファイルをダウンロードされた方は再度ダウンロードしてください。

2307用CFWのビルドと書き込み方法

必要なもの

CFWのビルド

  1. Psychsonのソースコードをダウンロードして展開する
  2. Psychsonの「templates/FWdummy.bin」をPsychson2307_diff.zipに含まれる同ファイルに置き換える
  3. Psychson2307_diff.zipに含まれる「firmware/serial.c」を追加する
  4. patchコマンド等で差分を適用する
  5. patch -p0 < firmware-firmware2307.diff
    patch -p0 < DriveCom-DriveCom2307.diff
    
  6. 「firmware/main.c」「firmware/usb.c」内の?マクロを展開する(後述)
  7. build.batを実行する

CFWの書き込み

  1. VS2012で差分適用後のDriveComをビルドする
  2. DriveCom.exeを実行してファームウェアを書き込む
  3. DriveCom.exe /drive=E /action=SendFirmware /burner=BN07V106M.BIN /firmware=fw.bin
    

ここで以下のようなエラーが出る場合は、バーナーがチップに対応していない(古い)可能性があります。

Action specified: SendFirmware
Gathering information...
Reported chip type: 2307
Reported chip ID: 98-3A-98-A3-76-51
Reported firmware version: 0.99.53
Mode: Firmware
Switching to boot mode...
Rebooting...
Sending firmware...
FATAL: System.InvalidOperationException: Header not accepted
   場所 DriveCom.PhisonDevice.TransferFile(Byte[] data, Byte header, Byte body)
場所 s:\Phison\2307release-test\Psychson-master\DriveCom\DriveCom\PhisonDevice.c
s:行 256
   場所 DriveCom.Startup._RunFirmware(String fileName) 場所 s:\Phison\2307releas
e-test\Psychson-master\DriveCom\DriveCom\Startup.cs:行 427
   場所 DriveCom.Startup._SendFirmware() 場所 s:\Phison\2307release-test\Psychso
n-master\DriveCom\DriveCom\Startup.cs:行 378
   場所 DriveCom.Startup.Main(String[] args) 場所 s:\Phison\2307release-test\Psy
chson-master\DriveCom\DriveCom\Startup.cs:行 114

その場合は、新しいバーナーが公開されているので、そっちを試すとよいかもしれません。

?マクロの実装

差分適用後のfirmware/main.cとfirmware/usb.cにはインラインアセンブラ(__asm~__endasm;)内に?から始まる以下のような行が含まれます。

?マクロ

この行は ?(対象ファイル, 始点アドレス, 終点アドレス) のフォーマットで、「対象ファイル」の「始点アドレス」から「終点アドレス」のデータ(バイナリ)をアセンブラの.dbディレクティブ形式で展開する独自のマクロを意味しています。

このマクロを展開するプログラムは今回公開する差分ファイルには含めていないので、ビルドの際はこの展開処理を各自実装してください。

何をすればいいかは、以下の画像を参考にしてください。


2016年10月03日 追記
以下、何件か質問をもらったので追記しておきます。
バーナーとしてBN07V502TAW.BINを使う場合でも、書き込むファームウェアに違いはありません。
各.cファイルのマクロで使用するのはBN07V106M.BINFW07FF01V10153M_20140116.binの2つだけです。


When you have some questions and want to get reply from us, you have to notify us the version of the chip and other important information.

- BadUSB , , ,

Comment

  1. kietho より:

    ps2251-07.rarファイルをアップロードできるか。
    ダウンロード リンクは下がる

    • nk. より:

      Thanks for your replay.

      To my regret, we can’t upload the ps2251-07.rar since we don’t have the right of uploading.
      And, I’ve confirmed to be able to download this file from the link from this page.
      You may access .ru sites by means of some HTTP proxy.

  2. someone より:

    bin\main.asm:416: Error: missing or improper operators, terminators, or deli
    miters

    __asm
    (“BN07V106M.BIN”, 0x6892, 0x68AB)
    (“BN07V106M.BIN”, 0x68AC, 0x68B3)

  3. fR30n より:

    In the image, you show the binary of a file called sample.bin. I am getting the error “: Error: missing or improper operators, terminators,..”, so from where I am supposed to get this values and update the diff file? Also, whats that macro for? Thanks in advance

    • nk. より:

      In the top-left panel of the image, the fire macro requires the data from 0x20 to 0x25 in “sample.bin”.
      You should write the program extracting this fire macro (or get the values manually) and update (or modify manually) .c files (firmware/main.c and firmware/usb.c) which are patched by .diff files to run build.bat.

  4. fR30n より:

    I got it now.. due to the translation I couldn’t understand correctly. I got the firmware compilation, getting “System.InvalidOperationException: Header not accepted” now but I will try some variants in mind.
    Thank you very much.

    • Mike より:

      hi how did you find the macro

      • fR30n より:

        Hi, I didn’t find the macro, I wrote a small bash script to extract the bytes in the macro statements, you can do it with BZ also (posted in the image) but I found more interesting to write it myself.
        Here the code:

        #!/bin/bash
        binary_file=$1
        from_offset=$2
        to_offset=$3
        length=$((0x$to_offset – 0x$from_offset + 1))

        for (( i=0; i<length; i++ ))
        do
        hex_byte=$(xxd -p -l 1 -s $((16#$from_offset + i)) "$binary_file")
        echo ".db 0x$hex_byte"
        done

        This will output the code you need to replace in the macro calls. You would need to call the script like this for example:
        sh extract_bytes.sh BN07V106M.BIN 68D1 68D9

        You will need to replace each macro call with the output.

  5. Aidyn より:

    Hi, I would like to help you with development. Could you please contact me?
    my e-mail is: right – hearted @ yandex . ru

    こんにちは、私は開発のお手伝いをしたいと思います。あなたは私に連絡してくださいませんか?
    私の電子メールは、次のとおりです。right – hearted @ yandex . ru

    • nk. より:

      Thank you for your offer.
      But we have run the Psychson from the chip 2307.
      Could you tell us how do you help on our development?

  6. Adam より:

    Can someone translate this to english? even with google translate I cant make it through the first few steps. For example, which files are we meant to patch in the first part?

  7. Fuat より:

    Hi,
    i put all the .db 0x.. values manually after patching in main.c and usb.c.
    when i try to build.bat, this happens:
    *** Building main.c…
    bin\main.asm:415: Error: missing or improper operators, terminators, or delimiters
    removing bin\main.rel
    *** There were errors! ***
    *** Done.
    so i checked main.asm:415:

    414: ; main.c:192: __endasm;
    415: .db 0x90
    416: .db 0xF8

    please tell me what to change to make this work.

    Thank you!

    • Fuat より:

      ok compiled it.
      Header not accepted haha. well. fail.

    • BadPhison より:

      Hello Phuat,

      i managed to get all the 0x values aswell and patched all files.
      I get the same error as you did:
      main.asm:415: Error: ” missing or improper operators, terminators, or delimiters”
      can you help me please?

  8. lu より:

    In your firmware2307_diff
    in main.c some codes are messy codes, i can’t get “馃敟” stands for what?or what instruction?
    + __asm
    + 馃敟(“BN07V106M.BIN”, 0x6892, 0x68AB)
    + 馃敟(“BN07V106M.BIN”, 0x68AC, 0x68B3)
    + jnz HELL
    + 馃敟(“BN07V106M.BIN”, 0xA256, 0xA263)
    + 馃敟(“BN07V106M.BIN”, 0x68BE, 0x68C9)
    + sjmp HEAVEN
    + HELL:
    + 馃敟(“BN07V106M.BIN”, 0xA256, 0xA263)
    + 馃敟(“BN07V106M.BIN”, 0x68D1, 0x68D9)
    + HEAVEN:
    + 馃敟(“BN07V106M.BIN”, 0x68DA, 0x692C)
    + __endasm;

  9. jone より:

    I don’t understand how to implement macros.
    If you’re okay, Can you show me a simple video?

  10. Seba より:

    I’m stuck at setting the correct bit to bypass pseudo encryption on the binary. It says “Scrambler mode. Clear bit 7 and set bits 3, 4 to bypass scrambler.” but bit 7 is not set at all and the code dumped is still “random” when dumped although I set bit 3,4 of 038.
    Could you give me some hints to get it working?

    >DriveCom.exe /drive=H /action=GetInfo
    Action specified: GetInfo
    Gathering information…
    Reported chip type: 2307
    Reported chip ID: 98-DE-88-A3-72-51
    Reported firmware version: 2.15.55
    Mode: Firmware

    Thank you :3

  11. lone より:

    Hi
    I get the firmware on to the USB drive without any issue, but following the USB is only detected when manually forcing boot mode and bypassing the firmware.
    Any hints on how I can detect the issue?
    Thanks

  12. Abdi より:

    Hi
    Can you post a link to download modified version of BN07V502TAW.BIN?
    ( without the 0F638 bytes). Thank you!
    Reported chip type: 2307
    Reported chip ID: 98-3A-A8-92-76-50
    Reported firmware version: 5.02.53
    Mode: Firmware

  13. Abdi より:

    works like a charm on both burners and firmwares you guys are the best!!!
    Corsair voyager mini 16GB 2015
    Thank you again
    —————–
    DriveCom.exe /drive=D /action=SendFirmware /burner=BN07V502TAW.BIN /firmware=fw.bin
    Action specified: SendFirmware
    Gathering information…
    Reported chip type: 2307
    Reported chip ID: 98-3A-A8-92-76-50
    Reported firmware version: 1.06.10
    Mode: Burner
    Rebooting…
    Sending firmware…
    Executing…
    Mode: Firmware
    ———-
    Modified offsets with vs community 2017
    0ecc30f42db2a8cdfa559292f5afc118 BN07V502TAW.BIN

  14. davodamirajam@gmail.com より:

    http://uupload.ir/view/tw7e_mpall_f1_9000_v389_0c.rar/

    i extract from toshiba u365 FW07V022055

Message

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

関連記事