Posts

BLE sniffing with UbertoothOne

Image
This time, I'd like to try monitoring smartlock's BLE packets with Ubertooth One. Smartlock  use this dongle and Ubertooth One Find BLE device  check BLE dongle is connected. ➜ ~ sudo hciconfig hci0: Type: BR/EDR Bus: USB BD Address: 00:1A:7D:DA:71:13 ACL MTU: 310:10 SCO MTU: 64:8 UP RUNNING PSCAN RX bytes:622 acl:0 sco:0 events:38 errors:0 TX bytes:952 acl:0 sco:0 commands:38 errors:0 Let's find BLE devices ➜ ~ sudo hcitool lescan LE Scan ... 30:F8:3F:06:4F:6F (unknown) 30:F8:3F:06:4F:6F (unknown) 30:F8:3F:06:4F:6F (unknown) 18:62:E4:46:60:AB (unknown) Then, trying gatttool. Peripheral is defined by service and characteristic. Each service contains charateristics which contains data. ➜ ~ sudo gatttool -I -b 18:62:E4:46:60:AB [ ][18:62:E4:46:60:AB][LE]> connect [CON][18:62:E4:46:60:AB][LE]> primary [CON][18:62:E4:46:60:AB][LE]> attr handle: 0x0001, end grp handle: 0x0008 uuid: 0000fee7-0000-1000-8000-00805f9b34fb attr handle: 0x0009, en...

MOVAPS triggered ACCESS_VIOLATION....

Image
Hi, I met a malware which has a decryption code in it. I tried unpack on debugger but it is stucked in mid of decryption. movaps instruction triggered ACCESS_VIOLATION exception in decryption code. I doubted it might be a anti debugging technique but it seem to be not. (they are found in Windows shared libraries too) I searched about this issue.. movaps instruction is explained like this  but I don't understand the difference between the situations which can be passed or not. MOVAPS--Move Aligned Packed Single-Precision Floating-Point Values > the operand must be aligned on a 16-byte boundary http://qcd.phys.cmu.edu/QCDcluster/intel/vtune/reference/vc181.htm It is also,  > To move packed single-precision floating-point numbers to or from unaligned memory locations, use the MOVUPS instruction.    Anyway, the difference seem to be aligned/unaligned.  16 byte boundary alignment is the answer..   > which generally means...

Firmware dumping via SPI

Image
I tried firmware dumping via SPI with Attify badge and Attify OS. Target camera is this one.. This camera seems to be famous among the IoT hackers. You would find many IoT hacking blogs about this camera. After the preview, I have extracted board. This time, I'd like to focus on Flash memory. It looks mxic mx25l12835f. From model number, we can find data-sheet. MX25L12835F . Now, let's connect flash memory pin and Attify Badge. Attify badge pin layout is.. D0 : SCK D1 : MISO  D2 : MOSI  D3 : CS  I have connected flash memory and Attify badge like this. D0 - SCLK(6) D1 - SI(5)  D2 - SO(2)  D3 - CS(1)  GND - GND(4)  3.3V - VCC(8)  3.3V - RESET(7)  3.3V - WP(3)  We dont need to connect power plug to camera. It is supplied via badge. For testing, trying spiflash.py and -i parameter. According to the python code, it returns ChipID. This command can be used for connectivity tesingt. "00 00 00" or "FF FF...

Zigbee sniffing

Image
I bought Attify's IoT Exploit lerning kit . Since that was soooo fun, I want to show you some. Zigbee sniffing with APImote Zigbee is a global standard for wireless technology which supports low cost, highly reliable networks for device-to-device communication. In the lerning kit, APImote enables to monitor zigbee packets. Following tools are used for hands-on demo. All of these tools are included in the IoT Exploit learning kit. (Since I bought this kit in beginning of 2019, contents may be changed.) And also we can use VM image that required tools are installed. https://github.com/adi0x90/attifyos Upload code to Arduino Nano Let's upload code to Arduino Nano with Arduino IDE. It just sending text and counting up value. #include int a=0; SoftwareSerial mySerial(2,3); //RX, TX void setup(){ Serial.begin(2400); //baudrate: 2400bps } void loop(){ Serial.println("Hello!!!"); Serial.println(a); a++; } For just in case, check if it ...

Malicious postscript code in hwp

