Author: David Zimmer
Date: 09.04.16 - 4:27am
I use the krypto analyzer plugin KANAL by Snaker allot. Its a small dll plugin that was designed to work with the PeID packer identifier. It is so handy that I actually use it in MAP and have an option to launch it on the file hash form.
One feature that I always wished it had, was the ability to copy all of the results to the clipboard. I poked around inside v2.7 a little bit, and it turns out if you right click on and entry it will copy the offset. Thats cool, but I want the whole thing text and all
I was not able to find the source to it, but with a couple small tweaks I was able to get what I wanted. Here's how.
First its upx compressed, so unpack it. Then open it up in reshacker and check out the dialog resource. Here I edited the script to include a new line
CONTROL "C&opy", 1022, BUTTON, BS_PUSHBUTTON | WS_CHILD | WS_VISIBLE | WS_TABSTOP, 83, 112, 45, 13 , 0x00020000This adds a copy button to the center of the form. Perfect. click the compile resource button and then save. The form now has a new button on it.
Now we need to handle the button events since KANAL knows nothing about it. We can do this through subclassing. Since the plugin is an in process dll we do not have to do anything funny, just subclass the form and watch for WM_COMMAND messages.
Before we get to the next step, we need to back track a second. PeID uses a cdecl api for its plugins. VB6 only has native support for stdcall. The first trick is actually just to launch the plugin. We have to build a small asm thunk in a RWE memory allocation and then call it using CallWindowProc
push asm(), "B8 " & lng2Hex(lpfn) 'B8 90807000 MOV EAX,708090 push asm(), "FF D0" 'FFD0 CALL EAX push asm(), "83 C4 " & Hex(argSize) '83 C4 XX add esp, XX 'cleanup args push asm(), "C2 10 00" 'C2 10 00 retn 10h 'cleanup our callwindowproc argsNow KANAL uses a modal dialog and VB6 is single threaded. So once we launch it execution does not return back to our VB6 code until the dialog closes. In order to get around this, just before we launch the plugin we start up a timer.
Below is the timer proc which scans for the KANAL window and subclasses it. Below that you can also see how we handle the subclass message. When we receive the BN_CLICKED and our button ID in wParam, then we find the treeview child window on the form, and extract the treeview contents using the winapi.
while the code looks pretty concise and compact, there is actually allot going on behind the scenes in all of the library functions. Its all open source though so feel free to wade through it.
Turns out it was wasnt to bad to add this wish list feature even without the source code to the plugin. Software re-engineering is fun ;)
Comments: (1)On 09.13.16 - 12:22pm Dave wrote: