INFLATE WIN32 FILE - Windows Mobile Development and Hacking General

Hi to all you experts,
I am not a software engineer, however, I have some good experience with assembly code as I am an electronic engineer. Now here's the thing:
I have an .exe file which is a win32 application. I have disassembled it and I can see parts of the code, but most of it looks compressed. There is a reference in the file about "Inflate" and "deflate" by Jean Loup, and I have found the source code for this inflation/deflation algorithm, called ZLIB along with compiled dlls. Now as I said before, I don't have any experience whatsoever on windows programming apart from simple pascal and C programming, so i don't know how to manipulate dlls etc. So as I said before, I would like to see if indeed parts of the file are compressed and in this case, inflate them, and hopefully see the rest of the code! Any help?
Cheers,
Angelos

This is the wrong forum to ask. You should ask in the reverse engeneering forums. For example http://tsehp.cjb.net or if you know russian - wasm.ru, reng.ru, reversing.net
Typically you should run the program under debugger, trace the program until it decompresses/decrypts the needed parts and dump them to disk. I think that you are studying a PC program, so I recommend you using IDA 4.70 (Interactive Disassembler - www.datarescue.com). It is the best disassembler I know and has a built-in x86 debugger.

Related

decomiling and recompiling - newb question

Hi,
Can someone assist me with how i might go about decompiling or viewing a dll, making changes to it and recompiling it? What tools can i use to do this?
I have tried copying some of the dlls from my device over to my local pc, however most of the time i get an "access violation" message.
Further, i realize i can use idlasm to disassemble .net files, but it seems most of the more interesting dlls and files may be standard c dlls. How can i take a look at the code in these and modify if wanted?
thanks much.
farseer: what level of experience do you have?
V
I'd like to think i am decent developer, but that may be in my own mind
However, i do not do a lot of "hacking", i.e., have not had the need to do much reverse engineering. I have been coding ground up apps for over 10 years however, uisng C++, Java, C#, VB, etc. You name the language, and i've probably done something in it .
vijay555 said:
farseer: what level of experience do you have?
V
Click to expand...
Click to collapse
was that the wrong answer?
farseer said:
I'd like to think i am decent developer, but that may be in my own mind
However, i do not do a lot of "hacking", i.e., have not had the need to do much reverse engineering. I have been coding ground up apps for over 10 years however, uisng C++, Java, C#, VB, etc. You name the language, and i've probably done something in it .
vijay555 said:
farseer: what level of experience do you have?
V
Click to expand...
Click to collapse
Click to expand...
Click to collapse
The correct answer should be "I know ARM assembler language, the structure of Win32 PE files, I know what is XIP DLL and why I cannot modify them directly, and I have read the WM5 source code".
In this case the process is simple - you decompile a DLL with IDA (www.datarescue.com), find the place you need, modify the code to suit your needs - and that is all. In most cases there is not enough place in DLL for your code, so you need to use virus-like techniques, my prefered method is to patch the code so that it loads my DLL and run it instead of original code. Or use some other hooking methods so that my code is executed instead of original.
Ah, thanks much, this was helpful. I do have a few follow up questions:
1. Is "Arm assembler" different than standard assembler? If so, any suggested readings?
2. There are some dlls that cannot be copied to my local pc (i get an access violation i believe). How does one extract an image of such dlls?
3. Where is the WM5 source code? and why would i need to read this to be able to hack/patch dlls?
thanks again.
mamaich said:
The correct answer should be "I know ARM assembler language, the structure of Win32 PE files, I know what is XIP DLL and why I cannot modify them directly, and I have read the WM5 source code".
In this case the process is simple - you decompile a DLL with IDA (www.datarescue.com), find the place you need, modify the code to suit your needs - and that is all. In most cases there is not enough place in DLL for your code, so you need to use virus-like techniques, my prefered method is to patch the code so that it loads my DLL and run it instead of original code. Or use some other hooking methods so that my code is executed instead of original.
Click to expand...
Click to collapse
Hi farseer!
I am nowhere near the level of mamaich or vijay555 but I have some experience in this and I believe I can give you some basic answers:
1. ARM is a different architecture then x86 processors and the assembler is different to accommodate it. There are some basic similarities like mov add and such, but even the registers are different (R0 - R15 if I am not mistaken). Sorry, I don't know any books on it, but if you google you will quickly find the list of commands with basic explanation.
2. Since the OS is in ROM you can't just copy and paste it's DLLs and EXEs. Look for ROM dumping tools on this forum, or already extracted images on the ftp. Keep in mind MS did some tricks to save memory and make it harder to get at the files, so like mamaich said, you need to learn about XIP and the ROM structure in general to understand whats going on.
3. Hmm... MS does have a program for sharing most of WM source code, but it's not for common people like us. (check out their site to see what I mean) I suspect there are other sources of getting the parts necessary to understand DLL hooking, but I have no idea what they might be.
Well that's my two cents until an expert can answer you. Hope this helps.
farseer: you gave a perfectly good answer IMHO, just needed to get an idea of what level to pitch a response without talking up or down to you!
It's well documented that I'm a self confessed newb to c++, and would say that your programming skills should certainly hold you in good stead. However, having a good knowledge of the Win32 API is certainly beneficial.
For decompiling, basically IDA. There is an IDA demo available on their website that should get you going, it's pretty much 100% functional other then it won't save, and closes itself (or crashes itself) after a reasonable, random period of time. IDA is "the daddy" for pretty much all mainstream reversing, although you could write your own decompiler/debugger.
Recompiling - that's a toughy. IDA won't permit recompiling on ARM AFAIK.
You'll have to hexedit into the target and patch directly. Otherwise you get into the exciting world of code injection, hooking etc, as Mamaich says.
For that area, read everything he's ever written, before you start reversing
Oh, and a helpful hint to all. Don't just read what Mamaich's written on this board, his posts on other boards are even more useful!
It's worth getting a good familiarity with reversing on x86 first, get used to how IDA works etc (and Soft Ice is very useful to give a good insight into x86, although AFAIK it's not available for WinCE). ARM assembler is different, but just grab a list of the opcodes and read through a few CPU developers' guides (online).
There are a number of tutorials on reversing ARM stuff online. In the usual places for that kind of stuff.
For getting access to the ROM files, easiest way is to grab a rom update file and decrypt it. Mamaich is once again your man, his romtools do the job. He also has a "live" rom grabber, that'll grab all the files/modules out of your running phone for your perusal.
Platform Builder is available free to give you (some) WinCE source code. Not all, but enough to give you years worth of reading.
V
Thanks all...very kind of you to respond in such detail. I look forward to dabbling a bit with IDA and some of mamaich tools. I suppose the first order of business is to do a lil more research and then just dive in! It's been a while since i wrote any assembly code (not since college!), but i am a bit excited at having an excuse to do so again.
thanks again.
Just remember that unless you really luck out and the developer left the symbol table intact, you're going to end up with garbage for the names of variables and subroutines.
I hate reading decompiled code.