I found a hwp(Hangul word processor) file which contains malicious postscript code. I take some analysis notes for my memo. Malicious postscript code is as following. /X240 def %kshvudgsjsye3 0 1 X240 length 1 sub % %kshvudgsjsye3 {/Y31 exch 1 2 and pop def %kshvudgsjsye3 X240 dup Y31 get Y31 15 and /Y104 8 def get xor Y31 exch put} for X240 cvx % exec I’ve googled and found some coding rules. ・Anything following a % on a postscript program line is ignored by the interpreter. ・initialize variable i with value 0 /i 0 def ・set each element of array ar to value n 0 1 ar length 1 sub {ar exch n put} for ・ exch     Exchange the top two values of stack. ・ dup      Duplicate the top element of stack. ・logical ' and ' operator. a&&b a b and ・ <hexadecimal string> cvx          makes string executable ・ <hexadecimal string> cvx exec    ...

Ubuntu 16.04 + Qemu + Raspberry Pi image triggered kernel panic

I tried to boot Raspbian OS on Qemu but failed!! Ubuntu 16.04 + Qemu + Raspberry Pi image Freeing unused kernel memory: 176K (c0530000 - c055c000) Kernel panic - not syncing: Attempted to kill init! exitcode=0x00000004 I googled it and resolved.. It need to edit raspberry pi's files in .img /etc/fstab by commenting out mmcblk entries and /etc/ld.so.preload old entries. OK, lets check .img file. umiushi@umiushi-VirtualBox:~/Desktop/armv6_stretch$ file raspbian-stretch.img raspbian-stretch.img: DOS/MBR boot sector; partition 1 : ID=0xc, start-CHS (0x0,130,3), end-CHS (0x7,165,30), startsector 8192, 114688 sectors; partition 2 : ID=0x83, start-CHS (0x7,165,31), end-CHS (0x18e,97,19), startsector 122880, 6277120 sectors Then, trying fdisk command. Which sector should be mounted.. umiushi@umiushi-VirtualBox:~/Desktop/armv6_stretch$ fdisk -l ./raspbian-stretch.img Disk ./raspbian-stretch.img: 3.1 GiB, 3276800000 bytes, 6400000 sectors Units: sectors of 1 * 512 = 512 by...

MBR debugging with Bochs

Image
I've tried Bochs for debugging MBR which is infected Petya just for fun. First of all, prepare disk image. $ dd if=xx.raw of=petya.img bs=512k count=20 (I've run petya on VM and convert .vmdk image into .raw image.) Setup bochsrc file like following. romimage: file=$BXSHARE/BIOS-bochs-latest vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest megs: 16 ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 ata0-master: type=disk, path="petya.img", mode=flat, cylinders=1, heads=16, spt=63 boot: disk vga: extension=vbe mouse: enabled=0 log: nul logprefix: %t%e%d panic: action=fatal error: action=report info: action=report debug: action=ignore Wrong cylinders, heads, spt value may be a glitch on setting up debugging environment. Now, my petya.img size is 0x7E000 bytes. (Disk image size must be multiples of 512.) 0x7E000 = 516,096 = 512*1008 It is addressed by following formula. img size = cylinders * heads * spt * 512 516,096 = 1 * 16 * 63 * 512 You need ...

Petyaのドクロのコードが見たい

Image
いよいよMBRの中のコードを覗いてみる…。 のだけどどうやって??? IDA proってツールを使います。 ベルギーのhex-raysって会社が出しているdisassembler。 フリーウェア版でも十分使える。 ライセンス版は2000ドル(!)くらいするのだが、x64も読めちゃう。 supports more than 50 processor families なんて書いてあるが、世の中にはそんなにプロセッサの種類あるんだね草。 よりマニアックなcpu instructionが見たいぜ!!という諸兄には必携かと。 https://www.hex-rays.com/products/ida/support/download_freeware.shtml 保存したpetya.imgの拡張子を.comに変えてから読み込むと捗る。 アセンブラの命令を一個一個解説していくことは困難なためさわりだけでオナシャス。。 bochsでステップ実行しながら、表示を比較していくとよい。 http://bochs.sourceforge.net/doc/docbook/user/internal-debugger.html 以下のコードで一文字づつ画面に書き込み。 https://en.wikipedia.org/wiki/INT_10H によると、、Teletype output てので出力してるみたいだね。 seg000:4C26 WRITE_CHAR_ANDADVANCE_CURSOR proc near ; CODE XREF: WRITE_CHAR_ANDADVANCE_CURSOR_0+E p seg000:4C26 ; sub_14C54+57 p ... seg000:4C26 seg000:4C26 arg_0 = byte ptr 4 seg000:4C26 seg000:4C26 55 push bp seg000:4C27 8B EC mov ...

