Notes

Do not read codes but patch binary.

高尾マンモストレイル (2024/03/16)

挑戦してきました。 高尾マンモストレイルとは、高尾山口駅起点の全長45km位のトレッキングコース。登山客が多い高尾山周辺で、適度に空いているトレイルを楽しめます。ルートは北高尾から入って、堂所山、陣場山、藤野駅方面まで一旦降りた後、再び明王峠に…

昭和記念公園ハーフマラソン (2024/03/02)

初ハーフマラソンでした。次にすぐ走る予定もないので、記憶がフレッシュな内に備忘録として書いておきます。 準備 ハーフマラソンに出ようと思い立ったのは大会1ヶ月前位だったですが、それまでに、ランニング の習慣は形成されてました。 ランニング を始…

emotetのRC4

emotet loaderのRC4 最近emotetがまた流行っているらしいので、昨年流行したemotet(解析したのは今年の初め)との違いを見てみる 今回はLoader周りの記述のみ簡単に解説 前回を簡単におさらいすると、 外側のPEから.dataセクションに存在したPE loaderとPEが…

DT_HASH and DT_GNU_HASH preparation by linker

Example of linker development reflecting loader implementation Here, I will show you how to prepare codes to resolve API dynamically on linker through reading elf loader codes(musl libc :: ldso/dynlink.c). On elf format, either of two API …

About linker development

It has been already a half year since I've written an article about a draft of my linker (http://vrodxda.hatenablog.com/entry/2019/11/30/160029) for PE format. Since then, it had been progressed slowly from time to time. (https://github.co…

windowsでパケットをinterceptするツール

windivert 年末年始休暇を利用して、windowsでパケットをインターセプト(capture + drop)する方法を探していてwindivert(https://github.com/basil00/Divert)というライブラリを見つけた。 npcap/winpcap辺りだと、dropができないようなので。良いツールだが…

Three chains for writing a linker

This is for organising my knowledge to create a simple linker of PE. Linker is a bit hard target for being written from scratch without being considered its abstraction to me. What a linker will do is roughly, having one or multiple object…

simple build command

https://github.com/Hiroshi123/bin_tools/blob/master/src/tools/build.c 暇だったので書いてみた。 makefile風のfileとtargetを指定して実行する. windowsでのみbuildできる。 元々,windows向けのld書こうと思ってたんだけど,次いでに作ってみた。 やって…

Dig into LdrInitializeThunk

On my previous post, I posted piece of code which ought to work out for a dll injection on the stage where kernel32.dll has not been mapped yet. It looked worked out apparently, in fact it missed a point. The point is kernel32.dll will be …

DLL injection with just ntdll

If you want to step back to the days before the high level languages had been prevailed, nevertheless still want to write somehow practical in a sense in this era, writing a piece of injection code is a good target. Windows supports functi…

x86-64 emulatorを作っていて思ったこと

平成最後の日ということで、てきとーに何か書き残しておく。 マルウェア解析をしていると、マルウェアがマシンを破壊してもよいように、動的解析では仮想環境を使うが、それも面倒な時がある。 その為、自作x86エミュレータを暇な時にせっせと作っていたのだ…

objtestについて

3月からお仕事でmalware解析やるので、役立ちそうなbinary解析ツールを作っている。 その中で、objtestというコマンドが割と自分の中でいいものができたなっという気がするので、 簡単に紹介。 qemuやllvmなど、大きなプロジェクトのソースを読む場合って、…

call graph生成toolについて

年明けてから、ふとした思い付きで、call graph生成ツール(https://github.com/Hiroshi123/bin_tools)を作っている。 目的としては、windowsとmacのsourceのないdllを効率良く理解することを目的としている。 現状はelf向けのもの(中途)のみできてる。 で、…

Simple overwriting of GOT

GOT overwriting is a good starting point for making sense of what is all about "relocation". Relocation can be done in two phases; statically or dynamically. Here, I will mention about dynamic relocation. When you call a function whatever …

Copying instruction area & executing it on the fly

Calling a function means setting one of the registers onto which the instructions for the function are stayed. Even when you call it at multiple times, the memory you access will never be changed by contrast with the allocation of the foot…

musl code reading ( 0. 概略編 )

xv6のuserland側を拡張しようと、最近musl(https://www.musl-libc.org/)のsourceを読んでいて、なかなか美しいので、備忘録的に何回かに分けてlogを残しておく。 先ず、musl自体なんだけど、軽量glibcの一種で,特徴として 1.単一のshared libraryになる. ->g…

xv6 code reading(7.channel編)

xv6

今回はchannelについてみてみるよ。このxv6のcommiterの一人がGo言語の作り手であるRusCoxであるように、channelの概念はGo言語のそれとも関連がある。 先ず、channelなんだけど、これはproc構造体に地味に付いている。 struct proc { uint sz; // Size of p…

xv6 code reading (6.fork編)

xv6

forkは処理としては簡単そうに見えるけど、中々奥深い。 先ず、概要として、やっていることはprocess内でprocessを生成すること。 forkは子processだと0,親processだと子pidが 帰るって仕様で、 userlandからみると、1つの処理から2つの別processが返る。 こ…

xv6 code reading (5.paging)

xv6

How CPU works for memory access When CPU is ordered to access a value on virtual address, it needs to address a specific page. Accessing same virtual address on two different processes must address mutually distinct physical pages. Given a…

xv6 code reading (4.file system編)

xv6

前回VFS(仮想ファイルシステム)について主に書いたので、今回はFileSystem. xv6はfsとvfsの差が明確に分かれていないが、fsの役割を担っているのは、mkfs.c/bio.c/log.c/fs.c(一部)のあたりか。先ず、FileSystemの構築だが、先ず、defaultで動かせるコマンド…

xv6 code reading(3.vfs編)

xv6

xv6 のsystemcallは次の21種類(因みに、linux2.6で190近くある). // process start extern int sys_exec(void); // operation towards a file(s) extern int sys_chdir(void); extern int sys_close(void); extern int sys_dup(void); extern int sys_fstat(…

xv6 code reading(2.exec編)

xv6

前回shellでexecが実行される部分までみたので次はexecの中(https://github.com/mit-pdos/xv6-public/blob/master/exec.c). 普通はforkを先に説明するべきなのかもしれないけど、後に回す。 前提としてexec自体はsystem callでそのざっくりとした処理の流れ…

xv6 code reading(1.shell編)

xv6

今回(初回)はshellについて。普通はbootloaderから見て行くのかもしれないけど身近なものから。 恐らく、shellについて理解する最短で最良の方法が,こいつhttps://github.com/mit-pdos/xv6-public/blob/master/sh.cをじっくり読むこと。 ざっとみて、新しく…

Trial

xv6

Hi