Reading the registry with Visual Studio 2003

I'm developing a small application for my HTC Wizard, which I'm programming with Visual Studio 2003.
I need to open the shell application for M3U files, which I've tracked down to HKCR\M3UFile\Shell\Open\Command... but now I can't figure out how to either read that key to open the relevant player, or to execute the m3u file directly.
Because I'm using VS2003, I don't have access to system.win32 with the compact framework, so what techniques have others of you used to read or write to the registry?
Also, just as a side note, how do you find the current path?
Thanks,
Jon
There is no real concept of current path in CE. If you want to know the path your EXE is in, use GetModuleHandle(NULL) -- it'll return the fully-qualified path name of that process's EXE, from which you can parse out a path.
I'd advise against using the compact framework; .Net is a loser on PPCs as it just slows things down, taking up extra memory & cycles on a platform where both are in short supply. Use the real Windows APIs instead -- i.e. call RegCreateKeyEx/RegSetValueEx.
And if you choose to use Win32 API you can just call ShellExecuteEx()
and not mess with the registry.
RegQueryValueEx is what you need. Just set the appropriate type and buffer.
V
I'm always willing to learn new stuff... are there any good resources on programming for PPC without using .net?
I know there's EVC++, but I've installed it, and now I don't know what to do with it!
Regards,
Jon
JonTheNiceGuy said:
I'm always willing to learn new stuff... are there any good resources on programming for PPC without using .net?
I know there's EVC++, but I've installed it, and now I don't know what to do with it!
Regards,
Jon
Click to expand...
Click to collapse
You can either use EVC++4, which is free but has an aged, not-so-standard C++ compiler (since it based on VC++6...but it only means a few quirks), or you can use Visual Studio 2005 which is supposed to replace EVC.
Jon, not to state the obvious, but there are many c++ tutorials for the PPC on the interweb.
What kind of experience do you have?
V
I have no prior experience with C++ - I bought the C++ For Dummies book in a charity shop a month or so ago, but it seems to refer to software that isn't available any more!
My core experience is with PHP, and recently I've been more interested in VB.NET for small apps at work, but most of what I want to do is with Windows Mobile - for which, all I have is Visual Studio 2003, and my co. won't fund me buying VS2005 as I got it for an old project that I still maintain, and anything new I need to write for work I can do with VS2005 Express...
That said, I'm not afraid of learning a new language, especially something as powerful as C++.
C++ for dummies is excellent, the best I've come across so far.
Have a read through this:
http://forum.xda-developers.com/viewtopic.php?p=209136#209136
I'm currently unlearning and then relearning my c++ - one thing I've learnt coming from other languages - c++ requires discipline. It's not about shortcuts, you build up from the basics and keep going steadily. But you need to be logical, and prepared to put in the effort. So discipline - it's been a long time since I've had to think about that!
V