BochsでMBR debugging

Image
今回は前回取り出したPetyaに書き換えられてしまったMBRをBochsで動かしてみよう。 https://ja.wikipedia.org/wiki/Bochs Bochsはここから入手できる。 http://bochs.sourceforge.net/getcurrent.html Bochsも前に出てきたVMware同様PCエミュレータなのだけど、 こいつはMBRのdebugができてしまうんだ。 OSが起動するより前のコードを追えるってわけだね。 そりゃ面白そうだ~笑 キモは設定ファイルの書き方くらいかなと。 サンプルの設定ファイルがあるのでチェックしてみて。 Bochs-2.6.9\bochsrc-sample.txt   多分もっとシンプルにもできるんだと思うんだけど、、 筆者のはこんな感じ。 romimage: file=$BXSHARE/BIOS-bochs-latest vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest megs: 16 ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14 ata0-master: type=disk, path="petya.img", mode=flat, cylinders=1, heads=16, spt=63 boot: disk vga: extension=vbe mouse: enabled=0 log: nul logprefix: %t%e%d panic: action=fatal error: action=report info: action=report debug: action=ignore   こいつをファイル名を変えてbochsrcとして保存。.txtもいらない。 Bochs-2.6.9\bochsrc 設定ファイルのポイントは赤文字のところ!! path="" には取り出したMBRのパスを記入する。 そして、もうひとつ重要なのが、Bochsに読み込ませるディスクイメージのサイズは512の倍数でなければいけないんだ。 どういうこっちゃ??なのだけど、、 切り出したMBRをバイナリエディタで読み...

Petyaと遊ぼう(4)

Image
さて、いつぞやにpetyaを実行したVMのイメージは残っているだろうか??(起動してもドクロがピカピカするやつ) 今回はVMイメージからpetyaが書き換えてしまったMBRの取り出しをやってみたい。 こんごのさぎょうのながれ VMイメージをrawフォーマットに変換(vmdk統合必要な場合は先にやっとく) ddでMBRを切り出し bochsでドクロをpkpkさせる MBRのコードを見てwktkする 解散 まずは、、 仮想ディスクイメージである.vmdkからrawフォーマットに変換する。 https://eelsden.net/blog/q1lk2m/qfks6b VMイメージのハードディスクサイズがデカめだと、rawに変換したときにクッッッッソ巨大になるので注意してくれ。 変換エラーできませんエラーが出たら疑ってみて。実験環境のハードディスク容量が十分にあるか。 数GBだとたぶん足りん。できたら数百GBはほすぃとこ。 またrawフォーマットに変換する前に、、 ファイル名が..-s00x.vmdkこんな感じになってるときは.vmdkをひとつに統合しておく必要がある。 Windows 7-000003-s007.vmdk Windows 7-000003-s006.vmdk Windows 7-000003-s005.vmdk .... vmware-vdiskmanagerっていうのでできるんだが、vmware playerには入ってないのね。。 ので別途vmwareのサイトから取ってくる必要があります。 https://server-setting.info/blog/vmware-disk-file-marge.html rawフォーマットに無事変換できただろうか? ddコマンドで必要な部分だけ切り出そう。 http://www.atmarkit.co.jp/ait/articles/1711/30/news027.html こんな感じで。 dd if=xx.raw of=petya.img bs=512k count=20 ddなんてコマンドねぇぞ!!? ってこともあるかもしれん。cygwinを入れるかWindows用のddを取ってくるかlinux系OSを持ってくるかお任せします。 h...

Petyaと遊ぼう(3)

💀:PCどうなったん? MBRが書き換えられてOSが起動しなくなった。 またファイルを暗号化されてしまっている。 💀:なんでこんなことするん? ファイルを人質に取って身代金をせしめるのが目的のようだ。 💀:儲かるん? これがどうも結構儲かるらしいんだ。。 過去のランサムウェアの例では身代金で何百億もの金を集めた例が存在する。 http://www.security-next.com/063951 💀:直るん? 「無理」※だ。 例えば数字4桁の鍵なら0000~9999まで全部試せばいつかは開くが、 petyaはファイルの暗号化にAES128やsalsa20という暗号化技術が用いられている。 計算が得意であるコンピュータを使っても、復号に何十年、何百年とかかる代物だ。 今回のサンプルに至っては、暗号化に使った鍵(ランダムに生成された)を捨てちまうため暗号化した側も元に戻せないんだとさ! つまりファイルを復号するのはまず不可能というわけだ。。 https://blog.trendmicro.co.jp/archives/15353 💀:でも鍵買えって、、 鍵買っても直る保証はないよね。。上記の通り鍵捨てちゃうやつもいるし。 今回のpetyaの例では攻撃者とのやりとりに使われる予定だったメールアカウントが速攻でBANされたため、 金を払ったところで攻撃者側は誰が払ってくれたかわからんし、被害者側は攻撃者と連絡つかんし、、な状態だったらしい。 そもそも直してくれたかもわからんよね。 💀:どうすりゃいいん? 覆水盆に返らずインジャパニーズっすわ。。。 よく言われることとして、、 重要なファイルはバックアップ取っておこう ウイルス対策やっとこう メールの添付ファイルはむやみに開かないこと OSやソフトウェアの脆弱性を攻撃して勝手に入ってくることもあるため、バージョンアップやパッチの適用はこまめにやろう とかですかね。。。 さて、次回はドクロピカピカどうやってるかを調べて行くぞ~ 本線の方が脱線してる感じあるなこれ(;´Д`) ※初期に登場したpetyaに対してはスーパーハカーがファイルの復号方法を発見公開している。 https://blog.kaspersky.co.jp/pe...

Petyaと遊ぼう(2)

Image
さて、実際にPetyaに感染して、、ってことだったのだけど。 もちろんここでは配布はできない!!! やってみたいひとはインターネットで探してみてください。結構見つかるものです。 但し、取り扱いには十分注意で! うっかり実行した日には マジでパソコン蛾ぶっ壊れる。 面白半分で他人のPCに感染させて、被害届->警察の捜査にまで及んだ場合、 最悪パクられる。馘だ。退学だ。名前がまとめサイトに晒され、、 始末書、減給、出世街道からは外れ、、嫁子供は路頭に迷い、、 と大変なことになるため学校に持って行ったり友達にあげたりしないように。 全然イケてないし、モテない。マジで。 今後の人生のあだ名がペチャ夫になる恐れが大だ。 2ちゃんでバカにされること間違いなしだ。あとツイッターで、、 もういいかな。 わざとであろうがなかろうが、意図していない場所で実行した場合、 大損害をもたらす危険なウイルスであるという認識で扱うように。 自分のまたは誰かのPCがぶっ壊れた場合も当方は責任持てません。 はい。 用意するもの 仮想環境 OSのインストールディスク Petya のsample 実は2がハードル高かったりするんだろうか。。。 XPでもPetyaは動いたわ。 1.はWindowsが動けばなんでもおk。 VMware Workstation Player https://my.vmware.com/en/web/vmware/free#desktop_end_user_computing/vmware_workstation_player/14_0 実機が32bitしかねーや。。という人はこちら。 https://my.vmware.com/jp/web/vmware/free#desktop_end_user_computing/vmware_player/6_0 仮想環境でOS動かすの件は省略します。。。説明めんどい。。(;´Д`) VM上でWindowsが立ち上がって、ファイルの移動(実機⇒仮想)ができるのが確認できたら準備完了だ。 さていよいよ実行、、なわけだが 実行すると仮想環境だろうがぶっ壊れるので注意を。 再セットアップめんどい人はバックアップ取っておこう。 あ!と!仮想環境のネッ...

Petyaと遊ぼう

Image
ドクロのピカピカが気になって。 Petyaはランサムウェアの類。 https://en.wikipedia.org/wiki/Petya_(malware) 新暗号型ランサムウェア「PETYA」、MBRを上書きしてPCへのアクセス不能に https://blog.trendmicro.co.jp/archives/13106 まずはこの動画を見てほしい。 なかなかインパクトあるよねw ドクロがピカピカしとるw 感染した人からすれば全くもって笑えないんだが、素直な感想としては「何じゃコレ!!!!w」ってなるよ。 さて、これ一体、どうやってんだ??? 当ブログは筆者が気になった、わりと(かなり)しょうもないことを書き綴っていく。 ボケてのタグでいうところの「バカ」だ。 そのためマジで被害に遭ってしまってる方のお役には立てないので、その点はご理解頂きたい。 次回はPetyaに実際に感染して、ドクロのピカピカを見てみたいと思う。 (もちろん仮想環境で!)