eVC4 with sp4 - How to begin?

OK, I have absolutely no programming experience beyond creating some batch files in DOS, way back in the day, and some even earlier experience trying to learn BASIC (on an ADAM computer, no less....).
I've dl'd eVC4 with sp4, opened it up, and begun reading the help files....
Unfortunately, this is about as foreign to me as trying to read a Mandarin Chinese primer written in Russian....
My initial goal is to gain an understanding of .CAB files, and write a few of my own.
Any suggestions on how to find a good starting point? I have a brain, but I also need a good reference point.
Any help would be greatly appreciated!
If you just want to create cab files I'd recommend you use WinCE Cab Manager instead. It's much more easy to use, and provides way better understanding on how cab files work than eVC4
If you really just want to pack a few things then as nomad suggested you should get the Cab Manager.
Though there is not much to learn about cabs as they are made by cabwiz.exe (a file which comes with the Pocket PC SDK you also need for eVC).
It reads a inf file that lists files to include in installation, shortcuts, and registry setting. All of it is documented here.
If you want to get in to writing apps, you should first get a good book on C/C++ or on another programing language should you choose it.
Currently WM development supports C/C++, VB .NET, C# and JAVA (in somewhat awkward way)
Once you learn basics of the programing language you can move on to Win32 programing which is the base for both desktop and pocket PC OS.
It's a bit of a long way, but there isn't much choice if you want to really understand what you are doing / can do.
I started with an excellent book called "complete guide to C" (it was a translated version so name may vary, black cover big C on it) then moved on to a 1000+ page Visual C++ and MFC book from MS.
Is this link the latest eVC version available?
http://www.microsoft.com/downloads/...3D-50D1-41B2-A107-FA75AE960856&displaylang=en
It looks like you install eVC then the latest SP for it which appears to be SP4
http://www.microsoft.com/downloads/...F4-91D3-4DBE-986E-A812984318E5&displaylang=en
If you have Visual Studio 2005 and the WM5 sdk is there any reason to install eVC or is it included or obsoleted?
Not that I'm one to speak, I'm very much a learner, but I posted way back about some of my pains in learning to program in c++.
http://forum.xda-developers.com/showthread.php?t=253443&highlight=brain
V

[Develop] How to combin the DLL and EXE

I had developed a software. The software are using the external dll library, how can I compile the exe embedded *.dlls??
PS: I am using a VS 2005, Language: VB.net
Also I would like to know how to protect my application code avoid the decompiler to decompile ???
sorry for my poor english.
Welcome to the forum.
Your English is fine, but unfortunately there is no simple answer to your questions.
I will start with the last one first:
There is no one simple way to protect your code. There are whole books and articles written on it and if you google you will even find commercial products that "scramble" compiled apps to make it difficult to disassemble and reverse engineer.
Unfortunately I can not give you more specific info like book titles since I am not too interested on the subject.
I can tell you this: whether you app gets hacked or not is a matter of how much it costs vs. how useful / desirable it is. That means that if your program is really grate and everyone wants it but it costs a lot someone will put in the effort and eventually crack it no matter what you do.
As for your first question: unless you have source code or the obj files for the DLL to link to there is no way to combine it with your exe. If something was released as a DLL library and only as a DLL library it will remain just that.
Like mentioned above; the only possibility to 'protect' your .NET application is to obfuscate the code. there are some good (but commercial) tools out there. Google for it and if you're lucky you can find a comparison as well. (hopefully somebody tested some tools already to compare them)
You cannot recompile a DLL unless you've the source code as well.
it's easier to do if one dont use .net

XAP/DLL/EXE Hacking Tool (disassembler, decompiler, compiler)

.NET decompiler with support for XAP applications. Allows hackers developers to decompile assemblies and resources in a code editor, make changes and compile the code back to the assembly.
Click to expand...
Click to collapse
View on GitHub
Features:
Decompile .NET assemblies to C# and allow editing/compiling the high-level code back to CIL
Edit CIL instructions in method bodies
Modify assembly structure
Edit and extract assembly resources
Edit the contents of a XAP by adding, removing or swapping files, or using internal editors for certain resource types.
Integrated editors for text, hex, manifest, resource, XML and XAML.
XAP package manager (compatible with Windows Phone and Silverlight applications) allowing to view and extract XAP contents.
Does laundry, has mastered Italian cuisine, cleans and makes mind-blowjobs when asked kindly and treated right.
Click to expand...
Click to collapse
Some of your skills that could be useful may be:
Blogging: You can write down the results of your testing, your ideas and stuff about .NET Rain the way you see it.
UI/UX design: You don't have to bother with WPF implementation. Photoshop designs are good enough.
C#/WPF programming: You can contribute to the code quality and all user-related features of the application.
C# Reflection mastery: The "core" is in a very alpha state and is full of bugs. The are many planned new features, too.
Donations: They will be wisely spent.
Crowd-funding experience: You can help with raising money to pay for community-hired professionals to write code that will later remain open-source.
Virgin goat blood: For recreational uses.
Click to expand...
Click to collapse
Not going to lie, I laughed at that last part in the description. Very good work. Thanks for sharing!
I laughed at the git hub title for DLL editing : DLL Deep Throat XD
lol WUT!
Edit : Screen****s ? XD
jepp nice way to word some things , but please let us not use the kind of words here
and yes real good jop
I live to serve the forum rules, so fear not. GitHub is quite liberal, on the other hand
Let me know how do you like it because as of a while I'm experimenting with great new substances.
The effects of which include, but are not limited to, reviving this old project into The Tool for Windows 10.
So I'd love some (a lot of) "pre-"feedback. Try it out. Open issues on GitHub. Help me make it awesome.
Cheers

Categories

Resources