Answer
stringlengths 38
29k
⌀ | Id
stringlengths 1
5
| CreationDate
stringlengths 23
23
| Body
stringlengths 55
28.6k
| Title
stringlengths 15
145
| Tags
stringlengths 3
68
|
---|---|---|---|---|---|
<p>As Guntram mentioned, the <a href="https://github.com/moyix/panda" rel="nofollow">PANDA project</a> is built to make this kind of thing possible. Essentially, it adds instrumentation points to QEMU so that you can build plugins that perform analysis on a whole system as it executes.</p>
<p>One challenge is that the kinds of analyses you want to do are extremely computationally intensive, to the point where it's not really feasible to perform them while the system is actually running. To solve this in PANDA, we have <em>record and replay</em>. Essentially, this lets you make a recording of a whole-system execution and then replay it later with instrumentation enabled. Recording itself incurs only a small overhead, and arbitrarily expensive analyses can then be performed on the replay without altering the execution. This basic idea is explained in more detail in a paper by Chow et al., <a href="http://cs.stanford.edu/people/jchow/papers/decoupled-usenix2008.pdf" rel="nofollow">Decoupling dynamic program analysis from execution in virtual environments</a>.</p>
<p>Currently we have two papers that are relevant to the kind of RE you're looking at:</p>
<ul>
<li><a href="http://www.cc.gatech.edu/~brendan/tzb_author.pdf" rel="nofollow">Tappan Zee (North) Bridge</a>: This is probably closest to the kind of thing you're talking about. Essentially, it involves tracking every memory access in the system and then splitting them up according to address space, program counter, and calling context. The resulting streams of data can then be mined for interesting artifacts (encryption keys, URLs, etc.), which tells you where various algorithms and functionality are located in the system.</li>
<li><a href="https://mice.cs.columbia.edu/getTechreport.php?techreportID=1588&disposition=inline&format=pdf" rel="nofollow">Repeatable Reverse Engineering for the Greater Good with PANDA</a>: This is a more general look at using PANDA for reverse engineering, with three case studies: creating a keygen for Starcraft, diagnosing a use-after-free bug in Internet Explorer, and extracting the censorship blacklist used by the LINE IM client on Android.</li>
</ul>
<p>A <em>drawback</em> of PANDA is that it does not, strictly speaking, use virtualization. Instead, it uses QEMU in TCG (i.e., emulation) mode. This makes it more detectable, since there are a number of bugs in QEMU's CPU emulation that are not present when using hardware virtualization. However, unless the program you're analyzing explicitly tries to detect QEMU, this is unlikely to be a problem.</p>
|
8069
|
2015-01-20T20:42:22.757
|
<p>Let us suppose that I have a program that perform some well known cryptographic routines like AES, RSA or whatever. I would like to detect when such algorithms run, on which key material and possibly on which input and output data streams.</p>
<p>The idea is to run the whole program inside a virtual machine and then instrument the virtual machine itself to study the behavior of the program. For example, I might implement heuristics to check whether AES S-box is computed (when you see certain bytes and some clock cycles later the corresponding bytes in S-box show up in some register, then you might have a clue that S-box is being run). Tracing down how those bytes were moved across memory before might lead me to where the encryption key is stored.</p>
<p>The point of doing all of this in a virtual machine is that I can make up the environment so that the program is unable to detect that I am trying to spy on him. This way I would like to avoid all the mess with protectors and whatever and just see how it behaves.</p>
<p>Are there already attempts at reverse engineering programs in a similar way? By "similar way" I mean running the program in a virtual machine and looking how it moves data around the memory and on the registers, in order to find patterns that may help me to track down the information I am seeking.</p>
<p>In case it helps, the architecture I would like to use is x86 and the practical program is the one that I described above: interception of known cryptography procedure.</p>
|
Detect specific algorithms running in a virtual machine via behavior analysis
|
|x86|virtual-machines|
|
<p>Assuming you're on Windows, you could write a script that regularly restores <code>HKEY_CURRENT_USER\Software\Hex-Rays\IDA\History</code>.</p>
<p>On Linux or Mac OS, I'm sure there's something similar than can be easily restored via a simple script.</p>
|
8078
|
2015-01-22T17:17:23.257
|
<p>I usually work with two or three IDBs open at the same time which are linked between themselves (basically the main .exe, and DLLs it loads).</p>
<p>However, every now and then I open different files to take a look, and my "recently used IDBs" quickly gets filled up and the IDBs I work with disappear.</p>
<p>Is there any way I can make IDA stick those IDBs at the top of the "recently opened files" so I can access them easily?</p>
|
Is there any way to make IDA permanently save recently used files in a list?
|
|ida|ida-plugin|
|
<p>I'm surprised nobody posted an answer, but here's what I eventually came to realize:</p>
<p>A lot of times disassembling is used for taking apart potential malicious apps like viruses, worms, or malware to understand how they affect a system. There is both <a href="https://reverseengineering.stackexchange.com/questions/3473/what-is-the-difference-between-static-disassembly-and-dynamic-disassembly">static and dynamic disassembly</a>. Static disassembly poses (little) threat to your system as it is only looking through the code - however dynamic disassembly is actually running the code ( with breakpoints, etc ) - which is something you probably don't want to do on your main computer if the code is potentially malicious.</p>
<p>Here's what IDA says in a <a href="https://www.hex-rays.com/products/ida/support/tutorials/unpack_pe/manual.shtml" rel="nofollow noreferrer">tutorial about disassembling a "hostile" executable</a>:</p>
<blockquote>
<p>We could put a breakpoint there and let the program run. Now, before we do that, let's repeat that it is not a good idea to run untrusted code on your computer. It is much better to have a separate "sandbox" machine for such tests, for example using the remote debugging facilities IDA offers. Therefore, IDA displays a warning when a new file is going to be started under debugger: ignore at your own risk.</p>
</blockquote>
<p>This finally made sense as an explanation for why you may want to use a remote debugger - seems so obvious now!</p>
<p>I'm still not exactly sure on how to setup and/or use Hopper's remote debugger but I'm sure I'll figure that out eventually.</p>
|
8092
|
2015-01-25T14:42:28.083
|
<p>Hopper offers a <a href="http://www.hopperapp.com/HopperGDBServer/index.html" rel="nofollow noreferrer">GDB/LLDB Debugger Server</a> companion to the standard program. I'm unclear on what this should / can be used for. When I run the debugger server on the same machine that I'm using I see this:</p>
<p><img src="https://i.stack.imgur.com/ODJUT.png" alt="enter image description here"></p>
<hr>
<p>There aren't really any options or built-in help. When I open <code>Hopper.app</code>'s debugger panel I only see the program running locally. I was initially thinking that the Remote Debugger was maybe used to offload some of the processing to another computer, but I've also tried running Hopper Debugger Server on another mac on my LAN but I don't see it come up in the list, only my local machine:</p>
<p><img src="https://i.stack.imgur.com/cCHgb.png" alt="enter image description here"></p>
<hr>
<p>As there are no settings to specify remote connection information, I think I need to do something remotely that would specify a the address of the machine running Hopper so that it can sort of 'dial in' and then show up on the list.</p>
<p>I haven't had any luck with the Hopper website, forum, FAQ.</p>
<p>What am I missing?</p>
<p>Can anyone give me a brief outline of how the GDB/LLDB remote debugger<br>
is intended to be used (with Hopper) ?</p>
|
What does Hopper's Debugger Server do?
|
|debuggers|debugging|gdb|hopper|lldb|
|
<p>The first byte is a simple checksum variant. In C:</p>
<pre><code>uint8_t firstbyte( uint8_t const *data, size_t bytes )
{
uint8_t sum;
for (sum = 0; bytes; --bytes)
sum -= *data++;
return sum;
}
</code></pre>
<p>The second byte is a shift and add thing something like the BSD checksum:</p>
<pre><code>uint8_t secondbyte( uint8_t const *data, size_t bytes )
{
uint8_t sum;
for (sum = 0; bytes; --bytes) {
sum = (sum << 1) | ((sum & 0x80) ? 1 : 0);
sum += *data++;
}
return sum;
}
</code></pre>
|
8097
|
2015-01-26T19:43:48.267
|
<p>I'm trying to reverse engineer a serial protocol of a compressor, but i've no luck calculation the checksum.</p>
<p>e.g. here are some messages including the 16-bit checksum at the end of the message.</p>
<pre>
ff 02 ff 01 10 00 10 00 41 9e e2
ff 02 ff 01 10 00 10 00 42 9d e3
02 fe 03 00 00 00 00 00 00 fd c1
00 fe 02 83 01 10 00 00 00 00 6c c1
</pre>
<p>By now i know following octets</p>
<pre>
00 target addr
fe seems like a seperator
02 own addr
83 register addr
01 value1 high
10 value1 low
00 value2 high
00 value2 low
00 value3 high
00 value3 low
6c Checksum
c1 Checksum
</pre>
<p>I've tried to calculate the Checksum with different 16-Bit CRC's and brute-forcing with "reveng", but sadly i had no luck.</p>
<p>Also there is no way to put own Bits into the checksum function, but i can provide additional messages.</p>
<p>Can anybody help?</p>
|
Reversing Checksum of serial protocol
|
|deobfuscation|decryption|cryptanalysis|
|
<pre><code>from pydbg import *
from pydbg.defines import *
def handler_breakpoint (pydbg):
if pydbg.first_breakpoint:
dbg.bp_set(dbg.func_resolve("user32","SendMessageW"))
return DBG_CONTINUE
retaddr = dbg.get_arg(0,dbg.context)
modname = dbg.addr_to_module(retaddr).szModule
print "Calling Module and Return Address %25s\t%08x" % (modname,retaddr)
return DBG_CONTINUE
dbg = pydbg()
dbg.set_callback(EXCEPTION_BREAKPOINT, handler_breakpoint)
dbg.load("c:\windows\system32\calc.exe")
pydbg.debug_event_loop(dbg)
</code></pre>
<p>result</p>
<pre><code>Calling Module and Return Address comctl32.dll 773f2883
Calling Module and Return Address comctl32.dll 773f2883
Calling Module and Return Address USER32.dll 7e4269ed
Calling Module and Return Address USER32.dll 7e4269fa
</code></pre>
|
8098
|
2015-01-26T21:33:33.593
|
<p>Is there any quick/ faster way to find , any address resides in which loaded module.</p>
<p>For example from stack if I have ret address of any api. I want to check from which module actually that function was get called ??</p>
|
Using PyDBG how to find in which loaded module callee functions is present
|
|debuggers|debugging|python|
|
<p>You got started well; plotting unknown data as pixels immediately showed you this is indeed graphic data, not compressed (at least the buttons aren't), and in a usable RGB order. I guess the missing RGB format was what held you back; now you know it, you can write a simple program to plot in color and show offsets and widths of the images. Armed with that information, you can inspect the unknown bytes before (and possibly after) the images, and derive their meaning.</p>
<hr>
<h2>General overview</h2>
<p>The file <code>001_buttons.tsp</code> consists of a series of images, without a general file header but with a header per image.</p>
<p>The first long word of this header (4 bytes, little endian format) is the size of the following data in bytes, excluding the header itself (this length may be <code>0</code>). Then follow width and height as words. The next 12 bytes are 3 word-sized x,y pairs; the first pair is the center of the image. The coordinates are signed words, they wrap around at <code>0xFFFF/2</code>. The other pairs still serve an unknown purpose.</p>
<p>After that, you have (height) times the offset of the next image scan line in <em>words</em>, offset from the start by 4 (so 4+2*offset = next line).</p>
<p>Each scan line pointed to by these offsets is Run-Length Encoded (RLE) compressed. Transparent runs are indicated only by the number of horizontal pixels to skip; opaque runs can be copied directly to the screen. There is no alpha transparency in these images. Each scan line fills exactly <em>width</em> pixels after decompressing.</p>
<p>The pixel format is packed 16-bit RGB: <code>RRRR.RGGG.GGGB.BBBB</code>, which can be converted to 24-bit RGB in the following (not optimized) way:</p>
<pre><code>putpixel (x,y, (((val >> 8) & 0xf8)<<16) | (((val >> 3) & 0xfc)<<8) | ((val & 0x1f)<<3) );
</code></pre>
<p>where <code>val</code> is simply the next word: <code>data[c]+(data[c+1]<<8)</code>.</p>
<p><img src="https://i.stack.imgur.com/x17Vf.png" alt="sample dump"></p>
<hr>
<h2>Run-Length Encoding format</h2>
<p><img src="https://i.stack.imgur.com/ComX6.png" alt="rle unpacked image"></p>
<p>All values mentioned hereafter are <em>word</em> sized (2 bytes, little endian).<br>
Each scan line starts with the <em>number of commands</em> for that line and a flag indicating whether to start with a "skip" or "copy". If the flag word after the number of commands is <code>0000</code>, the line starts with a "skip", and if it is <code>0001</code>, the line starts with a "copy".<br>
After that, "skip" and "copy" commands alternate until the entire scan line is filled. Each command is the number of pixels to skip or copy; for "copy", the actual pixel values follow directly after it.</p>
<p>All lines should be filled entirely -- if necessary, the command list ends with a number of 'empty' pixels to skip.</p>
<p><img src="https://i.stack.imgur.com/bUS0Y.png" alt="new game overlay"></p>
<hr>
<p>Not all objects in <code>sprites.data</code> <em>are</em> sprites in this format. There are at least two different types:</p>
<ol>
<li><p>A monochrome mask object, using the same RLE compression scheme but without pixel data -- it contains only the length of each run. This could be to draw a mask, overlay a color, or aid in pixel-perfect object selection.</p></li>
<li><p>A list of signed word pairs of unknown use.</p></li>
</ol>
<p>Neither these objects nor the actual sprites have a recognizable identifier at the start, so you can only find out which is which by trial and error (for example: if the reported 'size' of an image is negative or larger than the entire data file, you know it cannot be an RLE-compressed image after all).</p>
<hr>
<h2>Sprite index file</h2>
<p>The index file <code>sprite.info</code> is obfuscated, but not by much. It has the following format:</p>
<pre><code>4 x some byte flag (all `01` in this file)
long total number of objects (377, in this file)
377 x
0-terminated "filename" (obfuscated)
long offset in 'sprite.data'
long length in 'sprite.data'
</code></pre>
<p>The filename is obfuscated by adding the constant <code>10</code> to each character. Decoding this, you get a list of 377 items:</p>
<pre><code>__extras\compplay.ps6 | 00000000 000000C0
__extras\dim1.ps6 | 000000C0 00000BC4
__extras\dim2.ps6 | 00000C84 00000EB4
...
units\tur_05_blue.ps6 | 01FAC346 00013E12
units\tur_05_gren.ps6 | 01FC0158 00013E12
units\turrets_shadow.ps6 | 01FD3F6A 00013C9C
</code></pre>
<p>This is some sort of general index, as clearly not all images are listed. It must list only the first of an animated set; the 'length' is then the total length of all files in that particular set. The file extensions are a hint to their contents: files ending with <code>.ps6</code> all contain at least one image (and may contain more), files ending with <code>.msk</code> are probably a monochrome mask and <code>.sha</code> possibly shadows. The <code>.po<em>digit</em></code> files contain coordinate pairs.</p>
|
8105
|
2015-01-27T16:15:26.917
|
<p>I'm trying to reverse engineer a file that contains sprites. I want to extract the sprites out of the file. So far I've managed to find some kind of line end sequence, and with this I've been able to confirm that the sprites are in the file:</p>
<p><img src="https://i.stack.imgur.com/JNEA4.png" alt="monochrome dump of file"></p>
<p>I'm using C++ and SDL. I load the file as a series of chars, and then plot a white pixel if the char>128 and a black if the char<128. It's very crude and I don't know how to proceed. How do I find where color is stored? Or an alpha channel? Or what is in the header? Etc.</p>
<p>If you know of any online resources that could be helpfull, please let me know. I'm kind of lost at where to start. These are first couple of bytes from the file I'm trying to reverse engineer, maybe this will help:</p>
<p><img src="https://i.stack.imgur.com/TQdJl.png" alt="hex dump of file"></p>
<p>The game is State of War. Its my childhoods' dream to write a remake of this game. I'm currently making a remake, but I'm using placeholder graphics. Thats why I need the sprites. I will not use it for commercial purposes.</p>
<p>There are 2 kinds of sprite files. *.tsp files, and a big sprites.data and sprites.info file. I've uploaded some files <a href="http://www.filedropper.com/data_6" rel="nofollow noreferrer">here</a>.</p>
|
Reverse engineering file containing sprites
|
|binary-format|
|
<blockquote>
<p>So how exactly do i figure out what is the remote process it is going
to communicate with, or what pipe it is using to communicate?</p>
</blockquote>
<p>The first step is to find the RPC client interface. This can be found via the first argument to <code>NdrClientCall2()</code>, named <code>pStubDescriptor</code>. In your question, <code>pStubDescriptor</code> points to <code>SspiCli!sspirpc_StubDesc</code>:</p>
<blockquote>
<p>And here is how it looks like in windbg, when i put a breakpoint in
the NdrClientCall2 function</p>
<pre><code>0:006> .echo "Arguments:"; dds esp+4 L5
Arguments:
06d9ece4 74cc2158 SspiCli!sspirpc_StubDesc
</code></pre>
</blockquote>
<p><code>SspiCli!sspirpc_StubDesc</code> is a <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa374178(v=vs.85).aspx" rel="noreferrer"><code>MIDL_STUB_DESC</code></a>, and on my computer, here are its associated values (via IDA Pro):</p>
<pre><code>struct _MIDL_STUB_DESC const sspirpc_StubDesc MIDL_STUB_DESC
<
offset dword_22229B8,
offset SecClientAllocate(x),
offset MIDL_user_free(x),
<offset unk_22383F4>,
0,
0,
0,
0,
offset word_22224B2,
1,
60001h,
0,
700022Bh,
0,
0,
0,
1,
0,
0,
0
>
</code></pre>
<p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa374178(v=vs.85).aspx" rel="noreferrer">As documented on MSDN</a>, the first field in the structure above "points to an RPC client interface structure". Thus, we can parse the data at that address as an <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa378503(v=vs.85).aspx" rel="noreferrer"><code>RPC_CLIENT_INTERFACE</code></a> struct:</p>
<pre><code>stru_22229B8 dd 44h ; Length
dd 4F32ADC8h ; InterfaceId.SyntaxGUID.Data1
dw 6052h ; InterfaceId.SyntaxGUID.Data2
dw 4A04h ; InterfaceId.SyntaxGUID.Data3
db 87h, 1, 29h, 3Ch, 0CFh, 20h, 96h, 0F0h; InterfaceId.SyntaxGUID.Data4
dw 1 ; InterfaceId.SyntaxVersion.MajorVersion
dw 0 ; InterfaceId.SyntaxVersion.MinorVersion
dd 8A885D04h ; TransferSyntax.SyntaxGUID.Data1
dw 1CEBh ; TransferSyntax.SyntaxGUID.Data2
dw 11C9h ; TransferSyntax.SyntaxGUID.Data3
db 9Fh, 0E8h, 8, 0, 2Bh, 10h, 48h, 60h; TransferSyntax.SyntaxGUID.Data4
dw 2 ; TransferSyntax.SyntaxVersion.MajorVersion
dw 0 ; TransferSyntax.SyntaxVersion.MinorVersion
dd offset RPC_DISPATCH_TABLE const sspirpc_DispatchTable; DispatchTable
dd 0 ; RpcProtseqEndpointCount
dd 0 ; RpcProtseqEndpoint
dd 0 ; Reserved
dd offset _MIDL_SERVER_INFO_ const sspirpc_ServerInfo; InterpreterInfo
dd 4000000h ; Flags
</code></pre>
<p>From the <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa378503(v=vs.85).aspx" rel="noreferrer"><code>RPC_CLIENT_INTERFACE</code></a> struct above, we can extract the <code>InterfaceId</code> GUID: <code>4F32ADC8-6052-4A04-8701-293CCF2096F0</code></p>
<p>We can now look up that interface GUID with <a href="http://www.rpcview.org/" rel="noreferrer">RpcView</a> to find the associated DLL, running process, and endpoints:</p>
<p><img src="https://i.stack.imgur.com/T4JZp.png" alt="Interfaces">
<img src="https://i.stack.imgur.com/b1JI5.png" alt="Process">
<img src="https://i.stack.imgur.com/XRV4Z.png" alt="Endpoints"></p>
<p>To find out which specific endpoint is being used by the SSPI RPC server in the LSASS process, we can reverse engineer <code>sspisrv.dll</code>. In the exported function <code>SspiSrvInitialize()</code>, we see the following call:</p>
<pre><code>RpcServerUseProtseqEpW(L"ncalrpc", 0xAu, L"lsasspirpc", 0);
</code></pre>
<p>To figure out which specific function is being called in <code>sspisrv.dll</code>, we need to look at the <code>pFormat</code> data passed to <code>NdrClientCall2</code>. In your example code above, the <code>pFormat</code> data is:</p>
<pre><code>00 48 00 00 00 00 06 00-4c 00 30 40 00 00 00 00 ...
</code></pre>
<p>If we parse the <code>pFormat</code> data as an <a href="http://doxygen.reactos.org/d5/d5b/structNDR__PROC__HEADER__RPC.html" rel="noreferrer">NDR_PROC_HEADER_RPC</a> structure, we get:</p>
<pre><code>handle_type = 0x00
Oi_flags = 0x48
rpc_flags = 0x00000000
proc_num = 0x0006
stack_size = 0x004C
</code></pre>
<p>From <code>proc_num</code>, we can see that this RPC call is calling the 6th RPC function in <code>sspisrv.dll</code>. We can use RpcView again to get the address for the 6th RPC function:</p>
<p><img src="https://i.stack.imgur.com/ihKKv.png" alt="Procedures"></p>
<p>And with IDA Pro, we can see the function in <code>sspisrv.dll</code> at address <code>0x7573159D</code>:</p>
<pre><code>.text:7573159D __stdcall SspirProcessSecurityContext(x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x, x) proc near
</code></pre>
<p>RpcView also shows us a decompilation of that function's prototype:</p>
<p><img src="https://i.stack.imgur.com/yP5dk.png" alt="Decompilation"></p>
<p>(Note that on your computer, the 6th function might not be at virtual address <code>0x7573159D</code>, and furthermore, the 6th function might not be <code>SspirProcessSecurityContext()</code>, but this is the approach you would use nonetheless.)</p>
<p>As such, we can now say the following:</p>
<ul>
<li>The RPC server code for your <code>NdrClientCall2()</code> call is in <code>sspisrv.dll</code></li>
<li>The RPC server for your <code>NdrClientCall2()</code> call is running in LSASS's process</li>
<li>The endpoint for your <code>NdrClientCall2()</code> call is named <code>lsasspirpc</code></li>
<li>The RPC server function called by your <code>NdrClientCall2()</code> call in <code>sspisrv.dll</code> is <code>SspirProcessSecurityContext()</code></li>
</ul>
|
8116
|
2015-01-29T09:33:10.880
|
<p>Hey i have a very time consuming problem, and i thought i might find someone here with better experience than mine that could help me out.</p>
<p>I am reverse-engineering an application which at some point uses the <em>NdrClientCall2</em> api to use a remote procedure of some other service (which i dont know which one that is)</p>
<p>Now before i hear comments about not trying anything my self
There are some <strong>really good applications</strong> to accomplish what i want like <em><strong>NtTrace</strong></em>, <em><strong>Strace</strong></em> and roughly <em><strong>oSpy</strong></em> can achieve the same result aswell eventually.
But my application has some really hard anti-debugging techniques which force me to do everything manually.</p>
<p>What eventually i want to achieve is know what procedure is being called and on what service \ process.</p>
<p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa374215%28v=vs.85%29.aspx" rel="nofollow noreferrer">Here is the NdrClientCall2 Decleration by MSDN</a></p>
<pre><code>CLIENT_CALL_RETURN RPC_VAR_ENTRY NdrClientCall2(
__in PMIDL_STUB_DESC pStubDescriptor,
__in PFORMAT_STRING pFormat,
__in_out ...
);
</code></pre>
<p>so it uses the <strong>PMIDL_STUB_DESC</strong> struct which its definition is as the following:</p>
<pre><code>typedef struct _MIDL_STUB_DESC {
void *RpcInterfaceInformation;
void* (__RPC_API *pfnAllocate)(size_t);
void (__RPC_API *pfnFree)(void*);
union {
handle_t *pAutoHandle;
handle_t *pPrimitiveHandle;
PGENERIC_BINDING_INFO pGenericBindingInfo;
} IMPLICIT_HANDLE_INFO;
const NDR_RUNDOWN *apfnNdrRundownRoutines;
const GENERIC_BINDING_ROUTINE_PAIR *aGenericBindingRoutinePairs;
const EXPR_EVAL *apfnExprEval;
const XMIT_ROUTINE_QUINTUPLE *aXmitQuintuple;
const unsigned char *pFormatTypes;
int fCheckBounds;
unsigned long Version;
MALLOC_FREE_STRUCT *pMallocFreeStruct;
long MIDLVersion;
const COMM_FAULT_OFFSETS *CommFaultOffsets;
const USER_MARSHAL_ROUTINE_QUADRUPLE *aUserMarshalQuadruple;
const NDR_NOTIFY_ROUTINE *NotifyRoutineTable;
ULONG_PTR mFlags;
const NDR_CS_ROUTINES *CsRoutineTables;
void *Reserved4;
ULONG_PTR Reserved5;
} MIDL_STUB_DESC, *PMIDL_STUB_DESC;
</code></pre>
<p>And here is how it looks like in windbg, when i put a breakpoint in the NdrClientCall2 function</p>
<pre><code>0:006> .echo "Arguments:"; dds esp+4 L5
Arguments:
06d9ece4 74cc2158 SspiCli!sspirpc_StubDesc
06d9ece8 74cc2322 SspiCli!sspirpc__MIDL_ProcFormatString+0x17a
06d9ecec 06d9ed00
06d9ecf0 91640000
06d9ecf4 91640000
0:006> .echo "PMIDL_STUB_DESC:"; dds poi(esp+4) L20
PMIDL_STUB_DESC:
74cc2158 74cc2690 SspiCli!sspirpc_ServerInfo+0x24
74cc215c 74cca1cd SspiCli!MIDL_user_allocate
74cc2160 74cca1e6 SspiCli!MIDL_user_free
74cc2164 74ce0590 SspiCli!SecpCheckSignatureRoutineRefCount+0x4
74cc2168 00000000
74cc216c 00000000
74cc2170 00000000
74cc2174 00000000
74cc2178 74cc1c52 SspiCli!sspirpc__MIDL_TypeFormatString+0x2
74cc217c 00000001
74cc2180 00060001
74cc2184 00000000
74cc2188 0700022b
74cc218c 00000000
74cc2190 00000000
74cc2194 00000000
74cc2198 00000001
74cc219c 00000000
74cc21a0 00000000
74cc21a4 00000000
74cc21a8 48000000
74cc21ac 00000000
74cc21b0 001c0000
74cc21b4 00000032
74cc21b8 00780008
74cc21bc 41080646
74cc21c0 00000000
74cc21c4 000b0000
74cc21c8 00020004
74cc21cc 00080048
74cc21d0 21500008
74cc21d4 0008000c
0:006> .echo "PFORMAT_STRING:"; db poi(esp+8)
PFORMAT_STRING:
74cc2322 00 48 00 00 00 00 06 00-4c 00 30 40 00 00 00 00 .H......L.0@....
74cc2332 ec 00 bc 00 47 13 08 47-01 00 01 00 00 00 08 00 ....G..G........
74cc2342 00 00 14 01 0a 01 04 00-6e 00 58 01 08 00 08 00 ........n.X.....
74cc2352 0b 00 0c 00 20 01 0a 01-10 00 f6 00 0a 01 14 00 .... ...........
74cc2362 f6 00 48 00 18 00 08 00-48 00 1c 00 08 00 0b 00 ..H.....H.......
74cc2372 20 00 2c 01 0b 01 24 00-a2 01 0b 00 28 00 b8 01 .,...$.....(...
74cc2382 13 41 2c 00 a2 01 13 20-30 00 f8 01 13 41 34 00 .A,.... 0....A4.
74cc2392 60 01 12 41 38 00 f6 00-50 21 3c 00 08 00 12 21 `..A8...P!<....!
</code></pre>
<p>So how exactly do i figure out what is the remote process it is going to communicate with, or what pipe it is using to communicate?</p>
<p>As far as i understand from the MSDN, it is supposed to call a remote procedure. if i understand that right, it means it should call a remote function as if its an exported dll function. How can i set a breakpoint there?</p>
<p>P.S:</p>
<p>The main reason im posing this function is because the NdrClientCall2 seems to be pretty huge.</p>
|
at the rpcrt4!NdrClientCall2 function - how does it know which pipe to use in order to transfer data to another process?
|
|windbg|anti-debugging|
|
<p>Another program which can do what you're looking for is CFF Explorer:
<a href="https://i.stack.imgur.com/17XLV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/17XLV.png" alt="enter image description here" /></a></p>
|
8120
|
2015-01-29T17:52:30.907
|
<p>I've added some functionality to existing application which works through dll injection - my dll loads and patches some stuff. </p>
<p>I would like it to be added to this application permanently so I don't have to inject it manually every time - I know there are some solutions such as:</p>
<ol>
<li>Loader - another application that runs target application and then injects a dll</li>
<li>Patch EP - patch entry of target application so it loads my dll before executing rest</li>
<li>AppInit_DLL - making it loads to almost every process through this register entry and then checking if we are in the right one, unload otherwise</li>
</ol>
<p>But are those options most optimal? First and second requires some work (maybe there are some already existing tools of which I don't know and which allows it? so I don't have to prepare it all myself), and third seems a bit over-excessive.
Just to expand my knowledge - what are the other options?</p>
|
Making application load dll at start
|
|patching|
|
<p>Stack variables live in the stack's address space, not in the module's address space. Thus, there's nothing that the Hex View could show you statically.</p>
|
8125
|
2015-01-29T23:25:22.400
|
<p>You have the IDA View and Hex View right. When on IDA View you select an instruction you can see the instruction selected in Hex View as well. However, if you select a "data instruction" like "Format = dword ptr -10h" which is a stack variable, you don't see it in the hex view. It doesn't select the bytes corresponding to the variable definition. I mean I know the variable is going to be there in memory but somewhere on the hex view should tell me "hey allocate this stack variable" but it doesn't.</p>
<p>It's probably obvious by now, I'm a beginner in reverse engineering, I've been reading the book from <a href="http://beginners.re/" rel="nofollow">http://beginners.re/</a> . While I do know some assembly and have been able to reverse simple things, I have these knowledge gaps I'd like to fill. Thank you!</p>
|
ida pro stack variables in hex view
|
|ida|
|
<p>PE executables start with a header block that consists of a little DOS exe stub (with its own little header), a structure called <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms680336%28v=vs.85%29.aspx" rel="noreferrer">IMAGE_NT_HEADERS</a>, and a section table. A normal PE has no 32-bit/64-bit executable code there, so IDA doesn't load the header block unless you check "<strong>manual load</strong>".</p>
<p>Relevant resources:</p>
<ul>
<li>Microsoft's <a href="https://msdn.microsoft.com/en-us/windows/hardware/gg463119.aspx" rel="noreferrer">PE COFF specification</a> (currently at version 8.3)</li>
<li>Matt Pietrek's classic <a href="https://msdn.microsoft.com/en-us/library/ms809762.aspx" rel="noreferrer">Peering Inside the PE: A Tour of the Win32 Portable Executable File Format</a></li>
<li>its sequel <a href="https://msdn.microsoft.com/en-us/magazine/cc301805.aspx" rel="noreferrer">An In-Depth Look into the Win32 Portable Executable File Format</a></li>
<li>ReversingLabs' <a href="https://media.blackhat.com/bh-us-11/Vuksan/BH_US_11_VuksanPericin_PECOFF_WP.pdf" rel="noreferrer">Undocumented PECOFF</a></li>
</ul>
|
8128
|
2015-01-30T03:16:30.673
|
<p>I noticed that despite the imagebase for win32 executables be 0x400000, Ida Pro only starts the analysis at 0x401000. What is before that and how can I change IDA's settings to start the analysis at the imagebase? Thank you.</p>
|
How can I make IDA start the analysis at imagebase?
|
|ida|memory|
|
<p>The quick answer is:</p>
<p><code>14 00</code> are the first two bytes of a sprite. The raw bitmap data starts at offset 20, in this case with <code>03 00 0A 00</code>. The file is RLE encoded, <code>03 00</code> being the escape sequence and <code>0A 00</code> is telling me that 20 pixels with <code>00 00</code> (16 bpp) follow.</p>
<p>With this information I was able to reverse engineer the sprite group.</p>
|
8145
|
2015-02-01T21:45:43.547
|
<p>I am trying to get the sprites from a game from 1997 called Swing (US: Marble Master). The file is called <a href="https://drive.google.com/file/d/0BwnokKRE3G8URVdKWmdLSy1nM0E/view?usp=sharing" rel="nofollow noreferrer">NORMAL.SET</a> and contains a set of sprites. There is an executable named SHOWSET.EXE that displays the entire set after printing a number on each sprite.</p>
<p>There are also a file called <a href="https://drive.google.com/open?id=0BwnokKRE3G8UdU5VTFVVMFkwME0&authuser=0" rel="nofollow noreferrer">HINTERH.SWG</a> (SWG probably stands for SWING). I was able to figure out what this file type is using TiledGGD! It is raw data without headers, has the size 640x480, 16 bpp, big endian, (A)RGB. See Screenshot below.</p>
<p><img src="https://i.stack.imgur.com/6WsaQ.png" alt="HINTERH.SWG opened in TiledGGD"></p>
<p>Using the same settings in TiledGGD I get a close approximation of the <a href="https://drive.google.com/file/d/0BwnokKRE3G8URVdKWmdLSy1nM0E/view?usp=sharing" rel="nofollow noreferrer">NORMAL.SET</a> image. Below you find the output from SHOWSET.EXE (left), aswell as the image how TiledGGD displays it (right).</p>
<p><img src="https://i.stack.imgur.com/Rbr2h.png" alt="NORMAL.SET as displayd in game and in TiledGGD"></p>
<p>Using a screenshot of the SHOWSET.EXE output, I was able to get close to the codec (?correct term?) used for the pixel data in the NORMAL.SET. I do believe it is based on 16-bit ARGB1555, but still different. Below you see the image extracted from the screenshot. Let's call it screenshot-sprite.</p>
<p><img src="https://i.stack.imgur.com/E5Q7s.png" alt="Sprite extracted from Screenshot"></p>
<p>Those are the first 192 bytes from NORMAL.SET</p>
<pre><code>47 69 62 20 6D 69 72 20 27 6E 65 20 4B 75 67 65
6C 0A 00 1A 73 74 61 6E 64 61 72 64 00 00 00 00
00 00 00 00 9D 4F DD 32 00 00 00 00 68 27 01 00
14 00 01 0F 1E 00 1E 00 2C 03 00 00 03 00 00 00
00 00 00 00 03 00 0A 00 90 08 90 08 90 08 90 08 <1,2---
8F 08 8F 08 8E 08 6D 08 6C 04 6B 04 03 00 0A 00
03 00 08 00 90 08 91 08 91 08 91 08 91 08 91 08
90 08 90 08 8F 08 8E 08 6D 08 6C 04 6A 04 4A 04
03 00 08 00 03 00 06 00 91 08 91 08 B2 08 B2 08
B2 08 B2 08 B2 08 B2 08 B2 08 91 08 90 08 8F 08
8E 08 6D 08 6C 04 6B 04 49 04 48 04 03 00 06 00
03 00 05 00 90 08 B2 08 B2 08 B3 08 B3 0C B3 0C
</code></pre>
<p>Those are the first 192 bytes from the screenshot-sprite.</p>
<pre><code>42 4D 50 07 00 00 00 00 00 00 46 00 00 00 38 00
00 00 1E 00 00 00 E2 FF FF FF 01 00 10 00 03 00
00 00 0A 07 00 00 3B 00 00 00 3B 00 00 00 00 00
00 00 00 00 00 00 00 7C 00 00 E0 03 00 00 1F 00
00 00 00 80 00 00 00 00 00 00 00 00 00 00 00 00 <1---
00 00 00 00 00 00 00 00 00 00 90 08 90 08 90 08 <2---
90 08 8F 08 8F 08 8E 08 6D 08 6C 04 6B 04 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 90 08 91 08 91 08 91 08 91 08 91 08 90 08
90 08 8F 08 8E 08 6D 08 6C 04 6A 04 4A 04 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
</code></pre>
<p>You can see the point where the data does probably begin (arrow 1), you see a similar hex string <code>90 08 90 08 90 08</code>.</p>
<p>You also see that the data in the screenshot-sprite probably begins with 10 byte-pairs (arrow 2). In the NORMAL.SET you find <code>0A 00</code>. Now I read about RLE and with some fantasy I could see a link between 10 byte-pairs and <code>0A 00</code> which I could translate into "ten times a black pixel".</p>
<p>I am still confused why I see two blue sprites in the NORMAL.SET, where in the screenshot there is only one blue sphere. But that is something I would care about at a later time.</p>
<p><strong>NOTE</strong><br>
At this point I am quite sure that I am on the right track! I think RLE decompression is the only thing missing here, besides figuring out where the data starts and what the headers are supposed to mean. Maybe they aren't even of much use to me.</p>
<p>I am not sure, if I still have a question at the moment. If nobody disagrees, I would keep this here until I figured out the rest in the hopes that someday, to someone this will be helpful. I will update this as soon as I solved the riddle.</p>
<p>Until the, if you got a a solution for the RLE ready, don't be shy to post ;)</p>
|
Some help with sprite graphic
|
|digital-forensics|binary-format|
|
<p>According to the official <a href="http://global-download.acer.com/GDFiles/Document/QuickStartGuide/QuickStartGuide_Acer_1.0_A_A.zip?acerid=634304197158565322&Step1=NOTEBOOK&Step2=ASPIRE&Step3=ASPIRE%205750G&OS=ALL&LC=en&BC=ACER&SC=PA_6" rel="nofollow noreferrer">Quick Guide for the Acer Aspire 5750G</a>, you can use <kbd>Fn</kbd>+<kbd>F6</kbd> to turn the backlight completely off, and you can use <kbd>Fn</kbd>+<kbd>▷</kbd> and <kbd>Fn</kbd>+<kbd>◁</kbd> to increase or decrease the screen brightness, respectively:</p>
<p><img src="https://i.stack.imgur.com/SlUfo.png" alt="5750G"></p>
<p>The Acer Aspire 5750G has an Intel HD Graphics 3000 integrated graphics processor. So if you need more fine-grained control over the brightness, use the Intel HD Graphics Control Panel (<a href="http://global-download.acer.com/GDFiles/Driver/VGA/VGA_Intel_8.15.10.2342_W7x86W7x64_A.zip?acerid=634761931954606771&Step1=NOTEBOOK&Step2=ASPIRE&Step3=ASPIRE%205750G&OS=ALL&LC=en&BC=ACER&SC=PA_6" rel="nofollow noreferrer">latest drivers for your laptop</a>) to manually adjust the backlight brightness:</p>
<p><img src="https://i.stack.imgur.com/6Z4nm.jpg" alt="Intel HD Graphics Control Panel"></p>
|
8146
|
2015-02-01T22:46:41.923
|
<p>I've had two laptops, one Sony and another Acer. Sony laptops backlight can be decreased quite a bit, however the Acer laptops backlight brightness is too much.</p>
<p>I was wondering where these values sit and if there is a possibility to lower the laptop screen backlight brightness any lower than their current settings.</p>
<p>I don't know if this question belongs here but I've asked around a bit in forums and usual answer is to simply decrease brightness using GPU software. Yet this does nothing to the actual backlights, which in the night are eye piercing.</p>
|
Laptop monitor backlight
|
|hardware|
|
<p>Pintools on Windows can also aid you in instrumenting system calls. Also, if its discovered that the cpu supports <code>sysenter</code>/<code>syscall</code>, those are used in place of <code>int 2e</code>. However, this has no bearing on whether or not instrumentation can take place.</p>
<p>To answer your second question, yes, <code>NtReadFile</code>, <code>NtWriteFile</code> and <code>NtDeviceIoControlFile</code> are the *nix equivalent of <code>read</code>/<code>write</code>/<code>ioctl</code>.</p>
|
8154
|
2015-02-03T09:41:31.820
|
<p>On Linux the <em>strace.so</em> pintool gives a good overview on how system calls are intercepted in PIN. One could monitor the value of <code>EAX</code> to see which system call is being invoked(and mprotect and writes could be intercepted in the fashion).</p>
<p>How could we do something similar for Windows? I see that the <code>int 2e</code> interrupt is used to trap into the kernel and that the system calls numbers are given at <a href="http://j00ru.vexillium.org/ntapi/" rel="nofollow">here</a>. Is <code>NtWriteFile</code> the analogue of <code>write</code>? Also is <code>NtProtectVirtualMemory</code> the analogue of <code>mprotect</code>?</p>
|
pintool to intercept writes and VirtualProtect
|
|operating-systems|pintool|system-call|
|
<p>I <a href="https://github.com/zneak/fcd/blob/b29b4ac/scripts/macho.py#L307" rel="noreferrer">wrote</a> a Python script that parses entry points and imports from a Mach-O executable for one of my projects. The trick is to parse the <code>LC_DYLD</code> or <code>LC_DYLD_ONLY</code> loader commands. These two commands encode three import tables: bound symbols, weak symbols, and lazy symbols.</p>
<pre><code>struct dyld_info_command {
uint32_t cmd;
uint32_t cmdsize;
uint32_t rebase_off;
uint32_t rebase_size;
uint32_t bind_off;
uint32_t bind_size;
uint32_t weak_bind_off;
uint32_t weak_bind_size;
uint32_t lazy_bind_off;
uint32_t lazy_bind_size;
uint32_t export_off;
uint32_t export_size;
};
</code></pre>
<p>The interesting fields are <code>bind_off</code>, <code>bind_size</code>, <code>weak_bind_off</code>, <code>weak_bind_size</code>, <code>lazy_bind_off</code> and <code>lazy_bind_size</code>. Each pair encodes the offset and size of a block of data, inside the executable file, that contains the import table opcodes.</p>
<p>Each of these tables can be seen as having four (useful) columns: the segment, segment offset, library name and symbol name. Together, the segment and segment offset indicate the address where the symbol's actual address will be written to (so for instance, if you have <code>__TEXT</code> and 0x40, this conceptually means that <code>*(__TEXT+0x40) == resolvedSymbolAddress</code>).</p>
<p>The table is encoded as a stream of opcodes for compression purposes. The opcodes control a state machine that contains state for a would-be symbol, has operations to manipulate that state, and operations to "bind" a symbol (take all that state and make it a part of the symbol table). For instance, you could see:</p>
<ul>
<li>set segment to __TEXT</li>
<li>set offset to 0x40</li>
<li>set library to libSystem.dylib</li>
<li>set symbol name to "printf"</li>
<li>bind symbol</li>
<li>set offset to 0x48</li>
<li>set symbol name to "scanf"</li>
<li>bind symbol</li>
</ul>
<p>At the end of this sequence, you get two symbols: printf and scanf, whose addresses are located at __TEXT+0x40 and __TEXT+0x48 respectively, from libSystem.dylib. This means that if you see an instruction like <code>jmp [__TEXT+0x48]</code> (an indirect jump to the address contained at <code>__TEXT+0x48</code>), you know that you're going to <code>scanf</code>. This is how you can tell the destination of stubs.</p>
<p>Each opcode is at least 1 byte, separated as 0xCI (where C is the command name, and I is an immediate value, both 4 bits). When the command needs a larger operand (or more operands), they are encoded in <a href="https://en.wikipedia.org/wiki/LEB128" rel="noreferrer">ULEB-128</a> format (except for <code>BIND_OPCODE_SET_ADDEND_SLEB</code>, which uses signed LEB, but we don't really care about it for the purpose of finding imports).</p>
<pre><code>def readUleb(data, offset):
byte = ord(data[offset])
offset += 1
result = byte & 0x7f
shift = 7
while byte & 0x80:
byte = ord(data[offset])
result |= (byte & 0x7f) << shift
shift += 7
offset += 1
return (result, offset)
</code></pre>
<p>Libraries aren't actually identified by their names in the command stream. Rather, libraries are identified by their <strong>one-based</strong> "library ordinal", which is just the index of the library within all the <code>LC_LOAD_DYLIB</code>, <code>LC_LOAD_WEAK_DYLIB</code>, <code>LC_REEXPORT_DYLIB</code> and <code>LC_LOAD_UPWARD_DYLIB</code> loader commands. For instance, if an executable has a <code>LC_LOAD_DYLIB</code> command for libSystem and then one for libFoobar, libSystem has ordinal 1 and libFoobar has ordinal 2.</p>
<p>There are three special values: ordinal -2 means that the symbol is looked up in the flat namespace (first library with a symbol with that name wins); ordinal -1 looks for a symbol in the main executable, whatever it is; and ordinal 0 looks for a symbol within this file. As we've said above, ordinal 1 and above refer to libraries.</p>
<p>Symbol names are encoded within the command blob as null-terminated strings.</p>
<p>Each opcode is easily described in code, so I'll spare us the description of each. </p>
<pre><code>BIND_OPCODE_DONE = 0
BIND_OPCODE_SET_DYLIB_ORDINAL_IMM = 1
BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB = 2
BIND_OPCODE_SET_DYLIB_SPECIAL_IMM = 3
BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM = 4
BIND_OPCODE_SET_TYPE_IMM = 5
BIND_OPCODE_SET_ADDEND_SLEB = 6
BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB = 7
BIND_OPCODE_ADD_ADDR_ULEB = 8
BIND_OPCODE_DO_BIND = 9
BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB = 10
BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED = 11
BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB = 12
def parseImports(self, offset, size):
pointerWidth = self.bitness / 8
slice = self.data[offset:offset+size]
index = 0
name = ""
segment = 0
segmentOffset = 0
libOrdinal = 0
stubs = []
def addStub():
stubs.append((segment, segmentOffset, libOrdinal, name))
while index != len(slice):
byte = ord(slice[index])
opcode = byte >> 4
immediate = byte & 0xf
index += 1
if opcode == BIND_OPCODE_DONE:
pass
elif opcode == BIND_OPCODE_SET_DYLIB_ORDINAL_IMM:
libOrdinal = immediate
elif opcode == BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB:
libOrdinal, index = self.__readUleb(slice, index)
elif opcode == BIND_OPCODE_SET_DYLIB_SPECIAL_IMM:
libOrdinal = -immediate
elif opcode == BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM:
nameEnd = slice.find("\0", index)
name = slice[index:nameEnd]
index = nameEnd
elif opcode == BIND_OPCODE_SET_TYPE_IMM:
pass
elif opcode == BIND_OPCODE_SET_ADDEND_SLEB:
_, index = self.__readUleb(slice, index)
elif opcode == BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB:
segment = immediate
segmentOffset, index = self.__readUleb(slice, index)
elif opcode == BIND_OPCODE_ADD_ADDR_ULEB:
addend, index = self.__readUleb(slice, index)
segmentOffset += addend
elif opcode == BIND_OPCODE_DO_BIND:
addStub()
elif opcode == BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB:
addStub()
addend, index = self.__readUleb(slice, index)
segmentOffset += addend
elif opcode == BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED:
addStub()
segmentOffset += immediate * pointerWidth
elif opcode == BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB:
times, index = self.__readUleb(slice, index)
skip, index = self.__readUleb(slice, index)
for i in range(times):
addStub()
segmentOffset += pointerWidth + skip
else:
sys.stderr.write("warning: unknown bind opcode %u, immediate %u\n" % (opcode, immediate))
</code></pre>
|
8163
|
2015-02-05T16:25:42.513
|
<p>Before exposing my problem, here's my understanding of the whole thing, so that you may correct me if I'm saying something wrong.</p>
<p>In a Mach-O file (at least on x86), the <code>__TEXT.__stubs</code> section typically has stubs in it that all consist of a single indirect jump, like this:</p>
<pre><code>; __TEXT.__stubs
; symbol stub for unlink:
0x100000f46: jmpq *0xc4(%rip)
; symbol stub for puts:
0x100000f4c: jmpq *0xc6(%rip)
</code></pre>
<p>These point to a location inside the <code>__DATA.__nl_symbol_ptr</code> section. The pointer initially goes to a stub helper in the <code>__TEXT.__stub_helper</code> section:</p>
<pre><code>; __TEXT.__stub_helper
; stub helper for unlink
0x100000f64: pushq $0x0
0x100000f69: jmp 0x100000f54
; stub helper for puts
0x100000f6e: pushq $0xe
0x100000f73: jmp 0x100000f54
</code></pre>
<p>The stub helper calls <code>dyld_stub_binder</code>, which uses the pushed argument to figure out which stub it is and which function it needs to look up, then replaces the value in <code>__DATA.__nl_symbol_ptr</code> with the resolved address, and then hand over control to the function that was found (which then returns to the calling code normally).</p>
<p>To assist debugging, debuggers find stubs and pretend that they have symbols for them. In this example program, whenever lldb sees <code>call 0x100000f58</code>, it determines that the stub should point to <code>unlink</code>, and says <code>call 0x100000f58 ; symbol stub for: unlink</code> in the disassembly.</p>
<p>However, lldb does not use the pushed value: it appears to <a href="https://github.com/llvm-mirror/lldb/blob/5b0324a42cae28a07bc3683c6757dc1533b8fa0d/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp#L4375" rel="noreferrer">rely on the static linker placing undefined symbols and stubs in the same order</a>, or some variant of that. Just like that, it looks more like a heuristic than a precise way to figure out which stub goes where, unless there's something else preventing you from tampering.</p>
<p>So how do I reliably find which function is called by a stub? In the stub helpers, what do the constants in <code>pushq $constant</code> mean?</p>
|
In a Mach-O executable, how can I find which function a stub targets?
|
|osx|symbols|mach-o|
|
<p>in the code (or in the linker command file) create a memory name (say .stdio) and give it a specific address. then write a section statement: '.stdio' and list the 'stdio.text' will then be the first thing in the memory .stdio section. The linker command file can also have a global name at the .stdio section, that can be referenced from within a program.</p>
|
8166
|
2015-02-05T22:44:34.423
|
<p>The test is on Ubuntu 12.04, 32-bit, with <code>gcc</code> 4.6.3.</p>
<p>Basically I am doing some binary manipulation work on ELF binaries, and what I have to do now is to assemble a assembly program and guarantee the libc symbols are loaded to a predefined address by me.</p>
<p>Let me elaborate it in an simple example.</p>
<p>Suppose in the original code, libc symbols <code>stdout@GLIBC_2.0</code> is used. </p>
<pre><code>#include <stdio.h>
int main() {
FILE* fout = stdout;
fprintf( fout, "hello\n" );
}
</code></pre>
<p>When I compile it and check the symbol address using these commands:</p>
<pre><code>gcc main.c
readelf -s a.out | grep stdout
</code></pre>
<p>I got this:</p>
<pre><code>0804a020 4 OBJECT GLOBAL DEFAULT 25 stdout@GLIBC_2.0 (2)
0804a020 4 OBJECT GLOBAL DEFAULT 25 stdout@@GLIBC_2.0
</code></pre>
<p>and the <code>.bss</code> section is like this:</p>
<pre><code> readelf -S a.out | grep bss
[25] .bss NOBITS 0804a020 001014 00000c 00 WA 0 0 32
</code></pre>
<p>Now what I am trying to do is to load the <code>stdout</code> symbol in a predefined address, so I did this:</p>
<pre><code>echo "stdout = 0x804a024;" > symbolfile
gcc -Wl,--just-symbols=symbolfile main.c
</code></pre>
<p>Then when I check the <code>.bss</code> section and symbol <code>stdout</code>, I got this:</p>
<pre><code> [25] .bss NOBITS 0804a014 001014 000008 00 WA 0 0 4
4: 0804a024 0 NOTYPE GLOBAL DEFAULT ABS stdout
49: 0804a024 0 NOTYPE GLOBAL DEFAULT ABS stdout
</code></pre>
<ol>
<li><p>It seems that I didn't successfully load the symbol <code>stdout@@GLIBC_2.0</code>, but just a wired <code>stdout</code>. (I tried to write <code>stdout@@GLIBC_2.0</code> in <code>symbolfile</code>, but it can't compile... )</p></li>
<li><p>It seems that as I didn't make it, the beginning address of <code>.bss</code> section has also changed, which makes the address of <code>stdout</code> symbol in a non-section area. During runtime, it throws a segmentation fault when loading from <code>0x804a024</code>. </p></li>
</ol>
<p>Could anyone help me on how to successfully load the library symbol at a predefined address? Thanks! </p>
|
How to load library defined symbols to a specified location?
|
|assembly|c|elf|dynamic-linking|
|
<p>old question, but I think I can answer a part of it</p>
<blockquote>
<p>why the name of symbol _ZTTSt14basic_ifstreamIcSt11char_traitsIcEE
modified to _ZTTSt14basic_ifstreamIcS</p>
</blockquote>
<p>I think you've just run into as terminal width limit. By default <code>readelf</code> limits output lines to 80 characters, you neeed to pass <code>-W</code> to disable it:</p>
<pre><code>-W --wide Allow output width to exceed 80 characters
</code></pre>
|
8172
|
2015-02-06T20:43:57.853
|
<p>it's me again. I am working on a tool can that disassemble/reassemble stripped binaries and now I am sucked in a (external) symbol reuse issue.</p>
<p>The test is on 32-bit Linux x86 platform. </p>
<p>Suppose I am working on a C++ program, in the <code>GCC</code> compiler produced assembly code, there exists some instructions like this:</p>
<pre><code>call _ZNSt8ios_baseC2Ev
movl _ZTTSt14basic_ifstreamIcSt11char_traitsIcEE+4, %ebx
movb $0, 312(%esp)
movl _ZTTSt14basic_ifstreamIcSt11char_traitsIcEE+8, %ecx
....
</code></pre>
<p>Please pay special attention to symbol <code>_ZTTSt14basic_ifstreamIcSt11char_traitsIcEE</code>.</p>
<p>After the compilation, suppose I get an <code>unstripped</code> binary, and i checked this symbol like this:</p>
<pre><code>readelf -s a.out | grep "_ZTTSt14basic"
69: 080a7390 16 OBJECT WEAK DEFAULT 27 _ZTTSt14basic_ifstreamIcS@GLIBCXX_3.4 (3)
72: 080a7220 16 OBJECT WEAK DEFAULT 27 _ZTTSt14basic_ofstreamIcS@GLIBCXX_3.4 (3)
705: 080a7220 16 OBJECT WEAK DEFAULT 27 _ZTTSt14basic_ofstreamIcS
1033: 080a7390 16 OBJECT WEAK DEFAULT 27 _ZTTSt14basic_ifstreamIcS
</code></pre>
<p>See, this is my first question, <strong>why the name of symbol <code>_ZTTSt14basic_ifstreamIcSt11char_traitsIcEE</code> modified to <code>_ZTTSt14basic_ifstreamIcS</code> and <code>_ZTTSt14basic_ifstreamIcS@GLIBCXX_3.4 (3)</code> ?</strong> </p>
<p>What is <code>_ZTTSt14basic_ifstreamIcS@GLIBCXX_3.4 (3)</code> though?</p>
<p>Then I stripped the binary like this:</p>
<pre><code>strip a.out
readelf -s a.out | grep "_ZTTSt14basic"
69: 080a7390 16 OBJECT WEAK DEFAULT 27 _ZTTSt14basic_ifstreamIcS@GLIBCXX_3.4 (3)
72: 080a7220 16 OBJECT WEAK DEFAULT 27 _ZTTSt14basic_ofstreamIcS@GLIBCXX_3.4 (3)
</code></pre>
<p>Then after I disassemble the binary, and the corresponding disassembled assembly instructions are :</p>
<pre><code> 8063ee7: e8 84 54 fe ff call 8049370 <_ZNSt8ios_baseC2Ev@plt>
8063eec: 8b 1d 94 73 0a 08 mov 0x80a7394,%ebx
8063ef2: c6 84 24 38 01 00 00 movb $0x0,0x138(%esp)
8063ef9: 00
8063efa: 8b 0d 98 73 0a 08 mov 0x80a7398,%ecx
</code></pre>
<p>At this point we can figure out that 0x80a7394 equals to <code>_ZTTSt14basic_ifstreamIcSt11char_traitsIcEE+4</code>. </p>
<p>In order to reuse these instructions, I modified the code:</p>
<pre><code>call _ZNSt8ios_baseC2Ev
mov _ZTTSt14basic_ifstreamIcS+4,%ebx
movb $0x0,0x138(%esp)
mov _ZTTSt14basic_ifstreamIcS+8,%ecx
</code></pre>
<p>And did some update like these (please see this <a href="https://stackoverflow.com/questions/28355292/how-to-load-library-defined-symbols-to-a-specified-location">question</a> for reference):</p>
<pre><code>echo ""_ZTTSt14basic_ifstreamIcS@GLIBCXX_3.4 (3)" = 0x080a7390;" > symbolfile
g++ -Wl,--just-symbols=symbolfile final.s
readelf -s a.out | grep "_ZTTSt14basic"
3001: 080a7390 0 NOTYPE LOCAL DEFAULT 27 _ZTTSt14basic_ifstreamIcS
8412: 080a7390 0 NOTYPE GLOBAL DEFAULT ABS _ZTTSt14basic_ifstreamIcS
</code></pre>
<p>I debugged the newly produced binary, and to my surprise, in the newly produced binary, symbol <code>_ZTTSt14basic_ifstreamIcS</code> does not get any value after the function call of <code>_ZNSt8ios_baseC2Ev</code>, while in the original binary, after the function call, <code>_ZTTSt14basic_ifstreamIcS</code> do get some memory address referring to library section. Which means:</p>
<pre><code>call _ZNSt8ios_baseC2Ev
mov _ZTTSt14basic_ifstreamIcS+4,%ebx <--- %ebx gets zero!
movb $0x0,0x138(%esp)
mov _ZTTSt14basic_ifstreamIcS+8,%ecx <--- %ecx gets zero!
</code></pre>
<p>I must state that in these lines of the original binary, registers %ebx and %ecx both gets some addresses referring to the libc section. </p>
<p>This is my second question, why does symbol <code>_ZTTSt14basic_ifstreamIcS</code> didn't get any value after function call <code>_ZNSt8ios_baseC2Ev</code>? I also tried with symbol name <code>_ZTTSt14basic_ifstreamIcSt11char_traitsIcEE</code>. But that does not work also.</p>
<p>Am I clear enough? Could anyone save my ass? thank you!</p>
|
Reuse symbols in disassembling/reassembling a C++ program
|
|disassembly|assembly|elf|symbols|reassembly|
|
<blockquote>
<p>file_offset= address - segment.address + segment.offset + fat_arch.offset</p>
</blockquote>
<p>If does not contain <code>Fat headers</code> then <code>fat_arch.offset = 0</code></p>
<p>Check if fat: <code>otool -fh</code> or <code>lipo -detailed_info</code></p>
<pre><code>Architectures in the fat file: MyBinary are: x86_64 arm64
Fat headers
fat_magic 0xcafebabe
nfat_arch 2
architecture 0
...
offset 16384 <== fat_arch.offset for x86_64
size 58720
architecture 1
...
offset 81920 <== fat_arch.offset for arm64
size 73072
</code></pre>
<p>Assume we need x86_64 offset for 0000000100001921</p>
<pre><code>$ otool -tVj -arch x86_64 -function_offsets MyBinary | head -3
+0 0000000100001920 55 pushq %rbp
=> +1 0000000100001921 4889e5 movq %rsp, %rbp
+4 0000000100001924 53 pushq %rbx
</code></pre>
<p>then</p>
<pre><code>$ otool -l -arch x86_64 MyBinary | grep __text -A 5
sectname __text
segname __TEXT
addr 0x0000000100001920 <== segment.address
size 0x000000000000160a
offset 6432 <== segment.offset
align 2^4 (16)
</code></pre>
<blockquote>
<p>$ printf '0x%x\n' $(( 0x0000000100001921 - 0x0000000100001920 + 6432 + 16384 ))</p>
</blockquote>
<p><code>0x5921</code></p>
<pre><code>$ xxd -s 0x5921 -l 32 -c 16 MyBinary
=> 00005921: 4889 e553 5048 8b3d 5b2d 0000 e8ca 1600 H..SPH.=[-......
00005931: 0048 8b35 ff2c 0000 4889 c7e8 6116 0000 .H.5.,..H...a...
</code></pre>
|
8177
|
2015-02-07T18:06:30.313
|
<p>this maybe total no brainer but i'm really new to this and i'd really appreciate some help!</p>
<p>Basically i'm trying to patch(out aka nop) a obj-c function inside an iOS Application. I've successfully decrypted it and i'm able to disassemble it with otool. Needless to say the original application was stripped so no structure in the disassembly. </p>
<p>I then heard about <code>class-dump-z</code> which is modified version of class dump with the ability to give you the VM Address of a given Function Implementation.</p>
<p>Output of <code>class-dump-z -A</code>:</p>
<pre><code>#import <XXUnknownSuperclass.h> // Unknown library
#import "SomeHeader.h"
@class NSString;
__attribute__((visibility("hidden")))
@interface CensoredClassName : XXUnknownSuperclass <SomeDelegate> {
}
@property(readonly, copy) NSString* debugDescription;
@property(readonly, copy) NSString* description;
@property(readonly, assign) Class superclass;
@property(readonly, assign) unsigned hash;
-(void)showJailbreakAlert; // 0x1498d <--Patch this Method
@end
</code></pre>
<p>My Question: How to translate the given Implementation VM Address to binary File Offset which I can patch?
Or even better how can i find the Method in the TEXT Disassembly? Simply Searching for the offset inside the disassembly generated with the <code>otool -tV</code> command does not return any result.</p>
<p>Thank you very much in Advance</p>
<p>Malte</p>
<p>P.S. Link to Class-Dump-Z Google code Page:<a href="https://code.google.com/p/networkpx/wiki/class_dump_z""" rel="nofollow">here</a></p>
|
Convert Mach-O VM Address To File Offset
|
|disassembly|ios|patching|
|
<p>If you want a patch tool you dont need to code it. Use dUP (diablo2oo2 Universal Patcher) or R!SC Process Patcher to easily create a .exe that patches your defined offsets with your defined values.</p>
|
8178
|
2015-02-07T22:30:55.803
|
<p>In Olly I managed to patch the file to no longer compare for a specific flag. Is it possible to automate this?</p>
<p>Basically I changed a JNZ to a JZ.</p>
<p>Is there a way to could do the same thing with a hex editor? </p>
<p>The end goal would be to create a program to automate this patch.</p>
<p>Thanks.</p>
|
OllyDBG, managed to patch file, now can I automate this?
|
|ollydbg|
|
<p>For various reasons, it is generally not possible to decompile a non-trivial program to the point where it can be correctly recompiled. Among other things, there's a lot of things you can do in bytecode that don't correspond to Java language features, and even in the ideal case, it is hard to restructure certain complex code. </p>
<p>Decompilation is useful for understanding code, but if you want to edit it, you need to learn how to patch things at the bytecode level. The easiest way to do this for APKs is using baksmali. </p>
<p>Running baksmali gives you a directory with a smali file for each class in the dex file. You can then edit the smali to make the changes you want, and run smali to reassemble everything into a new dex file. Then of course you have to add your <code>classes.dex</code> back into the apk, then sign and format it.</p>
|
8181
|
2015-02-08T00:43:04.580
|
<p>Ive a problem.
I am unable to decompile a game apk successfully. I am using apktool.
I get many errors and but i get thw files. But then many of its smali files doesnt have a .end method in its code which makes a recompile impossible.</p>
<p>Can someone help me or decompile it?</p>
<p>Its this file <a href="https://www.dropbox.com/s/05kj2x4zie734b9/com.asobimo.iruna_en-1.apk?dl=0" rel="nofollow">https://www.dropbox.com/s/05kj2x4zie734b9/com.asobimo.iruna_en-1.apk?dl=0</a></p>
<p>Thanks in advance </p>
<p>//Edit: I figured out why it didnt work as I wanted to. The game has some kind of protection in apk since this year. So I used an older version of apk from 2014, and edited its files and set its version to actual version with APK Edit v0.4. Then save new apk and im fine =)
Thanks though for you help</p>
|
Error decompiling apk
|
|decompile|apk|
|
<h1>Yes, it is possible</h1>
<p>I'm going to explain you a bit how most games do it (I have never reversed any GTA but I suppose it's something like this anyway).</p>
<p>I'm going to cover static and dynamic allocation of structures.</p>
<hr>
<p><strong>The static way:</strong></p>
<pre><code>GlobalGameInfo g_info;
// ...
g_info.some_data = 1;
</code></pre>
<p>This is what ends up being a static offset in IDA, like so:</p>
<pre><code>lea eax, [g_info + 0xAABB] ; suppose 0xAABB is the offset for 'some_data'
mov [eax], 1;
</code></pre>
<p><code>g_info</code> is always going to stay at the same offset, so once you find it, you can just use <code>g_info + offset</code> to get your data.</p>
<p><strong>The dynamic way:</strong></p>
<pre><code>Player* players; // can be defined as Player* players[<count>] or Player** players;
// it's the same
// ...
players = new Player[players_count];
// ...
players[1].alive = false;
</code></pre>
<p>Which then results in:</p>
<pre><code>; this is a static location which is actually the "players" variable
; and it contains an address which points to the offset in memory of the
; actual players structure
dword_xxxx dd ?
</code></pre>
<p>So to use it in e.g. Cheat Engine, you <code>Add a new address</code>, check <code>Pointer</code>, add the <code>xxxx</code> part of <code>dword_xxxx</code>, and in offset, put your desired offset.
For example, to get <code>players[1].alive</code>, with <code>alive</code> being on offset e.g. 0x100, you'd calculate:</p>
<pre><code>value_stored_in_dword_xxxx + sizeof(Player) * player_id + 0x100
</code></pre>
<p>So if <code>dword_xxxx</code> -> <code>0xAABBCCDD</code>, <code>sizeof(Player)</code> -> <code>0x204</code>, <code>player_id</code> -> <code>8</code>, and <code>offset</code> -> <code>0x100</code>, your calculation would be:</p>
<pre><code>0xAABBCCDD + (0x204 * 8) + 0x100
// ^base ^size ^id ^offset
</code></pre>
<hr>
<h2>The example</h2>
<p>Since you gave us <code>mov [esi + 0x2F], dl</code>:</p>
<ul>
<li><code>esi</code> is a pointer to the structure. Look above (in the disassembly).
<ul>
<li><code>mov esi, dword ptr [dword_xxxx]</code> (most probably) means it's dereferencing a pointer, which means that the structure is allocated dynamically.</li>
<li><code>mov esi, offset dword_xxxx</code> (most probably) means that it's just assigning the address (<code>xxxx</code> part) to <code>esi</code>, so this is a static address.</li>
</ul></li>
</ul>
<hr>
<h2>The usage</h2>
<p><strong>Cheat Engine</strong></p>
<p>In Cheat Engine, it's easy as inputting the pointer and the offset:</p>
<p><img src="https://i.stack.imgur.com/gFBPU.png" alt="Cheat Engine"></p>
<p>As you can see, <code>0x5CCB138</code> is the <code>dword_xxxx</code>, the value inside <code>dword_xxxx</code> is <code>0x09021A00</code>, and that + <code>0x142</code> (my offset) results in the start of the in-game name.</p>
<p><strong>C</strong></p>
<p>In case you want to do it programmatically, you can do it like this in C:</p>
<pre><code>PCHAR my_name = PCHAR (*PDWORD(0x5CCB138) + 0x142);
^save the addr| | ^deref to get | add the offset
| ^cast | 0x09021A00 |
// -> be careful, do not surpass the max length!
// -> also remember that there's 'your name' length + 1 \x00 byte
// at the end!
char new_name[] = "newName";
strncpy(my_name, new_name, sizeof(new_name)); // again: be careful with the length!
</code></pre>
<p>The proper way, however, would be reversing the entire struct like this:</p>
<pre><code>struct player_data {
int ID;
char name[15];
int some_data;
...;
};
// make sure the order / size of each item is correct!
// a single error can fuck up the entire struct
// I'm going to assume you understand pointers
player_data* data = *(player_data**) 0x5CCB138;
// do your changes
// again, be careful with the length!
// also note that sizeof() will not work if you use char*
char new_name[] = "new name!";
strncpy(data->name, new_name, sizeof(new_name));
</code></pre>
|
8186
|
2015-02-09T11:45:13.567
|
<p>I found an assembler instruction: <code>mov [esi+2F],dl</code>. I think ESI is a reference to a struct or class. <code>0x2F</code> is the offset that references a property of the struct/class. Is it possible to find the value of the ESI register? I think this class or struct is initialized when the game is started.</p>
<p>For example, I tried to reverse GTA San Andreas. A lot of memory addresses of the GTA SA <a href="http://www.gtamodding.com/?title=Memory_Addresses_%28SA%29" rel="nofollow">here</a>.</p>
<p>I've found such information in this site: 0xB6F5F0 - Player pointer (CPed).</p>
<p>I think it's address that I finding now. But how I can find it with debugger like cheat-engine without pointer scan? I'd like to find addresses in asm code. It's possible?</p>
<p>I tried to set a breakpoint to the instruction. But I think it's useless because ESI address is dynamic. As I understand CPed struct/class uses dynamic memory allocation.</p>
<p>I am sorry for my bad English and thanks in advance.</p>
|
Is it possible to find static pointer with disassembler?
|
|disassembly|debuggers|pointer|
|
<p>Your broken addresses seem to be exactly 0x80000 plus the intended address.</p>
<p>There's two possibilities:</p>
<ul>
<li>Your binary is intended to be loaded at <code>0x80000</code>, but you're loading it to <code>0x00000</code>.</li>
<li>The hardware doesn't decode more than 19 address bits, so <code>0xa5c1e</code> maps to <code>0x25c1e</code> on the address bus, and the software uses address bit 19 as a kind of flag.</li>
</ul>
|
8192
|
2015-02-10T03:35:40.703
|
<p>Upon performing a disassembly of a binary, I noticed that many of the subroutines have the wrong offset for the address. It seems that the byte preceding the 2 byte address is wrong. For example, in the screenshot below, the disassembly indicates the functions should be at 0xA5C1E and 0xA5BCA. I've double checked the raw hex dump and confirmed that there is an "A" byte before the 2 byte address. It's also interesting to note that addresses which start with "A" are impossible in this binary since it's only 0x7FFFF in length. Based on experience from other binaries, I know the true addresses for these functions should be 0x25C1E and 0x25BCA, respectively. I can also confirm that I have subroutines which start at these locations.</p>
<p><img src="https://i.stack.imgur.com/nIPuj.png" alt="enter image description here"></p>
<p>I've disassembled other binaries (different application, same processor) and this problem didn't appear. However, every binary I've disassembled from this application shows this problem.</p>
<p>Is there a way to correct this in IDA Pro? Does it have anything to do with my DPP register values?</p>
|
Correcting subroutine offset in IDA Pro
|
|ida|
|
<p><strong>Answering Your Question Directly</strong>: </p>
<p>You can reverse Kernal Extensions with IDA Pro, Radare2, GDB or whatever dissasembler you would like. Yes, you will have to learn what C++ structures look like once disassembled. I can't answer the "static analysis or dynamic analysis?" question directly, since often the answer is "both, depending on exactly what you want." Some Reverse Engineers start with the static, and some start with the dynamic. </p>
<p>I <em>personally</em> would start with a static analysis tool because: </p>
<ul>
<li>I imagine the driver is rather large. If you don't know what you are looking for, you could spend a long, long time single stepping. </li>
<li>You will get more out of this by searching over and analyzing specific function calls in the driver. Their use will most likely be self evident in the driver once you see their relation to other functions</li>
<li>There isn't an element of obfuscation here. Nor do you need to check the <em>exact</em> position of anything in memory. </li>
<li>You are trying to rewrite a driver from this anyway, seeing things in a format that resembles source code will help that process. </li>
</ul>
<p>But to each his own. Given enough time I would go through both processes just for the sake of knowing. Also, to pull this off correctly, you will need to learn a little about Macintosh system programming. </p>
<p>There is a class at recon on this subject this year: <a href="http://www.recon.cx/2015/trainingosx.html" rel="noreferrer">http://www.recon.cx/2015/trainingosx.html</a> (once the white paper is published, it should be linked in this answer) </p>
<p>Here is a snippet from a book on kernal exploitation that takes you through the basics of reversing a kext with IDA pro: </p>
<p><a href="https://books.google.com/books?id=G6Zeh_XSOqUC&pg=PA215&lpg=PA215&dq=IDA+pro+kernel+extension+mac&source=bl&ots=0y3XXMAgqH&sig=6HkJnGKmW7OugZiHo42DwOYtaY8&hl=en&sa=X&ei=93nbVIe_BYWVyQT4z4HgDw&ved=0CEIQ6AEwBQ#v=onepage&q=IDA%20pro%20kernel%20extension%20mac&f=false" rel="noreferrer">https://books.google.com/books?id=G6Zeh_XSOqUC&pg=PA215&lpg=PA215&dq=IDA+pro+kernel+extension+mac&source=bl&ots=0y3XXMAgqH&sig=6HkJnGKmW7OugZiHo42DwOYtaY8&hl=en&sa=X&ei=93nbVIe_BYWVyQT4z4HgDw&ved=0CEIQ6AEwBQ#v=onepage&q=IDA%20pro%20kernel%20extension%20mac&f=false</a></p>
<p><strong>Regarding this particular camera:</strong> </p>
<p>It seems that the camera in question is referenced in the conversation found here: <a href="https://bugzilla.kernel.org/show_bug.cgi?id=71131" rel="noreferrer">https://bugzilla.kernel.org/show_bug.cgi?id=71131</a></p>
<p>Essentially, this camera speaks over <em>PCI</em> because it does not compress its video before being sent to the system. The thread states that there is already a project underway to make a driver for the camera, which can be found at <a href="https://github.com/patjak/bcwc_pcie" rel="noreferrer">https://github.com/patjak/bcwc_pcie</a></p>
<p>The wiki on this site is informative, and lists some of the issues with reverse engineering this sort of driver. The wiki page found at: <a href="https://github.com/patjak/bcwc_pcie/wiki/Mac-OS-X-driver" rel="noreferrer">https://github.com/patjak/bcwc_pcie/wiki/Mac-OS-X-driver</a> gives some great ideas for where you should be starting on the mac side of things. </p>
<p>Based on their to do list, you might want to focus on helping rip the device firmware from the device itself. </p>
<p><strong>Regarding developing your own driver:</strong> </p>
<p>I would start from a different direction, and reverse engineer the camera itself. Depending on the complexity of your camera, you may be able to speak to it directly without a driver over serial. You might also be able to open up the camera, and speak to it directly via a debug port (think JTAG, or even simpler.) </p>
<p>The first time I read your question, I thought you meant a small camera outside your computer, but I am guessing you mean a camera built into your laptop. I think in that case, you could just adapt a driver from an existing webcam, and see where it dies. I believe these cameras are fairly generic bits of hardware at this point. </p>
<p>Most webcam's on Linux use this driver: <a href="https://help.ubuntu.com/community/UVC" rel="noreferrer">https://help.ubuntu.com/community/UVC</a>, and potentially you can just run this driver and see where it dies/can't communicate with the camera. At any rate, watching the actual communications with the camera will give you a much better idea of what you need to do. </p>
<p><strong>Regarding the Utility of reversing a Macintosh Kernal extension:</strong></p>
<p>I would be less worried about the c++/C difference versus differences in system libaries, and the system call interface. It certainly wouldn't hurt to analyze the driver for your own edification, but you may find that it gets most of its work done by calling mac system libraries that don't work the same way in linux. You will be most interested in reading the parts of the driver that define the communication with the camera. At any rate, you wont be able to directly convert the KeXT into a Linux Kernal Module. </p>
<p><strong>My Final Advice:</strong></p>
<p>Instead, if your current webcam isn't working with your linux distro, I would first confirm that you have the proper generic driver, and then edit the generic driver to support your camera. You can do a pull request on the generic driver. </p>
<p>In most cases the communications with these cameras are very simple serial communications. I suspect that triggering an error from the generic driver will be faster than trying to decipher the mac driver. </p>
|
8195
|
2015-02-10T17:05:51.740
|
<p>I recently discovered there is no native Linux driver for the Web Cam in my computer. However, there is a person who has taking the initiative to start a <a href="https://github.com/patjak/bcwc_pcie" rel="nofollow">github project</a> for a driver. That being said, I was able to get the web cam working in a qemu guest OS running OS X (10.10), and now I'm at the point where I would like to start to analyze the .kext is question.</p>
<p>A quick google search revealed <a href="https://inficererk.wordpress.com/2014/01/30/debugging-kext-with-vmware-gdb-osx-10-8-4/" rel="nofollow">this</a>, but I am not sure if this method would still apply to OS X (10.10).</p>
<p>Should I try to debug the .kext on a running system, or should I just copy the .kext to my host OS (Linux) and start analyzing in a disassembler such as Hopper / Radare2?</p>
<p>Also I should note, from what I understand, most OS X kernel extensions are written in C++ while most if not all Linux drivers are written in C. So would I be wasting my time reversing / analyzing this .kext? Any help on this subject matter would be greatly appreciated.</p>
|
What are some methods to reversing a .kext?
|
|osx|
|
<p>So it turns out you can do this in the following way, from within GDB Python. The trick is <code>from_tty=False</code>.</p>
<pre><code>foo = open('foo.cc','w+')
foo.write('struct foobar { int x; }; foobar foo;')
foo.close()
subprocess.check_output('g++ -w -c -g foo.cc -o foo.o', shell=True)
gdb.execute('add-symbol-file foo.o 0', from_tty=False, to_string=True)
</code></pre>
<p>You should now be able to view the type in gdb:</p>
<pre><code>gdb $ ptype foobar
type = struct foobar {
int x;
}
</code></pre>
|
8197
|
2015-02-10T21:51:50.840
|
<p>GDB has a reasonably robust API which is exposed to Python at runtime. It allows for inspecting various types, but does not appear to allow creation of types.</p>
<p>However, types can be manually added by loading an object file at runtime (<a href="https://stackoverflow.com/q/7272558">https://stackoverflow.com/q/7272558</a>).</p>
<p>Is there any way to add or create a new <code>gdb.Type</code> object at runtime?</p>
<p>The intent is to then allow inspection of memory via <code>gdb.Value.cast</code> to the <code>type.pointer()</code> and then <code>.dereference()</code>d. This would be much better/easier than manually deserializing data field-by-field.</p>
<p>Alternatively, I thought that I could just load an object file programmatically. It looks like GDB is perfectly happy to load cross-architecture object files for symbol/type purposes. In order to not kill any real/useful symbols, or create misleading ones, a non-existent address should be used. However, loading a <code>.o</code> at an unmapped address requires the user to verify (type <code>y</code>), so when done from <code>gdb.execute(...)</code> it fails outright.</p>
|
Adding Types to GDB via Python
|
|gdb|python|
|
<p>This is a common task when looking at binaries with statically linked code. The static code varies in register assignment, relative pointer addressing to external object code and other details but is mostly identical across binaries.</p>
<p>IDA uses the FLIRT system to solve this problem.
<a href="https://www.hex-rays.com/products/ida/tech/flirt/in_depth.shtml" rel="nofollow">https://www.hex-rays.com/products/ida/tech/flirt/in_depth.shtml</a></p>
<p>Basically it filters those bits that vary across linker executions and matches the remaining pattern against a list. For very short functions there are many collisions, but for functions longer than ~30 bytes or so it's very good at identifying what you're looking at.</p>
<p>If you're using IDA then it comes with the tools to create your own FLIRT signatures. If you're not using IDA then you would have to make a tool to pull apart your particular static libraries, disassemble the first opcodes, filter the variable bits (this is tricky), and create a database to link names to patterns. You could apply the patterns as appropriate: borland libraries for borland program, MS runtime for visual studio, etc.</p>
|
8198
|
2015-02-11T00:28:29.120
|
<p>As we know, time is the bane of reverse engineering. I am wanting to know how are some ways that I can save time in reverse engineering? I have taken some thought and I have been going through many programs and finding that even if the program is considerably different I am able to find up to 255+ identical garbage/redundant functions. I was thinking this morning if there was a way to somehow fingerprint these, that it would save me a considerable amount of time.</p>
<p>In short, I would like to know:<br>
Has anyone tried to fingerprint or make a database of these redundant functions?</p>
<p>Also, what are some other ways that I can save time in my reversal process?</p>
|
Save Valuable Time Reverse Engineering
|
|functions|
|
<p>Did you remember to reload your program after <code>set write on</code> ?</p>
<p>And did you load your (writable) copy of the original program (as opposed to the professor's copy in a shared location that everyone has read access to, but noone can write) ?</p>
<p>Actually, i've never used gdb to patch files directly, i normally use a hex editor.</p>
<p>If you don't have a hex editor on your system, maybe you have <code>xxd</code>, which allows you to turn a binary into a hex dump and vice versa.</p>
<p>If all else fails, you can still do something like</p>
<pre><code>echo 'X' | dd of=binary.file bs=1 seek=12345 count=1
</code></pre>
<p>to patch the byte at offset 12345 in your file to an X. This method has the advantage that it doesn't depend on any gnu utilities, so it works on most variants of unix.</p>
|
8200
|
2015-02-11T04:33:04.480
|
<p>I'm working on an assignment for a systems programming class, and for extra credit we are asked to modify an executable to allow it to accept the reverse of our PIN (finding the PIN was the original assignment). I was able to use GDB to change the memory values being stored for the PIN to the reverse, and when I run the program it works as intended. The only issue is that I can't save these changes to the executable. Once I exit the debugger it reverts to normal. I've tried using "set write on" and "gdb -write " before making changes, but the changes still wouldn't stick. Does anyone know if what I'm tyring to do is even possible, or where I might be going wrong?</p>
|
Using GDB to modify an executable
|
|x86|gdb|
|
<p>I found a <a href="https://zairon.wordpress.com/2015/02/17/ctb-locker-encryptiondecryption-scheme-in-details/" rel="nofollow">full analysis of the cipher algorithm of CTB-Locker</a> performed by <a href="https://zairon.wordpress.com/" rel="nofollow">Zairon</a>. </p>
<p>He's not really optimistic about the possibility to cryptanalyse the files as the first paragraph of the blog post is the following:</p>
<blockquote>
<p>After my last post about CTB-Locker I received a lot of e-mails from people asking for a complete analysis of the malware. Most of them wanted to know if it’s possible to restore the compromised files without paying the ransom. The answer is simple: it’s impossible without knowing the Master key! That key resides on the malicious server and it’s the only way to restore every single compromised file.</p>
</blockquote>
<p>And, follow a full analysis of the encryption scheme of CTB-Locker. A good reading for anybody wants to know more about it !</p>
<ul>
<li><a href="https://zairon.wordpress.com/2015/02/17/ctb-locker-encryptiondecryption-scheme-in-details/" rel="nofollow">CTB-Locker encryption/decryption scheme in details</a>, by Zairon, February 17, 2015.</li>
</ul>
|
8202
|
2015-02-11T13:57:53.307
|
<p>CTB-Locker is a currently active ransomware that encrypts files to lock users out.</p>
<p>Here are a few links about this malware:</p>
<ul>
<li><a href="http://securelist.com/analysis/publications/64608/a-new-generation-of-ransomware/" rel="nofollow">A new generation of ransomware: Elliptic curve cryptography + Tor + Bitcoin</a>, by Fedor Sinitsyn, July 24, 2014.</li>
<li><a href="http://www.eset.com/int/about/press/eset-blog/article/ctb-locker-ransomware-striking-in-europe-and-latin-america/" rel="nofollow">CTB-Locker: Multilingual Malware Demands Ransom</a>, by Pablo Ramos, January 21, 2015.</li>
<li><a href="http://blog.trendmicro.com/trendlabs-security-intelligence/ctb-locker-ransomware-includes-freemium-feature-extends-deadline/" rel="nofollow">CTB-Locker Ransomware Includes Freemium Feature, Extends Deadline</a>, by Trend Micro, January 21, 2015.</li>
<li><a href="http://www.bleepingcomputer.com/virus-removal/ctb-locker-ransomware-information" rel="nofollow">CTB Locker and Critroni Ransomware Information Guide and FAQ</a>, by Lawrence Abrams, January 29, 2015.</li>
<li><a href="https://zairon.wordpress.com/2015/02/09/ctb-locker-files-decryption-demonstration-feature/" rel="nofollow">CTB-Locker: files decryption demonstration feature</a>, by Zairon, February 9, 2015.</li>
<li><a href="http://christophe.rieunier.name/securite/CTB-Locker/CTB-Locker_analysis_en.php" rel="nofollow">CTB-Locker dropper</a>, by Christophe Rieunier.</li>
<li><a href="https://www.decryptcryptolocker.com/" rel="nofollow">decryptcryptolocker.com</a>, by FireEye and Fox IT (doesn't seems to work for CTB-Locker).</li>
<li><a href="http://en.wikipedia.org/wiki/CryptoLocker" rel="nofollow">CryptoLocker</a>, Wikipedia (a similar Ransomware).</li>
</ul>
<p>Is there a complete analysis about the encryption used by CTB-Locker, and some hints about possible cryptanalysis based on some weaknesses of this cryptographic scheme that can be used to recover the encrypted files.</p>
<p>The idea would be to produce a (free) tool similar to <a href="https://www.decryptcryptolocker.com/" rel="nofollow">decryptcryptolocker.com</a>, that can perform the decryption for users.</p>
|
Where to find a full analysis of the encryption scheme of CTB-Locker?
|
|tools|malware|cryptanalysis|ransomware|
|
<blockquote>
<p>So the space between esp and var1 is going to be free without any use
? that's what I want to know.</p>
</blockquote>
<p>That stack space is used for the function's local variables (also known as "stack variables").</p>
<p>Here's a nice animated GIF that shows a function's stack frame being created and used to store local variables:</p>
<p><img src="https://i.stack.imgur.com/pvEF3.gif" alt="GIF"></p>
|
8206
|
2015-02-11T19:22:47.137
|
<p>I've disassembled some C/C++ codes and realized the stack boundary is specified at beginning of a procedure, somehow like this :</p>
<pre><code>1. push ebp
2. mov ebp , esp
3. sub esp , <power> ; <power> is specified by mpreferred-stack-boundary=2^power
</code></pre>
<p>The above code is used to create stack frames, But What I need to know is why this subtract is used, Cause the stack grows down (by using push for local variables) and such the subtract causes :</p>
<pre><code>---------------------------- ^
by sub esp,<power> <---- esp |
. |
. |
. |
---------------------------- |
esp <---- esp |
---------------------------- |
ret address |
---------------------------- |
</code></pre>
<p>The above picture shows that.So when in the rest of code if you have such the following codes:</p>
<pre><code>push var1
</code></pre>
<p>It should be taken at the top of it so it looks like this :</p>
<pre><code>-----------------------------
var1 (4 byte)
-----------------------------^
by sub esp,<power> <---- esp |
. |
. |
. |
---------------------------- |
esp <---- esp |
---------------------------- |
ret address |
---------------------------- |
</code></pre>
<p>So the space between esp and var1 is going to be free without any use ?
that's what I want to know.</p>
|
Stack frame boundary
|
|memory|stack-variables|
|
<p>OK... it seems to be LZVN compression. Following on from Igor's suggestions I ran <code>kextstat</code> on my Mac, however that only listed:</p>
<ul>
<li><code>com.apple.AppleFSCompression.AppleFSCompressionTypeZlib</code></li>
<li><code>com.apple.AppleFSCompression.AppleFSCompressionTypeDataless</code> </li>
</ul>
<p>Looking at the strings inside the 'dataless' compression it turned out to be type 5: <a href="https://github.com/dimones/Clevo-W370ET-Mavericks/blob/master/Extensions/AppleFSCompressionTypeDataless.kext/Contents/Info.plist#L53" rel="nofollow">AppleFSCompressionTypeDataless.kext</a>. Searching for the same string with type 8, I found this log:</p>
<pre><code>com_apple_AppleFSCompression_AppleFSCompressionTypeLZVN <class com_apple_AppleFSCompression_AppleFSCompressionTypeLZVN, id 0x10000025d, !registered, !matched, active, busy 0, retain 4>
| {
| "IOProbeScore" = 0x0
| "CFBundleIdentifier" = "com.apple.AppleFSCompression.AppleFSCompressionTypeLZVN"
| "IOMatchCategory" = "com_apple_AppleFSCompression_AppleFSCompressionTypeLZVN"
| "IOClass" = "com_apple_AppleFSCompression_AppleFSCompressionTypeLZVN"
| "IOProviderClass" = "IOResources"
| "com.apple.AppleFSCompression.providesType10" = Yes
| "com.apple.AppleFSCompression.providesType9" = Yes
| "com.apple.AppleFSCompression.providesType8" = Yes
| "IOResourceMatch" = "IOBSD"
| "com.apple.AppleFSCompression.providesType7" = Yes
| }
</code></pre>
<p>Which seems to be something the Chameleon guys already worked out: <a href="http://forge.voodooprojects.org/p/chameleon/source/tree/HEAD/trunk/CHANGES#L27" rel="nofollow">trunk/CHANGES</a></p>
<p><strong>Edit:</strong> Apple has just released an open source implementation: <a href="https://github.com/lzfse/lzfse" rel="nofollow">https://github.com/lzfse/lzfse</a></p>
|
8209
|
2015-02-12T03:48:52.483
|
<p>I'm trying to decompress a Mach-O binary which has been compressed using one of the compression algorithms in Mac 10.10's HFS+ implementation. Basically the file has the "com.apple.decmpfs" attribute on it, which says that it is compression type 8. Then the compressed contents of the file are stored in the file's resource fork.</p>
<p>It doesn't seem to have any identifiable header on it. Does anyone recognize it, or have any ideas what it might be? Below is a dump of the first 0x200 bytes of the compressed version of <code>/bin/bash</code>, and the first 0x200 bytes of the same file as viewed under Mac OS.</p>
<p>The Mach-O header (<code>CF FA ED FE</code>) and some executable's strings (e.g. <code>__PAGEZERO</code>) can be seem in the compressed version.</p>
<h3>Compressed (first 0x200 bytes of <code>/bin/bash</code>):</h3>
<pre><code>Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 E0 01 CF FA ED FE 07 00 00 01 03 00 00 80 02 00 à.Ïúíþ.......€..
00000010 00 00 12 00 04 E8 E8 06 00 00 85 00 20 00 08 01 .....èè...…. ...
00000020 40 04 19 46 48 EB 5F 5F 50 41 47 45 5A 45 52 4F @..FHë__PAGEZERO
00000030 00 38 01 F7 9E 01 00 F0 0C 08 48 8E 28 02 E5 54 .8.÷ž..ð..HŽ(.åT
00000040 45 58 54 00 38 01 F3 10 40 9E 60 08 F8 20 10 46 EXT.8.ó.@ž`.ø .F
00000050 07 46 05 48 0D 06 10 88 E5 74 65 78 74 00 30 01 .F.H...ˆåtext.0.
00000060 38 50 F6 9E EC 0B C8 10 5F 1C 07 F5 50 0A 02 20 8Pöžì.È._..õP..
00000070 01 E4 04 00 80 00 FA F1 E8 5F 5F 73 74 75 62 73 .ä..€.úñè__stubs
00000080 00 F8 38 50 F6 CE 4C 28 07 F1 CE 62 04 00 F1 28 .ø8PöÎL(.ñÎb..ñ(
00000090 10 28 01 60 50 08 6E 06 F5 E7 5F 68 65 6C 70 65 .(.`P.n.õç_helpe
000000A0 72 FA F9 9E B0 2C 9E 5E 07 08 10 38 A0 F0 04 E7 rúùž°,ž^...8 ð.ç
000000B0 63 73 74 72 69 6E 67 FA FD 9E 0E 34 9E 61 F8 08 cstringúýž.4žaø.
000000C0 10 38 01 F2 38 5C F3 18 50 C9 41 6F 6E 73 F6 38 .8.ò8\ó.PÉAonsö8
000000D0 50 F6 CE 70 2C 08 F1 9E F0 21 08 10 20 FB 38 01 PöÎp,.ñžð!.. û8.
000000E0 FB ED 5F 5F 75 6E 77 69 6E 64 5F 69 6E 66 6F 38 ûí__unwind_info8
000000F0 50 F9 9E 60 4E 9E 94 11 08 10 38 94 F6 38 01 F2 Pùž`Nž”...8”ö8.ò
00000100 0A 28 56 78 E4 44 41 54 41 FA F1 58 48 60 9E 00 .(VxäDATAúñXH`ž.
00000110 E0 32 30 5E B0 08 F6 60 08 03 08 01 E4 5F 5F 67 à20^°.ö`....ä__g
00000120 6F 3A 27 F1 38 50 FF 9E 38 01 F4 58 0A 03 10 01 o:'ñ8Pÿž8.ôX....
00000130 09 D0 98 01 BB 00 F4 EF 5F 5F 6E 6C 5F 73 79 6D .И.».ôï__nl_sym
00000140 62 6F 6C 5F 70 74 72 38 50 F7 9E 38 61 9E 10 00 bol_ptr8P÷ž8až..
00000150 08 10 38 50 F6 6E E2 F5 9E 6C 61 F0 06 66 48 9E ..8Pönâõžlað.fHž
00000160 D8 05 6E 48 F7 08 E8 98 01 E4 00 F4 39 D8 F8 38 Ø.nH÷.è˜.ä.ô9Øø8
00000170 50 F4 9E 20 67 9E 88 26 08 10 39 D8 F0 04 E5 64 Pôž gžˆ&..9Øð.åd
00000180 61 74 61 00 30 01 38 50 F6 9E B0 8D 9E 04 79 08 ata.0.8Pöž°.ž.y.
00000190 10 38 50 F0 04 E6 63 6F 6D 6D 6F 6E FA FE CE C0 .8Pð.æcommonúþÎÀ
000001A0 06 09 F1 C8 01 68 0E 00 F5 38 50 F2 6E 01 F9 9B ..ñÈ.h..õ8Pòn.ù›
000001B0 B6 62 73 F4 38 50 F8 9E 30 15 9E 10 21 F0 10 3C ¶bsô8Pøž0.ž.!ð.<
000001C0 E8 E7 4C 49 4E 4B 45 44 49 2A C4 58 48 40 9E 00 èçLINKEDI*ÄXH@ž.
000001D0 A0 F1 90 07 10 09 96 A0 87 11 88 38 4C F2 45 48 ñ....– ‡.ˆ8LòEH
000001E0 22 48 09 30 00 28 41 B1 50 C8 3B 50 13 09 F5 08 "H.0.(A±PÈ;P..õ.
000001F0 01 40 10 F0 EA 08 0C 00 00 F8 1F 09 00 F8 33 1B .@.ðê....ø...ø3.
</code></pre>
<h3>Uncompressed (first 0x200 bytes of <code>/bin/bash</code>):</h3>
<pre><code>Offset(h) 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F
00000000 CF FA ED FE 07 00 00 01 03 00 00 80 02 00 00 00 Ïúíþ.......€....
00000010 12 00 00 00 E8 06 00 00 85 00 20 00 00 00 00 00 ....è...…. .....
00000020 19 00 00 00 48 00 00 00 5F 5F 50 41 47 45 5A 45 ....H...__PAGEZE
00000030 52 4F 00 00 00 00 00 00 00 00 00 00 00 00 00 00 RO..............
00000040 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 ................
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
00000060 00 00 00 00 00 00 00 00 19 00 00 00 28 02 00 00 ............(...
00000070 5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00 __TEXT..........
00000080 00 00 00 00 01 00 00 00 00 60 08 00 00 00 00 00 .........`......
00000090 00 00 00 00 00 00 00 00 00 60 08 00 00 00 00 00 .........`......
000000A0 07 00 00 00 05 00 00 00 06 00 00 00 00 00 00 00 ................
000000B0 5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00 __text..........
000000C0 5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00 __TEXT..........
000000D0 EC 0B 00 00 01 00 00 00 5F 1C 07 00 00 00 00 00 ì......._.......
000000E0 EC 0B 00 00 02 00 00 00 00 00 00 00 00 00 00 00 ì...............
000000F0 00 04 00 80 00 00 00 00 00 00 00 00 00 00 00 00 ...€............
00000100 5F 5F 73 74 75 62 73 00 00 00 00 00 00 00 00 00 __stubs.........
00000110 5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00 __TEXT..........
00000120 4C 28 07 00 01 00 00 00 62 04 00 00 00 00 00 00 L(......b.......
00000130 4C 28 07 00 01 00 00 00 00 00 00 00 00 00 00 00 L(..............
00000140 08 04 00 80 00 00 00 00 06 00 00 00 00 00 00 00 ...€............
00000150 5F 5F 73 74 75 62 5F 68 65 6C 70 65 72 00 00 00 __stub_helper...
00000160 5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00 __TEXT..........
00000170 B0 2C 07 00 01 00 00 00 5E 07 00 00 00 00 00 00 °,......^.......
00000180 B0 2C 07 00 02 00 00 00 00 00 00 00 00 00 00 00 °,..............
00000190 00 04 00 80 00 00 00 00 00 00 00 00 00 00 00 00 ...€............
000001A0 5F 5F 63 73 74 72 69 6E 67 00 00 00 00 00 00 00 __cstring.......
000001B0 5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00 __TEXT..........
000001C0 0E 34 07 00 01 00 00 00 61 F8 00 00 00 00 00 00 .4......aø......
000001D0 0E 34 07 00 00 00 00 00 00 00 00 00 00 00 00 00 .4..............
000001E0 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................
000001F0 5F 5F 63 6F 6E 73 74 00 00 00 00 00 00 00 00 00 __const.........
00000200 5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00 __TEXT..........
</code></pre>
<p>Thanks in advance!</p>
|
Unknown Mac OSX 10.10 HFS+ compression
|
|file-format|osx|decompress|
|
<p><strong>Update</strong>: dnSpy is now my go to tool for .net decompiling. It's open-source, it exports to Visual Studio projects and the debugger works like a charm.</p>
<p><a href="https://github.com/0xd4d/dnSpy" rel="nofollow noreferrer">https://github.com/0xd4d/dnSpy</a></p>
<p><strong>Original answer</strong>: Telerik JustDecompile also can export to Visual Studio projects. I used it recently and it worked with very minor modifications to the code. It's a free tool.</p>
<p><a href="http://www.telerik.com/products/decompiler.aspx" rel="nofollow noreferrer">http://www.telerik.com/products/decompiler.aspx</a></p>
|
8215
|
2015-02-12T13:40:24.813
|
<p>I wonder if total decompilation of arbitrary non packed project .NET is possible? If no, what is the conditions that should be met to make it possible? If yes, is there tools that can automate this? I'm wondering not about basic decompilers, but about the ability of complete project recovery to compile result with VS again.</p>
<hr>
<p><strong>UPD1</strong></p>
<p>Yet tried to apply only dotPeek for my case. Unfortunately the output is not looks like ready-to-go project but all errors seems to be debugable. Disadvantage is the inability to export both dlls and exe into one project automatically(poor man's editing <code>.sln</code> file required)</p>
<p><strong>UPD2</strong></p>
<p>Seems like ILSpy has no option of export ready-to-go solutions for one/multiple .NET assemblies. Maybe there is some plugin/extension that should handle this? Will update this post if find one.</p>
|
Recovering .NET sources into full blown project
|
|decompilation|.net|
|
<p>To develop a driver, there's basically 3 steps you have to do:</p>
<ol>
<li>Learn about Linux driver programming in general. This is independent of your specifi hardware, and involves things like "How do i convert virtual memory addresses to physical and back? How do i read bytes / write bytes to hardware registers? How do i yield the CPU while waiting for the hardware to set a bit? If the device is interrupt-driven, how to i "stop" execution of the driver when it has written a command to the device, and how to i "restart" it when the device uses an interrupt to tell me the command has finished/data is ready for me to process?</li>
<li>Learn how the hardware works. How many and which registers does it have, what's the meaning of the individual bits of those registers, what do i have to write to which register to configure the hardware, how (in the case of a web cam) do i read a pixel from the hardware, and how do i set up a DMA transfer of a whole image to memory?</li>
<li>Apply the knowledge of 1) and 2) to your hardware, write a driver, and debug it if it doesn't work as it should. If your user level software tells the driver to configure the Webcam to 1024x768 pixels, does the driver write the correct data to the correct registers? Does it obey any timing the device imposes, or does it set your registers too fast sometimes?</li>
</ol>
<p>While 1) ist just a lot of reading and understanding documentation, an emulator might be able to help with 2), and certainly with 3).</p>
<p><strong>Learn how the hardware works</strong></p>
<p>If you're lucky, you can do 2) looking at vendor's datasheets. In your case, it seems like the vendor (Broadcom) hasn't published anything, so the only way to find out is looking at what an existing driver does. This is where an emulator <strong>that allows logging of certain actions</strong> might come handy.</p>
<p>If you're running MacOS under Qemu under Linux, and the MacOS driver accesses the webcam hardware, then it doesn't really access the hardware. Every hardware access goes to Qemu, which will intercept the access and route it to the real hardware. Each of these actions can be logged. Now, you can fire up some software in your MacOS, and, for example, tell it to set the resolution to 1024x768 pixels. This might result in a QEMU log like this:</p>
<pre><code>Write the value 01 to the memory address 1234500
Read memory address 1234501 and get 0x80
Read memory address 1234501 and get 0x80
Read memory address 1234501 and get 0x80
Read memory address 1234501 and get 0x00
Write the value 00 to the memory address 1234502
Write the value 04 to the memory address 1234503
Read memory address 1234501 and get 0x80
Read memory address 1234501 and get 0x00
Write the value 02 to the memory address 1234500
Read memory address 1234501 and get 0x80
Read memory address 1234501 and get 0x80
Read memory address 1234501 and get 0x80
Read memory address 1234501 and get 0x80
Read memory address 1234501 and get 0x00
Write the value 00 to the memory address 1234502
Write the value 03 to the memory address 1234503
Read memory address 1234501 and get 0x80
Read memory address 1234501 and get 0x00
Write the value 00 to the memory address 1234500
</code></pre>
<p>What does this tell us?</p>
<p>Well, your resolution values - 1024x768 - are 0400 and 0300 in hex. This corresponds to the bytes that are written to 1234502 and 1234503. So, these seem to be the registers that set the resolution. But unfortunately, the <em>same</em> registers seem to be used for width and height. This probably means that the byte written to 1234500 is a selector - writing a 1 there turns the other 2 registers into "height" mode, writing a 2 turns them into "width" mode.</p>
<p>And what about the repeated reading of 1234501?</p>
<p>Every time, after something is written to the device, bit 7 (0x80) of that register seems to be set, and the driver keeps reading it until it's clear; then proceeds to write some more. So it seems that bit is a "hardware ready" bit, meaning the hardware is processing your previous commands, and not able to accept further commands. Once everything is processed, the bit gets cleared, and the driver is allowed to write some more.</p>
<p>Of course, all of this would be much easier if you had documentation of the actual hardware. But, documentation of <em>similar</em> hardware might still help. Assume there was a different chip, the Broadcom 1571, which had a USB interface. And assume the documentation of that stated "To set the resolution to 1024x768, you'll have to send the bytes <code>0x01 0x00 0x04 0x02 0x00 0x03 0x00</code> over USB". You'd see that the byte sequence is the same, but the timing stuff is probably handled by the USB controller of the 1571 Chip. So you could easily translate the instruction "To turn on the LED, send <code>0x04 0x01 0x00</code>, to turn it off send <code>0x04 0x00 0x00</code>" to the corresponding PCI register sequence, and verify using your QEMU log whether or not the driver does the same thing when you turn the LED on/off from your emulated software.</p>
<p><strong>Develop the driver</strong></p>
<p>Once you have enough information about the hardware, you can start writing the linux driver. At this point, an emulator can help you in the same way as when you were tracing the other driver - running Linux with your driver in an emulator helps you debugging the code in just the same way as when you were tracing the original driver.</p>
<p>Also, you can use the emulator to prevent lots of crashes. Your driver might have some bugs that cause it to write bad data to bad addresses, and you certainly want to prevent it from sending a low level format command to the PCI/SATA adapter. You can for example, use QEMU to pass through only a specific range of PCI registers to the actual hardware. Or, if your device documentation states "Writing 0x01 to Register 7 sets a signal to ground, writing 0x02 sets it to +5V. Never set both bits at once, this will create a short circuit and fry your device within seconds", you could put an appropriate safeguard into the emulator to prevent this in case of a driver gone wild.</p>
<p><strong>Can Qemu actually do what has been described?</strong></p>
<p>Probably not the vanilla version. There's no reference to PCI register logging in the qemu description. But, it seems that <a href="https://github.com/koradlow/v4l2-rds-ctl/tree/master/contrib/pci_traffic" rel="nofollow">there is a project on github to add this kind of logging to qemu</a>. This project hasn't been updated in 4 years, which could mean it still works as intended (and there has never been a reason to update it), or the maintainer lost interest and it doesn't work at all anymore.</p>
<p>Some of the other uses described are just too specific to be easily configurable, so you'll probably need to hack qemu itself to implement them. But hey, that's what qemu is open source for.</p>
<p>Since there is already a project to develop drivers for your camera, chances are the maintainers of that project have done exactly that. I'd contact them for more information.</p>
|
8231
|
2015-02-12T23:57:04.383
|
<p>Presently, I am trying to analyze a piece of hardware, to be specific the Broadcom 1570 PCI web cam inside a late MBPr 2013. I can pass through the device using QEMU, and have the gusest OS / VM detect the web cam, and I tested it out using FaceTime, and it appears to be working. However, there currently isn't a Linux driver for this device. I am aware of one being developed, and there is a project page on Github for the device.</p>
<p>What are some "attack vectors" or possibilities of using qemu to aid in the development of a Linux driver for this device? My knowledge with QEMU is limited, but I have successfully set up several VM's on my host Linux machince (MBPr), and I am eager to learn. Any help would be greatly appreciated.</p>
|
How could using QEMU be useful in developing a driver for Linux?
|
|osx|qemu|
|
<p>Its just a technique to embed strings in the exploit, as u can define them in a regular fashion, as u need their address to access them but in an exploit these addresses are dynamic not static or constants.</p>
|
8241
|
2015-02-14T23:25:05.980
|
<p>I have found the following assembly lines presented in a tutorial which I do not understand:</p>
<pre><code> xor eax, eax => clear, I know that, it makes eax = 0
push eax => push 0 on the stack
push 0x68732f2f => push "//sh" to the stack (the numbers are opcodes I guess, output of hexdump)
push 0x6e69622f => push "/bin" to the stack (again opcodes, representing "/bin" )
mov ebx, esp => put address of "/bin//sh\0" into ebx, via esp
....
</code></pre>
<p><strong>My question:</strong>
Why we put address of "/bin//sh" into ebx, via esp using the line mov ebx, esp for that ?</p>
<p>I draw a sketch:</p>
<pre><code> | |
|------------------------|<-----ESP (I know that ESP always points to the top)
(a) | 0x6e69622f ("//sh") |
|------------------------|
(b) | 0x68732f2f ("/bin") |
|------------------------|
(c) | 0 |
|------------------------|
</code></pre>
<p><strong>How I try to explain it to myself</strong>(I am not sure if it is correct, but I thought to think about a little bit before I ask in that forum here):</p>
<p>ESP is a 32-bit register such that it is large enough to comprise the addresses at (a), (b) and (c) (which I marked above).</p>
<p>Is that right? I hope somebody can help me?</p>
<p>best regards, </p>
|
Assembly- Using push and ESP-Register to store addresses
|
|assembly|esp|register|
|
<p>I'll try to guess what happening in your binary, but this will remain only my guess until you provide it.</p>
<p>You need to break API functions while debugging application that process both getting keyboard code and printing the result. In <a href="http://windbg.info/" rel="nofollow">WinDbg</a> it can be done like <code>bp USER32!GetKeyboardState; dd esp+x (or dd poi(esp+x) )</code>
Note, that this operation requires debug symbols installed.</p>
<p>Your question was about IDA, but in my opinion separate debugger suits better for such task.</p>
|
8247
|
2015-02-15T20:41:57.877
|
<p>I'm trying to RE an application which shows after hitting a button a specific number.
The number comes from a file after parsing it. Input = 5, number displayed = 5 and so on.</p>
<p>I was able to track down the disassembled code where the number being loaded.</p>
<pre><code>v3 = *(_DWORD *)(*((_DWORD *)AfxGetModuleState() + 1) + 164);
ATL::CStringT<char,StrTraitMFC_DLL<char,ATL::ChTraitsCRT<char>>>::Format(v2 + 168, "%u", *(_DWORD *)(v13 + 1032));
</code></pre>
<p>The last part <code>v13 + 1032</code> told me where to look on the stack and indeed I found the number.</p>
<p><strong>Stack overview</strong></p>
<pre><code>00188F7C 0000000
00188F80 0000004
00188F84 0000001
00188F88 000001D
</code></pre>
<p><strong>Now my question is:</strong> Is there any way in IDA to show me the code which is putting those 4 values on the stack? The surounding lines (Line1, 3 and 4) <strong>always</strong> have the same values.</p>
|
Finding responsible part of code writing specific values on stack
|
|ida|
|
<p>There is a topic regarding the 2nd question, see <a href="https://reverseengineering.stackexchange.com/questions/2977/how-can-i-clean-up-strings-built-at-runtime">How can I clean up strings built at runtime?</a>. Personally I use the script by ASERT script, it works pretty well.</p>
|
8252
|
2015-02-16T12:13:41.830
|
<p>Is there a trick in IDA Pro to deal with unrolled loops like in the screenshot below?
<img src="https://i.stack.imgur.com/kTBj6.jpg" alt="enter image description here"></p>
<p>Another, possibly related compiler optimisation is this - instead of loading an offset into a memory area, it does mov for each character (MSVC8). Any quick way to deal with these?</p>
<p><img src="https://i.stack.imgur.com/1ZIxV.jpg" alt="enter image description here"></p>
|
IDA pro and unrolled loops
|
|ida|compilers|
|
<p>The source code for TLSCatch can be downloaded from:</p>
<ul>
<li><a href="https://myollyplugins.googlecode.com/files/TLSCatch.rar" rel="nofollow">https://myollyplugins.googlecode.com/files/TLSCatch.rar</a></li>
</ul>
<p>And the binary for it can be downloaded from these two locations:</p>
<ul>
<li><a href="https://myollyplugins.googlecode.com/files/TLSCatch.dll" rel="nofollow">https://myollyplugins.googlecode.com/files/TLSCatch.dll</a></li>
<li><a href="http://www.woodmann.com/collaborative/tools/images/Bin_ollytlscatch_2010-11-3_19.7_TlsCatch.zip" rel="nofollow">http://www.woodmann.com/collaborative/tools/images/Bin_ollytlscatch_2010-11-3_19.7_TlsCatch.zip</a></li>
</ul>
<p>Furthermore, you can download sample programs to test TLSCatch from:</p>
<ul>
<li><a href="https://web.archive.org/web/*/http://ollytlscatch.googlecode.com/files/*" rel="nofollow">https://web.archive.org/web/*/http://ollytlscatch.googlecode.com/files/*</a></li>
</ul>
|
8260
|
2015-02-17T14:07:00.223
|
<p>I've been trying to get antiResHacker.exe as mentioned in this question: </p>
<p><a href="https://reverseengineering.stackexchange.com/questions/1399/how-to-prevent-use-of-resource-editors">How to prevent use of Resource editors</a></p>
<p>However, the codebase for ollytlscatch (<a href="https://code.google.com/p/ollytlscatch/" rel="nofollow">https://code.google.com/p/ollytlscatch/</a>) seems to be inaccessible. Is there a canonical location for this set of tools or are they no longer in public circulation? </p>
|
Where is the code for ollytlscatch?
|
|ollydbg|debuggers|anti-debugging|digital-forensics|
|
<p><a href="https://mega.co.nz/#F!OAx0wL7K!gLPZh7pkMv7d8as5serOmg" rel="noreferrer">Here</a> you can find bunch of tools for unpacking upx. One of them(Upx Unpacker 0.2) solved my issue. Every unpacker should be used in specific case and this list may be incomplete. </p>
|
8268
|
2015-02-18T07:47:09.870
|
<p>I've decided to reverse <a href="https://mega.co.nz/#!iEpDETIY!h0xZgdQ7etqJBUupq-yIcglj79aQcs-fQnRW898n4Wc" rel="noreferrer">this</a> crackme. Obviously it's packed. I was told by PeID that there is only UPX inside. Ok, but <code>upx -d</code> simple crashed that's why I've concluded that this UPX may be scrambled somehow.</p>
<p><img src="https://i.stack.imgur.com/XEm04.png" alt="IDA warning"></p>
<p>Binary didn't run properly in debugger(windbg) for unpacking it so I've dumped exe from working process and tried to fix imports. Maybe I should have tried Olly with plugins? However IDA still warns me that some imports might be destroyed(see picture). My question is: did I unpacked it correctly? If no what else should I do to unpack it?</p>
<p><a href="https://mega.co.nz/#!OU4X1a4Y!00wN9c72-4nRtNgF5t7ZdGLxDzjYE9G6CNakblHBUOs" rel="noreferrer">Unpacked</a></p>
|
Unpacking UPX packed (possibly scrambled) executable
|
|unpacking|upx|
|
<p>Answering my own question for further reference:</p>
<p>Zeus and many other MiTB capable trojans use API hooking as preferred method to inject malicious code in the webpages before they are rendered by the victim. API hooking is sort of like doing a MiTM of a system call, whereby the bot intercepts the call, takes ownership and control, performs some malicious action and then returns control to the original function. Something like:</p>
<p>call <code>network_function</code>:</p>
<pre><code>JMP XYZ ----> JMPs to malicious code
.. |
.. |
... <---- returns to the original function
</code></pre>
<p>So, in this scenario, in order to extract the web injects, the best bet was to understand the logic of the trojan. That is, after a user opens a URL in the browser, this URL will be matched with a list containing the configuration of which URLs to inject. This will surely be performed on Wininet functions such as <code>HttpSendRequest</code>, <code>HttpOpenRequest</code>, etc. If we breakpoint on that function in the main process of <code>IExplore.exe</code> (in an infected machine) we'll see the first instruction to be that <code>JMP</code> instruction we've talked about. If we then proceed to step into, we'll access the actual instructions using the structure BinStorage and other, all related to Zeus. Since there is still a lot of code to go through and the interest was to retrieve the webinjects, one approach is to monitor for decryption / decode instructions (Zeus's configuration is stored encrypted; it only makes sense that if we monitor the instructions responsible for this operation will lead us to the actual decrypted content). </p>
<p>In this case searching for the sequence of bytes</p>
<pre><code> MOV ANY, ANY
XOR ANY, ANY
INC EAX
DEC ESI
</code></pre>
<p>If we breakpoint after the last instruction and then inspect the contents of the memory address pointed by the destination operands in the <code>MOV</code>/<code>XOR</code> operations we will most likely find the decrypted payload (i.e. our dynamic configuration section).</p>
|
8271
|
2015-02-18T10:39:56.333
|
<p>I'm doing some study on Zeus 2.x, trying to wrap my head around how it works. By using <a href="https://github.com/Visgean/Zeus" rel="nofollow">this code</a>. I've built my own builder to work on my test environment.</p>
<p>Right know I want to do a very specific thing, which is extracting from memory the webinjects configuration. The first experiments I did was to attach to IExplorer and monitor calls to functions I know Zeus hooks, like <code>HttpSendRequest*</code>. I was expecting that at some point while stepping through those executions I'd see the injections configuration loaded into memory. I've tried to automate the proccess setting a breakpoint upon call of this function and using OllyDbg's Memory Watch plugin, which dumps every string it encounters.</p>
<blockquote>
<p>So now I want to pinpoint and understand exactly where should I look to see this decrypted configuration in memory.</p>
</blockquote>
<p>My assumptions so far:</p>
<ul>
<li>I'm unable to see anything strange because the <code>HttpSendRequestX</code> function I'm setting a breakpoint is actually the original, unchanged from Wininet;</li>
<li>Dumping memory of the machine and analysing it offline is not enough, since the structure which holds the webinjects (BinStorage) is loaded in memory when it's needed and then discarded (free'd) </li>
</ul>
<p>At this point I was thinking to monitor calls to <code>VirtualAlloc</code> and place a breakpoint on memory write on those newly allocated areas (at some point Zeus is bound to place there the encrypted configuration and then decrypt it).</p>
<p>But this is still a long shot. Any ideas? Also I'm doing most of this work by attaching on <code>IExplore.exe</code>, should I do it on <code>explorer.exe</code> instead?</p>
<p>Any tips are appreciated !</p>
|
Studying Zeus 2.X
|
|disassembly|windows|ollydbg|malware|
|
<blockquote>
<p>how would I go about decoding/decrypting PHP code which is
encoded/encrypted using eAccelerator?</p>
</blockquote>
<p>You would have to reverse engineer the <code>eaccelerator_load()</code> function in eAccelerator.</p>
<p><a href="http://article.gmane.org/gmane.comp.php.eaccelerator.devel/381" rel="nofollow">Note that this function only exists in older versions of eAccelerator.</a> For example, see here for the function as it existed in version 0.9.4: <a href="https://github.com/eaccelerator/eaccelerator/blob/e48010887b429a203bf03c7562e30a4d2bfa07d3/loader.c" rel="nofollow">https://github.com/eaccelerator/eaccelerator/blob/e48010887b429a203bf03c7562e30a4d2bfa07d3/loader.c</a></p>
<p>The first thing the loader does is <code>base64_decode()</code> and <code>gzuncompress()</code> the string. You can see the (mostly plaintext) result of that here: <a href="http://ddecode.com/phpdecoder/?results=744654407d52841255a5b54c1d5b402d" rel="nofollow">http://ddecode.com/phpdecoder/?results=744654407d52841255a5b54c1d5b402d</a></p>
<p>It looks like restoring that to more readable code will take a bit more work with analyzing the <code>eaccelerator_load()</code> function, but I'm sure you'll be up to the task :)</p>
|
8272
|
2015-02-18T01:05:35.093
|
<p>Well I'm unsure if this is the correct site to use but how would I go about decoding/decrypting PHP code which is encoded/encrypted using eAccelerator?</p>
<pre><code><?php
session_start();
?>
<?php /*This encoded file was generated using PHPCoder (http://phpcoder.sourceforge.net/) and eAccelerator (http://eaccelerator.sourceforge.net/)*/ if (!is_callable("eaccelerator_load") && !@dl("eAccelerator.so")) { die("This PHP script has been encoded using the excellent eAccelerator Optimizer, to run it you must install <a href=\"http://eaccelerator.sourceforge.net/\">eAccelerator or the eLoader</a>"); }eaccelerator_load('eJyVPFuQG9WVt1saW7YBe2xsYPFDxrbGRg4YkhSGmSFII3mkGc2MND1je2ZNKRp1z0gjqSW3pBnPUMumCpKPkHwEtrYIrw+KRzC1IYD52TzIY2srbNWmyNZS7Ba1JNkN73cCJITX3nPuvd23H2ZZihp1n/c5995zzr3d7XRiaCidS08mpiYmSZgQopBQD/1ptI0yUdkPgAnZRNh/CbgdUEIK/YnCn4EwEf8poXXAWy1bzU61YSSRlIrhRConWkv/Gqda9aZuFFAnRSgKyNKYCUooRH+pbiUGgJCihFWkJEhJZMowt5aRUlhYzfd4pPQAQA1THZvOI8xBRVUV5eUQv1PDhN0pPaiFYq/tsS0OReifBaPTLjbaFCSumL7zuO/aWu4dmFdSvsJvARPh5kBw6s2SXsSwIph4wUpfhPEp+XWcjQmMwC2hPoTAqGuiA+tE0KUgIE/IJ1Ndx/wPh1AKjbeqMnk0CKE1MD5zVvTya/cjHbl2PbecReAivFjHh3ngHCIwjl7tnCAXldg5YvTymzgHhKWopSePpieJtolz7cBxspYMq9w056sLifGhUrut1+j/9URuZFRTYpuEJK2XM20Bpmq5YliJ5JBe0w9/8YuH9ZFRJdbL/FJCXwaK2qK+WGnrXX1kZETL6KZuLsIFFZrIpEZHElomtVhZvfrwl1a/9OWO3q7Mt9p6djPBGRkCUZddXjXL9a5uXEZ/L2tVWptSW/nI4fyq6mm4D5NzST9c0KDYmMGtYpCUiLZVnpVVXYltZYaGibbNg+pHAAw2BJT6WK4VKfzENj4wIRHJoYmJ0WyaXC8QKg0SYtpGu11tmklADKqAGnSYI7ZCiVSJbWNjFA4VLmQTS2WTo0vHpqofvBDn33aSgAlBM8AF9Cc3MZSYyk6MXxOl5hWXraa5ACHCvHAR16fwOVYxSrphTfwVvYykdmLIlNAG+jtsdKapilSpU0ojPBwl/TsxlGEfxeBOKaQ7pWkHVuqUoK3EdvLAhoejbJLjCl6q1uulBaMdychQYDNLDcOBwqQu1esrDgSsbzWrZqftprJK5oIDOVfSUWzQ5BbJ7OYoCHOp0ymVa20HCKvMNJaLltFqWh0HHuHwRqlad1ODVcX5ZtfUHfg6Aa/T8EYyl3DwBgGumkvVjuEgzhMIvUozcKNUXgnANejy4/oFDtJhtUF9i2T2SIa2KOVy09IdKKz55aqpN5eLy1W9U3Fj2hUK7zSb9bmS5Zakr5jFhmF2HSgEFBOC1Sie7BpdqnqvxNAoteiiWJWgOAKlcqlDp3ORDapAbZBRVd1BbJQRpXLZaHUcJOY3o9GMZPZxCKzZGh1kQy92zSotBLoxX6TzoOaQbPeSlOqdJi0aNFN5KH3C6BzhJDFOAplowSq1KtVyqV5s0hS5XDWWHDwMv96khoP9ES0qrWuY2e2TdSUGtDR3qqrWF7he+hEM2WYtW2vJlax+oo+4c41IE9cLBOYaJz8kAc5SDfKqxMn4whROA6hynzOv5kv1tpHgOMiBg32oGAREbKPDXJAS6yOirOwn/jxW2E+Yatk6bT93xZYyxXhDrKBW9dh+IVWLc6mA0OeU/riIDxhLZ6K1MgAgrgZFQr8TiaOE0C76M51PJabSUXQ8qqWnovVSu4PDRJfjymBYRWLqLVvZ0WU6O4worRj5uNfQAurqcSxlelQ13OMIAZJEnEUQs31cjBJNk4e4oXZ5OYQO8WVRbRfFAhg8xN1SSOQgXIeVfyb5Q94BKByyIxywfHqFdOzU4qicipm5UhJTHE5Pkdkr5XFiUziHVKoSR5zSJHkfW+FK4ufrvVK4BLB6c6HZ7dgysl8krAxttunblzMaqFaRmat8pl0VYNpV3DTEKadJ3sdWuCrItKuEaRB/w9RtAanD9GIN8aziNEDDa24k/XARCq/x4E8cthegNCbXCyiWbTZRkgAbxGEYtNF0PhwmTmdJu7TDhJXLNdrVLkT/1fK8L9ebbWPwajHvlcjVA4DODxB/jigMsDiEmIGVmrFyjUPtDhmShiBkoLWyeYBFKxyKD6CebxNtkDOBGYZlNWkKGCS8yYOcnzWXSvWqHgU9u2eu46FxqHPX4cipcUQpf0/y1/mm9HWfOaWvE1MaqGwxWsJvWEIYBulk2qqXunNtmrU7ltHpmgvR5a6lG9E5uthpvqe/dDoYnd0zKb/NKW4zopQHiZYm7qyUlkcHs1I+Tby5I20PBM8dSKKEciQgR7lq52Bf30GpYg5+4YqDnqgMHnLSFk1oINnJRXAnclFaTFglkj9CnLLAuyWlAEB54kaQSgldTOQWc4FaBev1K5xvMKwgIezlmFK4G2CjNHDEnvBy+6ll3FM8I4IIIWu2DHMw48zw1Cj9XUsYv9YoWZ2VNIDCa79P+kdxca6VkYOjnBcW2ShxevpOi5bhUb7M1mo5D6o/J6zArEHX0IKZyOHa9fc0YDgykAjrgwyz0ypZbeNEjjgV28kLAoqTwCctiWrYMDmUkUVUgIUawSoLiDbmtXwswPIxZrlY+dgRjHEhvm5CIFzJIjlGRJ8wOCapH/eqHxfqQaZebbfqpZXEONMfpT+XXXZ5x2hQaMdoX247ztrTy0ACkI4703MiD3HNT/nSw5SdHuSthE0I3rO9KyfFhAYNb6NqFgX5FiTH3DaF+p4h+Wm+HmQJ0/ZygA2o2ezQ7YRl2GLigA8r/0YSRwnuxHa5lomP3t6RHQ1cEhMnwOfELJO13SWrbBk0dEKSLWj2MwTNfFUKHiumXxWxk4rpV9nCPYg4ZYuilaWFWVViZbZaWMbNl3mUGPL8MuHpGCbGF+Dud5R4rXLULeQSLuRS+H2OaDpxZ1BdzB4ng+re9VPQCXFnUCRRQtDEa+lcemgqapfm6LzVbPCEKqdGncipUSdOatSdNWebB1GyjHa33lFiTBk0pYbHeEM2ft7olCsnDFuYS0jScNa4IIFDAIM4baHVXFZiDEmn5+yCGDFX55Fb4IOGaBrv/KJHRGHRnrouTgUJw3w8B5BKijR0z1sWmXC6OJCY+qbVPD7X/ANW8w1YzTtgNTZgsGvwlTzbQlruXENWcw1ZTRqyGrHTxaV1+rtWSZi4dhSFYwZMaX2Aqe26YbQubdKr50mqBavE1/QBNBw5T+mHi1A44m36WtLYOsldQOWmD2C86bPRNHe2pKWhK7EWWxrhiHbSheg/KWKMR0/Q9BVNY3nwJB8yKItd+ruOsPMCul08yrIDnt8AKrzuAqW/i26sCyIa7HJZYFaXa4dcydMMP8XpcgvXzSwTb0ZZFvNTaiNySKYqBxGpRBVtWYoX8k0ti1hJfDFGr7ChHj7FvJT2jpGMgPEJZd+DYHbOICAQxFPu2xXnFkPaNDtVkxbtSGZFUmUVl5tN3YGtRVi70zQNL2HVolt9Gwbxxc1ly2rqxVKt041kViX7rOJcxYFs4hZYzXrRORATWGh9LaNsdasdQy+2zeachHQdYt0geVRasAyjgR7dIBllg7lRN0hKdKNUp0uwSHdgdENqOEjYkPKig1tq7RQf+/XOgOGhxg1EHGrcyEeZzdfiXLda19tK/42E77oAvmBQKyyLNgc34urASOpzop8avNFeR5ExuCbraYEdx6sN4fUJxVYi8cUYk6pu0P6WYz1GDgF8ALNGEi+xXg0wapYd8FgPDCu2uu3KpV+jt1crV3wNbV+v3cTlRphrHaNcoZ7dFOzZTYGe3SR5BtfkHPAMr84Nn1NQbB2yZzdxz87Vbj6LZzfbnkVuJvZBDpxiFWlXfjPhXTmwgdnFurFk1BOcC6Nw89mj8HVYh8oVX0c/z9G+Qc6SIvoR4z24+gZxt8G48q8XUPuEnEtKAoIfW32DOMdWHoc5GXakggxq6DeIfzsTY7poJSt8kxCeqKDzNk5V6TrlZL3fFMMIug/Fv4lhrCn9twBPhK0TOrrzVavd4TwnbrG9kKuAgMpV4BZiVwGBBntv4bFc59gLjyJuYTLDoci3cEj+z52XehUSwvMjSCmxNl20dPMEB5RLVWM58S3i7MS+Jcxzd4vfBjfz3+EGufaD37HD5mRhm9Kp9EiGnTZzevN3iOivv4PR/Bul/9bPiOatgdEUUDmatzrRFGiI5q3B0bzVjuZtnzeat31mNG+TonlbcDT/Dtzsv517y7u/drV94nbbHXeQk7c7Pt0u+XS7FBAQocRut6fzd13jwkqW9l3ibOuE8KnvIk9IJowhIR7b3iENJeoo3GFLlgqfdkeQ6DuEaIkydoct+06f7Ds9VkP91O4MEn2n22ogjN1pS77LJ/kuW/I5tpvFcrPRKGl3Bcm/S8j3ksfusrXc7dNytyuJcI+5mruD1Nwt1PjoY3fbeu7x6bnH4w24z9XcE6TmHrc3DnnsHqFl+F6UGYlo93J10lMyVreU2L1ElPL7iLvfx3t3v39fgCUFpPM8j4gAsMe1T6vqbIMm8jpv+Bk9NP3Aoqo9LFtEE+Op6P79UBGjg9E+puQ8cUyBbR+qoFuW8xxOSAV9yFrVByQe3joGcED0DkQnJqOoauDzKgK2vgMHuKrdg8jmekyAocLHBIyJYuDRWrRp0YQRnVuJomu60S4fpJGB32iu2qh2olckgEHsd+4jzhZVDJC8Rb1PDLZ2v2f47peH7whuUe+3hbm3qPcTe4sqSCAZ3U88W9T77Vz0gD1bmbvaA3xm+GfY1ANipkJAoVmOPWCvgweJc6aEW9gHPYIjSMHOYgJSN6LhbRL0MlZqtPq1B89uyoPClHXclGK9atZiD4o1MPM9aV2yzc735PTFSkMOqehOHHHKvyt5H1vhe8TPF/ke82WtDQEPALjR5cGlAHpG2YYYtjE6ys0IcOoYU656nNrJjFPUjTMP+Zx6SBiHz1ibupF7iLuEGOV3St7HVHiIeLkiDzGHevg9uAOgTW53APTfyjbEcHceOrs7DwW78xB3Z9PMaZ87p91zJneaO4Nw5U0l72MpnPbOs9PMlRDegSMA6HU7AqC3lG2I4Y6cPrsjp4MdOc0d6Z152OfIw/Kk6ZQs2jPlHubOIE75UMn72AoPEz9f5GFnsjEIOAXAzW6nAPSRsg0x3KmHz+7Uw8FOPcyd2qx9n7jTEN67q8j3SUAVQTpvFQHg/7OKfJ98RhVBJe7kjiowuducchW5VuLhMyWAw11Frv28inxVBDCuKoKhwirCmCgG3uxxVxEoIHVeO4BM1A42FKx2iGGRawcKx9rxiGfQHpEHjdWOR2xh7trxCLFrhyCB2vEI8dQOhoTa8QPP0tN+QM6asH9ApNphGqc6sR8Io/OPEk/teNS7ph8ln1k7HiW+2vHo2U15VJiyjpvCasejRNSOx3zL+THirx2P8eWMOOWQmvexFR4jfr7IY85ydmoHALe4lzOArlC3IYYv58fOvpwfk5ez7dTOx/hy3jLzuM+px4m3djzOXUKMMqjmfUyFx4mXK/I48dUOAJ3vdgdA16rbEMPdefzs7jwe7M7j3J3zZ8743DnjnjO5M9wZhCsjat7HUjjjnWdniKd2AGCr2xEAjarbEMMdOXN2R84EO3KGO7J15gmfI08Qf+14gjuDOOWYmvexFZ4gfr7IE85kc2oHALe5nQLQcXUbYrhTT5zdqSeCnXqCO7Ut/4+cF/J96ph27FQiOVk+MjxqWjVrqbKQPTZabbTnK4VkIj171JqcSim9wILnOPBK3hHNSpYKiexqrj1j6Ynp9JhVmTbmC4uJU4WTE/mhbBw1KCtq/odcVZT+GourVmskM9QsDGWmUqupxeakkWw1xjLdVKFxfGVM6f2hrGU41x2eGalkphbLM4uF2eZYNbEw3anMzmnVylLKaifjPxRafsS1QOdfmq9MljVtaag2MT9SrrWG2jOjpULF0o8cOTU2W6skVqeV3h/JiqrNUrNtdI4fXV00Tw2nZsdzhXJlbrU2NFdfnGqtLLTjPxKKfswVAdvEzFRHq7TM2en5ydHC2FhmtJ1Yqeeqc/nRRLq60JpVen8s1IBh3ZHyaiIxkk+MzUxPmqvjXW1mZaR5pLs83Z6pT+ZWFtOV+I+Fop9IilqFbOFUZaRRz6Rq5dHpbjo3UchPFzpHk4Wc1lkqJZXenwhF8JS0MraqD5e65cVjI7NHyrXx0ebxSkHvlkayeimZTsR/IpQ8KSmZThSqp1LDVqo1eiSxeFLLjhwrzC8tTGrT+ZFMfrZK58CTQgm8ejq8UqlZM6NjS6lUem5xaWTOWh1NDx89upKfntQL8SeFjp9KQ1Nv56zJ8upRY97IF4610zOtJWs0PdYabaTGjlYrydn0ktL7U9dMq09XZycXR04OL+Ynjanh8amFhFZKd49PtEfyw2MLq/GfCkU/44rgXU5zdGmpkTHHMlO1ockFPXlytVFaSlWOLDasTDNRntQNpfdn8tgYC6PH5/V8/qg5ZKyMz2Wn88dnypnxWb2z0EmVppczpYX4z4Smn3NNEOvmfGm2vaQfbWZXVxb0cq2hHR+d0xLtZDsxPztOp8DPZXda5W63Mjy0mGmNz03WZi29cjxXGdZTwzPN+cJQYepY/OdCyS+ksdFPjnbbJWvmSMo8me+mG4vmwqkjc6spbcWqjS3P6lNK7y+EGngPcq6w2mnVF3Kdyc5SppNfmRleXh1fnTBzzbpZ61QS2vhqubN6EFUoq+rEPwEzvqA+bc4ZtZJpdmjXkyp1DHOuZNaiR4xK3bB2D/8SMk+IPQKMZMSd6roLue7Crrse190a191a113EdbfOdbfedbfBdXeO6+5c1915rjtoWyPaL3mUwTJ8vUqJ/ZJlTzWUf4p4n7o+xZK43TcmAcCffeAlO/V/ivBTf/5Uo2qy1BwHRFi5VZ34F4y4Rf9qrapBg8v6ynrVWOhE54xq9IovRznG3M2uoo1uux2danZKddoTGh2jE102aHtqHoy2m2a7E6299eSPTdMwozWjahpR0+jSay4k2jGqddOoNAxzt/YrbhoMeGIIjmu14lhC07JHR9MzxUx2OJNI0NtUSon9itUMJQQvOLb1xVKlrddGMlpiJDWaSeRG4TKFf8bbi3qlVKN/65WR8YSWGs0lnib2VzSXw5/808R5kCA+kCgAkNUriFU+k6eY3JHk0048n5biKX1Xs/g0G0pBItpmfFzHHrQ0W5ufFisDP3Dh7WkcRSr3qBO/xpGAWQTzvTqPUz31DL2/wP1OFIDCF9yr9sNFKHyB650ogKEbSkR7hjj9Mr4T9QwLYviCmWeJt5t4lkhdAX8BAalUJY445R/UvI+t8Czx8/U+KzyV3g4VMrL/Qchnvh36nM+052QVvKt+jpl2EHHKGVXjRNLT5+fEaDpssefENAKz888TZ3sj3gZ63p4E+MWAeCOgHX8el8wv1KvhQkFe1zMvxmlvaJnCa5B48/MiIOJrB5SmUmnab3x2/0a2m2mP/Ua2W/utlCyK+QmNMv02gOm3Lmf/xzd2ACEXugN76Pdo6oVs1jRKrfjvUcpTavb3fOA2SgNHCXDULgXk4dChFwQ3aIEn2vEXkP1f1ewLnH2TxA4UjP8Fxv+i4Ic1Ih7IxF9EGb9Wsy9yGedLMgQVk/Mik/OSbEejVDXjL6GMZ9TsSwF2AAXjf4nxvyz4eyU7nFfCXkZh/6lmX+bCdgQY5HojLHLpy0zyK7KHNHt2qibt615Bgf+lZl8J8FBQMTmvMDmvynLmIMuUa+34qyjnd2r21QA5gorJeZXJeU2OFDwiib+GMl5Qs68FRAooGP9rjP91wY9v3sCzj/jrKOAVNfs6F9ArOwMkTMLrTMIbsgXwWCP+Bgp4Q82+EWABUDD+Nxj/mzL/fMlqxN9E/nfU7JsB/EDB+N9k/G8J/rXMA4uOWfwtFPGemn2Li9ji9sHiL+hFLn2LSXlbtqJS1Y342yjiAzX7doAVQMH432b877jGgeaI+DvI/7GafSdoHCgF43+H8f9B8ONa7pTm6kb8DywBhLJ/IP6cy2iYjD8wGX+UZSyUMBB/RBk9oewfA2QwGibjj0zGu675QHuJSvxdFLEulH03aD4ACZPwLpPwniyhVS+Vjfh7KOHcUPa9AAlIwiS8xyS8LyRAF1Y155tiKcbfR0G9oez7XNCF8sySKJm895m8P8lxYR+Qxf+EkraGsn8KiAujYTL+xGT82WcTPrwz9fifUdJFoeyfz2YTp2Ty/szkfSDPWviKiWaI+Acoakco+0HArOVETMoHTMpfZM9oB1EzOvG/oJDdoexfAjxjNEzGX5iMDz25th7/ECXsC2U/DM61fOZ+yPg/kvmxOH6E/AdC2Y8C+IGC8X/E+D8W/BtEZOG9ZMOKf4xivhDKfszFXOANLCNk0j5m0j4R0tYJaWjSJyjrilD2Ey5rq1eWY9cnTNKnPrsaRmOO2vUpyvpyKPvp2exihEzap0waNJVOlI1GMw4QVTkcyiLKG2VKgfxXYFsavlALK+4jX7x3n9MDyL3PCNsv8fCTLyRhm7vPdUDfF1aRB0+yoXNg5+x4QD8wGO2zdbqeDaDaHtdpOtLhwbgtbjuK8z9ftc/GgVKcjTP32dm4CIV8Ns4cg7PxHk+geuRAsbPxHluY+2y8R7HPxgUJnI3DtetsnCHhbHwNF2Ofja/h2iFWeGQmztRgS7hGGDmzXvF2yesVLgi/HYV3DnNIRPt3RCl/HdI2KO4dQf8G4Zv0QQHABiUxYGF5A4pgrw9bXYMRqewNLcThnI70b8QtuedTiY1SuORxvl4gFPn1zuRGxX5VxuGMaBsDZsoUI5AmSmyjiNHwZvbeMPZAWCT4d58da6U4RxuhSGYLp3DyugM71+biX8U6KG9ZcTB2yYpkzpdAWOQckGiOHQhvth2A3P+6GaFXjWS2ckhgf+qg5SbTDRXNYCSzTRLO3ordJpvO3omVidgbsTIEeioHIvVRbrIKvnx6gayPZk0H4rQubhhrMxyYt4RGMhdKqnmdc4BObXNgW2yYGN5i25AliWLmhrAv1S/iEE/BcRCu2hFAz/K7gxA5PaJt5iv0XKasuVxk+7K2ErtIES/uXOxdxhcHLOOL2TJeT8S/9gBv+II+xAyw0R2+pnpNG88tLpbWKJijlzrG4sUIwUV+sbPIte1e/dsD9G9X7Bdk+d6aXp3YLsS4t93J7Yr9wud2SdMOr6YdAZp2ME3ufw0DfAIEIU5Nw3+0A4A9xPePdgCYJuRwD4obYFVjYIcUlR7M3l1TX9zhhGWHZOxOr7E7A4zdqfg/19rJhfg+19ppR0v+XGunE6udkvpdXvW7AtTvYurlHAoW7JKGxfXa4i5H1y5JV9SrKxqgK+q4it0EKIpKimxEMupoiUpadnu17A7QstuZZ2ypoJ7dUkid15J3y/F0OJK7Hf27Jf2XePVfEqD/EsX+ctC9YMGMSyR3/RTJSxy9l0h693j17gnQu8fRi282tgyrWGl2Mcz5PYp/LAsApFNfSvU2HX5BYFn4VUOXfUPEyEN0UfTYZPJBmSMNy0TLMPTQHnsR7ZEW0R7PIpqvN5vW4h5nEe2RfN/r9X1vgO97me/nEV6f3M7vDXJ+r9tc4LIJg7zf63i/N8D7vQHe77W93yt5vzfQ+72O93sl7/d5vd8X4P0+Z+TxLVCX8/uCnN/nGnlgsumCfN/n+L4vwPd9Ab7vs33fJ/m+L9D3fY7v+yTfY17fYwG+x5jvUEkbpVNF3mag57Egz2O2rVJXciImZQcRACpOSLte4GmeCPckY84qjUn29nnt7Quwt8/JTmDvXAVN7Qsytc81SNBSneiT7IxwOwGhXN/nsrDPsbBPsnC/18L9ARbud2aT+/E95K/9nvzlpkjud/Tul/Qe8Oo9EKD3ANMr/pUM0HZA0ibgyQOOjgOSjrhXR1zokD9OjjMlsFl3fZyMj1/EF8lxMUuVyLUHFcL/dTT4738BVInP+g=='); ?>
</code></pre>
|
Decoding eAccelerator PHP code?
|
|php|
|
<p>Android APKs are signed to ensure the developer (holder of the private key) is the only person who can update the application. When the apk is signed, much like that of a jar file, hashes are taken of all the files.</p>
<p>What is likely happening is that you are modifying a file and not resigning the application - this will cause the package manager to reset due to hash mismatches when checking the signatures.</p>
|
8277
|
2015-02-18T20:51:38.060
|
<p>i created an android app(simple cocos2d-x project) that in this project i have a method that takes a string and then render it, in initialize state of my app i pass the "abcde" as parameter to this method. This works fine in windows and android devices.
but when i open SO file that placed in apk and edit any of character of "abcde" string and then replace so file with older so in apk file, the apk does't install on android devices.
I get this error when trying to install the apk : application not installed.</p>
<p>anyone can explain me why this happen??</p>
|
Changing .SO files in android cause to damage the apk
|
|android|decompile|
|
<blockquote>
<p>Is Olly 2.01 actually "smarter", recognizing the packer and stopping
at the unpacked OEP?</p>
</blockquote>
<p>Yes! You can disable it in OllyDbg's options though by going to <em>Debugging</em> → <em>SFX</em> and unchecking <em>Unpack SFX modules automatically</em>:</p>
<p><img src="https://i.stack.imgur.com/DyJWK.png" alt="Self-extractable modules"></p>
|
8287
|
2015-02-19T16:22:49.723
|
<p>I was playing around with tutorials/white papers concerning unpacking, specifically UPX. As Olly 2.01 is my debugger of choice, I attempted to unpack an UPX-packed exe with it and to my surprise, it looks as though it fails to break where it should. </p>
<p>With Olly 1.10, the execution will stop twice:</p>
<p>1) First in ntdll
<img src="https://i.stack.imgur.com/hvxUk.png" alt="enter image description here"></p>
<p>2) Then the well known PUSHAD instruction in the actual module:
<img src="https://i.stack.imgur.com/K79Ov.png" alt="enter image description here"></p>
<p>The JMP visible above will jump to the unpacked code:
<img src="https://i.stack.imgur.com/lyRVQ.png" alt="enter image description here"></p>
<p><br>
This is the kind of behavior I'd expect. However, Olly 2.01 with the same settings (break at "Entry point of main module") will stop at this jump instead:
<img src="https://i.stack.imgur.com/SiAtW.png" alt="enter image description here"></p>
<p>Which, if followed, will immediately bring us to the unpacked code:
<img src="https://i.stack.imgur.com/S1a9L.png" alt="enter image description here"></p>
<p>Additionally, the bytes preceding the JMP in both cases seem to differ, as do the addresses, suggesting this is actually a different piece of code. </p>
<p><br>
<b>What is happening?</b> Is Olly 2.01 actually "smarter", recognizing the packer and stopping at the unpacked OEP? Also, why are the JMPs to unpacked code different (as stated above, different instructions before them and different addresses)?</p>
|
Why does Olly 2.01 fail to break at the module EP?
|
|ollydbg|upx|entry-point|
|
<p>use <code>CTRL + P</code> protocol only the following EIP ranges </p>
<p>Add the ranges above and below the block to be skipped </p>
<p>the skipped block !</p>
<p><img src="https://i.stack.imgur.com/CQyiN.png" alt="enter image description here"></p>
<p>edit</p>
<p>no there doesn't seem to be any skip feature looking inside plugin.h i see only MAX 64 (NRTPROT) ranges can be protocolled and the address is defined in t_range the code below can automate putting one range automatically into the dialog box for subsequent ranges you may need to implement logic that checks if selection is within an earlier block or not if yes split that block into pieces code below compilable in vc++ 2010 express </p>
<pre><code>#define UNICODE
#define _CHAR_UNSIGNED
#include <windows.h>
#include "plugin.h"
#pragma comment(lib,"ollydbg.lib")
//grab the plugin.h and ollydbg.lib from visual c folder in plugin kit and put them along
//this cpp file open vs2k10 express ->new -> project from existing code -> Dll ->finish
// open project properties and disable INCREMENTAL save solution and quit gui
// open a vs2k10 command prompt and do msbuild /p:configuration=Release
BOOL WINAPI DllEntryPoint( HINSTANCE,DWORD,LPVOID ) { return 1; };
int Skiprangefromrtprot( t_table *pt, wchar_t *name, ulong index, int mode ) {
if (mode==MENU_VERIFY) { return MENU_NORMAL;
} else if ( mode==MENU_EXECUTE) {
Resumeallthreads();
t_dump *cpudump = Getcpudisasmdump();
ulong startsel = cpudump->sel0;
ulong endsel = cpudump->sel1;
t_module *curmod = Findmodule(startsel);
if(curmod != 0) {
Addprotocolrange(curmod->base,startsel);
Addprotocolrange(endsel,(curmod->base + curmod->size));
}
Suspendallthreads();
return MENU_NOREDRAW;
} else {
return MENU_ABSENT;
}
};
t_menu disasmmenu[] = {
{ L"|SkipFromRunTrace", NULL,K_NONE, Skiprangefromrtprot, NULL, 0 },
{ NULL, NULL,K_NONE, NULL, NULL, 0 }
};
extc int __cdecl ODBG2_Pluginquery( int ollydbgversion, ulong *features,
wchar_t pluginname[SHORTNAME], wchar_t pluginversion[SHORTNAME] ) {
if (ollydbgversion<201)
return 0;
wcscpy_s( pluginname, SHORTNAME,L"SkipFromRunTrace" );
wcscpy_s( pluginversion,SHORTNAME, L"2.00.01" );
return PLUGIN_VERSION;
};
extc t_menu * __cdecl ODBG2_Pluginmenu( wchar_t *type ) {
if (wcscmp(type,PWM_DISASM)==0)
return disasmmenu;
return NULL;
};
</code></pre>
|
8290
|
2015-02-19T20:37:25.807
|
<p>In OllyDbg 1.10 it was possible to skip some parts of code when starting run trace(just example):</p>
<p><img src="https://i.stack.imgur.com/lLiXR.png" alt="enter image description here"></p>
<p>So when there is some heavy code it was possible to skip to trace only some useful information.</p>
<p>I cannot find same "Run trace -> Skip selection from run trace" option in OllyDbg 2.01. I cannot find any info on that on the internet too. Does it mean there is no such option in the newer version of the software? How is this possible at all?</p>
<p>I need to exclude some heavy code that is always present in the run trace, but I don't need it, and I cannot interact with the application when it records all those lines.</p>
<p><strong>update</strong></p>
<p>There is an answer that shows some workaround, but this is not exactly what 1.10 has, because in 1.10 you can select the code and just skip it. So I just want confirmation if this functionality was removed from the new version of OllyDbg, or there is some other (but also comfortable, not manual) way to do it.</p>
|
OllyDbg 2.01 Run Trace "Skip selection option"
|
|ollydbg|
|
<p>Those are 16-bit USB keyboard/Keypad scan codes. Please see <a href="http://download.microsoft.com/download/1/6/1/161ba512-40e2-4cc9-843a-923143f3456c/scancode.doc" rel="nofollow">Keyboard Scan Code Specification</a> for details. Appendix C contains the complete mapping </p>
|
8293
|
2015-02-19T23:10:15.113
|
<p>I am finalizing the reverse-engineering of a linux driver for the <a href="https://rads.stackoverflow.com/amzn/click/com/B0083H4NG4" rel="nofollow noreferrer" rel="nofollow noreferrer">Perixx MX-2000 IIB</a> mouse. One of the features the mouse has is arbitrary button mapping. I can assign a button to produce various keys or mouse buttons. I have recorded a few button assignments available in the Windows driver, and figured out a few myself, but there doesn't seem to be a discernible (to me) pattern to map the whole address space.</p>
<p>The keys behave like this: Two bytes control a particular mouse button. I have learned a few keys and modifiers, and will post below. Setting the mouse button to the <em>hex value</em> gives me <em>keyboard output</em> when clicked. </p>
<p><strong>keyboard output</strong> | <strong>hex value</strong><br>
<kbd>a</kbd> | <code>0x0400</code><br>
<kbd>b</kbd> | <code>0x0500</code><br>
<kbd>c</kbd> | <code>0x0600</code><br>
...<br>
<kbd>z</kbd> | <code>0x1D00</code><br>
<kbd>1</kbd> | <code>0x1E00</code><br>
<kbd>2</kbd> | <code>0x1F00</code><br>
...<br>
<kbd>9</kbd> | <code>0x2600</code><br>
<kbd>0</kbd> | <code>0x2700</code><br>
<kbd>return</kbd> | <code>0x2800</code><br>
<kbd>esc</kbd> | <code>0x2900</code><br>
<kbd>backspace</kbd> | <code>0x2A00</code><br>
<kbd>tab</kbd> | <code>0x2B00</code><br>
<kbd>space</kbd> | <code>0x2C00</code><br>
...<br>
<kbd>Volume Up</kbd> | <code>0x8000</code> (XF86AudioRaiseVolume)<br>
<kbd>Volume Down</kbd> | <code>0x8100</code> (XF86AudioLowerVolume)<br>
... </p>
<p>I've mapped through <code>0x8A00</code> but will spare you the whole table. The interesting things are that thing like XF86 commands appear pretty early, like in <code>0x6F00</code> is XF86AudioMicMute, or <code>0x6600</code> is the power off key.</p>
<p>As for the least significant byte, part of that is modifiers, applied as a mask. <kbd>Ctl</kbd> is <code>(1 << 0)</code>, <kbd>shift</kbd> is <code>(1 << 1)</code>, <kbd>alt</kbd> is <code>(1 << 2)</code> and <kbd>super/meta/windows</kbd> is <code>(1<<3)</code>. So this way, <kbd>shift</kbd>+<kbd>a</kbd> (capital A) is <code>0x0402</code>. <kbd>Ctl</kbd>+<kbd>Alt</kbd>+<kbd>a</kbd> would be <code>0x0405</code>. All four modifiers give you <code>0x0F</code> for the least sig. byte. Playing around with the high nybble of the LSB, say with values like <code>0x0440</code> gives me more keys, like XF86Mute. So it seems the address space is massive.</p>
<p>On top of this, there are some keys from the windows driver that presented as an entirely different scheme.</p>
<p><strong>Output</strong> | <strong>hex value</strong><br>
<kbd>aMouse Scroll up</kbd> | <code>0x0143</code><br>
<kbd>Mouse Scroll down</kbd> | <code>0xFF43</code><br>
<kbd>WWW Search</kbd> | <code>0x2122</code><br>
<kbd>WWW Back</kbd> | <code>0x2422</code><br>
<kbd>WWW Forward</kbd> | <code>0x2522</code><br>
<kbd>Email</kbd> | <code>0x8A21</code><br>
<kbd>Internet Expl Back</kbd> | <code>0x8842</code> (presents as mouse button 8 in X11)<br>
<kbd>IE Forward</kbd> | <code>0x9042</code> (mouse button 9)<br>
<kbd>Calculator</kbd> | <code>0x9221</code><br>
<kbd>My Computer</kbd> | <code>0x9421</code><br>
<kbd>Mute</kbd> | <code>0xE220</code><br>
<kbd>Volume Up</kbd> | <code>0xE920</code><br>
<kbd>Volume Down</kbd> | <code>0xEA20</code> </p>
<p>And a few mouse buttons:</p>
<p><strong>output</strong> | <strong>hex</strong><br>
<kbd>Left Click</kbd> | <code>0x8142</code><br>
<kbd>Right Click</kbd> | <code>0x8242</code><br>
<kbd>Wheel Click</kbd> | <code>0x8442</code> </p>
<p>and finally, these are internal mouse commands. They don't register any events on my linux machine, but do change things in the mouse's internal settings</p>
<p><strong>action</strong> | <strong>hex</strong></p>
<p><kbd>Cycle DPI setting</kbd> | <code>0x034A</code><br>
<kbd>DPI increase</kbd> | <code>0x014A</code><br>
<kbd>DPI decrease</kbd> | <code>0x004A</code><br>
<kbd>Cycle mouse profile</kbd> | <code>0x074A</code><br>
<kbd>Profile Up</kbd> | <code>0x054A</code><br>
<kbd>Profile Down</kbd> | <code>0x044A</code> </p>
<p>And finally there is a special set that looks like <code>0x0a88</code> that point internally to macro memory.</p>
<p>I can't find any encoding schemes or keyboard mappings that might match this. Alphabetical keys? And If you notice, <kbd>volume up</kbd> is both <code>0x8000</code> and <code>0xE920</code> while <kbd>vol down</kbd> is both <code>0x8100</code> and <code>0xEA20</code>. So somewhat of a light at the end of the tunnel that there is a consistent distance between those. </p>
<p>But really, I can't figure out a standard mapping this matches. Or any way to figure out all the keys without manually fiddling with the memory and looping through <code>0x0000</code> to <code>0xFFFF</code> and clicking with <code>xev</code> each time.</p>
<p>Thoughts? is any of this familiar? or other patterns spotted?</p>
<p><strong>edit</strong>: All key information I've mapped so far is <a href="https://gist.github.com/pzl/94438a72f578b478a610" rel="nofollow noreferrer">in this gist</a> including <code>0x0000</code> through <code>0xFF00</code> (leaving LSByte <code>0x00</code>). So there is still a massive address space left. And it still makes no sense to me with the extra keys from the windows driver like <code>0x9421</code> = XF86Explorer</p>
|
Does anyone recognize this keyboard encoding scheme?
|
|encodings|driver|
|
<p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa366907%28v=vs.85%29.aspx" rel="nofollow">VirtualQueryEx()</a> fills a <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa366775%28v=vs.85%29.aspx" rel="nofollow">MEMORY_BASIC_INFORMATION</a> record with information about a contiguous range of pages containing the queried address. This can be used to walk the address space of a process, by starting with 0 and then using mbi.BaseAddress + mbi.RegionSize as the next address to query and so on. <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms683195%28v=vs.85%29.aspx" rel="nofollow">GetMappedFileName()</a> can give you the name of mapped binaries (mbi.Type == MEM_IMAGE) and mapped files (MEM_MAPPED).</p>
<p>Address overflow is an issue when a 32-bit process runs queries on a 64-bit process; it seems that VirtualQueryEx() fails to fail in that situation and instead saturates the field in question (by setting it to 0xFFFFFFFF). However, that is not documented and hence not reliable. Alternative tests are <code>mbi.RegionSize > DWORD_PTR(-1) - mbi.BaseAddress</code>, or <code>next_va <= curr_va</code> when iterating.</p>
<p>Results for 32-bit process querying 64-bit notepad.exe:</p>
<pre><code> 00000000 10000 -
00010000 00010000 10000 c m rw-- rw--
...
FF5F0000 FF5F0000 1000 c i rwxc r--- notepad.exe
FF5F0000 FF5F1000 B000 c i rwxc r-x-
FF5F0000 FF5FC000 4000 c i rwxc r---
FF5F0000 FF600000 2000 c i rwxc rw--
FF5F0000 FF602000 1000 c i rwxc rw-c
FF5F0000 FF603000 22000 c i rwxc r---
FF625000 FFFFFFFF -
overflow -> aborting
</code></pre>
<p>Dito for a 64-bit process:</p>
<pre><code> 0000000000000 10000 -
0000000010000 0000000010000 10000 c m rw-- rw--
...
00000FF5F0000 00000FF5F0000 1000 c i rwxc r--- notepad.exe
00000FF5F0000 00000FF5F1000 B000 c i rwxc r-x-
00000FF5F0000 00000FF5FC000 4000 c i rwxc r---
00000FF5F0000 00000FF600000 2000 c i rwxc rw--
00000FF5F0000 00000FF602000 1000 c i rwxc rw-c
00000FF5F0000 00000FF603000 22000 c i rwxc r---
00000FF625000 7FDFB2CB000 -
007FEFA8F0000 007FEFA8F0000 1000 c i rwxc r--- winspool.drv
...
007FFFFFE0000 007FFFFFE0000 10000 r r--- !---
</code></pre>
|
8297
|
2015-02-20T02:02:56.217
|
<p>I see that inspecting <code>/proc/self/maps</code> on Linux machines lets me see the pages that have been mapped in. As a result I can write a program to read and parse the pages it has mapped in.</p>
<p>How could one go about doing something similar for Windows? Are there any APIs for the same? If not, do you have any suggestions on how this could be done? Do you have any references you could link me to?</p>
|
/proc/self/maps equivalent on windows
|
|windows|linux|virtual-memory|pages|
|
<p>Yes, it is possible. The enum must be set to the 'bitfield' kind, and the bit masks must be set appropriately. Position the cursor on the enum name (in the Enums view) and hit Ctrl-N; in the lower left corner of the dialogue that appears there's a check box named "Bitfield".</p>
<p>If all values are independent then the bitmask for each value is the value itself; if there are sub fields that contain enumerated values then those must have the same mask. I don't know the exact details for HttpQueryInfo() so I'm using a mask of 0xFFFF for the enumerated part and assume that the upper 16 bits are independent flags. What you need is something like this:</p>
<pre><code>HTTP_QUERY_FLAG_REQUEST_HEADERS value 0x80000000 mask 0x80000000
HTTP_QUERY_CONTENT_TYPE value 1 mask 0x0000FFFF
...
HTTP_QUERY_CONNECTION value 23 mask 0x0000FFFF
HTTP_QUERY_ACCEPT value 24 mask 0x0000FFFF
...
</code></pre>
<p>However, it can be extremely difficult to modify an existing enum. You can't switch the enum to 'bitfield' if there are values that need masking ('blah is hindering' or some such rot), but if the enum isn't set to 'bitfield' then IDA doesn't let you set the masks for the enum members. Best to build a new enum from scratch.</p>
|
8300
|
2015-02-20T13:18:49.407
|
<p>Is there a way to modify the IDA decompiled source to reflect "OR"ed values of two or more enums?</p>
<p>For instance, I have the following enums,</p>
<pre><code>HTTP_QUERY_CONNECTION has the value 23 and
HTTP_QUERY_FLAG_REQUEST_HEADERS has the value 0x80000000
</code></pre>
<p>I would like to change the code which has the value 0x80000023 into</p>
<pre><code>HTTP_QUERY_CONNECTION | HTTP_QUERY_FLAG_REQUEST_HEADERS
</code></pre>
<p>Is that modification possible in IDA?</p>
|
Coalesce Enums in IDA?
|
|ida|decompilation|
|
<p>I downloaded the <a href="http://www.watlow.com/downloads/en/software/ezzone.cfm">EZ-ZONE Configurator</a> and reverse engineered it to see how it works.</p>
<p>The serial data you're seeing is actually the <a href="http://en.wikipedia.org/wiki/BACnet">BACnet</a> MS/TP (master-slave/token-passing) protocol. You can find the <a href="https://www.wireshark.org/">Wireshark</a> protocl decoder for it <a href="http://anonsvn.wireshark.org/wireshark/trunk/epan/dissectors/packet-mstp.c">here</a>. However, to save you the time, I'll help you get to the meat of calculating those check bytes.</p>
<p>In BACnet parlance, <code>55 FF</code> is called the "preamble", the first check byte is called the "Header CRC", the last two check bytes are called the "Data CRC", etc. For simplification though, let's call <code>b[]</code> your byte array: <code>b[0]</code> = <code>55</code>, <code>b[1]</code> = <code>FF</code>, etc.</p>
<p>The first check byte (a.k.a. "Header CRC") (<code>b[7]</code>) is calculated using the BACnet 8-bit CRC as follows.</p>
<p>We first define our CRC table:</p>
<pre><code>BYTE crc[256] =
{
0x00, 0xfe, 0xff, 0x01, 0xfd, 0x03, 0x02, 0xfc,
0xf9, 0x07, 0x06, 0xf8, 0x04, 0xfa, 0xfb, 0x05,
0xf1, 0x0f, 0x0e, 0xf0, 0x0c, 0xf2, 0xf3, 0x0d,
0x08, 0xf6, 0xf7, 0x09, 0xf5, 0x0b, 0x0a, 0xf4,
0xe1, 0x1f, 0x1e, 0xe0, 0x1c, 0xe2, 0xe3, 0x1d,
0x18, 0xe6, 0xe7, 0x19, 0xe5, 0x1b, 0x1a, 0xe4,
0x10, 0xee, 0xef, 0x11, 0xed, 0x13, 0x12, 0xec,
0xe9, 0x17, 0x16, 0xe8, 0x14, 0xea, 0xeb, 0x15,
0xc1, 0x3f, 0x3e, 0xc0, 0x3c, 0xc2, 0xc3, 0x3d,
0x38, 0xc6, 0xc7, 0x39, 0xc5, 0x3b, 0x3a, 0xc4,
0x30, 0xce, 0xcf, 0x31, 0xcd, 0x33, 0x32, 0xcc,
0xc9, 0x37, 0x36, 0xc8, 0x34, 0xca, 0xcb, 0x35,
0x20, 0xde, 0xdf, 0x21, 0xdd, 0x23, 0x22, 0xdc,
0xd9, 0x27, 0x26, 0xd8, 0x24, 0xda, 0xdb, 0x25,
0xd1, 0x2f, 0x2e, 0xd0, 0x2c, 0xd2, 0xd3, 0x2d,
0x28, 0xd6, 0xd7, 0x29, 0xd5, 0x2b, 0x2a, 0xd4,
0x81, 0x7f, 0x7e, 0x80, 0x7c, 0x82, 0x83, 0x7d,
0x78, 0x86, 0x87, 0x79, 0x85, 0x7b, 0x7a, 0x84,
0x70, 0x8e, 0x8f, 0x71, 0x8d, 0x73, 0x72, 0x8c,
0x89, 0x77, 0x76, 0x88, 0x74, 0x8a, 0x8b, 0x75,
0x60, 0x9e, 0x9f, 0x61, 0x9d, 0x63, 0x62, 0x9c,
0x99, 0x67, 0x66, 0x98, 0x64, 0x9a, 0x9b, 0x65,
0x91, 0x6f, 0x6e, 0x90, 0x6c, 0x92, 0x93, 0x6d,
0x68, 0x96, 0x97, 0x69, 0x95, 0x6b, 0x6a, 0x94,
0x40, 0xbe, 0xbf, 0x41, 0xbd, 0x43, 0x42, 0xbc,
0xb9, 0x47, 0x46, 0xb8, 0x44, 0xba, 0xbb, 0x45,
0xb1, 0x4f, 0x4e, 0xb0, 0x4c, 0xb2, 0xb3, 0x4d,
0x48, 0xb6, 0xb7, 0x49, 0xb5, 0x4b, 0x4a, 0xb4,
0xa1, 0x5f, 0x5e, 0xa0, 0x5c, 0xa2, 0xa3, 0x5d,
0x58, 0xa6, 0xa7, 0x59, 0xa5, 0x5b, 0x5a, 0xa4,
0x50, 0xae, 0xaf, 0x51, 0xad, 0x53, 0x52, 0xac,
0xa9, 0x57, 0x56, 0xa8, 0x54, 0xaa, 0xab, 0x55
};
</code></pre>
<p>And next we can calculate <code>b[7]</code>:</p>
<pre><code>b[7] = ~crc[b[6] ^ crc[b[5] ^ crc[b[4] ^ crc[b[3] ^ crc[~b[2]]]]]]
</code></pre>
<p>To calculate the value of the last two check bytes ("Data CRC"):</p>
<p>Perform a CRC-16 of the 6 bytes between the first check byte and the last two check bytes (in your first example, this would be the bytes <code>01 03 01 04 01 01</code>), with <code>0xFFFF</code> (<code>-1</code>) as the initial value for the CRC-16, and <code>0x8408</code> as the polynomial. Then bit-flip (a.k.a. "not", a.k.a. "invert") the result and read it in little-endian.</p>
|
8303
|
2015-02-20T21:45:49.160
|
<p>I am trying to reverse engineer a two wire RS-485 standard serial bus interface to talk to a <a href="https://www.watlow.com/products/controllers/ez-zone-pm-controller.cfm?famid=19" rel="noreferrer">Watlow EZ-Zone PM</a> of which I have not been able to find any documentation of the protocol. I have managed to figure out most of the hex commands except for the "check bytes" by sniffing the serial communications from the <a href="http://sine.ni.com/apps/utf8/niid_web_display.model_page?p_model_id=16725" rel="noreferrer">Labview driver</a> (which doesn't work for my particular application).</p>
<p><strong>I am having trouble figuring out the 3 check bytes. Any help is appreciated.</strong></p>
<p>Example hex command:</p>
<pre><code> Instance
Zone Parameter |
|| |---| ||
55 FF 05 10 00 00 06 E8 01 03 01 04 01 01 E3 99
^^ ^^ ^^
check byte check bytes
</code></pre>
<p>The first check byte only changes with the bytes before it:</p>
<pre><code>55 FF 05 10 00 00 06 E8 01 03 01 04 01 01 E3 99
55 FF 05 11 00 00 06 61 01 03 01 04 01 01 E3 99
55 FF 05 12 00 00 06 F9 01 03 01 04 01 01 E3 99
55 FF 05 13 00 00 06 70 01 03 01 04 01 01 E3 99
55 FF 05 14 00 00 06 CA 01 03 01 04 01 01 E3 99
</code></pre>
<p>The second two bytes only change with the bytes after the first check byte:</p>
<pre><code>55 FF 05 10 00 00 06 E8 01 03 01 04 01 01 E3 99
55 FF 05 10 00 00 06 E8 01 03 01 04 02 01 8B B3
55 FF 05 10 00 00 06 E8 01 03 01 04 03 01 53 AA
55 FF 05 10 00 00 06 E8 01 03 01 04 04 01 5B E7
55 FF 05 10 00 00 06 E8 01 03 01 04 05 01 83 FE
55 FF 05 10 00 00 06 E8 01 03 01 05 05 01 5F A4
55 FF 05 10 00 00 06 E8 01 03 01 06 05 01 3B 4B
55 FF 05 10 00 00 06 E8 01 03 01 07 05 01 E7 11
55 FF 05 10 00 00 06 E8 01 03 01 08 05 01 20 5B
55 FF 05 10 00 00 06 E8 01 03 01 09 05 01 FC 01
55 FF 05 10 00 00 06 E8 01 03 01 0A 05 01 98 EE
</code></pre>
<p>I did find reference to a CRC checksum in the Watlow Modbus documentation. However I have no idea what the polynomial is. Any ideas?</p>
|
RS-485 Checksum Reverse Engineering (Watlow EZ-Zone PM)
|
|hardware|serial-communication|
|
<p>Information about symbols resolved at link time, including the symbol name and memory address, can be acquired by by executing <code>ld</code> with the <code>-M</code> option plus the name of the object file to be linked:</p>
<pre><code>$ ld -M <OBJECT FILE>
</code></pre>
<p>This will result in a link map being printed to STDOUT. Of course, this output can also be redirected to a file:</p>
<pre><code>$ ld -M <OBJECT FILE> > <OUTPUT FILE>
</code></pre>
<p>The following description of the <code>-M</code> option is given in the <a href="http://man7.org/linux/man-pages/man1/ld.1.html" rel="nofollow noreferrer">manual page for ld(1)</a> as well as in <a href="https://sourceware.org/binutils/docs/ld/Options.html" rel="nofollow noreferrer">section 2.1 "Command Line Options"</a> in the <a href="https://sourceware.org/binutils/docs/ld/" rel="nofollow noreferrer">sourceware.org documentation of ld</a>: </p>
<blockquote>
<p>-M</p>
<p>--print-map</p>
<p>Print a link map to the standard output. A link map provides information about the link, including the following:</p>
<ul>
<li><p>Where object files are mapped into memory.</p></li>
<li><p>How common symbols are allocated.</p></li>
<li><p>All archive members included in the link, with a mention of the symbol which caused the archive member to be brought in.</p></li>
<li><p>The values assigned to symbols.</p>
<p>Note - symbols whose values are computed by an expression which involves a reference to a previous value of the same symbol may not have correct result displayed in the link map. This is because the linker discards intermediate results and only retains the final value of an expression. Under such circumstances the linker will display the final value enclosed by square brackets. Thus for example a linker script containing:</p>
<pre><code> foo = 1
foo = foo * 4
foo = foo + 8
</code></pre></li>
</ul>
<p>will produce the following output in the link map if the -M option is used:</p>
<pre><code> 0x00000001 foo = 0x1
[0x0000000c] foo = (foo * 0x4)
[0x0000000c] foo = (foo + 0x8)
</code></pre>
<p>See <a href="https://sourceware.org/binutils/docs/ld/Expressions.html#Expressions" rel="nofollow noreferrer">Expressions</a> for more information about expressions in linker scripts. </p>
</blockquote>
<p>Here is an example link map snippet for an i386 ELF32 object file:</p>
<pre><code><<= snip =>>
.plt.got
*(.plt.got)
.text 0x0000000008048074 0xa
*(.text.unlikely .text.*_unlikely .text.unlikely.*)
*(.text.exit .text.exit.*)
*(.text.startup .text.startup.*)
*(.text.hot .text.hot.*)
*(.text .stub .text.* .gnu.linkonce.t.*)
.text 0x0000000008048074 0xa test.o
0x0000000008048074 main
*(.gnu.warning)
.fini
*(SORT(.fini))
[!provide] PROVIDE (__etext, .)
[!provide] PROVIDE (_etext, .)
[!provide] PROVIDE (etext, .)
.rodata
*(.rodata .rodata.* .gnu.linkonce.r.*)
.rodata1
*(.rodata1)
.eh_frame_hdr
*(.eh_frame_hdr)
*(.eh_frame_entry .eh_frame_entry.*)
.eh_frame 0x0000000008048080 0x38
*(.eh_frame)
.eh_frame 0x0000000008048080 0x38 test.o
*(.eh_frame.*)
<<= snip =>>
</code></pre>
<p>If this is insufficient for your purposes and would like to manipulate the linker with a custom script, section "<a href="https://sourceware.org/binutils/docs/ld/Scripts.html#Scripts" rel="nofollow noreferrer">3: Linker Scripts</a>" at sourceware.org may be helpful. Some documentation of the Link Editor Command Language can also be found on page 524 in the <a href="http://tenox.net/docs/attunixpc/ATT_UnixPC_Model_7300_Unix_System_V_Programmers_Guide.pdf" rel="nofollow noreferrer">AT&T UNIX™ PC Model 7300 Unix System V Programmers Guide</a>.</p>
<p>More information can also be found in the <a href="https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=blob;f=ld/ld.texinfo" rel="nofollow noreferrer">ld.texinfo</a> file which is part of the <a href="https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;a=tree;f=ld" rel="nofollow noreferrer">source for <code>ld</code></a>. There is also a document called <a href="https://www.eecs.umich.edu/courses/eecs373/readings/Linker.pdf" rel="nofollow noreferrer">The GNU Linker</a>, which discusses linker scripts in 40 pages or so. </p>
|
8306
|
2015-02-21T01:53:05.350
|
<p>The test is on 32-bit Linux, x86. With <code>gcc</code> 4.6.3 and GNU <code>ld</code> 2.22.</p>
<p>So I am trying to get the information of "how many symbols are resolved by linker" during link time? And how can I list the information of all the resolved symbols? say, the symbol name, memory address. </p>
<p>I am thinking I should manipulate the linker to do so, but I have no idea how to do it. I have some experiences to fed linker with a link-script, but I didn't find anything related to resolved symbol information in the link-scripts..</p>
<p>Could anyone give me some help? I really appreciate that! Thank you!</p>
|
How to get the information of "how many and which symbols are resolved by linker"?
|
|c|elf|gcc|
|
<p>Okay, after a few more days I sort of have a solution.</p>
<p>First off, I still have absolutely no idea what the code is doing to cause the exception - this is what the only call to the function looks like (and I've made sure this is how the code gets there - the return address is the same):</p>
<p><img src="https://i.stack.imgur.com/K4lt8.png" alt="enter image description here"></p>
<p>No RaiseException, the trap flag is not set - I have no ideas what this means. Regardless, I was able to discard the exception in this way:</p>
<pre><code>LONG WINAPI VEH_Handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
{
printf("Got an exception %X at address %X\n", ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress);
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_SINGLE_STEP)
{
printf("patching trap flag\n");
__asm PUSHF
__asm POP EAX
__asm AND EAX, 0xFEFF
__asm PUSH EAX
__asm POPF
return EXCEPTION_CONTINUE_EXECUTION;
}
return EXCEPTION_CONTINUE_SEARCH;
}
</code></pre>
<p>It works, which I find somewhat amusing.</p>
|
8314
|
2015-02-22T17:11:48.393
|
<p>I'm reversing an application and I know for a fact it employs CRC checks, so if I modify the code, for instance hooking something, it'll be detected. The application uses a DLL which I replaced with my custom one and I'm trying to get around the CRC checks. The symptoms are, however, puzzling me. This is what happens if I modify the code and it gets detected:</p>
<p><img src="https://i.stack.imgur.com/xBw4G.png" alt="enter image description here"></p>
<p>However, it seems that the code at this address is just the start of some unrelated function:
<img src="https://i.stack.imgur.com/Y5VRN.png" alt="enter image description here"></p>
<p><br>
I find that a bit puzzling; I expected something like
<code>if (detected) RaiseException(EXCEPTION_SINGLE_STEP)</code>, and instead it simply "crashes" at the start of this function.</p>
<ul>
<li><strong>What does that mean?</strong></li>
<li><strong>Am I right in thinking that what we see in the first screenshot implies RaiseException must be deliberately called somewhere in the code?</strong></li>
</ul>
|
Single step exception at the beginning of an unrelated function
|
|exception|crc|
|
<p>I assume this is a follow-up on <a href="https://reverseengineering.stackexchange.com/questions/8314/single-step-exception-at-the-beginning-of-an-unrelated-function">this question</a>.</p>
<p>If the program you're injecting the DLL into is setting the processor's trap flag, then returning from the exception will restore the trap flag as well, which would explain why the trap exception is thrown again and windows will keep calling your exception handler.</p>
<p>You might check the stack, find where the pushed flags from the exception are saved, and clear the trap flag before returning (<code>*flagptr &= ~0x100</code>).</p>
<p>However, the fact that your application sets the trap flag in the first place might mean one of those two things:</p>
<ul>
<li>The application has detected that you're trying to crack it, and sets the trap flag to make it crash, or enter the debugger in an inconvenient way. It might do anything else to your program as well.</li>
<li>The application installs a trap exception handler, sets the trap flag, and has the trap handler modify the code that's being executed (25 years ago, i've seen this in a dos application, where the trap handler decrypted instructions just before they got executed, and re-encrypted them immediately afterwards, so you never saw the real assembly in a whole, so that's hardly a new technique).</li>
</ul>
<p>Both possibilities probably mean that just ignoring the traps won't help you much; you should find the code that sets the trap flag, check why it's doing this, and continue your analysis from there.</p>
|
8320
|
2015-02-23T12:09:57.990
|
<p>In a 3rd party application I'm modifying by means of DLL injection, there's a chunk of code that throws an EXCEPTION_SINGLE_STEP exception if it detects changes to the code. To bypass this countermeasure, I wish to catch that exception and discard it completely. However, Windows keeps rethrowing it and therefore my exception handler is stuck in an endless loop.</p>
<p>My code currently:</p>
<pre><code>LONG WINAPI VEH_Handler(struct _EXCEPTION_POINTERS *ExceptionInfo)
{
printf("Got an exception %X at address %X\n", ExceptionInfo->ExceptionRecord->ExceptionCode, ExceptionInfo->ExceptionRecord->ExceptionAddress);
if (ExceptionInfo->ExceptionRecord->ExceptionCode == EXCEPTION_SINGLE_STEP)
{
return EXCEPTION_CONTINUE_EXECUTION;
}
return EXCEPTION_CONTINUE_SEARCH;
}
//...
//in DllMain
AddVectoredExceptionHandler(1, VEH_Handler);
</code></pre>
<p><strong>Is there a way for me to force Windows to forget about the exception and continue execution?</strong></p>
|
Windows VEH - catch and discard a single step exception
|
|windows|exception|
|
<p>Do a function tracing like this:</p>
<ol>
<li>set a breakpoint at the main function and at your target function</li>
<li>start debugging</li>
<li>when the process is halted: Go to Debugger->Tracing->Function Tracing</li>
<li>continue Process</li>
<li>once the process is halted again, go to Debugger->Tracing->Tracing Window and check for the info you need.</li>
</ol>
<p>If this does not give you the needed info try basic block or instruction tracing. This will work even if there is a problem with identifying functions / the stack frame ...</p>
<p>More info on the tracing feature can be found here: <a href="https://www.hex-rays.com/products/ida/support/tutorials/tracing.pdf" rel="noreferrer">hex-rays tutorial on tracing</a></p>
|
8324
|
2015-02-23T19:45:34.207
|
<p>I have breakpoint in function 'A', but 'A' can be called by functions 'B' and 'C'. When a breakpoint is hit, i'd like to know what called 'A' in the first place. Is there something like a function call stack?</p>
<p>I have found 'debugger->tracing->stack trace' option, but when i press it after breakpoint is hit, it only shows this, which doesnt make any sense:
<img src="https://i.stack.imgur.com/pHQbr.png" alt="enter image description here"></p>
|
How to find which function called the one currently being executed in IDA?
|
|ida|
|
<p>After some research I think that I can add some explanations from a theoretical perspective. Note that my discussion is restricted to stripped (no debug information) executables. We know that several kinds of data can be mixed with code in executables including padding bytes and <strong>switch</strong> jump address calculations. </p>
<p>In order to separate date from code we need to <em>precisely</em> extract the bytes that belong to the code and by that we can assume that the rest of the bytes belong to data. The main challenge in <em>precisely</em> extracting code starting from a well-known entry point is indirect jumps i.e. control flow redirection to memory addresses that are computed at run-time. DarthZirka mentioned a few examples including switch tables, function pointers, and vtables in C++.</p>
<p>An analysis that can precisely solve indirect jumps statically (without running the program) can also solve the halting problem which is known to be undecidable. This result has been established since late 70's when work on disassembly started to gain ground in Academia, I can refer to the following early paper for further details.</p>
<blockquote>
<p>R.N. Horspool and N. Marovac. <strong>An approach to the problem
of detranslation of computer programs</strong>. The Computer
Journal, 23(3):223-229, 1979.</p>
</blockquote>
<p>Based on that, the problem of precisely determining addresses of indirect jumps is also undecidable in general. Therefore, <strong>any</strong> approach to disassembly shall be based on heuristics like recognizing common compiler idioms and/or over(under) approximating the set of addresses reachable from an indirect jump. The later is usually done by static analysis based on the framework of abstract interpretation. Variable size instructions in X86 can make things harder (a more loose overapproximation) compared to ARM but the essential problem still exists. </p>
|
8328
|
2015-02-24T12:30:19.393
|
<p>I'm interested in formal verification of software at binary code level. Obviously, the first step would be to recover the actual assembly instructions from binaries.</p>
<p>IDAPro can do a pretty good job at disassembly of x86, however, it is still possible that some data can be interpreted as code. Therefore an analysis based on in it is still unsound.</p>
<p>Given that: </p>
<ul>
<li>Software in my application domain is not obfuscated and not self-modifying,</li>
<li>and ARM instructions are less variable than x86 (2 or 4 bytes length).</li>
</ul>
<p>Can the disassembly of ARM binaries be sound? In other words, can disassemblers recover the actual code precisely?</p>
|
Soundness of ARM disassembly
|
|disassembly|arm|
|
<blockquote>
<p>I can only definitely recognize code sections by looking if the
<code>IMAGE_SCN_MEM_EXECUTE</code> flag is set, as other sections should not have
this flag set.</p>
</blockquote>
<p>The presence of this flag doesn't "definitely" mean that that section contains code, and the absence of this flag doesn't "definitely" mean that that section doesn't contain code:</p>
<ul>
<li>A PE file can have that flag on a non-code (data) section and still run fine (though this is not advisable from a security perspective).</li>
<li>A PE file can have that flag missing from an actual code section, assuming that the operating system does not have <a href="http://en.wikipedia.org/wiki/Data_Execution_Prevention">DEP</a> enabled and/or other code changes the memory protection of that section at runtime to make it executable.</li>
</ul>
<blockquote>
<p>But how could I, for example, recognize the resource directory?</p>
</blockquote>
<p>The only reliable way to find the resource directory is via the <code>IMAGE_DIRECTORY_ENTRY_RESOURCE</code> entry in the PE file's <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms680305%28v=vs.85%29.aspx"><code>IMAGE_DATA_DIRECTORY</code></a>.</p>
|
8350
|
2015-02-28T17:27:26.677
|
<p>I was recently working with the <a href="https://msdn.microsoft.com/en-us/windows/hardware/gg463119.aspx" rel="noreferrer">Microsoft documentation about the PE and COFF specifications</a>.</p>
<p>Chapter 5 shows several more or less "soft" indicators and characteristics to recognize what kind of stuff a section contains. However, the section characteristics flag is often the same for several different sections, and as I have read, the section name can be of arbitrary value, so it is not a big help too.</p>
<p>Actually, I can only definitely recognize code sections by looking if the <code>IMAGE_SCN_MEM_EXECUTE</code> flag is set, as other sections should not have this flag set.</p>
<p>But how could I, for example, recognize the resource directory? It only has <code>IMAGE_SCN_CNT_INITIALIZED_DATA</code> or <code>IMAGE_SCN_MEM_READ</code> set, and many other sections have the same flag.</p>
<p>Do I have to evaluate with some made-up and typical section names (<code>RSRC</code> or <code>.rsrc</code> for this example)? It will mean that I may get tricked out by custom section names. Do I even have to try-and-error analyzation of section data to get a more definite result of what the section contains?</p>
<p>Or is there a flag somewhere in the PE headers I skipped, helping me out in this case?</p>
|
What is an indicator that a PE section definitely contains stuff of a specific type?
|
|windows|pe|file-format|executable|
|
<p>I think I got the answer from :
<a href="https://stackoverflow.com/questions/89607/what-is-a-privileged-instruction">https://stackoverflow.com/questions/89607/what-is-a-privileged-instruction</a></p>
<p>Summary of the answers in that post :</p>
<p>The cause is probably a corrupted stack or a messed up function pointer call ,this usually happens when using function pointers that point to invalid data. It can also happen if you have code that trashes your return stack or if you are using old compilers/libraries.</p>
<p>The guy who programmed the exe may be using a local array and it is near the top of the function declaration. His bounds checking may have gone insane and overwritten the return address and it points to some instruction that only kernel is allowed to execute.</p>
|
8351
|
2015-02-28T10:03:42.770
|
<p>I am reversing a file which is not running properly in Vmware.The code from the AEP is as shown below :</p>
<pre><code>POP EDI ; value of edi is 0x7C816D4F kernel32.7C816D4F
PUSH EAX ;value of eax is 0
INC EBP ;value of ebp was 0x12FFF0
IN EAX,DX ;value of DX is 0xEB94
AAS
IN AL,0BF
DEC ESP
</code></pre>
<p>What I think is that a privileged instruction(IN) is called from user mode which is not allowed and therefore execution fails.
IN is used for anti VM code but it requires specific values (VMXh port value in EAX etc) but in my case it is not being used.</p>
<p>My question is ,is it some kind of anti debugging or is the file corrupt and will it run on a non VM machine(in my case XP).</p>
<p>And lastly,if a packer uses the method I mentioned above ie calling IN from usermode for Anti-reversing how come the sample runs on a real machine(since in this case also the privileged instruction will be called in user mode).</p>
|
Will this code run in real machine or is it some kind of Anti Reversing code?
|
|malware|debugging|x86|
|
<p>No scripting required.</p>
<p>In OllyDbg's disassembly window, left-click on line <code>.text:00403855 32 C3 xor al, bl</code> to select the line, then right-click on the selected line and choose <code>Breakpoint → Conditional log...</code>.</p>
<p>In the breakpoint dialog box that opens up, use the following options:</p>
<p><img src="https://i.stack.imgur.com/jRcz0.png" alt="Conditional log"></p>
<p>Press <kbd>OK</kbd>, run the program, and every time <code>.text:00403855 32 C3 xor al, bl</code> is executed, OllyDbg will print the values of <code>al</code> and <code>bl</code> to the log window.</p>
|
8369
|
2015-03-03T15:28:23.607
|
<p>I'm currently reversing a function which looks like the following</p>
<pre><code>.text:0040383F 8D 04 BF lea eax, [edi+edi*4]
.text:00403842 6A 14 push 20
.text:00403844 C1 E0 03 shl eax, 3
.text:00403847 99 cdq
.text:00403848 59 pop ecx
.text:00403849 F7 F9 idiv ecx
.text:0040384B 03 45 08 add eax, [ebp+arg_0]
.text:0040384E 8A 84 30 C8 31 00+mov al, [eax+esi+31C8h]
.text:00403855 32 C3 xor al, bl
.text:00403857 88 84 3E 28 27 00+mov [esi+edi+2728h], al
.text:0040385E 47 inc edi
.text:0040385F 81 FF 07 0B 00 00 cmp edi, 0B07h
.text:00403865 75 D8 jnz short loc_40
</code></pre>
<p>Since I don't have any clue what's going there I wanted to Debug this part with OllyDbg. I want to understand what's inside <strong>al</strong>, <strong>bl</strong> and the result of <strong>xor al, bl</strong> for all "<strong>0B07h</strong>" steps the loop is running.</p>
<p>I just saw that Immunity provides some sort of scripting functionality. Is it possible to achieve this with a simple python script in Immunity? Maybe there are other ways with OllyDbg?</p>
<p>I just want something like:</p>
<pre><code>If EIP == "403855" then print al, bl
Else go_ahead
</code></pre>
|
How to efficiently debug Loops with OllyDbg/Immunity?
|
|ollydbg|debugging|immunity-debugger|xor|
|
<p>This question is a bit broad, since it's not asking about a specific program, or a specific network packet you found. A better question would probably be "I have a program that sends network packets, but dumping the packets with wireshark doesn't produce anything readable. I assume the application is encrypting the packets, how can i investigate this"?</p>
<p>You say "Logically any program that sends or receives packets must have the encryption scheme used". This isn't true - your Web browser, FTP client, and many other programs send everything unencrypted. Unless you're using https in your browser, of course, and there's a lot of documentation about how that works.</p>
<p>So, let's assume you have a program, dump the network packets, and assume they're encrypted. So you'd like to know if there's any encryption code in your application. This is what <a href="http://aluigi.altervista.org/mytoolz.htm" rel="nofollow">signsrch</a> is for; it detects if your program contains any constants that are used in standard encryption schemes like AES.</p>
<p>Next, you'll want a debugger like <a href="http://www.ollydbg.de/" rel="nofollow">Ollydbg</a>, or even <a href="https://www.hex-rays.com/products/ida/support/download_freeware.shtml" rel="nofollow">IDA Pro</a>, to further analyze the program. There are tons of tutorials out there that show how to use them. However, i won't recommend a specific one, since what is good for you depends very much on how much you know already - any recommendation would be very opinion-based, and we don't like opinion based answers on Stackexchange.</p>
|
8371
|
2015-03-03T17:01:31.150
|
<p>I've been playing around with recording packets being sent to and from applications on my pc.</p>
<p>Logically any program that sends or receives packets must have the encryption scheme used. So I'd like to try and find this in the code of a test application.</p>
<p>Can anyone advise on how to go about doing this? I unsure as to how to identify what lines of code are being called when, and even if I new this I can know exactly when the packets are created exactly. Any link to helpful software, tutorials etc. would be great!</p>
<p>P.S. First time asking on this site, let me know if/how I can improve the question.</p>
|
How to locate the code used for encryption
|
|decompilation|decryption|
|
<p>Last time I worked with .img file it was image of qnx6 file system.
I using linux with installed qnx6 drivers, so mount -t qnx6 works for me.</p>
<p>In addition you can download QNX sample virtual machine from qnx.com/download/index.html ,run it, mount img using standard qnx command line tools and scp it outside.</p>
|
8372
|
2015-03-03T18:06:06.727
|
<p>I am currently investigating firmware of an embedded system (car navigation) and have identified the OS as QNX.</p>
<p>The firmware has .ifs files which I was able to extract/unpack using QNX <a href="http://www.qnx.com/developers/docs/660/index.jsp?topic=%2Fcom.qnx.doc.neutrino.user_guide%2Ftopic%2Ffiles_FILEEXTENSIONS.html" rel="nofollow noreferrer">dumpifs</a> tool and .img files. The .img files do not appear to be compressed, is there a file format or dump tool for QNX .img files?</p>
<p>/edit: some extra information
file -sL file.img reports <code>x86 boot sector</code>
Mount attempt in Ubuntu <code>mount -t qnx6 ./file.img -o loop/dev/loop1,blocksize=512 /media/qnx</code> fails with wrong fs type, bad option, bad superblock on /dev/loop1</p>
<p>dmesg reports <code>qnx4: wrong fsid in superblock</code> or <code>qnx6: invalid mount operation</code></p>
<p><code>cat /proc/filesystems</code> reports both qnx4 and qnx6</p>
|
Unpack QNX .img files
|
|qnx|
|
<p><em>This answer was originally added by me as an edit to my question, I have now separated it from there:</em></p>
<p>Thanks to Guntrams accepted answer, I found out where my brain was faulty. This is how it really is:</p>
<ul>
<li>The ordinal of each exported address is simply the index in the export address array (plus the ordinal base specified in the export directory table however, which <em>may</em> make it differ from simple indices. And that is often the case since ordinals usually start at 1 according to the documentation).</li>
<li>Some exports have names, and these names are mapped to the export address array with an ordinal, which in turn is the index to the export address array.</li>
<li>Since some exports have no names, the ordinal is not explicitly specified in the ordinal array, because it would make no sense to map "no name" to an export.</li>
</ul>
<p>My C# code does it like this, for reference - the output is the same like the one in Dependency Walker:</p>
<pre><code>private void ReadExportTables(
PEFile peFile,
BinaryReader reader,
DataDirectoryHeader header)
{
// Read export address table which contains RVAs to exported code or forwarder names.
ExportEntry[] exportEntries = new ExportEntry[EntryCount];
reader.BaseStream.Seek(peFile.GetFileOffset(CodeAddressTableRva), SeekOrigin.Begin);
for (int i = 0; i < exportEntries.Length; i++)
{
exportEntries[i].Ordinal = (ushort)(i + OrdinalStartNumber);
exportEntries[i].CodeOrForwarderRva = reader.ReadUInt32();
}
// Read ordinal table containing indices (with base) to named entries in export entry table.
reader.BaseStream.Seek(peFile.GetFileOffset(OrdinalTableRva), SeekOrigin.Begin);
uint[] ordinals = new uint[NameEntryCount];
for (int i = 0; i < ordinals.Length; i++)
{
// Get name for ordinal, which has the same index as the ordinal array element.
ordinals[i] = reader.ReadUInt16();
}
// Read the export name pointer table which contains pointers to names of exports.
reader.BaseStream.Seek(peFile.GetFileOffset(NameAddressTableRva), SeekOrigin.Begin);
for (int i = 0; i < ordinals.Length; i++)
{
exportEntries[ordinals[i]].Hint = i;
exportEntries[ordinals[i]].NameRva = reader.ReadUInt32();
}
// Read the names of the exports or forwarders.
for (int i = 0; i < exportEntries.Length; i++)
{
if (exportEntries[i].NameRva > 0)
{
reader.BaseStream.Seek(peFile.GetFileOffset(
exportEntries[i].NameRva),
SeekOrigin.Begin);
exportEntries[i].Name = reader.Read0AsciiString();
}
// Check if forwarder export (RVA points within export directory to forwarder name).
if (exportEntries[i].CodeOrForwarderRva >= header.Rva
&& exportEntries[i].CodeOrForwarderRva < header.Rva + header.Size)
{
reader.BaseStream.Seek(
peFile.GetFileOffset(exportEntries[i].CodeOrForwarderRva),
SeekOrigin.Begin);
exportEntries[i].ForwarderName = reader.Read0AsciiString();
}
}
}
</code></pre>
<p>In case you wondered: There can still be completely empty exports, with a code address of 0, no name and thus not forwarded. Just sort these out when displaying your exports.</p>
|
8379
|
2015-03-04T13:01:10.817
|
<p>I don't understand one thing in the export data directory of PE files.</p>
<p>The documentation says that there is a set count of exports (let's name it <code>ExportCount</code>, first row of following table) and another count of names/ordinals (name it <code>NameCount</code>, second row in following table). I read it like that the count of export names is the same as the ordinal indices count. At least that's what <a href="https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#export-directory-table" rel="nofollow noreferrer">their documentation</a> says:</p>
<p><img src="https://i.stack.imgur.com/KcSxK.png" alt="Microsoft Documentation" /></p>
<p>I tried parsing a Win8.1.1 x64 Shell32.dll, and I get different results compared to Dependency Walker. I have 933 as <code>ExportCount</code> and 354 as <code>NameCount</code>. So there should be 933 exports in total, with only 354 having an ordinal and/or name. Don't ask me how you would import the remaining 579 exports, as that's what I don't understand.</p>
<p>If I open Shell32 in Dependency Walker, it first lists <code>NameCount</code> exports with a name and ordinal, but then it shows the remaining amount of <code>ExportCount - NameCount</code> exports which surprisingly <em>do</em> have ordinals (starting at the blue line here):</p>
<p><img src="https://i.stack.imgur.com/rKVrl.png" alt="Dependency Walker" /></p>
<p>To me, this doesn't make any sense according to the documentation. I tried to read <code>ExportCount</code> ordinals instead of only <code>NameCount</code> ones in sequence, but only rubbish comes out.</p>
<p>So my questions are:</p>
<ul>
<li>Is the documentation wrong / incomplete?</li>
<li>Am I understanding something wrong in the documentation?</li>
<li>How to get the remaining ordinals like Dependency Walker does it?</li>
</ul>
|
Are there exports with neither ordinal nor name or am I not understanding the PE documentation?
|
|windows|pe|file-format|executable|
|
<p>Masm uses 0 and 1 as the address constants is: you told it to do so because you told it to use the offset in the structure, NOT the memory location. And indeed, the field "first" sits at offset 0 and occupies a byte. This makes the offset for "second" equal to 1.
You probably wanted to access the <strong>instantiation</strong> of your structure, which you placed at the address called Initializedstructure. In this case, you would have to use</p>
<pre><code>mov eax, [Initializedstructure].First
</code></pre>
<p>to access the field "first" of that Initializedstructure.
And, by the way, should you try to access such structures using vector instructions (SSE, AVX), Masm frequently looses it altogether and you need to additionally specify the operand size, such as</p>
<pre><code>vmovdqu xmm0, xmmword ptr [Initializedstructure].Some128bitField
</code></pre>
<p>Hope it helps.</p>
|
8382
|
2015-03-04T19:03:09.403
|
<p>I'm trying to create a demo program demonstrating struct(s) in MASM ,</p>
<p>I've written a code like this :</p>
<pre><code>struct1 struct
first db ?
second dw ?
struct1 EndS
.386
.model flat,stdcall
option casemap:none
include \masm32\include\windows.inc ; holds predifned structures
include \masm32\include\kernel32.inc
include \masm32\include\user32.inc
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\user32.lib
.data
MessageTitle db "The title",0
MessageText db "The first program which shows simple messagebox",0
.code
start:
Initializedstructure struct1 <'A',1024>
;invoke MessageBox, NULL, addr MessageText, addr MessageTitle, MB_OK
mov eax, struct1.first
;invoke ExitProcess, NULL
end start
</code></pre>
<p>but when I disassembled the program I found some kind of instructions that
not sensible for initializing the structure of the program :</p>
<pre><code>.text:00401000 start:
.text:00401000 inc ecx
.text:00401001 add [eax+edi*4], al
.text:00401001 ; ---------------------------------------------------------------------------
.text:00401004 dd 7Fh dup(0)
.text:00401200 dd 380h dup(?)
.text:00401200 _text ends
</code></pre>
<p>Why MASM assembled the code like this ? I think I've made some mistake in the code,haven't I? I think there's no well-explained document about it ...</p>
|
Initializing a struct in win32 assembly programming using MASM
|
|windows|disassemblers|struct|
|
<p>This is the "stolen bytes" technique, where the first few bytes of the function are copied to a remote location and executed from there, then the original function is called from the location after the bytes that were copied.</p>
<p>The purpose of skipping the first few bytes of the function allows you to call the function body without being "detected". That is, any code which detoured the function at exactly the start would be bypassed.</p>
<p>In your example, the EBP manipulation is meaningless. Those instructions exist in the original function in order to provide a familiar signature for routines that, for example, detour the code (but which is presumably broken by also including the hot-patching support). Note that the POP instruction did not exist in that location before Windows 7, with the introduction of the kernelbase.dll. Previously, the real function body would have followed the MOV instruction.</p>
|
8384
|
2015-03-04T22:01:56.210
|
<p>Someone said to do something like this to avoid scans for WPM calls: </p>
<pre><code>__declspec(naked) BOOL WINAPI SafeWriteProcessMemory(HANDLE hProcess,
LPCVOID lpBaseAddress, LPVOID lpBuffer, SIZE_T nSize,
SIZE_T *lpNumberOfBytesRead)
{
__asm
{
mov edi, edi
push ebp
mov ebp, esp
pop ebp
mov eax, WriteProcessMemory
add eax, 6
jmp eax
}
}
</code></pre>
<p>I put it in a program and debugged it in olly. I looked at <code>kernel32.WriteProcessMemory</code>. We're using the <code>add eax, 6</code> to jump from here:</p>
<pre><code>MOV EDI,EDI ; BOOL kernel32.WriteProcessMemory(hProcess, ...)
PUSH EBP
MOV EBP,ESP
POP EBP
JMP <JMP.&API-MS-Win-Core-Memory-L1-1-0. ; Jump to KERNELBASE.WriteProcessMemory
</code></pre>
<p>To there. Effectively skipping over the instructions between the two. We're executing those instructions in our own call. But I don't understand why those instructions are being executed. We're pushing <code>EBP</code> onto the stack, moving <code>ESP</code> into <code>EBP</code>, then restoring <code>EBP</code> from the stack. That shouldn't actually be doing anything.</p>
<p>I debugged it instruction-by-instruction, and still can't figure out why it's being done.</p>
<p>Does it have something to do with Windows' useless <code>mov edi,edi</code>s at the beginning of functions to allow jump patching?</p>
|
Why does WriteProcessMemory in kernel32.dll do this? (ASM)
|
|windows|assembly|
|
<p>This depends a bit on your compiler, Actually, as you seem to be using a 32 bit OS, i wouldn't expect any far calls.</p>
<p>Near calls and Far calls are relicts from 16-bit area, where a call within the same 64 kbyte segment, that only changes <code>IP</code>, but not <code>CS</code>, was named a <code>near call</code>, and a call to anywhere in the address space, that changes <code>CS</code> <em>and</em> <code>IP</code>, was named a <code>far call</code>. Correspondingly, there were two different instructions <code>ret</code> and <code>retf</code> to return from the subroutine, that would pop just <code>IP</code>, or <code>CS</code> and <code>IP</code> from the stack.</p>
<p>With the introduction of protected mode, and 32 bit segments, management of segment registers became the responsibility of the operating system, and user mode programs stopped fiddling with them. So you shouldn't see any far calls, or <code>retf</code> instructions, anymore - unless you're disassembling the parts of the operating system that handle task switching, possibly.</p>
<p>You might see the occasional jump to a function, however (ref type 19), depending on your compiler. If the compiler optimizes tail recursion, it will replace the last "call self / ret" instruction with a "jmp self" instruction, and if parameter types match, it might replace a "call someotherfunction / ret" with "jmp someotherfunction" as well. I've seen this a lot in ARM code, and 64 bit Intel code, but can't remember seeing it in 32 bit compiled Intel code at the moment. However, i haven't worked with 32 bit Intel assembly much, recently, so there might be some newer compilers that do this without me noticing.</p>
|
8397
|
2015-03-06T10:55:28.563
|
<p>Given a disassembly line in IDA Pro such as</p>
<pre><code>.text:0040255B call sub_407C10
</code></pre>
<p>Am I right to assume that analyzing the belonging address using</p>
<pre><code>idautils.XrefsFrom(0x0040255B)
</code></pre>
<p>always returns an xref of type 'Code_Far_Call' (xref.type 16) or 'Code_Near_Call' (xref.type 17)
and not
an xref of type "Code_Near_Jump" or "Code_Far_Jump"?</p>
<p>In other words, can function call destination addresses always be identified by checking if the xref.type is of type 16 or 17 and then taking the value in xref.to?</p>
<p>Of course in addition to the Call/Jump xref, the above statement always returns an xref of type 21 (the ordinary control flow).</p>
<p>A list of possible xref types can be found here: <a href="https://code.google.com/p/idapython/source/browse/trunk/python/idautils.py" rel="nofollow">https://code.google.com/p/idapython/source/browse/trunk/python/idautils.py</a></p>
<p>What is the difference between a Code_Far_Call xref and a Code_Near_Call xref anyway?</p>
<p>Thanks for your help!</p>
|
Function calls: xref.type always 'Code_Far_Call' or 'Code_Near_Call'?
|
|ida|disassembly|assembly|idapython|python|
|
<p>As I'm working with the malware samples provided by <a href="https://www.kaggle.com/c/malware-classification/data" rel="nofollow noreferrer">kaggle</a> too, I faced the same problem. I found a solution by the processing in two steps, which extracts all the <code>mnemonics</code> used in the complete set.</p>
<p><strong><em>Note:</strong> As I'm not finished with my work yet, I'm not able to post the full script. The real implementation is realized with threading and the process takes roughly one hour for all 9 families. Addtionally the solution is not perfect and with good performance - rather a dirty fix.</em></p>
<hr>
<p><strong>1. Step:</strong> Roughly cleaning the <code>IDA</code> listing format of an <code>INPUT.ASM</code> into an <code>OUTPUT.ASM</code> (extraction from my script; see the discussion for this step <a href="https://reverseengineering.stackexchange.com/questions/13192/convert-ida-listings-to-assembly-without-using-ida-non-free">here</a>)</p>
<p><strong><em>Note:</strong> It should be mentioned that ignore <code>dd</code> like instructions. Additionally I keep the subroutines and basic blocks delimeted by <code>====</code> and <code>-----</code>.</em></p>
<pre>
grep -E '^.text:*' INPUT.ASM | grep -v align | grep -E '^.{10,15}[0-9A-F]{2} *|=======================|-----------------------------------' | sed 's/\t/ /g' | grep -v ' dq ' | grep -v ' dd ' | grep -v ' db ' | grep -v ' dw ' | cut -c100-200 | sed -e 's/^[ \t]*//' | tr -s [:blank:] | cut -d ';' -f1 > OUTPUT1.ASM
</pre>
<hr>
<p><strong>2. Step:</strong> Process the cleaned <code>OUTPUT.ASM</code> in python (extraction from my script)</p>
<pre>
#!/usr/bin/python
mneLocal = set()
with open('OUTPUT.ASM') as oFile:
for line in oFile.readlines():
mne = line.split(" ")[0]
if mne[0] != '-' and mne[0] != '=' and len(mne)≤6 and not mne[0].isdigit() and mne.islower():
mneLocal.add(mne)
print(mneLocal)
</pre>
<hr>
<p><strong>3. Output:</strong> Applied on the <code>Ramnit</code> dataset</p>
<pre>
set(['jns', 'fbstp', 'jnp', 'rol', 'psrlw', 'fld1', 'jnz', 'movd', 'imul', 'lds', 'jnb', 'psrlq', 'cdq', 'psrld', 'pand', 'pfmax', 'ror', 'fxch', 'jno', 'dt', 'fisub', 'movq', 'cmps', 'arpl', 'pi2fd', 'pfmin', 'cld', 'nop', 'pf2id', 'maxss', 'add', 'jcxz', 'adc', 'fadd', 'pf2iw', 'fistp', 'setbe', 'aad', 'maxps', 'fmulp', 'movzx', 'fdivp', 'fdivr', 'femms', 'not', 'repe', 'cmc\r\n', 'svts', 'repne', 'shr', 'pfadd', 'sgdt', 'mulps', 'leave', 'div', 'mulpd', 'shl', 'btc', 'cmp', 'rcpps', 'psubd', 'psubb', 'bts', 'btr', 'loope', 'jle', 'pandn', 'fist', 'out', 'fstcw', 'cbw\r\n', 'xor', 'sub', 'neg', 'rep', 'lddqu', 'jge', 'movs', 'pfrcp', 'fdiv', 'jecxz', 'xchg', 'mul', 'pavgb', 'lea', 'ficom', 'pfsub', 'jz', 'addpd', 'jp', 'subsd', 'js', 'bt', 'fidiv', 'daa\r\n', 'jo', 'clc\r\n', 'lods', 'jg', 'ja', 'jb', 'addps', 'jl', 'cmovz', 'movsd', 'cld\r\n', 'xorpd', 'les', 'cmovl', 'subss', 'movsx', 'xlat', 'cmova', 'cmovb', 'nop\r\n', 'sbb', 'or', 'cmovg', 'shrd', 'fsub', 'por', 'bound', 'pop', 'setnb', 'fmul', 'pabsw', 'subps', 'minsd', 'minss', 'sti\r\n', 'xadd', 'cdq\r\n', 'setnl', 'retf', 'faddp', 'retn', 'rcr', 'rcl', 'pslld', 'call', 'setnz', 'das\r\n', 'aas\r\n', 'setns', 'setnp', 'sldt', 'ptest', 'fcomi', 'divps', 'jmp', 'rcpss', 'ffree', 'lgdt', 'pfacc', 'utes', 'shld', 'fcomp', 'fsave', 'psraw', 'aam', 'subpd', 'fstsw', 'psrad', 'pxor', 'fsubp', 'fsubr', 'fldcw', 'dec', 'fld', 'loop', 'and', 'addsd', 'cmovs', 'fldz', 'psubq', 'sal', 'int', 'lock', 'andpd', 'in', 'fucom', 'ud2\r\n', 'addss', 'fild', 'sar', 'scas', 'psllw', 'andps', 'bswap', 'inc', 'mulss', 'paddd', 'std\r\n', 'paddb', 'psubw', 'stc\r\n', 'idiv', 'psllq', 'paddw', 'cli\r\n', 'mulsd', 'paddq', 'test', 'setp', 'fiadd', 'hnt', 'orpd', 'enter', 'minps', 'bsr', 'mov', 'orps', 'fstp', 'xorps', 'setle', 'bsf', 'fo', 'pfmul', 'movss', 'setb', 'aaa\r\n', 'setl', 'divsd', 'fimul', 'seto', 'fcom', 'hlt\r\n', 'jbe', 'fst', 'divss', 'sets', 'push', 'pavgw', 'setz'])
</pre>
|
8400
|
2015-03-06T18:06:29.720
|
<p>I have ~20,000 .asm files from IDA pro output via hex-rays.</p>
<p>These were all created from known malware, and all from 32bit Windows Portable Executables.</p>
<p>I <strong>do not</strong> have the original executables, just the disassembled output(.asm) files. </p>
<ul>
<li><p>What I am trying to obtain is a list of any possible mnemonics (i.e. add, xor, jump, etc..) ,that IDA could output into an .asm file</p>
<p>With this list I will be attempting a machine learning/ malware classification task using grep (or similar) to compile statistics.</p></li>
</ul>
<p>Inspecting them visually I have hand crafted a list of 30 or so ( jmp, push,mov, call, lea.. etc etc) with help from this site, which list common instructions <a href="http://www.strchr.com/x86_machine_code_statistics" rel="nofollow noreferrer">http://www.strchr.com/x86_machine_code_statistics</a>.</p>
<p>Are there any clues in the headers of these files which could assist in defining possible mnemonics ? Are these consistent across platforms or specific to some attribute of the original file?</p>
<p>I searched IDA pros documentation, and it seem all the functionality for this is available during the disassembling process, but I am stuck with the .asm files to parse.</p>
<p>similar questions with no help.</p>
<p><a href="https://reverseengineering.stackexchange.com/questions/2632/parsing-ida-pro-asm-files">Parsing IDA Pro .asm files</a></p>
<p><a href="https://reverseengineering.stackexchange.com/questions/2493/ida-pro-list-of-functions-with-instruction">IDA Pro List of Functions with Instruction</a></p>
<p><strong><em>sample .asm Header</em></strong></p>
<pre><code> ;
; +-------------------------------------------------------------------------+
; | This file has been generated by The Interactive Disassembler (IDA) |
; | Copyright (c) 2013 Hex-Rays, <support@hex-rays.com> |
; | License info: |
; | Microsoft |
; +-------------------------------------------------------------------------+
;
; ---------------------------------------------------------------------------
; Format : Portable executable for 80386 (PE)
; Imagebase : 400000
; Section 1. (virtual address 00001000)
; Virtual size : 0002964D ( 169549.)
; Section size in file : 00029800 ( 169984.)
; Offset to raw data for section: 00000400
; Flags 60000020: Text Executable Readable
; Alignment : default
; OS type : MS Windows
; Application type: Executable 32bit
include uni.inc ; see unicode subdir of ida for info on unicode
.686p
.mmx
.model flat
; ===========================================================================
</code></pre>
<p>sample from inside</p>
<pre><code>.text:00401080 ; ---------------------------------------------------------------------------
.text:00401081 CC CC CC CC CC CC CC CC CC CC CC CC CC CC CC align 10h
.text:00401090 8B 44 24 10 mov eax, [esp+10h]
.text:00401094 8B 4C 24 0C mov ecx, [esp+0Ch]
.text:00401098 8B 54 24 08 mov edx, [esp+8]
.text:0040109C 56 push esi
.text:0040109D 8B 74 24 08 mov esi, [esp+8]
.text:004010A1 50 push eax
.text:004010A2 51 push ecx
.text:004010A3 52 push edx
.text:004010A4 56 push esi
.text:004010A5 E8 18 1E 00 00 call _memcpy_s
.text:004010AA 83 C4 10 add esp, 10h
.text:004010AD 8B C6 mov eax, esi
.text:004010AF 5E pop esi
.text:004010B0 C3 retn
.text:004010B0 ; ---------------------------------------------------------------------------
</code></pre>
<p>Thanks for any pointers or clues as to the best way to approach this and my apologies if this isn't suitable for this forum.</p>
|
Large number of IDA .ASM files, need list of potential mnemonics
|
|ida|hexrays|
|
<p>This program uses the PharLap DOS extender, as can be seen in its MZ header. The 32-bit executable program starts at offset <code>18A0</code>, per "offset within header of relocation table" (see <a href="http://www.program-transformation.org/Transform/PcExeFormat">http://www.program-transformation.org/Transform/PcExeFormat</a>), and at that position you can see the correct signature <code>P3</code>. According to the header info, the executable's length is <code>0x95851</code>, which is another hint this is correct. Near the end of this part, starting at <code>18A0</code>, you can see a text string "Hello EA", and at the next 32-byte "page" the signature <code>MZ</code> that indicates another executable is embedded. So this large part must contain the main executable.</p>
<p>Browsing the file with a simple hex editor at my preferred width of 16 hex characters, I noticed a recurring pattern when doing page-downs (a good way to get a 'sense' of what sort of data a file contains). I saw the pattern repeated every 2 lines, and when I set the display width to 32, the pattern was evident. Executable formats always start with a fixed header, and are usually followed by lots of zeroes for padding, so I suspected the repeating pattern may be the XOR key. A simple C program confirmed this; I did not know where to start with decoding but the first non-all-zeroes multiple of 32 seemed a good guess: offset <code>0x1AA0</code>. </p>
<p>Decoding from there proved the hunch to be correct:</p>
<pre><code>00000 : Y...r9..n3.>..-.A@I.7P........h4..a"1.P(s.......x. rG..f...X.+..
00040 : ..a|D.P(.b..A...x......f3..F..h4....a.P(...........o7..f3..F2...
00080 : .@@@@@@...@@BLASTER=@ULTRASND=@GOLD=@mvsound.sys@DEVICEdevice@@@
000C0 : @@@@@@@@@@@.......ULTRAMID@@@@@@@@@@@@@@@ ..@.@@@@@@.........@.@
00100 : .@.@.@.@.@.@.@.@.@.@.@.@.@.@.@.@.@@.@@@@..@@...@@@..@@......&...
00140 : ./....8....C....N....X...@c.@@ m....y...................C.......
00180 : .PCSPKR.ADV@MT32MPU.ADV@ADLIB.ADV@ADLIBG.ADV@SBFM.ADV@SBFM.ADV@S
001C0 : BP1FM.ADV@SBP2FM.ADV@PASFM.ADV@PASOPL.ADV@TANDY.ADV@GF1MIDI.ADV@
00200 : CUST_MID.ADV@SBP2FM.ADV@SBAWE32.ADV@@@@ALGDIG.ADV@SBDIG.ADV@SBDI
00240 : G.ADV@SBPDIG.ADV@SBPDIG.ADV@PASDIG.ADV@PASDIG.ADV@@GF1DIGI.ADV@C
(etc.)
</code></pre>
<p>so the next step was scroll down to near the end of this part and see what was there. Disaster! Rather than readable texts, all I saw was random data -- yet still with clear patterns.</p>
<p>But 'an executable' is not one contiguous long chunk of data. It's common to see it divided up into separate sections for "executable code", "initialized data", "uninitialized data", "relocations" and so on. The sections all start at an aligned address when loaded into memory, but not necessarily in the file itself, or with the same 'memory page' size. Therefore, it may be possible that the XOR encryption restarts at the start of new section. The PharLap header should contain information on where each section starts and ends (and if you are going to attempt to adjust the program, you should look into this), but to confirm the XOR key is the same all I had to do is adjust the starting position. Starting one position further, no success, but 2 positions further on I noticed this piece of data:</p>
<pre><code>890C0 : B.@.L.@^W.@.a.@^l.@.v.@^..@...@ @ @ @ @ @ @ @~FIFA International
89100 : Soccer@ @PC Version by@~The Creative Assembly@ @~Lead Programme
89140 : r@ @Tim Ansell@ @ @ @~Programmers@ @Adrian Panton@Clive Gratton@
89180 : @ @~Lead Artist@ @Will Hallsworth@ @ @ @~Additional Artwork@ @A
891C0 : lan Ansell@ @ @ @~Original Music@Composed, Produced@and Performe
89200 : d by@Ray Deefholts@for ~HFC Music@ @Additional Drum@Programming
89240 : and@Assistance@ @Tim Ansell@ @~Sound Effects@ @Bill Lusty@ @ @ @
89280 : ~Producer@ @Kevin Buckner@ @ @ @~Associate Producer@ @Nick Golds
(etc.)
</code></pre>
<p>That was the proof I needed: the data section <em>does</em> use the same XOR key. Next: testing all possibilities from 0 to 31 and see if something turns up. Only at +30 that turned out to work, just as I was going to give up:</p>
<pre><code>782C0 : ..@...@,..@..Algeria@Ali Mehdaoui Igail@Mohammed Said@Abdel Dahb
78300 : i@Hamid Ahkmar@Nagar Baltuni@Omar Mahjabi@Ali Cherif@Hamar Mahbo
78340 : ud@Khered Adjali@Imahd Tasfarouk@Alamar Sahid@Mahmar Ahboud@Akha
78380 : r Binnet@Mouhrad Dahlib@Mahied Amruk@Lakhar Diziri@Amaar Azir@Mu
783C0 : stafa Farai@Akmar Bahoud@Ahmad Said@Taraki Aziz@Argentina@Alfio
(etc.)
</code></pre>
<p>So each individual section in the executable is encrypted with a 32-byte XOR key; this XOR key is the same for all <em>sections</em>; it starts a-new per section.</p>
<p>The C program below will decrypt the entire file and you have to adjust the starting position manually. To edit the file, you have to:</p>
<ol>
<li>Read up on PharLap's sections.</li>
<li>Decrypt each section individually.</li>
<li>Write all into a new file.</li>
<li>Adjust what you want.</li>
<li>Encrypt the sections again (it's a XOR key, so this uses the exact same algorithm).</li>
<li>Copy the encrypted file back into the main executable.</li>
</ol>
<p>A note on #4: you mentioned changing the names of the players. Since it's a zero-terminated list of names, you can assume there is a list of pointers <em>to</em> these names somewhere else. That means you can only change the individual <em>characters</em> of a name -- not make it longer. If you want to adjust all names freely, you must find the list of pointers and adjust that as well.</p>
<hr>
<p>(Preliminary updates)</p>
<ol>
<li><p>The XOR encoding does not use sections. Instead, it seems like every block starts with a word determining its length, and possibly 1 or 2 next words (possibly (again) to set the XOR key starting position). Not conclusive so far.</p></li>
<li><p>Executables are <em>abundant</em> with zeroes. If you count the number of zeroes in each 32-byte chunk, XORed against all 32 possible positions, and print out the XOR position with the highest number of them, you can see successive lists of the same 'best' guess. That shows there are longer and shorter sections XORed with the same key and may help determining the length algorithm.</p></li>
</ol>
<hr>
<pre><code>#include <stdio.h>
#include <stdlib.h>
unsigned char encrypt[32] = {
0x23, 0x91, 0xC8, 0xE4, 0x72, 0x39, 0x9C, 0xCE,
0x67, 0x33, 0x99, 0xCC, 0xE6, 0x73, 0xB9, 0x5C,
0x2E, 0x17, 0x8B, 0x45, 0xA2, 0x51, 0xA8, 0x54,
0x2A, 0x95, 0xCA, 0x65, 0x32, 0x19, 0x8C, 0x46
};
int main(int argc, char *argv[])
{
FILE *f;
int i, c, d = 0;
f = fopen ("../Downloads/fifa/fifa.exe", "rb");
if (!f)
{
printf ("yeah no such file\n");
return 0;
}
/* reasonable assumption for start: */
fseek (f, 0x1aa0, SEEK_SET);
/* adjust per section! this position is valid for the names only */
fseek (f, 30, SEEK_CUR);
c = 0;
printf ("%05X : ", d);
do
{
d++;
i = fgetc (f);
if (i == EOF) break;
i ^= encrypt[c & 31];
if (i >= ' ' && i <= '~') putchar (i); else if (i) putchar ('.'); else putchar ('@');
if (++c >= 64)
{
c = 0;
printf ("\n");
printf ("%05X : ", d);
}
} while (d < 0x95851);
fclose (f);
return 0;
}
</code></pre>
|
8406
|
2015-03-07T07:23:45.287
|
<p>I am attempting to amend some strings in an old DOS game (FIFA International Soccer), specifically the names of players.</p>
<p>In the past it hasn't been too hard to pull off such a task on post-DOS games as either the strings are easy to track down in the executable or a data file. However, for this DOS game I am stuck.</p>
<p>I have scanned through the game files and the executable with a hex-editor but cannot find the strings. The game includes a <code>english.dat</code> file which does contain readable localised strings. However, this file only contains names for in game headers and menu options as opposed to the player names I am seeking. The other files consist of localised strings for other languages, graphics and sounds.</p>
<p>I have used a debug build of DOSBOX to perform a memory dump using the following command:</p>
<pre><code>memdumpbin 180:0 1000000
</code></pre>
<p>I got the command from here: <a href="http://www.vogons.org/viewtopic.php?t=9635">http://www.vogons.org/viewtopic.php?t=9635</a></p>
<p>In the memory dump I <strong>can</strong> find the strings I wish to change.</p>
<p>What is the best way of linking this information to find the source of the strings? I assume that these strings are somehow encrypted or compressed in the executable, although it could be in another obscure game file. If the strings are compressed/encrypted perhaps there is a common method for pulling this data out of the executable.</p>
<p>I have IDA5 (free version) installed and would be happy using this as part of process. My operating system is Windows 8 / 64 bit.</p>
<p>Also, to be clear - I want to modify the strings at source (i.e. in the file) and not in memory.</p>
|
How can I find the source of a string in an old DOS game?
|
|disassembly|debugging|strings|dos|
|
<p>The @1 part should be the instruction number within the assembly where the variable is defined.</p>
<p>For the rest of your question, you'll probably have to look at the assembly code. r1 is the register to pass the second argument on an ARM processor all right, but a function call doesn't have to preserve its arguments, so the compiler is allowed to use r1 for something else once it doesn't need the argument (a2) anymore. I'd assume the assembly modifies r1 somewhere, which makes it different from a2, so the decompiler chooses to create a different variable name for it instead of producing a (possibly confusing) assignment to a2.</p>
<p>If your function calls other functions, it will even need to overwrite r0..r3 (depending on the number of arguments to that function), so most code i've seen saves the arguments to the stack, or some other register. If your r1 doesn't get saved anywhere (because it's just needed at the start of your function and never again), this might be the reason why the decompiler doesn't want to assign a variable name, as well.</p>
<p>To get a definite answer, i think you'd have to ask your question on the hex-rays forum and include the disassembled code, they tend to have excellent support there.</p>
|
8410
|
2015-03-07T15:15:35.507
|
<p>Well, I've got an function that the pseudo code looks like: </p>
<pre><code>void d4l_auxadc_cali_unlocked_ioctl()
{
unsigned int v0; // r1@1
unsigned int v1; // r7@1
...
</code></pre>
<p>However, I am aware that the definition of the function is as follow:</p>
<pre><code>int d4l_auxadc_cali_unlocked_ioctl(void* a1, unsigned long a2, unsigned long a3)
</code></pre>
<p>So I tell the decompiler what I know by using the "Set Item Type", and here is what I got:</p>
<pre><code>int __fastcall d4l_auxadc_cali_unlocked_ioctl(void *a1, unsigned __int32 a2, unsigned __int32 a3)
{
unsigned int v3; // r1@1
unsigned int v4; // r7@1
</code></pre>
<p>The problem is, the local variable "v3" is actually as same as the function argument "a2", but the decompiler failed to connect them together.</p>
<p>I've tried to map "v3" to "a2" by using "Map to another variable", but I am only allow to do the mapping with "v4", "v5" ...</p>
<p>What can I do now ... ?</p>
<p>And BTW, does anyone know the meaning of "@1" as a part of "r1@1" ? </p>
<p>The head of assembly codes is as follow. It seems that none of them modify the r1 register, so I don't know why the compile chooses to create a different variable.</p>
<pre><code>ROM:C04C54E8 MOV R12, SP
ROM:C04C54EC STMFD SP!, {R4-R7,R11,R12,LR,PC}
ROM:C04C54F0 SUB R11, R12, #4
ROM:C04C54F4 STR LR, [SP,#0x1C+var_20]!
ROM:C04C54F8 ; 25: d4l___gnu_mcount_nc();
ROM:C04C54F8 BL d4l___gnu_mcount_nc
ROM:C04C54FC ; 28: d4l_mutex_lock(&unk_C0D661A4);
ROM:C04C54FC LDR R0, =unk_C0D661A4 ; void *
//So far, none of the codes have modified r1, so why the compiler chooses to create a v3 ?
ROM:C04C5500 ; 26: v4 = v3;
ROM:C04C5500 MOV R7, R1
ROM:C04C5504 ; 27: v6 = v5;
ROM:C04C5504 MOV R4, R2
ROM:C04C5508 BL d4l_mutex_lock
//Note that d4l_mutex_lock only takes one argument.
ROM:C04C550C ; 29: if ( v4 == 1074031362 )
ROM:C04C550C LDR R3, =0x40046B02
ROM:C04C5510 LDR R6, =unk_C0D661A4
ROM:C04C5514 CMP R7, R3
ROM:C04C5518 LDR R5, =0xC0E748B4
ROM:C04C551C BEQ loc_C04C55EC
</code></pre>
|
How to map a function argument to local variable?
|
|arm|hexrays|local-variables|arguments|
|
<p>You can just use the <code>-x</code> command line argument for <a href="https://technet.microsoft.com/en-us/sysinternals/dd996900.aspx" rel="nofollow">ProcDump</a>:</p>
<blockquote>
<p><code>-x</code> Launch the specified image with optional arguments. If it is a Store Application or Package, ProcDump will start on the next
activation (only).</p>
<p>...</p>
<p>Launch a process and then monitor it for exceptions:</p>
<p><code>C:\>procdump -e 1 -f "" -x c:\dumps consume.exe</code></p>
</blockquote>
|
8415
|
2015-03-08T11:21:44.690
|
<p>Using tools like strace I can figure out the signals a program receives as it executes, regardless of whether or not signal handlers for those signals have been defined.</p>
<p>[EDIT]
In order to do the same on Windows I'm following what's mentioned <a href="https://docs.microsoft.com/en-us/archive/blogs/dau-blog/how-to-capture-exceptions-in-process-monitor-traces-using-pocdump" rel="nofollow noreferrer">here</a>. I tested it by having a test process sleep at the start for about 20 seconds, then crash by jumping to 0x41414141. As it sleeps I attach procdump.exe to the process and then monitor the exceptions in procmon.exe. Is there a way I can do this without the sleep? I tried running it from OllyDbg and then attaching procdump.exe but the message would say that the process is already being debugged.</p>
<p>Any advice on how I could proceed?</p>
|
Monitoring Exceptions raised by an executable
|
|windows|linux|seh|exception|
|
<p>Based on provided information I suspect that the used method here is Dynamic forking of a process or as it also know process hollowing. The idea is to execute some arbitrary process in suspended state and replace its "guts" with the contents of another executable image. In general the idea could be implemented as following (based on <em>Dynamic forking</em> by Tan Chew Keong, 2004):</p>
<ol>
<li>Use the <code>CreateProcess</code> API with the <code>CREATE_SUSPENDED</code> parameter to create a suspended process from any EXE file. (Call this the first EXE).</li>
<li>Call <code>GetThreadContext</code> API to obtain the register values (thread context) of the suspended process. The EBX register of the suspended process points to the process's PEB. The EAX register contains the entry point of the process (first EXE).</li>
<li>Obtain the base-address of the suspended process from its PEB, i.e. at [EBX+8]</li>
<li>Load the second EXE into memory (using ReadFile) and perform the neccessary alignment manually. This is required if the file alignment is different from the memory alignment</li>
<li>If the second EXE has the same base-address as the suspended process and its image-size is <= to the image-size of the suspended process, simply use the <code>WriteProcessMemory</code> function to write the image of the second EXE into the memory space of the suspended process, starting at the base-address.</li>
<li>Otherwise, unmap the image of the first EXE using <code>ZwUnmapViewOfSection</code> (exported by ntdll.dll) and use VirtualAllocEx to allocate enough memory for the second EXE within the memory space of the suspended process. The <code>VirtualAllocEx</code> API must be supplied with the base-address of the second EXE to ensure that Windows will give us memory in the required region. Next, copy the image of the second EXE into the memory space of the suspended process starting at the allocated address (using <code>WriteProcessMemory</code>).</li>
<li>If the unmap operation failed but the second EXE is relocatable (i.e. has a relocation table), then allocate enough memory for the second EXE within the suspended process at any location. Perform manual relocation of the second EXE based on the allocated memory address. Next, copy the relocated EXE into the memory space of the suspended process starting at the allocated address (using <code>WriteProcessMemory</code>).</li>
<li>Patch the base-address of the second EXE into the suspended process's PEB at [EBX+8].</li>
<li>Set EAX of the thread context to the entry point of the second EXE.</li>
<li>Use the SetThreadContext API to modify the thread context of the suspended process.</li>
<li>Use the ResumeThread API to resume execute of the suspended process.</li>
</ol>
<p>So, to answer your question I firstly suggest to verify that this indeed happens. Secondly, if it does you can do the following to break on the new created thread entry point. The proposed way is not the only one, but IMHO will be easy done taking into account your relatively small experience in RE/executable analysis:</p>
<ul>
<li><p>Check the <a href="http://www.rohitab.com/discuss/topic/35564-win32-forking/" rel="nofollow">PoC</a> to actually get the full understanding of the whole process.</p>
<ol>
<li>Place BP on <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms680632(v=vs.85).aspx" rel="nofollow">SetThreadContext</a>. The second parameter is <code>CTX</code> variable which holds among various aspects of the thread context, also the address of the thread function.</li>
<li>In the nutshell, you need to examine <code>CTX.eax</code> to get the address of the thread function. For example <code>0x00402030</code> is the address you've found there. </li>
<li>Download and install <a href="http://processhacker.sourceforge.net" rel="nofollow">ProcessHacker</a> and with its help, examine the address space of the suspended process. Open the memory page to which the thread function belongs to - <em>Right click on process -> Properties -> Memory</em>. For example page <code>0x00400000</code>.</li>
<li>ProcessHacker will show you the memory page with local offsets to the page. You will need to go to the offset <code>0x2030</code>.</li>
<li>Patch the memory at offset <code>0x2030</code> with <code>0xEBFE</code> (remember the previous bytes), this makes the thread loop indefinitely - <code>jmp 0x00402030</code>.</li>
<li>Now, resume the parent process and attache the new instance of <code>Olly</code> to the suspended process which now is already running. Go to the EP and patch back to the original bytes. </li>
<li>Good luck with the analysis.</li>
</ol></li>
</ul>
<p>I hope this is understandable otherwise ask and I'll clarify. </p>
|
8422
|
2015-03-09T09:45:01.020
|
<p>How do I go into the thread function (so I can do step by step tracing), knowing only the handle to the thread. I am using OllyDbg for tracing and the thread is created through the API <code>ZwCreateProcess()</code>. However, the documentation that I have seen for this API does not contain the creation flags and pointer to the defined function which it will execute, which I both need.</p>
<p>Is there a way to go into the thread function, knowing only the thread handle? Also, are there other ways to create suspended threads aside from <code>CreateThread()</code> and <code>CreateRemoteThread()</code>?</p>
|
How to go into thread function knowing only the thread handle
|
|ollydbg|debugging|thread|
|
<blockquote>
<p>Is there something I'm missing?</p>
</blockquote>
<p>The disconnect is that the <a href="http://www2.onlinedisassembler.com/odaweb/" rel="nofollow">ODA</a> disassembler referenced in <a href="http://blog.onlinedisassembler.com/blog/?p=23" rel="nofollow">http://blog.onlinedisassembler.com/blog/?p=23</a> produces different output than WinDbg's disassembler given the same input.</p>
<p>Perhaps what you're "missing" is based on the assumption that all disassemblers produce the same output given the same input, which is not a correct assumption to make.</p>
|
8425
|
2015-03-09T14:50:01.407
|
<p>I read the recent article "Longest x86 Instruction" </p>
<p><a href="http://blog.onlinedisassembler.com/blog/?p=23" rel="nofollow">http://blog.onlinedisassembler.com/blog/?p=23</a></p>
<p>I attempted to reproduce the curious disassembly issue on a Win7x86 development platform using masm and as the article suggested, redunant prefixes.</p>
<p>Talk is cheap, so here's a toy program (masm32):</p>
<pre><code>.386 .model flat, stdcall
option casemap:none
includelib \x\x\kernel32.lib
includelib \x\x\user32.lib
include \x\x\kernel32.inc
include \x\x\user32.inc
include \x\x\windows.inc
.code
start:
db 0F3h
db 0F3h
db 0F3h
db 0F3h
db 0F3h
db 0F3h
db 0F3h
;...6 more bytes later
db 089h
db 0E5h
end start
invoke ExitProcess, NULL
</code></pre>
<p>After linking and assembling, I opened the resulting executable in windbg. </p>
<p>To my disappointment, when I single step, unassemble the $exentry, etc. windbg simply sees the prefixes/bytes as individual instructions, says 'to hell with it' and executes only the valid instructions.</p>
<p>Is there something I'm missing?</p>
|
Longest x86 Instruction
|
|disassembly|assembly|windbg|
|
<p>execute this bat file you will need windbg in path </p>
<p>it attaches to a running process (hard coded as calc.exe you can script it with %1) dumps the memory map filtered by page_readonly and mapped file and detaches automatically when quitting and sleeps for 10 seconds before repeating and pipes (appends its output to a file of choice that can be processed with your favorite text processing tool)</p>
<pre><code>:begin
echo Date and Time of Address Dump = %date%%time% >> address.text
cdb -pd -c "!address -1 -F:PAGE_READONLY,FILEMAP;q" -pn calc.exe >> address.text
sleep 10
goto begin
</code></pre>
<p>you can use any test processing tool to parse the output</p>
<pre><code>:grep -iE "Date and Time of Address Dump | 80000 " address.text
Date and Time of Address Dump = 11/03/201512:25:21.01
80000 83000 3000 MEM_MAPPED MEM_COMMIT PAGE_READONLY MemoryMappedFile "PageFile"
Date and Time of Address Dump = 11/03/201512:25:23.15
80000 83000 3000 MEM_MAPPED MEM_COMMIT PAGE_READONLY MemoryMappedFile "PageFile"
Date and Time of Address Dump = 11/03/201512:25:26.82
80000 83000 3000 MEM_MAPPED MEM_COMMIT PAGE_READONLY MemoryMappedFile "PageFile"
</code></pre>
|
8434
|
2015-03-10T23:38:26.527
|
<p>I am trying to obtain the memory map of a process. One way I can think of doing this is to attach Olly/Immunity Debugger to the process and copy the memory map to the clipboard. However, this is probably not a good idea when I'd like to repeat this multiple times consecutively. Is there a tool similar to <a href="https://technet.microsoft.com/en-us/sysinternals/bb896656.aspx" rel="nofollow">ListDLLs</a> that can be used to achieve this? I noticed procdump can be used to dump the memory of a process but I don't need a memory dump: I just need a list of valid memory locations.</p>
|
Automatically list of mapped memory locations(and their attributes) of a running process
|
|windows|memory|dumping|
|
<p>Double click the variable name in the disassembly, or press ctrl-k, to open the stack frame window. You can change your variable types there.</p>
|
8440
|
2015-03-11T11:33:14.170
|
<p>I've got a procedure in IDA Pro with a few local stack variables, but part of them belong to an array. I would like to define the array, but pressing <code>*</code> (Create Array) fails, and pressing <code>Y</code> (Set Type) just brings up the type for the procedure, not the variable.</p>
<p>The same happens if I hover over an instance of its usage rather than its definition in the function prologue.</p>
<p>Oddly enough I seem to be able to rename them just fine.</p>
<p>How do I define a range of local variables to be an array; or, why is it not working for me?</p>
|
How to make stack variables into an array in IDA Pro
|
|ida|stack-variables|stack|array|
|
<h2><strong>1:</strong></h2>
<p>See the <strong>Immediates</strong> section on <a href="https://web.archive.org/web/20160719053302/www.x86-64.org/documentation/assembly.html" rel="nofollow noreferrer">this 64 bit assembly reference</a>.</p>
<blockquote>
<p>Immediate values inside instructions remain 32 bits and their value is sign extended to 64 bits</p>
</blockquote>
<p>There just isn't an instruction to move a 64 bit immediate value to <em>memory</em> (*). And because it can be emulated nicely by moving two chunks of 32 bit, there was no reason to introduce new 64 bit instructions. (They could have changed the immediate <code>mov</code>s to always use 64 bits. But considering that most constants you'll ever use are <= 2^31, using 32 bit only saves a lot of space for the upper zero bytes, and costs a bit when you actually use larger constants, so this saves memory).</p>
<p>(*) However, there are instructions to move a 64 bit immediate value to the 64 bit registers, because you can't access the high 32 bit in registers, opposed to memory.</p>
<p>I don't know why your program produced separate addl/adcl instructions; this is what i got from your program:</p>
<pre><code> pushq %rbp
movq %rsp, %rbp
movl $2041302511, -24(%rbp)
movl $1193046, -20(%rbp)
movl $-2023406815, -16(%rbp)
movl $16632745, -12(%rbp)
movq -16(%rbp), %rax
movq -24(%rbp), %rdx
leaq (%rdx,%rax), %rax
movq %rax, -8(%rbp)
movl $0, %eax
leave
ret
</code></pre>
<p>As you can see, the <code>leaq (%rdx,%rax), %rax</code> adds 64 bit numbers all right. This was a gcc 4.4.7 on a RHEL 6.6 64 bit system. Please, always state your compiler and OS version, as the output may be quite dependent on those.</p>
<h2><strong>2:</strong></h2>
<p>As long as you're dealing with an x86/amd64 architecture, you can probably rely on local variables being put on the stack, and global variables not on the stack. But please note the concept of 'stack' and 'heap' aren't as clearly defined as it would seem. The <code>brk/sbrk</code> mechanism of allocating memory is deprecated; modern implementations use <code>mmap</code>. This might mean you have several small heaps in different sections of your address space. On ARM and MIPS, there's no stack pointer at all - there's just a convention that one specific register serves as the stack pointer, but the instructions to push/pop would work with other registers as well(*). In theory, the compiler is free to do a <code>mmap()</code> at the start of each function to allocate local memory, and <code>munmap()</code> it at the end of the function. The only thing the compiler <em>must</em> do is not keep the memory allocated (for reasonable definitions of allocated) after the function exits.</p>
<p>(*) This is a bit of an oversimplification but demonstrates the concept.</p>
<p>Of course, the idea of using <code>mmap()</code> to make space for local variables is an extreme example, that <em>probably</em> noone uses. But lots of compilers put local variables into processor registers and never reserve space on the stack for them (if you never use a pointer to them, and on architectures that aren't as register-starved as x86). Many architectures use processor registers for function arguments as well. And i've seen microcontroller C compilers that allow you to put all variables local to a function into a static area, if you use a certain keyword so the compiler knows the function isn't called recursively. So, while most of the time, local variables will be placed on the stack, you shouldn't assume this is carved in stone.</p>
<h2><strong>3.</strong></h2>
<p>The instruction will be misunderstood. The processor can be in 32 bit or 64 bit mode, and the same instructions (in the meaning of: the same sequence of instruction bytes) have different meanings in each of them. For example, <code>48 89 43 ec</code> is <code>mov [rbx-20],rax</code> in 64 bit mode, but <code>dec eax; mov DWORD PTR [ebx-0x14],eax</code> in 32 bit mode.</p>
|
8454
|
2015-03-13T12:44:29.593
|
<p>Let's say I create a program in C like this and compile it on a regular 64-bit desktop machine:</p>
<pre><code>#include <stdint.h>
int main(void)
{
uint64_t a = 0x12345679abcdefULL;
uint64_t b = 0xfdcba987654321ULL;
uint64_t c = a + b;
return 0;
}
</code></pre>
<p>I just tested the code using <code>gcc -O0 -S</code>. It seems to allocate two 32-bit values on the stack and add then with <code>addl</code> and <code>adcl</code> separately. This happens for both <code>-m32</code> and <code>-m64</code> switch, even though I am on a 64-bit machine, and there indeed seem to be a dedicated instruction set for 64-bit integers, including operations such as <code>movq</code> and <code>addq</code>.</p>
<ol>
<li><p>Why did <code>gcc</code> produce code like for a 32-bit machine even if I told it to use 64-bit arithmetic with <code>-m64</code>?</p>
<pre><code>>uname -a
CYGWIN_NT-6.2-WOW work 1.7.35(0.287/5/3) 2015-03-04 12:07 i686 Cygwin
>gcc --version
gcc (GCC) 4.9.2
</code></pre></li>
</ol>
<p>Now, let's say I'm on a 32-bit machine and I operate on 64-bit integers.</p>
<ol start="2">
<li><p>The program allocated two 32-bit variables <strong>on the stack</strong>. Is this part of a C/C++ standard, or is allocating them on the heap to be expected with some compilers (because they try to fit a 64-bit integer into a 32-bit stack in a different way)?</p></li>
<li><p>If I put <code>movq</code> in a program designed for a 32-bit machine, will the desired behavior be emulated, or will the instruction be misunderstood?</p></li>
</ol>
|
64-bit integers on 32-bit machines
|
|x86|c|x86-64|stack-variables|
|
<p>Your files aren't plain disk images, they are using the <a href="http://www.forensicswiki.org/wiki/ASR_Data%27s_Expert_Witness_Compression_Format" rel="nofollow">Encase File Format</a>. Your repetitive bytes seem to be artifacts of that file format.</p>
<p>There's a <a href="https://www.guidancesoftware.com/resources/Pages/doclib/Document-Library/EnCase-Evidence-File-Format-Version-2.aspx" rel="nofollow">newer specification</a> of the file format as well, but it requires registration.</p>
<p>Autopsy probably recognizes the file format, so it removes the parts of the file that belong to the file format, not the sector dump data.</p>
|
8457
|
2015-03-13T17:47:43.843
|
<p>I am currently investigating a disk image with a FAT12 file system for data recovery purpose/researching for image file carving. For this investigation, I have the actual files (JPEG images) that need to be carved/recovered from the disk image so that I can validate my results obtained from the carving process/recovery.</p>
<p>During the comparison and analysis from the recovered files, I noticed that exactly between two consecutive clusters (each of size 16384 bytes/32 sectors) of file data, 4 extra/embedded bytes are being encountered. These repetitive and distinct 4 bytes that are being encountered between clusters are not found in the corresponding actual files. I think that these bytes are used somehow by the file system and hence they should be removed, is this right? If yes, what is their purposes and how can be identified during the recovery process?</p>
<p>In fact, when I analyzed the same disk image using <a href="http://www.sleuthkit.org/autopsy/" rel="nofollow">Autopsy</a> the embedded 4 bytes between consecutive clusters were discarded. </p>
<p><strong>Hex dump:</strong></p>
<p>Actual File that needs to be recovered from disk (hex between 2 clusters):</p>
<pre><code>Offset 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
00016336 BC 55 B4 F8 A5 E1 69 82 2A DD 4A 5D DC 46 B9 80 ¼U´ø¥ái‚*ÝJ]ÜF¹€
00016352 E1 33 D3 F9 76 AE 8A 79 2E 22 0F 58 EE 67 FD AD á3Óùv®Šy." Xîgý
00016368 49 E9 7B 76 45 99 3E 25 69 36 F2 00 8B 71 70 C0 Ié{vE™>%i6ò ‹qpÀ
00016384 FC BB 6D 65 E9 DC F2 30 7E BD 6A B4 BF 17 52 0B ü»meéÜò0~½j´¿ R
00016400 64 9A 2D 13 58 B8 0E FB 13 65 9B 1E 87 93 F9 00 dš- X¸ û e› ‡“ù
00016416 7F 11 55 4F 21 AD A7 3A 51 D7 B9 CF 3C DE 35 25 UO!§:Q×¹Ï<Þ5%
</code></pre>
<p>Disk Image:</p>
<pre><code>Offset 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
00132880 BC 55 B4 F8 A5 E1 69 82 2A DD 4A 5D DC 46 B9 80 ¼U´ø¥ái‚*ÝJ]ÜF¹€
00132896 E1 33 D3 F9 76 AE 8A 79 2E 22 0F 58 EE 67 FD AD á3Óùv®Šy." Xîgý
00132912 49 E9 7B 76 45 99 3E 25 69 36 F2 00 8B 71 70 C0 Ié{vE™>%i6ò ‹qpÀ
00132928 08 B5 A9 88 FC BB 6D 65 E9 DC F2 30 7E BD 6A B4 µ©ˆü»meéÜò0~½j´
00132944 BF 17 52 0B 64 9A 2D 13 58 B8 0E FB 13 65 9B 1E ¿ R dš- X¸ û e›
00132960 87 93 F9 00 7F 11 55 4F 21 AD A7 3A 51 D7 B9 CF ‡“ù UO!§:Q×¹Ï
00132976 3C DE 35 25 <Þ5%
</code></pre>
<p>From the above hex dump it can be visualized that <strong>08 B5 A9 88</strong> is exactly between the two clusters, however in the actual file those 4 bytes were eliminated.</p>
<p>This case was encountered while recovering JPEG images from <a href="http://digitalcorpora.org/corpora/disk-images/nps-2009-canon2/" rel="nofollow">nps-2009-canon2-gen6 disk image</a></p>
|
Extra bytes between clusters in FAT12
|
|file-format|hex|digital-forensics|operating-systems|binary-format|
|
<p>As Jason writes, I should use 64-bit pointers. Besides that, it also turns out that I had to copy four numbers from the stack frame. This is working code:</p>
<pre><code>uint64_t * my_ptr = &buf;
int * x = my_ptr;
while (*(++x) != 0xa0b1c2d3); // Find the beacon. We could of course simply have a look
uint64_t * y = x + 1; // with gdb where it's stored, but this works generically.
*(my_ptr+7) = *(y+3); // Copy frame information
*(my_ptr+6) = *(y+2);
*(my_ptr+5) = *(y+1);
*(my_ptr+4) = *y;
</code></pre>
<p>Typically you need to fiddle a bit with what addresses you have to copy. You can get a rough idea using gdb, as you did. The exact numbers depend on the functions and their variables.</p>
|
8464
|
2015-03-14T13:05:44.540
|
<p>This is a homework assignment, so I'd appreciate it if I would get a hint only, not a full answer. I wrote this program which is supposed to print the following:</p>
<pre><code>Executing function_a
Executing function_b
Finished!
</code></pre>
<p>The <code>main()</code> and <code>function_a()</code> functions were given, and I'm only allowed to change <code>function_b()</code> in the marked part.</p>
<pre><code>#include <stdio.h>
#include <stdint.h>
void function_b(void) {
char buffer[4];
// edit between here...
uint32_t * x = &buffer;
while (*(x++) != 0xa0b1c2d3); // Find the beacon
*(uint32_t*)(&buffer + 6) = *(x + 2); // Copy return address from caller
*(uint32_t*)(&buffer + 5) = *(x + 1); // Copy frame pointer from caller
// ... and here
fprintf(stdout, "Executing function_b\n");
}
void function_a(void) {
int beacon = 0xa0b1c2d3;
fprintf(stdout, "Executing function_a\n");
function_b();
fprintf(stdout, "Executed function_b\n");
}
int main(void) {
function_a();
fprintf(stdout, "Finished!\n");
return 0;
}
</code></pre>
<p>The problem is of course to make sure that 'Executed function_b' is not outputted. We have to manipulate the stack so that when returning from <code>function_b()</code> we don't go back to its actual parent <code>function_a()</code> but to its grandfather <code>main()</code>.</p>
<p>The part of the code I wrote finds the beacon from <code>function_a()</code> and then copies the return address and saved frame pointer of <code>function_a()</code> to the frame of <code>function_b()</code>. My program does the following:</p>
<pre><code>Executing function_a
Executing function_b
Finished!
Segmentation fault (core dumped)
</code></pre>
<p>So it does the right thing, except for the segfault. It fails when returning from the <code>main()</code> function. I used gdb to get this:</p>
<pre><code>(gdb) run
Starting program: /.../exercise2c
Executing function_a
Breakpoint 1, function_b () at exercise2c.c:9
9 *(uint32_t*)(&buffer + 6) = *(x + 2); // Copy return address from caller
(gdb) backtrace
#0 function_b () at exercise2c.c:9
#1 0x0000000000400607 in function_a () at exercise2c.c:18
#2 0x0000000000400630 in main () at exercise2c.c:23
(gdb) info frame
Stack level 0, frame at 0x7fffffffdcb0:
rip = 0x400593 in function_b (exercise2c.c:9); saved rip = 0x400607
called by frame at 0x7fffffffdcd0
source language c.
Arglist at 0x7fffffffdca0, args:
Locals at 0x7fffffffdca0, Previous frame's sp is 0x7fffffffdcb0
Saved registers:
rbp at 0x7fffffffdca0, rip at 0x7fffffffdca8
(gdb) frame 1
#1 0x0000000000400607 in function_a () at exercise2c.c:18
18 function_b();
(gdb) info frame
Stack level 1, frame at 0x7fffffffdcd0:
rip = 0x400607 in function_a (exercise2c.c:18); saved rip = 0x400630
called by frame at 0x7fffffffdce0, caller of frame at 0x7fffffffdcb0
source language c.
Arglist at 0x7fffffffdcc0, args:
Locals at 0x7fffffffdcc0, Previous frame's sp is 0x7fffffffdcd0
Saved registers:
rbp at 0x7fffffffdcc0, rip at 0x7fffffffdcc8
(gdb) step
10 *(uint32_t*)(&buffer + 5) = *(x + 1); // Copy frame pointer from caller
(gdb) step
12 fprintf(stdout, "Executing function_b\n");
(gdb) frame 0
#0 function_b () at exercise2c.c:12
12 fprintf(stdout, "Executing function_b\n");
(gdb) info frame
Stack level 0, frame at 0x7fffffffdcb0:
rip = 0x4005b5 in function_b (exercise2c.c:12); saved rip = 0x400630
called by frame at 0x7fffffffdcd0
source language c.
Arglist at 0x7fffffffdca0, args:
Locals at 0x7fffffffdca0, Previous frame's sp is 0x7fffffffdcb0
Saved registers:
rbp at 0x7fffffffdca0, rip at 0x7fffffffdca8
(gdb) backtrace
#0 function_b () at exercise2c.c:12
#1 0x0000000000400630 in main () at exercise2c.c:23
(gdb) continue
Continuing.
Executing function_b
Finished!
Program received signal SIGSEGV, Segmentation fault.
0x0000000000400654 in main () at exercise2c.c:26
26 }(gdb)
Continuing.
Program terminated with signal SIGSEGV, Segmentation fault.
The program no longer exists.
</code></pre>
<p>You can clearly see that <code>function_b()</code> indeed returns to <code>main()</code>, but for some reason that I don't understand <code>main()</code> crashes. The only way I could see that happen is that I messed with the stack frame of <code>main()</code>, which I didn't, or that I should have changed something there - but I wouldn't know what.</p>
<p>What's going on here?</p>
<p>Note: the program is compiled with GCC and the flags <code>-g -fno-omit-frame-pointer -fno-stack-protector</code>. I'm on a 64-bit machine.</p>
|
Returning a C function to its grandfather
|
|c|gdb|x86-64|callstack|
|
<p>I'll make the assumption that the application is written in Visual C++.</p>
<p>CheatEngine itself is already pretty useful for finding your objects - first you need to find the place in code where these objects are created. For example in C++ you'd write:</p>
<pre><code>GameObject* obj = new GameObject();
</code></pre>
<p>In assembly this is often inlined to a malloc call. So if you use something like IDA Pro to more accurately reverse engineer the assembly, you might see something like this:</p>
<pre><code>;; void* obj = malloc(64);
push 40h ;; alloc 64 bytes
call _malloc ;; easilly detected only if program dynamically links to msvcrt.dll
add esp, 4
mov [esp+local_C0], eax
</code></pre>
<p>From this you can figure out that your objects are always 64 bytes in size (this is just an example, so your concrete program probably might have bigger objects).</p>
<p>If you launch the program in Visual Studio (File -> Open.. -> Project/Solution.. -> YourProgram.exe), you can force it to use the Windows debug heap, which will allow you to walk all the dynamically allocated heap nodes and filter out all nodes that are 64 bytes in size.</p>
<p>Now you should have a large collection of potential GameObject pointers and the final level of filtering would be detecting some basic patterns - for example if the class uses virtual functions, the first field of the object will be its VTable entry, thus giving you an easy identifier whether it's a GameObject or not.</p>
<p>This might not be a complete example, but it should be good enough to get you in the right direction.</p>
|
8467
|
2015-03-15T02:10:39.373
|
<p>So in a given game there are objects randomly placed around the map. I've managed (through playing with the memory in cheat engine) find that a single value changes when a certain object is within my draw distance. It's a boolean either 0 or 1. I had expect to then be able to search for the location of these objects (based on an interval of my location at N,E,S, and W of the object in x and y) however I was surprised to find that no values were found in this range! Is there a piece of software/method by which I could try and figure this sort of problem out?</p>
<p>I realise this is a broad question - I wouldn't like to limit it to a specific game since I wish to apply the method to more than one game. If there are other ways to make the question more narrow please say so in comments and I'll amend!</p>
|
What's a good method to find the location of objects in a game
|
|memory|
|
<p>The image data is stored as raw RGBA quads, with width/height/start defined in a block near the beginning.</p>
<p>You can extract the image data from the uncompressed bins using this python script:</p>
<pre><code>import struct
import sys
import os
from PIL import Image
if len(sys.argv) != 3:
print 'usage: process.py <filename> <outdir>'
sys.exit(1)
out_dir = sys.argv[2]
if not os.path.exists(out_dir):
os.mkdir(out_dir)
data = open(sys.argv[1],'rb').read()
offset = 0
(magic,) = struct.unpack_from('<8s', data, offset)
offset = offset + 8
if magic != 'ANIM1 ':
print 'incorrect magic!'
sys.exit(1)
(stage_width, stage_height, cmdblock_len, unk) = struct.unpack_from('<LLLL', data, offset)
offset = offset + 16
print "stage_width: %d\nstage_height: %d\ncmdblock_len: %d\n" %(stage_width, stage_height, cmdblock_len)
(cmd_code, img_num, img_width, img_height, bytes_per_pixel, data_start) = struct.unpack_from('<LLLLLL', data, offset)
while cmd_code == 0x11:
print 'generating img_%d' % (img_num)
im = Image.frombuffer('RGBA', (img_width, img_height), data[0x20+cmdblock_len+data_start:], 'raw', 'RGBA', 0, 1)
im.save(os.path.join(out_dir, 'img_%d.png'%img_num))
offset = offset + 0x20
(cmd_code, img_num, img_width, img_height, bytes_per_pixel, data_start) = struct.unpack_from('<LLLLLL', data, offset)
</code></pre>
<p>The other data in that initial block must be used composite them into the actual animation.</p>
<p>You may be able to inject your own images of the same dimensions/format to replace elements of the animations. It doesn't give you full control, but it should give you some basic capability to customise the animations.</p>
|
8475
|
2015-03-16T08:12:59.297
|
<p>I am investigating car navigation software which runs on QNX and want to replace the startup animation with my own. I have found the files in the firmware which have the extension .canim which likely stands for compressed animation.</p>
<p>The files are zlib compressed and after deflating the files start with HEX <code>41 4E 49 4D 31 20 20 20 20 03 00 00 E0 01 00 00</code>(ANIM1). My question is what file format is this? (possible match: <a href="http://en.wikipedia.org/wiki/ANIM" rel="nofollow noreferrer">Amiga ANIM</a>)</p>
<p>I know that the screen resolution for the device is 800x480 so after DWORD 3&4 are resolution (<code>20 03 00 00</code> -> 80 and <code>E0 01 00 00</code> -> 480</p>
<p>I've uploaded the files <a href="https://remkoweijnen.sharefile.eu/d/sf4c7977d4f44fa59" rel="nofollow noreferrer">here</a>, bin files are deflated versions of the .canim files.</p>
<p>EDIT: some additional info: I found startup pictures in the same folder and they are zlib compressed and are simple RGB pairs with a padding 00 to align at DWORD, eg : <code>04 02 04 00 04 02 04 00 04 02 04 00 04 02 04 00</code></p>
<p>EDIT2: <a href="http://ankk-vagcom.com/discover-pro-modifier-le-logo-de-demarrage/" rel="nofollow noreferrer">This site</a> has video's for each of the possible startup animations.
And these are the startup pictures I have extracted:
<img src="https://i.stack.imgur.com/ThSjK.png" alt="startup_generic.raw2"></p>
<p>and</p>
<p><img src="https://i.stack.imgur.com/xSyJ5.png" alt="startup_vw_dynaudio.raw2"></p>
|
What image format is ANIM1
|
|file-format|qnx|
|
<p>From <a href="https://code.google.com/p/corkami/wiki/PE#PointerToRawData" rel="nofollow">https://code.google.com/p/corkami/wiki/PE#PointerToRawData</a> --</p>
<blockquote>
<p>if a section's physical start is lower than 200h (the lower limit for
standard alignment), it is rounded down to 0.</p>
</blockquote>
<p>Thus, the entry point's physical offset would be:
<code>0x00000018 = 0x00000000 + 0x00001018 - 0x00001000</code> (PointerToRawData_rounded_down + AddressOfEntryPoint - VirtualAddress)</p>
|
8476
|
2015-03-16T10:59:13.120
|
<p>I have found problem with finding file offset which actually is program entry point.</p>
<p>In case I experience problem, value of AddressOfEntryPoint is 0x1018. Here is a section which maps this address.</p>
<p><img src="https://i.stack.imgur.com/903S0.png" alt="Section header"></p>
<p>I assume entry point should be <code>0x28 = 0x10 + 0x1018 - 0x1000 (PointerToRawData + AddressOfEntryPoint - VirtualAddress)</code></p>
<p>However tools says it is 0x18 instead. I'm not sure why, made some experiments and came up with another formula. </p>
<pre><code>0x18 = (0x10 / 0x200) * 0x200 + 0x1018 - 0x1000 ((PointerToRawData / FileAlignment) * FileAlignment + AddressOfEntryPoint - VirtualAddress)
</code></pre>
<p>I use FileAlignment from OptionalHeader and it works great, however I don't know if it is a coincidence or somewhere documented, so asking here for confirmation.</p>
<hr>
<p>Also, probably not important, but file is packed with UPack(0.399), packer signature BE****AD50FF7634EB7C4801.</p>
|
Problem with entry point detection as a file offset
|
|pe|entry-point|
|
<p>It all depends on what the obfuscator does. Proguard is a relatively weak obfuscator - it basically only renames things and strips out unused methods. So running Proguard on the same application twice is pretty much useless, but it won't cause any ill effects.</p>
<p>If you use a stronger obfuscator however, things will almost certainly break. For example, Allatori and Stringer both encrypt constant strings with a key derived from the class and method name of the caller. At runtime, the string decrpytion function uses various hacks to get the name of the caller and then decrypts the string with that. </p>
<p>If you then run Proguard on the obfuscated application, Proguard will blindly rename the classes, meaning that when the string decryption functions are called, the decryption key will be incorrect and the application will get garbage strings at best or much more likely just crash.</p>
|
8479
|
2015-03-16T17:20:23.567
|
<p>I'm wondering what happens if we try to run a jar through Proguard that has already been obfuscated by another obfuscator or Proguard itself? Will the obfuscated class names and methods names be changed by the new obfuscator?</p>
<p>For example, I would like to have those names renamed to something simpler such as <code>a</code> or <code>aab</code> rather than unicode characters. Will another obfuscator change the names?</p>
<p><img src="https://i.stack.imgur.com/LupVn.jpg" alt="enter image description here"></p>
|
Obfuscating jar already obfuscated
|
|obfuscation|java|
|
<p>Note: You'll probably get a better answer on stackoverflow, as your question is more about creating software than about reversing it.</p>
<p>First, you'll want to split your text file into blocks. You can do that looking for the <code>============= S U B R O U T I N E ============</code> comments that IDA emits, or checking the <code>sub_XXXX proc [near|far]</code> and <code>sub_XXXX endp</code> markers.</p>
<p>Then, to find your connections, look for the <code>call</code> statements in each of these procedures.</p>
<p>Last, you need to layout the boxes and draw connections. You could use <a href="http://en.wikipedia.org/wiki/Graphviz" rel="nofollow">Graphviz</a> to do that (you need to write a definition file in a syntax they call "dot language"), or check the Wikipedia <a href="http://en.wikipedia.org/wiki/Graph_drawing" rel="nofollow">Graph drawing</a> page, which has explanations of the algorithms used, as well as links to various other software packages which might fit your need better.</p>
|
8482
|
2015-03-17T12:38:12.853
|
<p>I am totally new to reverse engineering science and does not know much about the assembly language. By the way, I am working on a data set of disassembled malicious files available at <a href="https://www.kaggle.com/c/malware-classification" rel="nofollow">kaggle</a>. These files are generated by IDA Pro and I do not have access to executable files or IDA Pro.</p>
<p>In addition, I have read several papers on this topic and tried to implement one of them, <a href="http://dx.doi.org/10.1145/1653662.1653736" rel="nofollow">this one</a>. However, I need to generate a <strong>Function Call Graph</strong> from these codes. I have googled for hours, but could not find any open source tool to <strong>statically</strong> generate this graph from disassembled files.</p>
<p>I am a computer science student, hence, as is expected, I am willing to implement one if there are no ones out there, however, I do not know how or where to begin. </p>
<p>To sum it up, I have the following questions:</p>
<pre><code>1- How to generate function call graphs from disassembled files, statically?
2- Are there any algorithms, tools, or libraries to do this task or similar ones?
</code></pre>
<p>Regards</p>
|
How to extract a function call graph from IDA's Pro disassembled file (.asm file)?
|
|disassembly|functions|call|
|
<p>idc unattended </p>
<pre><code>F:\IDA_FRE_5>del outtext.txt & idag.exe -A -S.\segbase.idc c:\WINDOWS\system32\c
alc.idb & sleep 5 & type outtext.txt
Segment Base is 1001000
F:\IDA_FRE_5>type segbase.idc
#include <idc.idc>
static main ()
{
auto fpo,fullstr,segbase;
Batch(1);
segbase = SegStart(MinEA());
Message("base is %x\n",segbase);
fpo = fopen("outtext.txt","wb");
fullstr = form("Segment Base is %x\n",segbase);
writestr(fpo,fullstr);
fclose(fpo);
Exit(0);
}
F:\IDA_FRE_5>
</code></pre>
|
8488
|
2015-03-18T08:55:18.717
|
<p>As a beginner I'm trying to disassemble a file with IDA Pro 6.5.
I know that the image base can be find in IDA Pro manu Edit -> Segment -> Rebase program.</p>
<p>Now, I want to get the image base of current setting through IDC or IDAPython. Are there anyone to tell me how to write script? </p>
<p>Thanks in advance.</p>
|
How to get imge base of current setting through script in IDA pro?
|
|ida|idapython|
|
<p>According to the <a href="http://thegameagency.com/index.php/portfolio-posts/monopoly-zapped_draft/" rel="nofollow noreferrer">app developer's website</a>, the cards use <a href="http://en.wikipedia.org/wiki/Conductive_ink" rel="nofollow noreferrer">conductive ink</a> which can interact with the mobile device's capacitive screen.</p>
<p><img src="https://i.stack.imgur.com/BlIbJ.jpg" alt="Monopoly Zapped"></p>
|
8493
|
2015-03-18T15:52:56.287
|
<p>Last night I was playing Monopoly Zapped with the kids and I because quite intrigued as to how it worked. Basically, you interact with a tablet (or phone) whenever you want to do something... buy property, get out of jail, etc. </p>
<p>The weird thing is it all works just by touching the card to the screen (not the camera and there is no chip in the card) and the device does all the work... it even knows if a player is using the wrong card.</p>
<p>I've done a lot of searching on the Internet and cannot find ANYTHING to describe how this works. The only think I can think is there is some sort of "electrified" ink that is reacting with the digitizer on the screen. </p>
<p>Does anyone have any other ideas?</p>
<p>Thanks.</p>
|
Special ink for iPhone (or other mobile) screen for interaction
|
|android|ios|
|
<p>You can try the following steps:</p>
<ol>
<li><p>convert binary file to IDB:</p>
<pre><code>$IDA_PATH\\idaq.exe -B -p+ $FILE_TO_CONVERT
</code></pre></li>
<li><p>create <code>BinExport</code> from idb</p>
<pre><code>$IDA_PATH\\idaq.exe -A -SC:\\bindiff_export.idc
</code></pre>
<p>where <code>bindiff_export.idc</code> looks like:</p>
<pre><code>#include <idc.idc>
static main()
{
Batch(0);
Wait();
Exit( 1 - RunPlugin("zynamics_binexport_5", 2 ));
}
</code></pre></li>
</ol>
<p>Should you also want to diff files, you can use BinDiff directly on <code>BinExports</code>:</p>
<pre><code>$PATH_TO_BINDIFF\\bin\\BinDiff_Deluxe.exe -i $BIN_EXPORT_A -j $BIN_EXPORT_B -o $OUTPUT
</code></pre>
|
8495
|
2015-03-19T02:30:07.720
|
<p>I am trying to evaluate a very large amount of binaries (thousands) using <code>BinDiff</code>, and currently I only need some instruction level statistics from BinDiff, which can be acquired from its dumped <code>sqlite</code> file easily. </p>
<p>But my problem is that testing thousands of binaries using the GUI of IDA/BinDiff looks too time consuming.. </p>
<p>I am wondering can I invoke plugins of IDA-Pro, in particular, <code>BinDiff</code>, from command line and dump its output out? Is it possible to do so? </p>
<p>I have some experience to use command line ida, but that only limits to execute some IDAPython scripts. </p>
<p>The test is on Windows 7, with IDA-Pro 6.6 and BinDiff 4.1. </p>
|
Can I invoke IDA's plugin BinDiff from command line?
|
|ida|idapython|ida-plugin|tool-bindiff|
|
<p>They can load their dynamic libraries dynamically by using <code>dlopen</code> and <code>dlsym</code> functions.
Here is the <a href="http://linux.die.net/man/3/dlsym" rel="nofollow">man page of dlsym</a> and <a href="http://christopherpoole.github.io/dynamically-linking-shared-objects-in-c++/" rel="nofollow">usage example</a></p>
|
8512
|
2015-03-22T02:13:16.133
|
<p>I'm trying understand how some parts of a closed source program distributed as a stripped binary implemented. When I run <code>ldd</code> on the program, it prints only 4-5 most basic C libraries as dynamic dependencies. (e.g. <code>libc</code>, <code>glib</code>, <code>gobject</code> etc.) However, when I run it in gdb or attach gdb to it and run <code>info sharedlibrary</code>, it prints a huge list of libraries. Indeed, that program clearly uses GTK for GUI, for example, but gtk libraries are missing in <code>ldd</code> output and shown in <code>info sharedlibrary</code> output.</p>
<p>I was wondering does it work and how did they achieve this. Any ideas?</p>
<p>Thanks.</p>
|
ldd doesn't show dynamic libraries
|
|gdb|libraries|dynamic-linking|
|
<p>This is just a bit of optimization. A <code>call xxxx</code> followed by a <code>ret</code> can be optimized to a <code>jmp xxxx</code>.</p>
|
8517
|
2015-03-22T10:26:16.650
|
<p><img src="https://i.stack.imgur.com/Dtwx4.png" alt="IDA Pro function with no ret as last instruction but a jump to a label"></p>
<p>Analyzing the ELF file /usr/bin/curl (Ubuntu 14.04, 64bit), I stumbled upon a strange function (see image). It is called regularly via <code>call sub_403D90</code> but does not end with a ret. Instead, it jumps to a label / another function (<code>sub_403C90</code>).
This is strange because there seems to be no return to <code>sub_403D90</code>, as from <code>sub_403C90</code> onwards in the control flow, there are no jumps but only rets.</p>
<p>Can someone explain to me why this is? Does it makes sense?</p>
|
Strange function in IDA Pro: Only one basic block ending with a jmp sub_xxxxxx (instead of a ret)
|
|ida|disassembly|idapython|compilers|functions|
|
<p>You can do this pretty easily with Pwntools:</p>
<pre><code>from pwn import *
elf = ELF('./your-binary')
elf.asm(elf.symbols.ptrace, 'xor eax, eax; ret')
elf.save('./your-patched-binary')
</code></pre>
|
8520
|
2015-03-22T15:26:35.430
|
<p>I was reading <a href="http://blog.frizn.fr/hacklu-2013/reverse-400-elf" rel="nofollow">this CTF</a> write up and wanted to know more than the author cared to explain. </p>
<blockquote>
<p>I actually just patched the PLT entries of getenv(), ptrace() and sleep(), as sleeps get pretty annoying during debug</p>
</blockquote>
<p>What I wanted to know is what's the best way of going about patching PLT or GOT entries directly into the binary? </p>
|
Patching PLT entries
|
|elf|got|plt|
|
<p>Each section in the firmware file has a crc32 over its contents.</p>
<p>See <a href="https://github.com/booto/develo_fw" rel="nofollow">this</a>.</p>
<p>It should make option 1 more viable.</p>
<p>More details:
Inside the squashfs image there's whole heap of busybox based tools and a handful of standalone programs. There's one (<em>/usr/sbin/chunk</em>) that looked likely to have logic concerning the traversal of the firmware files. It contains a number of the 32bit values that matched the values in the firmware file that look like magic/fourcc values. strings(1) output was also pretty encouraging.</p>
|
8521
|
2015-03-22T19:06:20.433
|
<p>I am trying to do some reverse engineering to a Devolo dlan wifi 500 device (MIPS architecture). My objective is to put there some firmware modified by me.</p>
<p>This is where I got so far:</p>
<ol>
<li>Downloaded a firmware update from <a href="http://update.devolo.com/linux2/apt/pool/main/d/devolo-firmware-dlan500-wifi/" rel="nofollow noreferrer">http://update.devolo.com/linux2/apt/pool/main/d/devolo-firmware-dlan500-wifi/</a></li>
<li>Extracted firmware image from debian package</li>
<li>Analyzed image with binwalk</li>
<li>Extracted contents with firmware mod kit (present on google code).</li>
<li>Modded image</li>
<li>Rebuilded with fmk</li>
<li>Used web interface of device to upload new firmware</li>
</ol>
<p>It failed on step 7. I get a message saying something like "this file does not contain valid data". So, some sort of verification is performed by the device before installing updates.</p>
<p>So I kept investigating. The devolo image contains a devolo header/footer, a uboot and a uimage. The header/footer must contain some sort of checksum. I tried picking the valid (unmodified) update and changed one bit on the padding, uploaded it to the device and got the same error message.</p>
<p>If I knew where the checksum is or how is obtained, I could change it after rebuilding the image. However I found no documentation about the devolo formats. To try to find the sum I compared the hexadecimal of two devolo images: wifi and wireless(the wireless image is on the same site from where I downloaded the wifi image; could not post this link and the fmk link because I have less than 10 reputation :( ). The headers/footers are very similar in most fields, though I found no 32byte field to be a sum. Perhaps someone more experienced on reverse engineering could help me.</p>
<p>I could try to brute force the sum. Since it is a sum, I could create a collision by adding bits to the padding areas. For this I have two ideas:</p>
<ol>
<li>Send through the network every combination possible;</li>
<li>Use the downloaded image's libraries to test the sum locally;</li>
</ol>
<p>Option 1 would probably take a few years...</p>
<p>For option 2, I tried using a qemu virtual machine and compile there, and cross compiling, with no results, due to the devolo libs using an old libc version (<a href="https://stackoverflow.com/questions/29153924/how-to-solve-c-conflicts-between-system-and-library-dependencies">https://stackoverflow.com/questions/29153924/how-to-solve-c-conflicts-between-system-and-library-dependencies</a>).</p>
<p>My last idea is to somehow emulate the downloaded firmware in my amd64 machine, to compile some code there that would use the devolo libs, thus circumventing the dependency problems.</p>
<p>So, I would thank any tips/mistakes on my previous steps, and any pointers on how to run the downloaded image on my pc.</p>
|
Reverse engineering Devolo firmware
|
|firmware|mips|
|
<p>2) The system call is <a href="http://en.wikipedia.org/wiki/Ptrace" rel="noreferrer"><code>ptrace</code></a>. That call has lots of functionality, including "copy a section of the tracee's memory into a local buffer in my address space" and the reverse "copy my buffer to the tracee's memory". These are quite similar to windows' <code>ReadProcessMemory</code> and <code>WriteProcessMemory</code>. The tracing program needs to use these to access memory in the traced program.</p>
<p>1) The fact that you can't, really, attach to processes that aren't yours, unless you have <code>root</code> access, or (on Linux), the <code>CAP_SYS_PTRACE</code> capability. In some newer Linuxes, you don't even have rights to <code>ptrace</code> all of your own processes, depending on the <code>yama</code> settings and whether the traced process is a (grand)child of the tracing process. The wikipedia page explains this in more detail.</p>
<p>3) No, you can't. At least not reliably. Whichever trick you'd want to use could be intercepted by the tracer. Also, you generally don't want to do this, since you need <code>ptrace</code> to debug your program, and whoever has rights to <code>ptrace</code> you could screw you in various other ways as well. However, a process can't have more than one tracer attached at a time, so you could have a master process that spawns and <code>ptrace</code>s the worker, so noone else can attach to the worker to trace it. Of course, the worker would still need a way to check if it's parent is alive (compare <code>getppid()</code> with 1 for example) and that the tracer isn't intercepting your <code>getppid()</code> calls and patching them to return the old parent id.</p>
|
8531
|
2015-03-23T15:59:15.793
|
<p>The fact that GDB can attach to any process without having su rights is terrifying to me. For example, what prevents me from writing a malware/virus(/whatever the correct term is) that uses same system calls with GDB to attach to any processes, send interrupts, change instructions on the fly, add breakpoints to branching instructions to alter ZF etc.?</p>
<p>You can clearly do lots of harmful things with this ability. For example, I'm doing some minor hacks using some GDB Python scripts and I can't see what's preventing me from writing some seriously dangerous/malicious stuff.</p>
<p>So I have some number of questions related with how is this possible and how is this safe:</p>
<p>(I'm assuming that it's the operating system who allows a process to somehow send interrupts to some other one, and access to it's address space and alter the memory. Please correct me if I'm wrong)</p>
<p>1) What makes this safe? What prevents me from writing a program that alters behaviours of every single process running in a system?</p>
<p>2) What system calls are involved? How does operating system give me access to address space of some other process, while not taking my own address space from me. (e.g. GDB has it's own address space, but it can also read attached process' address space)</p>
<p>3) In my user-level program, is it possible to detect this kind of "attaching"? Like, can I print a message and terminate if another process is attached to my program? How do I detect this?</p>
<p>(I'm using "attaching" as "starting writing/reading my address space")</p>
<p>Thanks.</p>
|
Why/how is GDB allowed to attach to a process and read/write to attached process' address space?
|
|gdb|operating-systems|process|
|
<p>Someone pointed me to <a href="https://github.com/LongSoft/UEFITool" rel="nofollow">UEFITool</a>, which does exactly what I wanted. There's also an extractor version which dumps out all the separate nested binary components to directories. From this I was able to go through and analyse individual modules in IDA (they're x86 PE files, so it's easy).</p>
<p>I've not got quite as far as identifying whether the rowhammer mitigations are in place, but I'm writing some scripts to do bindiffs of each changed component, which should hopefully give me some idea of what I'm looking for.</p>
|
8538
|
2015-03-23T20:53:13.537
|
<p>I'm looking to identify code changes in the latest UEFI release for my motherboard, to verify whether the changes include mitigations for the <a href="http://en.wikipedia.org/wiki/Row_hammer" rel="nofollow">row hammer</a> vulnerability. I'm specifically looking at the last 3 releases (2401, 2304, 2201) of the Asus Maximus VII Hero board, which can be downloaded <a href="http://www.asus.com/uk/Motherboards/MAXIMUS_VII_HERO/HelpDesk_Download/" rel="nofollow">here</a>.</p>
<p>The UEFI binaries are provided as CAP files, which I'm not used to seeing. Apparently these are "UEFI Capsules", which Intel has <a href="http://www.intel.com/content/www/us/en/architecture-and-technology/unified-extensible-firmware-interface/efi-capsule-specification.html" rel="nofollow">a specification</a> for, but I've tried both automatic analysis (with <a href="https://github.com/theopolis/uefi-firmware-parser" rel="nofollow">uefi-firmware-parser</a>) and some manual digging to no avail. Running binwalk across them results in the usual noise of supposed LZMA blobs, but even once I grep past those I just run into a couple of false positive detections for encrypted data.</p>
<p>The actual data within alternates between repetitive, structured, and high-entropy (encrypted / compressed) blocks, but I can't find anything obvious. Running a bindiff across the different revisions shows me some majorly changed blocks, and some odd bytes here and there.</p>
<p>IDA doesn't seem to recognise anything in there as being EFI code, so I'm now stumped.</p>
<p>How can I get started with these CAP files? Is there any research out there that I should read? Are there any toolchains to work with them?</p>
|
Reverse engineering UEFI CAP files
|
|firmware|static-analysis|
|
<p>First thing i'd use is a digital oscilloscope, possibly with an included logic analyzer. Something like <a href="http://www.linkinstruments.com/mso19.html" rel="nofollow">this</a> is affordable and allows you to monitor up to 8 channels at the same time. Being able to see the delta times between different lines changing High/Low might help you a lot. (I'm not affiliated with this specific company; their products seem fine from the web site description; you may or may not find a better product/better price elsewhere).</p>
<p>Once you have reason to assume one of the lines uses serial communication, you might be interested in a <a href="http://en.wikipedia.org/wiki/Bus_Pirate" rel="nofollow">Bus Pirate</a> to investigate further. The Bus pirate also allows you to emulate serial transmission without having to program the arduino a lot; once you know how the protocol works, you can start implementing it (or use a pre-made library).</p>
<p>Since you don't know which of the lines is GND, i'd connect ground to the ground pin of the camera's battery. That way, you know for sure it's not on a data line that might change its voltage, and once you've identified the lines that seem to be 'always high' or 'always low', you know which ones are (probably) the power supply.</p>
<p>Depending on the physical layout of your hardware, it might be difficult to hook the logic analyzer/bus pirate to the pins while the lens is on the camera. What worked for me in such cases was making a paper template that had holes where the pins were supposed to be, and glue a bunch of thin aluminium foil stripes between two of these templates (of course the stripes need to be insulated from each other). If done with thin paper, you should be able to put it between the camera and the lens.</p>
<p>Also, i suggest some kind of precise time source with the logic analyzer, and using a cheap webcam to make a movie when you experiment with camera settings and lens reactions. This will allow you to match individual movie frames with signal transitions later, so you have a much better reference between "which switches did i press", "what did the camera/lens do", and "which signals appeared on the data lines" than when you try to write things down while experimenting.</p>
|
8541
|
2015-03-24T11:23:56.920
|
<p>I would like to control a lens with an Arduino board, but of course, I first have to find out how the protocol works. Using an oscilloscope I was able to find out that the protocol uses High and Low states (about 20ms long) to transfer information, but without even knowing where the ground is, that information is rather unreliable.
So what I know so far is this:</p>
<p>There are 10 pins, two of which would have to be power and ground for the motors in the lens.
The communication is digital, but not necessarily serial (e.g. Camera sends High on Pin X and the shutter in the lens opens and on the next High the shutter closes)
My guess is that the protocol is in fact serial as there seems to be a control mechanism in the lens checking the accuracy of the shutter speeds (for which it would need to know them; the shutter speed dial is on the camera)</p>
<p>How would I find out the pinout of this connector?</p>
<p>The lens is from the Rollei 6000 Series with the PQ shutter. By googling I could only find information about the communication with the filmback.</p>
<p>Thank you for you answers.</p>
|
Identifying the pinout of an unknown protocol (Rollei 6000 Camera-Lens communication)
|
|serial-communication|protocol|communication|
|
<p>The ELF binaries have in them headers named "program headers". When the kernel loads up a binary into memory, it only cares about 3 types of headers. <code>PT_LOAD</code> indicating whether or not the content corresponding to the header needs to be loaded into memory, <code>PT_GNU_STACK</code> indicating whether or not the stack needs to be made executable and <code>PT_INTERP</code> for determining the interpreter used to execute the binary.</p>
<p>So yes, the kernel sets the stack as non-executable or executable depending on whether or not a program header is present in the ELF. The ELF process can later use <code>mmap/mmap2/mprotect</code> libc/system calls to give executable privileges to specific pages in memory.</p>
|
8557
|
2015-03-25T18:27:04.003
|
<p>Perhaps I am misunderstanding how this works, but to my knowledge ELF binaries can either have NX protections for the stack, or not. What I am assuming is that there is a place in the binary that spells this out, but I'm not sure exactly where this information is stored. </p>
<p>How do you figure out the page permissions for an ELF binary from a disassembly? </p>
|
Where are page permissions stored in an ELF binary?
|
|disassembly|
|
<p>I'm not sure it's a checksum either. FF may be used as a padding flag. Also I think your "record size" needs to be reevaluated. I see this as a series of bytes that start with
<code>10 02 xx yy yy zz zz</code>
x and y might be options
z looks like data or a sequence (ish)
Then the next record looks like this
<code>10 03 xx xx</code>
Here's an observation on the <code>10 03</code> records:
<code>
10 03 d2 26
10 03 c2 07
10 03 f2 64
10 03 e2 45</code>
looking at the last 2 bytes, </p>
<p><code>0xD226 - 0xC207 = 0x101F</code></p>
<p><code>0xF264 - 0xE245 = 0x101F</code></p>
<p>I don't know what that means, but I think that relationship is not coincidence.</p>
<p>I took the data and did some binary find and replace to shift it from one line with two records to two lines, one of each record type. Specifically, I added three leading bytes to <code>0x1002</code>, removed those bytes at the very start to align the first record with the start of the file. Then they aligned nicely. However, when I found the FF, I saw that the records got misaligned, hence more evidence that its some sort of padding flag or something to keep the protocol on track, I guess. I added null bytes to shift the records back into conformance. I'll paste the results below, but only partial, because of the hastiness of my find and replace I think a portion of the data towards the end got borked up and I had "run out of time" to mess with it. I'll leave a little bit of where things got shifted, but keep in mind I tinkered with it a bit so I don't think I preserved it as well as the first section.</p>
<p>Edit:
That last byte of the <code>0x1002</code> record might be some sort of counter, note that when it becomes a full byte that's when some sort of sequence starts to reset.
Search for this string
10 02 41 02 20 00 FF</p>
<p>PS: Politely, it would have been nice to know what you were doing with the hardware to generate this data, some context for the evaluation may have been helpful.</p>
<p><code>
10 02 41 02 20 01 46
10 03 CB A4 00 00 00
10 02 41 02 20 00 18
10 03 43 AE 00 00 00
10 02 41 02 20 00 19
10 03 53 8F 00 00 00
10 02 41 02 20 00 1A
10 03 63 EC 00 00 00
10 02 41 02 20 00 1B
10 03 73 CD 00 00 00
10 02 41 02 20 00 1C
10 03 03 2A 00 00 00
10 02 41 02 20 00 1D
10 03 13 0B 00 00 00
10 02 41 02 20 00 1E
10 03 23 68 00 00 00
10 02 41 02 20 00 1F
10 03 33 49 00 00 00
10 02 41 02 20 00 20
10 03 F4 F5 00 00 00
10 02 41 02 20 00 21
10 03 E4 D4 00 00 00
10 02 41 02 20 00 22
10 03 D4 B7 00 00 00
10 02 41 02 20 00 23
10 03 C4 96 00 00 00
10 02 41 02 20 00 24
10 03 B4 71 00 00 00
10 02 41 02 20 00 25
10 03 A4 50 00 00 00
10 02 41 02 20 00 26
10 03 94 33 00 00 00
10 02 41 02 20 00 27
10 03 84 12 00 00 00
10 02 41 02 20 00 28
10 03 75 FD 00 00 00
10 02 41 02 20 00 29
10 03 65 DC 00 00 00
10 02 41 02 20 00 2A
10 03 55 BF 00 00 00
10 02 41 02 20 00 2B
10 03 45 9E 00 00 00
10 02 41 02 20 00 2C
10 03 35 79 00 00 00
10 02 41 02 20 00 2D
10 03 25 58 00 00 00
10 02 41 02 20 00 2E
10 03 15 3B 00 00 00
10 02 41 02 20 00 2F
10 03 05 1A 00 00 00
10 02 41 02 20 00 30
10 03 E6 C4 00 00 00
10 02 41 02 20 00 31
10 03 F6 E5 00 00 00
10 02 41 02 20 00 32
10 03 C6 86 00 00 00
10 02 41 02 20 00 33
10 03 D6 A7 00 00 00
10 02 41 02 20 00 34
10 03 A6 40 00 00 00
10 02 41 02 20 00 35
10 03 B6 61 00 00 00
10 02 41 02 20 00 36
10 03 86 02 00 00 00
10 02 41 02 20 00 37
10 03 96 23 00 00 00
10 02 41 02 20 00 38
10 03 67 CC 00 00 00
10 02 41 02 20 00 39
10 03 77 ED 00 00 00
10 02 41 02 20 00 3A
10 03 47 8E 00 00 00
10 02 41 02 20 00 3B
10 03 57 AF 00 00 00
10 02 41 02 20 00 3C
10 03 27 48 00 00 00
10 02 41 02 20 00 3D
10 03 37 69 00 00 00
10 02 41 02 20 00 3E
10 03 07 0A 00 00 00
10 02 41 02 20 00 3F
10 03 17 2B 00 00 00
10 02 41 02 20 00 40
10 03 98 53 00 00 00
10 02 41 02 20 00 41
10 03 88 72 00 00 00
10 02 41 02 20 00 42
10 03 B8 11 00 00 00
10 02 41 02 20 00 43
10 03 A8 30 00 00 00
10 02 41 02 20 00 44
10 03 D8 D7 00 00 00
10 02 41 02 20 00 45
10 03 C8 F6 00 00 00
10 02 41 02 20 00 46
10 03 F8 95 00 00 00
10 02 41 02 20 00 47
10 03 E8 B4 00 00 00
10 02 41 02 20 00 48
10 03 19 5B 00 00 00
10 02 41 02 20 00 49
10 03 09 7A 00 00 00
10 02 41 02 20 00 4A
10 03 39 19 00 00 00
10 02 41 02 20 00 4B
10 03 29 38 00 00 00
10 02 41 02 20 00 4C
10 03 59 DF 00 00 00
10 02 41 02 20 00 4D
10 03 49 FE 00 00 00
10 02 41 02 20 00 4E
10 03 79 9D 00 00 00
10 02 41 02 20 00 4F
10 03 69 BC 00 00 00
10 02 41 02 20 00 50
10 03 8A 62 00 00 00
10 02 41 02 20 00 51
10 03 9A 43 00 00 00
10 02 41 02 20 00 52
10 03 AA 20 00 00 00
10 02 41 02 20 00 53
10 03 BA 01 00 00 00
10 02 41 02 20 00 54
10 03 CA E6 00 00 00
10 02 41 02 20 00 55
10 03 DA C7 00 00 00
10 02 41 02 20 00 56
10 03 EA A4 00 00 00
10 02 41 02 20 00 57
10 03 FA 85 00 00 00
10 02 41 02 20 00 58
10 03 0B 6A 00 00 00
10 02 41 02 20 00 59
10 03 1B 4B 00 00 00
10 02 41 02 20 00 5A
10 03 2B 28 00 00 00
10 02 41 02 20 00 5B
10 03 3B 09 00 00 00
10 02 41 02 20 00 5C
10 03 4B EE 00 00 00
10 02 41 02 20 00 5D
10 03 5B CF 00 00 00
10 02 41 02 20 00 5E
10 03 6B AC 00 00 00
10 02 41 02 20 00 5F
10 03 7B 8D 00 00 00
10 02 41 02 20 00 60
10 03 BC 31 00 00 00
10 02 41 02 20 00 61
10 03 AC 10 00 00 00
10 02 41 02 20 00 62
10 03 9C 73 00 00 00
10 02 41 02 20 00 63
10 03 8C 52 00 00 00
10 02 41 02 20 00 64
10 03 FC B5 00 00 00
10 02 41 02 20 00 65
10 03 EC 94 00 00 00
10 02 41 02 20 00 66
10 03 DC F7 00 00 00
10 02 41 02 20 00 67
10 03 CC D6 00 00 00
10 02 41 02 20 00 68
10 03 3D 39 00 00 00
10 02 41 02 20 00 69
10 03 2D 18 00 00 00
10 02 41 02 20 00 6A
10 03 1D 7B 00 00 00
10 02 41 02 20 00 6B
10 03 0D 5A 00 00 00
10 02 41 02 20 00 6C
10 03 7D BD 00 00 00
10 02 41 02 20 00 6D
10 03 6D 9C 00 00 00
10 02 41 02 20 00 6E
10 03 5D FF 00 00 00
FF 00 00 00 00 00 00
10 02 41 02 20 00 6F
10 03 4D DE 00 00 00
10 02 41 02 20 00 70
10 03 AE 00 00 00 00
10 02 41 02 20 00 71
10 03 BE 21 00 00 00
10 02 41 02 20 00 72
10 03 8E 42 00 00 00
10 02 41 02 20 00 73
10 03 9E 63 00 00 00
10 02 41 02 20 00 74
10 03 EE 84 00 00 00
10 02 41 02 20 00 75
10 03 FE A5 00 00 00
10 02 41 02 20 00 76
10 03 CE C6 00 00 00
10 02 41 02 20 00 77
10 03 DE E7 00 00 00
10 02 41 02 20 00 78
10 03 2F 08 00 00 00
10 02 41 02 20 00 79
10 03 3F 29 00 00 00
10 02 41 02 20 00 7A
10 03 0F 4A 00 00 00
10 02 41 02 20 00 7B
10 03 1F 6B 00 00 00
10 02 41 02 20 00 7C
10 03 6F 8C 00 00 00
10 02 41 02 20 00 7D
10 03 7F AD 00 00 00
10 02 41 02 20 00 7E
10 03 4F CE 00 00 00
10 02 41 02 20 00 7F
10 03 5F EF 00 00 00
10 02 41 02 20 00 80
10 03 41 1F 00 00 00
10 02 41 02 20 00 81
10 03 51 3E 00 00 00
10 02 41 02 20 00 82
10 03 61 5D 00 00 00
10 02 41 02 20 00 83
10 03 71 7C 00 00 00
10 02 41 02 20 00 84
10 03 01 9B 00 00 00
10 02 41 02 20 00 85
10 03 11 BA 00 00 00
10 02 41 02 20 00 86
10 03 21 D9 00 00 00
10 02 41 02 20 00 87
10 03 31 F8 00 00 00
10 02 41 02 20 00 88
10 03 C0 17 00 00 00
10 02 41 02 20 00 89
10 03 D0 36 00 00 00
10 02 41 02 20 00 8A
10 03 E0 55 00 00 00
10 02 41 02 20 00 8B
10 03 F0 74 00 00 00
10 02 41 02 20 00 8C
10 03 80 93 00 00 00
10 02 41 02 20 00 8D
10 03 90 B2 00 00 00
10 02 41 02 20 00 8E
10 03 A0 D1 00 00 00
10 02 41 02 20 00 8F
10 03 B0 F0 00 00 00
10 02 41 02 20 00 90
10 03 53 2E 00 00 00
10 02 41 02 20 00 91
10 03 43 0F 00 00 00
10 02 41 02 20 00 92
10 03 73 6C 00 00 00
10 02 41 02 20 00 93
10 03 63 4D 00 00 00
10 02 41 02 20 00 94
10 03 13 AA 00 00 00
10 02 41 02 20 00 95
10 03 03 8B 00 00 00
10 02 41 02 20 00 97
10 03 23 C9 00 00 00
10 02 41 02 20 00 98
10 03 D2 26 00 00 00
10 02 41 02 20 00 99
10 03 C2 07 00 00 00
10 02 41 02 20 00 9A
10 03 F2 64 00 00 00
10 02 41 02 20 00 9B
10 03 E2 45 00 00 00
10 02 41 02 20 00 9C
10 03 92 A2 00 00 00
10 02 41 02 20 00 9D
10 03 82 83 00 00 00
10 02 41 02 20 00 9E
10 03 B2 E0 00 00 00
10 02 41 02 20 00 9F
10 03 A2 C1 00 00 00
10 02 41 02 20 00 A0
10 03 65 7D 00 00 00
10 02 41 02 20 00 A1
10 03 75 5C 00 00 00
10 02 41 02 20 00 A2
10 03 45 3F 00 00 00
10 02 41 02 20 00 A3
10 03 55 1E 00 00 00
10 02 41 02 20 00 A4
10 03 25 F9 00 00 00
10 02 41 02 20 00 A5
10 03 35 D8 00 00 00
10 02 41 02 20 00 A6
10 03 05 BB 00 00 00
10 02 41 02 20 00 A7
10 03 15 9A 00 00 00
10 02 41 02 20 00 A8
10 03 E4 75 00 00 00
10 02 41 02 20 00 A9
10 03 F4 54 00 00 00
10 02 41 02 20 00 AA
10 03 C4 37 00 00 00
10 02 41 02 20 00 AB
10 03 D4 16 00 00 00
10 02 41 02 20 00 AC
10 03 A4 F1 00 00 00
10 02 41 02 20 00 AD
10 03 B4 D0 00 00 00
10 02 41 02 20 00 AE
10 03 84 B3 00 00 00
10 02 41 02 20 00 AF
10 03 94 92 00 00 00
10 02 41 02 20 00 B0
10 03 77 4C 00 00 00
10 02 41 02 20 00 B1
10 03 67 6D 00 00 00
10 02 41 02 20 00 B2
10 03 57 0E 00 00 00
10 02 41 02 20 00 B3
10 03 47 2F 00 00 00
10 02 41 02 20 00 B4
10 03 37 C8 00 00 00
10 02 41 02 20 00 B5
10 03 27 E9 00 00 00
10 02 41 02 20 00 B6
10 03 17 8A 00 00 00
10 02 41 02 20 00 B7
10 03 07 AB 00 00 00
10 02 41 02 20 00 B8
10 03 F6 44 00 00 00
10 02 41 02 20 00 B9
10 03 E6 65 00 00 00
10 02 41 02 20 00 BA
10 03 D6 06 00 00 00
10 02 41 02 20 00 BB
10 03 C6 27 00 00 00
10 02 41 02 20 00 BC
10 03 B6 C0 00 00 00
10 02 41 02 20 00 BD
10 03 A6 E1 00 00 00
10 02 41 02 20 00 BE
10 03 96 82 00 00 00
10 02 41 02 20 00 BF
10 03 86 A3 00 00 00
10 02 41 02 20 00 C0
10 03 09 DB 00 00 00
10 02 41 02 20 00 C1
10 03 19 FA 00 00 00
10 02 41 02 20 00 C2
10 03 29 99 00 00 00
10 02 41 02 20 00 C3
10 03 39 B8 00 00 00
10 02 41 02 20 00 C4
10 03 49 5F 00 00 00
10 02 41 02 20 00 C5
10 03 59 7E 00 00 00
10 02 41 02 20 00 C6
10 03 69 1D 00 00 00
10 02 41 02 20 00 C7
10 03 79 3C 00 00 00
10 02 41 02 20 00 C8
10 03 88 D3 00 00 00
10 02 41 02 20 00 C9
10 03 98 F2 00 00 00
10 02 41 02 20 00 CA
10 03 A8 91 00 00 00
10 02 41 02 20 00 CB
10 03 B8 B0 00 00 00
10 02 41 02 20 00 CC
10 03 C8 57 00 00 00
10 02 41 02 20 00 CD
10 03 D8 76 00 00 00
10 02 41 02 20 00 CE
10 03 E8 15 00 00 00
10 02 41 02 20 00 CF
10 03 F8 34 00 00 00
10 02 41 02 20 00 D0
10 03 1B EA 00 00 00
10 02 41 02 20 00 D1
10 03 0B CB 00 00 00
10 02 41 02 20 00 D2
10 03 3B A8 00 00 00
10 02 41 02 20 00 D3
10 03 2B 89 00 00 00
10 02 41 02 20 00 D4
10 03 5B 6E 00 00 00
10 02 41 02 20 00 D5
10 03 4B 4F 00 00 00
10 02 41 02 20 00 D6
10 03 7B 2C 00 00 00
10 02 41 02 20 00 D7
10 03 6B 0D 00 00 00
10 02 41 02 20 00 D8
10 03 9A E2 00 00 00
10 02 41 02 20 00 D9
10 03 8A C3 00 00 00
10 02 41 02 20 00 DA
10 03 BA A0 00 00 00
10 02 41 02 20 00 DB
10 03 AA 81 00 00 00
10 02 41 02 20 00 DC
10 03 DA 66 00 00 00
10 02 41 02 20 00 DD
10 03 CA 47 00 00 00
10 02 41 02 20 00 DE
10 03 FA 24 00 00 00
10 02 41 02 20 00 DF
10 03 EA 05 00 00 00
10 02 41 02 20 00 E0
10 03 2D B9 00 00 00
10 02 41 02 20 00 E1
10 03 3D 98 00 00 00
10 02 41 02 20 00 E2
10 03 0D FB 00 00 00
10 02 41 02 20 00 E3
10 03 1D DA 00 00 00
10 02 41 02 20 00 E4
10 03 6D 3D 00 00 00
10 02 41 02 20 00 E5
10 03 7D 1C 00 00 00
10 02 41 02 20 00 E6
10 03 4D 7F 00 00 00
10 02 41 02 20 00 E7
10 03 5D 5E 00 00 00
10 02 41 02 20 00 E8
10 03 AC B1 00 00 00
10 02 41 02 20 00 E9
10 03 BC 90 00 00 00
10 02 41 02 20 00 EA
10 03 8C F3 00 00 00
10 02 41 02 20 00 EB
10 03 9C D2 00 00 00
10 02 41 02 20 00 EC
10 03 EC 35 00 00 00
10 02 41 02 20 00 ED
10 03 FC 14 00 00 00
10 02 41 02 20 00 EE
10 03 CC 77 00 00 00
10 02 41 02 20 00 EF
10 03 DC 56 00 00 00
10 02 41 02 20 00 F0
10 03 3F 88 00 00 00
10 02 41 02 20 00 F1
10 03 2F A9 00 00 00
10 02 41 02 20 00 F2
10 03 1F CA 00 00 00
10 02 41 02 20 00 F3
10 03 0F EB 00 00 00
10 02 41 02 20 00 F4
10 03 7F 0C 00 00 00
10 02 41 02 20 00 F5
10 03 6F 2D 00 00 00
10 02 41 02 20 00 F6
10 03 5F 4E 00 00 00
10 02 41 02 20 00 F7
10 03 4F 6F 00 00 00
10 02 41 02 20 00 F8
10 03 BE 80 00 00 00
10 02 41 02 20 00 F9
10 03 AE A1 00 00 00
10 02 41 02 20 00 FA
10 03 9E C2 00 00 00
10 02 41 02 20 00 FB
10 03 8E E3 00 00 00
10 02 41 02 20 00 FC
10 03 FE 04 00 00 00
10 02 41 02 20 00 FD
10 03 EE 25 00 00 00
10 02 41 02 20 00 FE
10 03 DE 46 00 00 00
10 02 41 02 20 00 FF
FF 00 00 00 00 00 00
10 03 CE 67 00 00 00
10 02 41 02 20 01 00
10 03 E3 A6 00 00 00
10 02 41 02 20 01 01
10 03 F3 87 00 00 00
10 02 41 02 20 01 02
10 03 C3 E4 00 00 00
10 02 41 02 20 01 03
10 03 D3 C5 00 00 00
10 02 41 02 20 01 04
10 03 A3 22 00 00 00
10 02 41 02 20 01 05
10 03 B3 03 00 00 00
10 02 41 02 20 01 06
10 03 83 60 00 00 00
10 02 41 02 20 01 07
10 03 93 41 00 00 00
10 02 41 02 20 01 08
10 03 62 AE 00 00 00
10 02 41 02 20 01 09
10 03 72 8F 00 00 00
10 02 41 02 20 01 0A
10 03 42 EC 00 00 00
10 02 41 02 20 01 0B
10 03 52 CD 00 00 00
10 02 41 02 20 01 0C
10 03 22 2A 00 00 00
10 02 41 02 20 01 0D
10 03 32 0B 00 00 00
10 02 41 02 20 01 0E
10 03 02 68 00 00 00
10 02 41 02 20 01 0F
10 03 12 49 00 00 00
10 02 41 02 20 01 10
10 10 03 F1 97 00 00
10 02 41 02 20 01 11
10 03 E1 B6 00 00 00
10 02 41 02 20 01 12
10 03 D1 D5 00 00 00
10 02 41 02 20 01 13
10 03 C1 F4 00 00 00
10 02 41 02 20 01 14
10 03 B1 13 00 00 00
10 02 41 02 20 01 15
10 03 A1 32 00 00 00
10 02 41 02 20 01 16
10 03 91 51 00 00 00
10 02 41 02 20 01 17
10 03 81 70 00 00 00
10 02 41 02 20 01 18
10 03 70 9F 00 00 00
10 02 41 02 20 01 19
10 03 60 BE 00 00 00
10 02 41 02 20 01 1A
10 03 50 DD 00 00 00
10 02 41 02 20 01 1B
10 03 40 FC 00 00 00
10 02 41 02 20 01 1C
10 03 30 1B 00 00 00
10 02 41 02 20 01 1D
10 03 20 3A 00 00 00
10 02 41 02 20 01 1E
10 03 10 59 00 00 00
10 02 41 02 20 01 1F
10 03 00 78 00 00 00
10 02 41 02 20 01 20
10 03 C7 C4 00 00 00
10 02 41 02 20 01 21
10 03 D7 E5 00 00 00
10 02 41 02 20 01 22
10 03 E7 86 00 00 00
10 02 41 02 20 01 23
10 03 F7 A7 00 00 00
10 02 41 02 20 01 24
10 03 87 40 00 00 00
10 02 41 02 20 01 25
10 03 97 61 00 00 00
10 02 41 02 20 01 26
10 03 A7 02 00 00 00
10 02 41 02 20 01 27
10 03 B7 23 00 00 00
10 02 41 02 20 01 28
10 03 46 CC 00 00 00
10 02 41 02 20 01 29
10 03 56 ED 00 00 00
10 02 41 02 20 01 2A
10 03 66 8E 00 00 00
10 02 41 02 20 01 2B
10 03 76 AF 00 00 00
10 02 41 02 20 01 2C
10 03 06 48 00 00 00
10 02 41 02 20 01 2D
10 03 16 69 00 00 00
10 02 41 02 20 01 2E
10 03 26 0A 00 00 00
10 02 41 02 20 01 2F
10 03 36 2B 00 00 00
10 02 41 02 20 01 30
10 03 D5 F5 00 00 00
10 02 41 02 20 01 31
10 03 C5 D4 00 00 00
10 02 41 02 20 01 32
10 03 F5 B7 00 00 00
10 02 41 02 20 01 33
10 03 E5 96 00 00 00
10 02 41 02 20 01 34
10 03 95 71 00 00 00
10 02 41 02 20 01 35
10 03 85 50 00 00 00
10 02 41 02 20 01 36
10 03 B5 33 00 00 00
10 02 41 02 20 01 37
10 03 A5 12 00 00 00
10 02 41 02 20 01 38
10 03 54 FD 00 00 00
10 02 41 02 20 01 39
10 03 44 DC 00 00 00
10 02 41 02 20 01 3A
10 03 74 BF 00 00 00
10 02 41 02 20 01 3B
10 03 64 9E 00 00 00
10 02 41 02 20 01 3C
10 03 14 79 00 00 00
10 02 41 02 20 01 3D
10 03 04 58 00 00 00
10 02 41 02 20 01 3E
10 03 34 3B 00 00 00
10 02 41 02 20 01 3F
10 03 24 1A 00 00 00
10 02 41 02 20 01 40
10 03 AB 62 00 00 00
10 02 41 02 20 01 41
10 03 BB 43 00 00 00
10 02 41 02 20 01 42
10 03 8B 20 00 00 00
10 02 41 02 20 01 43
10 03 9B 01 00 00 00
10 02 41 02 20 01 44
10 03 EB E6 00 00 00
10 02 41 02 20 01 45
10 03 FB C7 00 00 00
10 02 41 02 20 01 46
10 03 CB A4 00 00 00
10 02 41 02 20 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 05
10 03 68 94 00 00 00
10 02 41 02 02 00 06
10 03 58 F7 00 00 00
10 02 41 02 02 00 06
10 03 58 F7 00 00 00
10 02 41 02 02 00 06
10 03 58 F7 00 00 00
10 02 41 02 02 00 06
10 03 58 F7 00 00 00
10 02 41 02 02 00 06
10 03 58 F7 00 00 00
10 02 41 02 02 00 07
10 03 48 D6 00 00 00
10 02 41 02 02 00 07
10 03 48 D6 00 00 00
10 02 41 02 02 00 07
10 03 48 D6 00 00 00
10 02 41 02 02 00 07
10 03 48 D6 00 00 00
10 02 41 02 02 00 07
10 03 48 D6 00 00 00
10 02 41 02 02 00 08
10 03 B9 39 00 00 00
10 02 41 02 02 00 08
10 03 B9 39 00 00 00
10 02 41 02 02 00 09
10 03 A9 18 00 00 00
10 02 41 02 02 00 09
10 03 A9 18 00 00 00
10 02 41 02 02 00 09
10 03 A9 18 00 00 00
10 02 41 02 02 00 0A
10 03 99 7B 00 00 00
10 02 41 02 02 00 0A
10 03 99 7B 00 00 00
10 02 41 02 02 00 0B
10 03 89 5A 00 00 00
10 02 41 02 02 00 0B
10 03 89 5A 00 00 00
10 02 41 02 02 00 0D
10 03 E9 9C 00 00 00
10 02 41 02 02 00 0D
10 03 E9 9C 00 00 00
10 02 41 02 02 00 0E
10 03 D9 FF 00 00 00
FF 00 00 00 00 00 00
10 02 41 02 02 00 0F
10 03 C9 DE 00 00 00
10 02 41 02 02 00 10
10 00 00 00 00 00 00
10 03 2A 00 00 00 00
10 02 41 02 02 00 11
10 03 3A 21 00 00 00
10 02 41 02 02 00 12
10 03 0A 42 00 00 00
10 02 41 02 02 00 13
10 03 1A 63 00 00 00
10 02 41 02 02 00 14
10 03 6A 84 00 00 00
10 02 41 02 02 00 17
10 03 5A E7 00 00 00
10 02 41 02 02 00 19
10 03 BB 29 00 00 00
10 02 41 02 02 00 1D
10 03 FB AD 00 00 00
10 02 41 02 02 00 20
10 03 1C 53 00 00 00
10 02 41 02 02 00 27
10 03 6C B4 00 00 00
10 02 41 02 02 00 2D
10 03 CD FE 00 00 00
10 02 41 02 02 00 3C
10 03 CF EE 00 00 00
10 02 41 02 02 00 49
10 03 E1 DC 00 00 00
10 02 41 02 02 00 7E
10 03 A7 68 00 00 00
10 02 41 02 02 00 C4
10 03 A1 F9 00 00 00
10 02 41 02 02 7E E3
10 03 DE 2A 00 00 00
10 02 41 02 02 7E DA
10 03 79 50 00 00 00
10 02 41 02 02 7E D1
10 03 C8 3B 00 00 00
10 02 41 02 02 7E C8
10 03 4B 23 00 00 00
10 02 41 02 02 7E B3
10 03 84 DF 00 00 00
10 02 41 02 02 7E 80
10 03 82 EF 00 00 00
10 02 41 02 02 7E 3A
10 03 84 7E 00 00 00
10 02 41 02 02 7D D5
10 03 DD EC 00 00 00
10 02 41 02 02 7D 36
10 03 10 A1 00 00 00
10 02 41 02 02 7C 18
10 03 E6 3C 00 00 00
10 02 41 02 02 7B A9
10 03 C8 51 00 00 00
10 02 41 02 02 00 49
10 03 E1 DC 00 00 00
10 02 41 02 02 00 2D
10 03 CD FE 00 00 00
10 02 41 02 02 00 3C
10 03 CF EE 00 00 00
10 02 41 02 02 00 7E
10 03 A7 68 00 00 00
10 02 41 02 02 01 C6
10 03 B2 8A 00 00 00
10 02 41 02 02 7E E3
10 03 DE 2A 00 00 00
10 02 42 02 01 00 00
10 03 05 8E 00 00 00
10 02 F4 02 20 00 01
00 01 10 03 4A BB 00
10 02 F4 02 20 00 01
10 03 5A 9A 00 00 00
10 02 F4 02 20 00 02
01 10 03 92 93 00 00
10 02 F4 02 20 00 02
00 10 03 82 B2 00 00
10 02 F4 02 28 00 FC
10 03 4F 80 00 00 00
10 02 F4 02 28 00 00
F9 10 03 1F 25 00 00
10 02 F4 02 28 00 00
F6 10 03 EE CA 00 00
00 10 02 F4 02 28 00
00 F3 10 03 BE 6F 00
00 00 10 02 F4 02 28
00 00 F0 10 03 8E 0C
00 00 00 10 02 F4 02
28 00 00 ED 10 03 4D
90 00 00 00 10 02 F4
02 28 00 00 EA 10 03
3D 77 00 00 00 10 02
F4 02 28 00 00 E7 10
03 EC DA 00 00 00 10
02 F4 02 28 00 00 E4
10 03 DC B9 00 00 00
10 02 F4 02 28 00 00
E1 10 03 8C 1C 00 00
00 10 02 F4 02 28 00
00 DE 10 03 4B A0 00
00 00 10 02 F4 02 28
00 00 DB 10 03 1B 05
00 00 00 10 02 F4 02
28 00 00 D8 10 03 2B
66 00 00 00 10 02 F4
02 28 00 00 D5 10 03
FA CB 00 00 00 10 02
F4 02 28 00 00 D3 10
03 9A 0D 00 00 00 10
02 F4 02 28 00 00 D0
10 03 AA 6E 00 00 00
10 02 F4 02 28 00 00
CD 10 03 69 F2 00 00
00 10 02 F4 02 28 00
00 CA 10 03 19 15 00
00 00 10 02 F4 02 28
00 00 C7 10 03 C8 B8
00 00 00 10 02 F4 02
28 00 00 C4 10 03 F8
DB 00 00 00 10 02 F4
02 28 00 00 C1 10 03
A8 7E 00 00 00 10 02
F4 02 28 00 00 BE 10
03 27 06 00 00 00 10
02 F4 02 28 00 00 BB
10 03 77 A3 00 00 00
10 02 F4 02 28 00 00
B8 10 03 47 C0 00 00
00 10 02 F4 02 28 00
00 B5 10 03 96 6D 00
00 00 10 02 F4 02 28
00 00 B2 10 03 E6 8A
00 00 00 10 02 F4 02
28 00 00 AF 10 03 25
16 00 00 00 10 02 F4
02 28 00 00 AC 10 03
15 75 00 00 00 10 02
F4 02 28 00 00 A9 10
03 45 D0 00 00 00 10
02 F4 02 28 00 00 A6
10 03 B4 3F 00 00 00
10 02 F4 02 28 00 00
A3 10 03 E4 9A 00 00
00 10 02 F4 02 28 00
00 A0 10 03 D4 F9 00
00 00 10 02 F4 02 28
00 00 9D 10 03 33 07
00 00 00 10 02 F4 02
28 00 00 9A 10 03 43
E0 00 00 00 10 02 F4
02 28 00 00 94 10 03
A2 2E 00 00 00 10 02
F4 02 28 00 00 91 10
03 F2 8B 00 00 00 10
02 F4 02 28 00 00 8E
10 03 11 55 00 00 00
10 02 F4 02 28 00 00
8B 10 03 41 F0 00 00
00 10 02 F4 02 28 00
00 88 10 03 71 93 00
00 00 10 02 F4 02 28
00 00 85 10 03 A0 3E
00 00 00 10 02 F4 02
28 00 00 82 10 03 D0
D9 00 00 00 10 02 F4
02 28 00 00 7F 10 03
EE 6B 00 00 00 10 02
F4 02 28 00 00 7D 10
03 CE 29 00 00 00 10
02 F4 02 28 00 00 7A
10 03 BE CE 00 00 00
10 02 F4 02 28 00 00
77 10 03 6F 63 00 00
00 10 02 F4 02 28 00
00 74 10 03 5F 00 00
00 00 10 02 F4 02 28
00 00 71 10 03 0F A5
00 00 00 10 02 F4 02
28 00 00 6E 10 03 EC
7B 00 00 00 10 02 F4
02 28 00 00 6B 10 03
BC DE 00 00 00 10 02
F4 02 28 00 00 68 10
03 8C BD 00 00 00 10
02 F4 02 28 00 00 65
10 03 5D 10 00 00 00
10 02 F4 02 28 00 00
62 10 03 2D F7 00 00
00 10 02 F4 02 28 00
00 5F 10 03 CA 09 00
00 00 10 02 F4 02 28
00 00 5C 10 03 FA 6A
00 00 00 10 02 F4 02
28 00 00 59 10 03 AA
CF 00 00 00 10 02 F4
02 28 00 00 56 10 03
5B 20 00 00 00 10 02
F4 02 28 00 00 53 10
03 0B 85 00 00 00 10
02 F4 02 28 00 00 50
10 03 3B E6 00 00 00
10 02 F4 02 28 00 00
4D 10 03 F8 7A 00 00
00 10 02 F4 02 28 00
00 4A 10 03 88 9D 00
00 00 10 02 F4 02 28
00 00 47 10 03 59 30
00 00 00 10 02 F4 02
28 00 00 44 10 03 69
53 00 00 00 10 02 F4
02 28 00 00 41 10 03
39 F6 00 00 00 10 02
F4 02 28 00 00 3E 10
03 B6 8E 00 00 00 10
02 F4 02 28 00 00 3B
10 03 E6 2B 00 00 00
10 02 F4 02 28 00 00
38 10 03 D6 48 00 00
00 10 02 F4 02 28 00
00 35 10 03 07 E5 00
00 00 10 02 F4 02 28
00 00 32 10 03 77 02
00 00 00 10 02 F4 02
28 00 00 2F 10 03 B4
9E 00 00 00 10 02 F4
02 28 00 00 2C 10 03
84 FD 00 00 00 10 02
F4 02 28 00 00 2A 10
03 E4 3B 00 00 00 10
02 F4 02 28 00 00 27
10 03 35 96 00 00 00
10 02 F4 02 28 00 00
24 10 03 05 F5 00 00
00 10 02 F4 02 28 00
00 21 10 03 55 50 00
00 00 10 02 F4 02 28
00 00 1E 10 03 92 EC
00 00 00 10 02 F4 02
28 00 00 1B 10 03 C2
49 00 00 00 10 02 F4
02 28 00 00 18 10 03
F2 2A 00 00 00 10 02
F4 02 28 00 00 15 10
03 23 87 00 00 00 10
02 F4 02 28 00 00 12
10 03 53 60 00 00 00
10 02 F4 02 28 00 00
0F 10 03 90 FC 00 00
00 10 02 F4 02 28 00
00 0C 10 03 A0 9F 00
00 00 10 02 F4 02 28
00 00 09 10 03 F0 3A
00 00 00 10 02 F4 02
28 00 00 06 10 03 01
D5 00 00 00 10 02 F4
02 28 00 00 03 10 03
51 70 00 00 00 10 02
F4 02 28 00 00 00 10
03 61 13 00 00 00 10
02 F4 02 28 00 00 01
10 03 71 32 00 00 00
10 02 F4 02 28 00 00
00 10 03 61 13 00 00
00 10 02 F4 02 28 00
00 FE 10 03 6F C2 00
00 00 10 02 F4 02 28
00 00 FF FF 10 03 7F
E3 00 00 00 10 02 F4
02 28 00 00 01 10 03
71 32 00 00 00 10 02
F4 02 28 00 00 00 10
03 61 13 00 00 00 10
02 F4 02 00 00 00 10
03 5B 38 00 00 00 10
02 F4 02 20 00 00 10
03 DD FE
</code></p>
|
8561
|
2015-03-26T08:38:03.247
|
<p>I am writing a program to control an old camera over serial.
I have no access to the protocol or source code of the demonstration program that i have, but i can generate some correct checksums by monitoring the communications in wireshark.</p>
<p>The length of the packets changes depending on what function i perform, and seems to sometimes change depending on the values of the contained data. (FF sometimes repeats in longer frames, although i cant be sure that these arent just errors)</p>
<p>The last 2 bytes of data are the checksum i assume. Other parts are the message function and data. In the packet below, the 01 46 corresponds with the value 326 which the software reports.</p>
<pre><code>10 02 41 02 20 01 46 10 03 cb a4
</code></pre>
<p>I personally cant see an obvious pattern to the checksum. The first byte seems to increment by 0x10 nicely with the data for a while, before jumping around then decrementing by 0x10, acting erratically.</p>
<p>Does this seem familiar to anyone?
How can I go about determining the algorithm to generate the checksum on an arbitrary message?</p>
<p>Ill attach lots of data for you to look at:</p>
<pre>
10 02 41 02 20 01 46 10 03 cb a4
10 02 41 02 20 00 18 10 03 43 ae
10 02 41 02 20 00 19 10 03 53 8f
10 02 41 02 20 00 1a 10 03 63 ec
10 02 41 02 20 00 1b 10 03 73 cd
10 02 41 02 20 00 1c 10 03 03 2a
10 02 41 02 20 00 1d 10 03 13 0b
10 02 41 02 20 00 1e 10 03 23 68
10 02 41 02 20 00 1f 10 03 33 49
10 02 41 02 20 00 20 10 03 f4 f5
10 02 41 02 20 00 21 10 03 e4 d4
10 02 41 02 20 00 22 10 03 d4 b7
10 02 41 02 20 00 23 10 03 c4 96
10 02 41 02 20 00 24 10 03 b4 71
10 02 41 02 20 00 25 10 03 a4 50
10 02 41 02 20 00 26 10 03 94 33
10 02 41 02 20 00 27 10 03 84 12
10 02 41 02 20 00 28 10 03 75 fd
10 02 41 02 20 00 29 10 03 65 dc
10 02 41 02 20 00 2a 10 03 55 bf
10 02 41 02 20 00 2b 10 03 45 9e
10 02 41 02 20 00 2c 10 03 35 79
10 02 41 02 20 00 2d 10 03 25 58
10 02 41 02 20 00 2e 10 03 15 3b
10 02 41 02 20 00 2f 10 03 05 1a
10 02 41 02 20 00 30 10 03 e6 c4
10 02 41 02 20 00 31 10 03 f6 e5
10 02 41 02 20 00 32 10 03 c6 86
10 02 41 02 20 00 33 10 03 d6 a7
10 02 41 02 20 00 34 10 03 a6 40
10 02 41 02 20 00 35 10 03 b6 61
10 02 41 02 20 00 36 10 03 86 02
10 02 41 02 20 00 37 10 03 96 23
10 02 41 02 20 00 38 10 03 67 cc
10 02 41 02 20 00 39 10 03 77 ed
10 02 41 02 20 00 3a 10 03 47 8e
10 02 41 02 20 00 3b 10 03 57 af
10 02 41 02 20 00 3c 10 03 27 48
10 02 41 02 20 00 3d 10 03 37 69
10 02 41 02 20 00 3e 10 03 07 0a
10 02 41 02 20 00 3f 10 03 17 2b
10 02 41 02 20 00 40 10 03 98 53
10 02 41 02 20 00 41 10 03 88 72
10 02 41 02 20 00 42 10 03 b8 11
10 02 41 02 20 00 43 10 03 a8 30
10 02 41 02 20 00 44 10 03 d8 d7
10 02 41 02 20 00 45 10 03 c8 f6
10 02 41 02 20 00 46 10 03 f8 95
10 02 41 02 20 00 47 10 03 e8 b4
10 02 41 02 20 00 48 10 03 19 5b
10 02 41 02 20 00 49 10 03 09 7a
10 02 41 02 20 00 4a 10 03 39 19
10 02 41 02 20 00 4b 10 03 29 38
10 02 41 02 20 00 4c 10 03 59 df
10 02 41 02 20 00 4d 10 03 49 fe
10 02 41 02 20 00 4e 10 03 79 9d
10 02 41 02 20 00 4f 10 03 69 bc
10 02 41 02 20 00 50 10 03 8a 62
10 02 41 02 20 00 51 10 03 9a 43
10 02 41 02 20 00 52 10 03 aa 20
10 02 41 02 20 00 53 10 03 ba 01
10 02 41 02 20 00 54 10 03 ca e6
10 02 41 02 20 00 55 10 03 da c7
10 02 41 02 20 00 56 10 03 ea a4
10 02 41 02 20 00 57 10 03 fa 85
10 02 41 02 20 00 58 10 03 0b 6a
10 02 41 02 20 00 59 10 03 1b 4b
10 02 41 02 20 00 5a 10 03 2b 28
10 02 41 02 20 00 5b 10 03 3b 09
10 02 41 02 20 00 5c 10 03 4b ee
10 02 41 02 20 00 5d 10 03 5b cf
10 02 41 02 20 00 5e 10 03 6b ac
10 02 41 02 20 00 5f 10 03 7b 8d
10 02 41 02 20 00 60 10 03 bc 31
10 02 41 02 20 00 61 10 03 ac 10
10 02 41 02 20 00 62 10 03 9c 73
10 02 41 02 20 00 63 10 03 8c 52
10 02 41 02 20 00 64 10 03 fc b5
10 02 41 02 20 00 65 10 03 ec 94
10 02 41 02 20 00 66 10 03 dc f7
10 02 41 02 20 00 67 10 03 cc d6
10 02 41 02 20 00 68 10 03 3d 39
10 02 41 02 20 00 69 10 03 2d 18
10 02 41 02 20 00 6a 10 03 1d 7b
10 02 41 02 20 00 6b 10 03 0d 5a
10 02 41 02 20 00 6c 10 03 7d bd
10 02 41 02 20 00 6d 10 03 6d 9c
10 02 41 02 20 00 6e 10 03 5d ff ff
10 02 41 02 20 00 6f 10 03 4d de
10 02 41 02 20 00 70 10 03 ae 00
10 02 41 02 20 00 71 10 03 be 21
10 02 41 02 20 00 72 10 03 8e 42
10 02 41 02 20 00 73 10 03 9e 63
10 02 41 02 20 00 74 10 03 ee 84
10 02 41 02 20 00 75 10 03 fe a5
10 02 41 02 20 00 76 10 03 ce c6
10 02 41 02 20 00 77 10 03 de e7
10 02 41 02 20 00 78 10 03 2f 08
10 02 41 02 20 00 79 10 03 3f 29
10 02 41 02 20 00 7a 10 03 0f 4a
10 02 41 02 20 00 7b 10 03 1f 6b
10 02 41 02 20 00 7c 10 03 6f 8c
10 02 41 02 20 00 7d 10 03 7f ad
10 02 41 02 20 00 7e 10 03 4f ce
10 02 41 02 20 00 7f 10 03 5f ef
10 02 41 02 20 00 80 10 03 41 1f
10 02 41 02 20 00 81 10 03 51 3e
10 02 41 02 20 00 82 10 03 61 5d
10 02 41 02 20 00 83 10 03 71 7c
10 02 41 02 20 00 84 10 03 01 9b
10 02 41 02 20 00 85 10 03 11 ba
10 02 41 02 20 00 86 10 03 21 d9
10 02 41 02 20 00 87 10 03 31 f8
10 02 41 02 20 00 88 10 03 c0 17
10 02 41 02 20 00 89 10 03 d0 36
10 02 41 02 20 00 8a 10 03 e0 55
10 02 41 02 20 00 8b 10 03 f0 74
10 02 41 02 20 00 8c 10 03 80 93
10 02 41 02 20 00 8d 10 03 90 b2
10 02 41 02 20 00 8e 10 03 a0 d1
10 02 41 02 20 00 8f 10 03 b0 f0
10 02 41 02 20 00 90 10 03 53 2e
10 02 41 02 20 00 91 10 03 43 0f
10 02 41 02 20 00 92 10 03 73 6c
10 02 41 02 20 00 93 10 03 63 4d
10 02 41 02 20 00 94 10 03 13 aa
10 02 41 02 20 00 95 10 03 03 8b
10 02 41 02 20 00 97 10 03 23 c9
10 02 41 02 20 00 98 10 03 d2 26
10 02 41 02 20 00 99 10 03 c2 07
10 02 41 02 20 00 9a 10 03 f2 64
10 02 41 02 20 00 9b 10 03 e2 45
10 02 41 02 20 00 9c 10 03 92 a2
10 02 41 02 20 00 9d 10 03 82 83
10 02 41 02 20 00 9e 10 03 b2 e0
10 02 41 02 20 00 9f 10 03 a2 c1
10 02 41 02 20 00 a0 10 03 65 7d
10 02 41 02 20 00 a1 10 03 75 5c
10 02 41 02 20 00 a2 10 03 45 3f
10 02 41 02 20 00 a3 10 03 55 1e
10 02 41 02 20 00 a4 10 03 25 f9
10 02 41 02 20 00 a5 10 03 35 d8
10 02 41 02 20 00 a6 10 03 05 bb
10 02 41 02 20 00 a7 10 03 15 9a
10 02 41 02 20 00 a8 10 03 e4 75
10 02 41 02 20 00 a9 10 03 f4 54
10 02 41 02 20 00 aa 10 03 c4 37
10 02 41 02 20 00 ab 10 03 d4 16
10 02 41 02 20 00 ac 10 03 a4 f1
10 02 41 02 20 00 ad 10 03 b4 d0
10 02 41 02 20 00 ae 10 03 84 b3
10 02 41 02 20 00 af 10 03 94 92
10 02 41 02 20 00 b0 10 03 77 4c
10 02 41 02 20 00 b1 10 03 67 6d
10 02 41 02 20 00 b2 10 03 57 0e
10 02 41 02 20 00 b3 10 03 47 2f
10 02 41 02 20 00 b4 10 03 37 c8
10 02 41 02 20 00 b5 10 03 27 e9
10 02 41 02 20 00 b6 10 03 17 8a
10 02 41 02 20 00 b7 10 03 07 ab
10 02 41 02 20 00 b8 10 03 f6 44
10 02 41 02 20 00 b9 10 03 e6 65
10 02 41 02 20 00 ba 10 03 d6 06
10 02 41 02 20 00 bb 10 03 c6 27
10 02 41 02 20 00 bc 10 03 b6 c0
10 02 41 02 20 00 bd 10 03 a6 e1
10 02 41 02 20 00 be 10 03 96 82
10 02 41 02 20 00 bf 10 03 86 a3
10 02 41 02 20 00 c0 10 03 09 db
10 02 41 02 20 00 c1 10 03 19 fa
10 02 41 02 20 00 c2 10 03 29 99
10 02 41 02 20 00 c3 10 03 39 b8
10 02 41 02 20 00 c4 10 03 49 5f
10 02 41 02 20 00 c5 10 03 59 7e
10 02 41 02 20 00 c6 10 03 69 1d
10 02 41 02 20 00 c7 10 03 79 3c
10 02 41 02 20 00 c8 10 03 88 d3
10 02 41 02 20 00 c9 10 03 98 f2
10 02 41 02 20 00 ca 10 03 a8 91
10 02 41 02 20 00 cb 10 03 b8 b0
10 02 41 02 20 00 cc 10 03 c8 57
10 02 41 02 20 00 cd 10 03 d8 76
10 02 41 02 20 00 ce 10 03 e8 15
10 02 41 02 20 00 cf 10 03 f8 34
10 02 41 02 20 00 d0 10 03 1b ea
10 02 41 02 20 00 d1 10 03 0b cb
10 02 41 02 20 00 d2 10 03 3b a8
10 02 41 02 20 00 d3 10 03 2b 89
10 02 41 02 20 00 d4 10 03 5b 6e
10 02 41 02 20 00 d5 10 03 4b 4f
10 02 41 02 20 00 d6 10 03 7b 2c
10 02 41 02 20 00 d7 10 03 6b 0d
10 02 41 02 20 00 d8 10 03 9a e2
10 02 41 02 20 00 d9 10 03 8a c3
10 02 41 02 20 00 da 10 03 ba a0
10 02 41 02 20 00 db 10 03 aa 81
10 02 41 02 20 00 dc 10 03 da 66
10 02 41 02 20 00 dd 10 03 ca 47
10 02 41 02 20 00 de 10 03 fa 24
10 02 41 02 20 00 df 10 03 ea 05
10 02 41 02 20 00 e0 10 03 2d b9
10 02 41 02 20 00 e1 10 03 3d 98
10 02 41 02 20 00 e2 10 03 0d fb
10 02 41 02 20 00 e3 10 03 1d da
10 02 41 02 20 00 e4 10 03 6d 3d
10 02 41 02 20 00 e5 10 03 7d 1c
10 02 41 02 20 00 e6 10 03 4d 7f
10 02 41 02 20 00 e7 10 03 5d 5e
10 02 41 02 20 00 e8 10 03 ac b1
10 02 41 02 20 00 e9 10 03 bc 90
10 02 41 02 20 00 ea 10 03 8c f3
10 02 41 02 20 00 eb 10 03 9c d2
10 02 41 02 20 00 ec 10 03 ec 35
10 02 41 02 20 00 ed 10 03 fc 14
10 02 41 02 20 00 ee 10 03 cc 77
10 02 41 02 20 00 ef 10 03 dc 56
10 02 41 02 20 00 f0 10 03 3f 88
10 02 41 02 20 00 f1 10 03 2f a9
10 02 41 02 20 00 f2 10 03 1f ca
10 02 41 02 20 00 f3 10 03 0f eb
10 02 41 02 20 00 f4 10 03 7f 0c
10 02 41 02 20 00 f5 10 03 6f 2d
10 02 41 02 20 00 f6 10 03 5f 4e
10 02 41 02 20 00 f7 10 03 4f 6f
10 02 41 02 20 00 f8 10 03 be 80
10 02 41 02 20 00 f9 10 03 ae a1
10 02 41 02 20 00 fa 10 03 9e c2
10 02 41 02 20 00 fb 10 03 8e e3
10 02 41 02 20 00 fc 10 03 fe 04
10 02 41 02 20 00 fd 10 03 ee 25
10 02 41 02 20 00 fe 10 03 de 46
10 02 41 02 20 00 ff ff 10 03 ce 67
10 02 41 02 20 01 00 10 03 e3 a6
10 02 41 02 20 01 01 10 03 f3 87
10 02 41 02 20 01 02 10 03 c3 e4
10 02 41 02 20 01 03 10 03 d3 c5
10 02 41 02 20 01 04 10 03 a3 22
10 02 41 02 20 01 05 10 03 b3 03
10 02 41 02 20 01 06 10 03 83 60
10 02 41 02 20 01 07 10 03 93 41
10 02 41 02 20 01 08 10 03 62 ae
10 02 41 02 20 01 09 10 03 72 8f
10 02 41 02 20 01 0a 10 03 42 ec
10 02 41 02 20 01 0b 10 03 52 cd
10 02 41 02 20 01 0c 10 03 22 2a
10 02 41 02 20 01 0d 10 03 32 0b
10 02 41 02 20 01 0e 10 03 02 68
10 02 41 02 20 01 0f 10 03 12 49
10 02 41 02 20 01 10 10 10 03 f1 97
10 02 41 02 20 01 11 10 03 e1 b6
10 02 41 02 20 01 12 10 03 d1 d5
10 02 41 02 20 01 13 10 03 c1 f4
10 02 41 02 20 01 14 10 03 b1 13
10 02 41 02 20 01 15 10 03 a1 32
10 02 41 02 20 01 16 10 03 91 51
10 02 41 02 20 01 17 10 03 81 70
10 02 41 02 20 01 18 10 03 70 9f
10 02 41 02 20 01 19 10 03 60 be
10 02 41 02 20 01 1a 10 03 50 dd
10 02 41 02 20 01 1b 10 03 40 fc
10 02 41 02 20 01 1c 10 03 30 1b
10 02 41 02 20 01 1d 10 03 20 3a
10 02 41 02 20 01 1e 10 03 10 59
10 02 41 02 20 01 1f 10 03 00 78
10 02 41 02 20 01 20 10 03 c7 c4
10 02 41 02 20 01 21 10 03 d7 e5
10 02 41 02 20 01 22 10 03 e7 86
10 02 41 02 20 01 23 10 03 f7 a7
10 02 41 02 20 01 24 10 03 87 40
10 02 41 02 20 01 25 10 03 97 61
10 02 41 02 20 01 26 10 03 a7 02
10 02 41 02 20 01 27 10 03 b7 23
10 02 41 02 20 01 28 10 03 46 cc
10 02 41 02 20 01 29 10 03 56 ed
10 02 41 02 20 01 2a 10 03 66 8e
10 02 41 02 20 01 2b 10 03 76 af
10 02 41 02 20 01 2c 10 03 06 48
10 02 41 02 20 01 2d 10 03 16 69
10 02 41 02 20 01 2e 10 03 26 0a
10 02 41 02 20 01 2f 10 03 36 2b
10 02 41 02 20 01 30 10 03 d5 f5
10 02 41 02 20 01 31 10 03 c5 d4
10 02 41 02 20 01 32 10 03 f5 b7
10 02 41 02 20 01 33 10 03 e5 96
10 02 41 02 20 01 34 10 03 95 71
10 02 41 02 20 01 35 10 03 85 50
10 02 41 02 20 01 36 10 03 b5 33
10 02 41 02 20 01 37 10 03 a5 12
10 02 41 02 20 01 38 10 03 54 fd
10 02 41 02 20 01 39 10 03 44 dc
10 02 41 02 20 01 3a 10 03 74 bf
10 02 41 02 20 01 3b 10 03 64 9e
10 02 41 02 20 01 3c 10 03 14 79
10 02 41 02 20 01 3d 10 03 04 58
10 02 41 02 20 01 3e 10 03 34 3b
10 02 41 02 20 01 3f 10 03 24 1a
10 02 41 02 20 01 40 10 03 ab 62
10 02 41 02 20 01 41 10 03 bb 43
10 02 41 02 20 01 42 10 03 8b 20
10 02 41 02 20 01 43 10 03 9b 01
10 02 41 02 20 01 44 10 03 eb e6
10 02 41 02 20 01 45 10 03 fb c7
10 02 41 02 20 01 46 10 03 cb a4
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 05 10 03 68 94
10 02 41 02 02 00 06 10 03 58 f7
10 02 41 02 02 00 06 10 03 58 f7
10 02 41 02 02 00 06 10 03 58 f7
10 02 41 02 02 00 06 10 03 58 f7
10 02 41 02 02 00 06 10 03 58 f7
10 02 41 02 02 00 07 10 03 48 d6
10 02 41 02 02 00 07 10 03 48 d6
10 02 41 02 02 00 07 10 03 48 d6
10 02 41 02 02 00 07 10 03 48 d6
10 02 41 02 02 00 07 10 03 48 d6
10 02 41 02 02 00 08 10 03 b9 39
10 02 41 02 02 00 08 10 03 b9 39
10 02 41 02 02 00 09 10 03 a9 18
10 02 41 02 02 00 09 10 03 a9 18
10 02 41 02 02 00 09 10 03 a9 18
10 02 41 02 02 00 0a 10 03 99 7b
10 02 41 02 02 00 0a 10 03 99 7b
10 02 41 02 02 00 0b 10 03 89 5a
10 02 41 02 02 00 0b 10 03 89 5a
10 02 41 02 02 00 0d 10 03 e9 9c
10 02 41 02 02 00 0d 10 03 e9 9c
10 02 41 02 02 00 0e 10 03 d9 ff ff
10 02 41 02 02 00 0f 10 03 c9 de
10 02 41 02 02 00 10 10 10 03 2a 00
10 02 41 02 02 00 11 10 03 3a 21
10 02 41 02 02 00 12 10 03 0a 42
10 02 41 02 02 00 13 10 03 1a 63
10 02 41 02 02 00 14 10 03 6a 84
10 02 41 02 02 00 17 10 03 5a e7
10 02 41 02 02 00 19 10 03 bb 29
10 02 41 02 02 00 1d 10 03 fb ad
10 02 41 02 02 00 20 10 03 1c 53
10 02 41 02 02 00 27 10 03 6c b4
10 02 41 02 02 00 2d 10 03 cd fe
10 02 41 02 02 00 3c 10 03 cf ee
10 02 41 02 02 00 49 10 03 e1 dc
10 02 41 02 02 00 7e 10 03 a7 68
10 02 41 02 02 00 c4 10 03 a1 f9
10 02 41 02 02 7e e3 10 03 de 2a
10 02 41 02 02 7e da 10 03 79 50
10 02 41 02 02 7e d1 10 03 c8 3b
10 02 41 02 02 7e c8 10 03 4b 23
10 02 41 02 02 7e b3 10 03 84 df
10 02 41 02 02 7e 80 10 03 82 ef
10 02 41 02 02 7e 3a 10 03 84 7e
10 02 41 02 02 7d d5 10 03 dd ec
10 02 41 02 02 7d 36 10 03 10 a1
10 02 41 02 02 7c 18 10 03 e6 3c
10 02 41 02 02 7b a9 10 03 c8 51
10 02 41 02 02 00 49 10 03 e1 dc
10 02 41 02 02 00 2d 10 03 cd fe
10 02 41 02 02 00 3c 10 03 cf ee
10 02 41 02 02 00 7e 10 03 a7 68
10 02 41 02 02 01 c6 10 03 b2 8a
10 02 41 02 02 7e e3 10 03 de 2a
10 02 42 02 01 10 03 05 8e
10 02 f4 02 20 00 01 00 01 10 03 4a bb
10 02 f4 02 20 00 01 00 00 10 03 5a 9a
10 02 f4 02 20 00 02 01 10 03 92 93
10 02 f4 02 20 00 02 00 10 03 82 b2
10 02 f4 02 28 00 00 fc 10 03 4f 80
10 02 f4 02 28 00 00 f9 10 03 1f 25
10 02 f4 02 28 00 00 f6 10 03 ee ca
10 02 f4 02 28 00 00 f3 10 03 be 6f
10 02 f4 02 28 00 00 f0 10 03 8e 0c
10 02 f4 02 28 00 00 ed 10 03 4d 90
10 02 f4 02 28 00 00 ea 10 03 3d 77
10 02 f4 02 28 00 00 e7 10 03 ec da
10 02 f4 02 28 00 00 e4 10 03 dc b9
10 02 f4 02 28 00 00 e1 10 03 8c 1c
10 02 f4 02 28 00 00 de 10 03 4b a0
10 02 f4 02 28 00 00 db 10 03 1b 05
10 02 f4 02 28 00 00 d8 10 03 2b 66
10 02 f4 02 28 00 00 d5 10 03 fa cb
10 02 f4 02 28 00 00 d3 10 03 9a 0d
10 02 f4 02 28 00 00 d0 10 03 aa 6e
10 02 f4 02 28 00 00 cd 10 03 69 f2
10 02 f4 02 28 00 00 ca 10 03 19 15
10 02 f4 02 28 00 00 c7 10 03 c8 b8
10 02 f4 02 28 00 00 c4 10 03 f8 db
10 02 f4 02 28 00 00 c1 10 03 a8 7e
10 02 f4 02 28 00 00 be 10 03 27 06
10 02 f4 02 28 00 00 bb 10 03 77 a3
10 02 f4 02 28 00 00 b8 10 03 47 c0
10 02 f4 02 28 00 00 b5 10 03 96 6d
10 02 f4 02 28 00 00 b2 10 03 e6 8a
10 02 f4 02 28 00 00 af 10 03 25 16
10 02 f4 02 28 00 00 ac 10 03 15 75
10 02 f4 02 28 00 00 a9 10 03 45 d0
10 02 f4 02 28 00 00 a6 10 03 b4 3f
10 02 f4 02 28 00 00 a3 10 03 e4 9a
10 02 f4 02 28 00 00 a0 10 03 d4 f9
10 02 f4 02 28 00 00 9d 10 03 33 07
10 02 f4 02 28 00 00 9a 10 03 43 e0
10 02 f4 02 28 00 00 94 10 03 a2 2e
10 02 f4 02 28 00 00 91 10 03 f2 8b
10 02 f4 02 28 00 00 8e 10 03 11 55
10 02 f4 02 28 00 00 8b 10 03 41 f0
10 02 f4 02 28 00 00 88 10 03 71 93
10 02 f4 02 28 00 00 85 10 03 a0 3e
10 02 f4 02 28 00 00 82 10 03 d0 d9
10 02 f4 02 28 00 00 7f 10 03 ee 6b
10 02 f4 02 28 00 00 7d 10 03 ce 29
10 02 f4 02 28 00 00 7a 10 03 be ce
10 02 f4 02 28 00 00 77 10 03 6f 63
10 02 f4 02 28 00 00 74 10 03 5f 00
10 02 f4 02 28 00 00 71 10 03 0f a5
10 02 f4 02 28 00 00 6e 10 03 ec 7b
10 02 f4 02 28 00 00 6b 10 03 bc de
10 02 f4 02 28 00 00 68 10 03 8c bd
10 02 f4 02 28 00 00 65 10 03 5d 10
10 02 f4 02 28 00 00 62 10 03 2d f7
10 02 f4 02 28 00 00 5f 10 03 ca 09
10 02 f4 02 28 00 00 5c 10 03 fa 6a
10 02 f4 02 28 00 00 59 10 03 aa cf
10 02 f4 02 28 00 00 56 10 03 5b 20
10 02 f4 02 28 00 00 53 10 03 0b 85
10 02 f4 02 28 00 00 50 10 03 3b e6
10 02 f4 02 28 00 00 4d 10 03 f8 7a
10 02 f4 02 28 00 00 4a 10 03 88 9d
10 02 f4 02 28 00 00 47 10 03 59 30
10 02 f4 02 28 00 00 44 10 03 69 53
10 02 f4 02 28 00 00 41 10 03 39 f6
10 02 f4 02 28 00 00 3e 10 03 b6 8e
10 02 f4 02 28 00 00 3b 10 03 e6 2b
10 02 f4 02 28 00 00 38 10 03 d6 48
10 02 f4 02 28 00 00 35 10 03 07 e5
10 02 f4 02 28 00 00 32 10 03 77 02
10 02 f4 02 28 00 00 2f 10 03 b4 9e
10 02 f4 02 28 00 00 2c 10 03 84 fd
10 02 f4 02 28 00 00 2a 10 03 e4 3b
10 02 f4 02 28 00 00 27 10 03 35 96
10 02 f4 02 28 00 00 24 10 03 05 f5
10 02 f4 02 28 00 00 21 10 03 55 50
10 02 f4 02 28 00 00 1e 10 03 92 ec
10 02 f4 02 28 00 00 1b 10 03 c2 49
10 02 f4 02 28 00 00 18 10 03 f2 2a
10 02 f4 02 28 00 00 15 10 03 23 87
10 02 f4 02 28 00 00 12 10 03 53 60
10 02 f4 02 28 00 00 0f 10 03 90 fc
10 02 f4 02 28 00 00 0c 10 03 a0 9f
10 02 f4 02 28 00 00 09 10 03 f0 3a
10 02 f4 02 28 00 00 06 10 03 01 d5
10 02 f4 02 28 00 00 03 10 03 51 70
10 02 f4 02 28 00 00 00 10 03 61 13
10 02 f4 02 28 00 00 01 10 03 71 32
10 02 f4 02 28 00 00 00 10 03 61 13
10 02 f4 02 28 00 00 fe 10 03 6f c2
10 02 f4 02 28 00 00 ff ff 10 03 7f e3
10 02 f4 02 28 00 00 01 10 03 71 32
10 02 f4 02 28 00 00 00 10 03 61 13
10 02 f4 02 00 00 00 10 03 5b 38
10 02 f4 02 20 00 00 10 03 dd fe
</pre>
|
Reversing checksum algorithm
|
|serial-communication|sniffing|packet|crc|
|
<p>In the case of linux, debuggers typically use the ptrace API to inspect and modify the process space of the process being debugged. And no, they do not share the address space.</p>
<p>As a side note, dynamic binary instrumentation frameworks such as PIN do involve inserting itself into the process space of the binary being instrumented.</p>
|
8564
|
2015-03-26T16:20:07.673
|
<p>This post might be specific to IDA Pro, so bear that in mind.</p>
<p>I'm currently trying to write a plugin for debugging specifically one executable. I know that a certain object in the executable's process exists at 0xAB40C0 (it always exists there). Can I simply write object* obj = (object*)0xAB40C0; and then access the various members of it? </p>
|
During debugging, is the process memory the same as the debugger's memory space?
|
|ida|debugging|c|
|
<p>Conditional returns are found in some instruction set architectures.</p>
<p>For example, the 8085 has instructions which will action a subroutine return if a status flag is set/clear:</p>
<pre><code>RZ ... return if Z flag set
RC ... return if C flag set
RNZ ... return if Z flag clear
...
</code></pre>
|
8570
|
2015-03-27T08:26:43.000
|
<p>IDA Pro's <code>idaapi.BasicBlock</code> objects returned by <code>idaapi.FlowChart()</code> can be of the following types (see <code>gdl.hpp</code> in the SDK sources):</p>
<pre><code>// flow chart block types
enum fc_block_type_t
{
fcb_normal, // normal block
fcb_indjump, // block ends with indirect jump
fcb_ret, // return block
fcb_cndret, // conditional return block
fcb_noret, // noreturn block
fcb_enoret, // external noreturn block (does not belong to the function)
fcb_extern, // external normal block
fcb_error, // block passes execution past the function end
};
</code></pre>
<p>I was able to find examples for all types except <code>fcb_cndret</code>. What does </p>
<blockquote>
<p>conditional return block</p>
</blockquote>
<p>mean? Could somebody give an example?</p>
|
IDA basic block type fcb_cndret - what does it mean?
|
|ida|disassembly|idapython|idapro-sdk|
|
<p>Before jumping straight to interesting articles and sources I'll start by defining the key words, just in case.</p>
<ul>
<li><p><strong>Static analysis :</strong> consists in analyzing the target binary file without executing it. Hence the <code>static</code>. Such analysis can be used in order to build a first draft of the application's <strong>Control Flow Graph</strong>, <strong>Call Graph</strong>, ...
For example, building the <strong>CFG</strong> consists of cutting the code into <em>basic blocks</em> and then linking them using the branch targets (if they're not indirect branches). </p></li>
<li><p><strong>Dynamic analysis :</strong> consists in inserting probes (function calls) around key areas of the binary, running the binary and dumping the probes' results. Such probes can be <strong>rdtsc</strong> instructions on x86, or any other hardware counter.
For example, dynamic analysis is used by <strong>Gprof</strong> to assess the amount of time spent in each function. Many other profilers such as <strong>VTune</strong>, <strong>MAQAO</strong>, <strong>DynInst</strong>, ... use dynamic analysis to locate hotspots.</p></li>
</ul>
<p>Both of these analyses can be applied to a binary file (meaning an executable program), and that's what we call binary analysis.
On the other hand, static analysis can be applied on source code as well as binary. <a href="http://en.wikipedia.org/wiki/Lint_%28software%29" rel="nofollow">Lint</a>, for example, performs static analysis in order to find buggy code constructs.</p>
<p>There aren't many detailed references I can cite, rather a set of scientific publications which span the use and benefits of those techniques, along with some interesting algorithms. </p>
<p>For static analysis I would recommend this collection of articles : <a href="http://www.springer.com/fr/book/9783642388552?cm_mmc=EVENT-_-BookAuthorEmail-_-&wt_mc=event.BookAuthor.Congratulation" rel="nofollow">Static Analysis 20th International Symposium, SAS 2013, Seattle, WA, USA, June 20-22, 2012, Proceedings.</a> </p>
<p>For dynamic analysis I would recommend you going through the publications around of <a href="http://maqao.org/" rel="nofollow">MAQAO</a>, <a href="http://www.dyninst.org/" rel="nofollow">DynInst</a>, <a href="https://silc.zih.tu-dresden.de/scorep-current/html/" rel="nofollow">ScoreP</a>, and <a href="https://www.cs.uoregon.edu/research/tau/news.php" rel="nofollow">TAU</a> </p>
|
8577
|
2015-03-27T16:01:04.260
|
<p>Currently I am learning about profiling parallel programs. All the profilers heavily use all kinds of instrumentations but this topic is not well explained. Do you know any good sources from which I could learn about instrumentation (static, binary, dynamic)?</p>
|
Where can I learn about code instrumentation?
|
|binary-analysis|static-analysis|dynamic-analysis|instrumentation|
|
<p>If <code>ebx</code> really points to an <code>IMAGE_IMPORT_DESCRIPTOR</code>, then [ebx+20h] points to the <code>name</code> field of the next <code>IMAGE_IMPORT_DESCRIPTOR</code>.</p>
<pre><code>mov eax, [ebx+20h] ; 0x20 = 0x14 + 0xc
</code></pre>
<p>where 0x14 is <code>sizeof(IMAGE_IMPORT_DESCRIPTOR)</code> and 0x0c is <code>offsetof(IMAGE_IMPORT_DESCRIPTOR, Name)</code>.</p>
<p>Also, remember that the last <code>IMAGE_IMPORT_DESCRIPTOR</code> is always an <code>IMAGE_IMPORT_DESCRIPTOR</code> with all fields set to 0 (according to the <a href="https://msdn.microsoft.com/en-us/windows/hardware/gg463119.aspx" rel="nofollow">official PE documentation</a>):</p>
<blockquote>
<p>The last directory entry is empty (filled with null values), which
indicates the end of the directory table</p>
</blockquote>
<p>As noted by @peterferrie, if the <code>Name</code> field is NULL/0 then the other field are meaningless so your code is checking if the next <code>IMAGE_IMPORT_DESCRIPTOR</code> is the last, so it can stop processing the array of <code>IMAGE_IMPORT_DESCRIPTOR</code>.</p>
<p>You could surely test this by checking the value in <code>eax</code> and comparing it to the value in an hex editor or a PE browsing tool.</p>
|
8582
|
2015-03-28T12:10:34.103
|
<p>During RCE of a piece of code, I have found this:</p>
<pre><code> loc_40244F:
mov eax, [ebx+20h]
add ebx, 14h
test eax, eax
jnz loc_402397
</code></pre>
<p>What I know is that ebx points to the import directory structure of the considered PE file.</p>
<p>But when I look at it, I see the following:</p>
<pre><code> Import Directory
+0 DWORD OriginalFirstThunk;
4 DWORD TimeDateStamp;
8 DWORD ForwarderChain;
c DWORD Name;
10 DWORD FirstThunk;
</code></pre>
<p>So, to which location is the [ebx+20h] expression pointing ?
I hope somebody can help me.</p>
<p>best regards,</p>
|
Target of offset into import directory unclear
|
|assembly|struct|
|
<p>I think this is too late but let's reply though.
By default ImpREC has "Use PE Header From Disk" enabled. Which means it will NOT use the relocated DLL imagebase. 2 options :</p>
<ul>
<li>1 - Untick it in options and reselect your target</li>
<li>2 - Use a custom PE header with Advanced commands / Load PE Header</li>
</ul>
<p>-> First choice is the best for your case.</p>
<p>Explaination : the reason "Use PE Header From Disk" is enabled by default, comes from protector which destroys the header in memory so it's best to rely on disk but it's bad for DLL.</p>
|
8584
|
2015-03-28T17:13:17.470
|
<p>I am trying to unpack a DLL and fix the import tables with ImpRec. However, I am stuck with this error. Following is what I have tried. </p>
<ol>
<li>Modified the flag in its PE header so that windows loads the file as an exe, not a dll. </li>
<li>Loaded to Immunity Debugger and found the real entry point(Entry point of unpacked binary)</li>
<li>Dumped the the binary at this entry point.</li>
<li>Now I opened ImpREC to fix the import table of the of the dumped DLL. However, in ImpREC the base memory displayed is 7100000. When I give "068BA2A0" as entry point, ImpRec complaints invalid OEP!. I dont understand how the base address of the debugged process is "7100000". I suspect this could be the problem.</li>
</ol>
<p><img src="https://i.stack.imgur.com/X3C6W.png" alt="enter image description here"></p>
<p>Why is this error? Any pointers to fix it? </p>
|
Fixing import table of unpacked DLL with ImpREC : ImpRec throws "invalid OEP!" error
|
|dll|unpacking|immunity-debugger|dumping|import-reconstruction|
|
<blockquote>
<p>Is it possible that the thread with the manipulated start address is
still running after we close the handle to the corresponding process?
Is the thread still running although the process to which it belongs
is closed because of the changed starting address or will the thread
also closed automatically after CloseHandle(processhandle) ?</p>
</blockquote>
<p>Yes. From <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/ms724211%28v=vs.85%29.aspx" rel="nofollow">the official <code>CloseHandle()</code> documentation</a>:</p>
<p>"Closing a thread handle does <strong>not</strong> terminate the associated thread or remove the thread object. Closing a process handle does <strong>not</strong> terminate the associated process or remove the process object."</p>
|
8589
|
2015-03-29T14:51:00.080
|
<p>During the analysis of a piece of code, I have seen that a process is created in a suspended state. The process had one thread. Then they are changing the start address of that thread. After doing that, the thread is started with ResumeThread(). Later, it closes the handle to the process using CloseHandle(). </p>
<p>So, my question would be : Is it possible that the thread with the manipulated start address is still running after we close the handle to the corresponding process? Is the thread still running although the process to which it belongs is closed because of the changed starting address or will the thread also closed automatically after CloseHandle(processhandle) ? </p>
<p>Best regards, </p>
|
Running thread without process - special case
|
|process|
|
<p>If I understand your question correctly, you're asking how many addresses have names.</p>
<p>For example, in the following snippet, two of the addresses in the snippet have names (<code>loc_4385E4</code> and <code>dword_4385F8</code>), since both are cross-referenced from other addresses:</p>
<pre><code>.text:004385E4 loc_4385E4: ; CODE XREF: sub_4254E0+1C0j
.text:004385E4 ; CODE XREF: sub_4254E0+1E6j
.text:004385E4 push ecx
.text:004385E5 push ecx
.text:004385E6 push 0Eh
.text:004385E8 pop edx
.text:004385E9 mov ecx, offset dword_438618
.text:004385EE call sub_4421A7
.text:004385F3 jmp loc_4256A6
.text:004385F3 ; END OF FUNCTION CHUNK FOR sub_4254E0
.text:004385F3 ; ---------------------------------------------------------------------------
.text:004385F8 dword_4385F8 dd 1000000Ah, 80204h, 10000h, 80010000h
.text:004385F8 ; DATA XREF: sub_4254E0+13092o
</code></pre>
<p>You can use the IDC script below to count all named addresses in your disassembly:</p>
<pre><code>auto ea;
auto names = 0;
for (ea = BeginEA(); ea != BADADDR; ea = NextNotTail(ea))
{
if (Name(ea) != "")
{
names++;
}
}
Message("%d named addresses found.\n", names);
</code></pre>
<p></p>
<p><strong><em>Edit</em></strong></p>
<p>The change you made to your original question now makes it sounds like you want to capture all function names. To do this, open the Functions window (in the menubar: <em>View</em> → <em>Open subviews</em> → <em>Functions</em>), right-click in the Functions window, and choose <em>Copy all</em>. You can now paste the list of function names into a text editor or spreadsheet.</p>
|
8590
|
2015-03-29T15:24:53.180
|
<p>We all know that in typical programs, there exist some references. </p>
<p><img src="https://i.stack.imgur.com/Ue99a.png" alt="enter image description here"></p>
<p>When compiling, linker will translate all the memory references into <strong>concrete memory addresses</strong> during the symbol relocation step. And by doing some quick experiments (IDA-Pro 6.4), I notice that IDA-Pro can help to lift these memory addresses back into symbols. </p>
<p>However, I found that the symbolization functionality of IDA-Pro can be mislead by some cases. So what I am interested is to calculate how many references have been recovered by IDA-Pro. I am asking that is there anyway to obtain the information of <strong>"how many memory references are recovered by IDA-Pro?"</strong></p>
<p>Thanks @Jason a lot for his answer, but what I am trying to do is not collect all the labels. Here is an example:</p>
<p><img src="https://i.stack.imgur.com/jKc9B.png" alt="enter image description here"></p>
<p>Please pay attention to the symbol <code>sub_80484AE</code> in address <code>0x804a020</code>. Note that the 4 byte data <code>0x08, 0x04, 0x84, 0xae</code> in porocessed binary are considered as a symbol, as it is equal to the beginning address of function <code>sub_80484AE</code>. This is true. However, as no instruction refers to the address <code>0x804A020</code>, so there is no <code>name</code> in address <code>0x804a020</code>. </p>
<p>What I want to collect is all the symbols with its corresponding address, for example, in the above case, I need to collect this </p>
<pre><code>0x804a018 : sub_804847b
0x804a01dc : _strchr
0x804a020 : sub_80484AE
</code></pre>
<p>Am I clear enough? I really appreciate if anyone can give me some help! Thank you a lot!!</p>
<p>----------------------------------------------- update ---------------------------------------</p>
<p>Am I still not clear enough? </p>
<p>Let me put it in this way. Can I obtain all the symbol information which used to be resolved by linker? Say, in the picture I updated, during compiling linker resolved three symbols, at memory address 0x804a018, 0x804a01dc, 0x804a020. IDA-Pro recovers some of these information. So I want to collect all the IDA recovered symbol information (this information could be <strong>function name</strong>, or it could be <strong>an entry of jump table</strong>, or it could be a <strong>jump destination</strong>, as I draw in the picture). </p>
<p>Note that I want to recover the information in a format that each resolved symbol together with the memory address. For example in the picture, it should be:</p>
<pre><code>0x804a018 : sub_804847b
0x804a01dc : _strchr
0x804a020 : sub_80484AE
</code></pre>
<p>I am thinking to traverse all the memory address of a binary, and check each the oprend of instruction (or content if it is in the data section), to see whether it is a recovered symbol or not. If so, I will store this symbol together with this instruction (or data)'s memory address.</p>
<p>But basically how to check whether a oprend in a instruction is a symbol? </p>
|
How can I obtain the data of how many memory references are symbolized by IDA-Pro?
|
|ida|symbols|
|
<p>After downloading ChessBase Reader and playing with ProcMon a bit to find the function that reads the archive and writes the data file, i loaded up the whole thing in IDA to analyze it. The data is <a href="http://en.wikipedia.org/wiki/Huffman_coding" rel="noreferrer">Huffman-coded.</a> </p>
<p>Each data block has the following structure. Note that Huffman compression works with bits, not bytes, so each size in the following table is in bits as well. The block length is 16 bits, or 2 bytes, for example.</p>
<pre><code>+----------------------------------------------+
| |
|16 bits - uncompressed block length (len) |
| |
+-----------+----------------------------------+
| | |
|Repeat | 4 bits - length of entry (n) |
|256 | |
|times +----------------------------------+
| | |
|one entry | n bits - tree left/right |
|per byte | information for this byte |
|(0-255) | |
| | |
+-----------+----------------------------------+
| |
| Huffman encoded bit sequences. The number of |
| bits isn't stored anywhere, but the number |
| of sequences, which is equal to the number |
| of output bytes, is the block length (len) |
| |
+----------------------------------------------+
</code></pre>
<p>Assuming the word "foobar" was coded in this scheme, this would possibly result in (i made up the bit values for the characters):</p>
<pre><code>+----------------+
|Huffman code for|
|character is |
+--------+-------+
| | |
| o | 0 |
| f | 100 |
| b | 101 |
| a | 110 |
| r | 111 |
| | |
+--------+-------+
</code></pre>
<p>This would result in the word foobar being coded as
<code>100 0 0 101 110 111</code>. The length is 6 bytes, or <code>0000 0000 0000 0110</code> in 16 bits.</p>
<p>The bitarray for <code>foobar</code>, formatted to the above table, would read</p>
<pre><code>0000 0000 0000 0110 (16 bit output length)
..... array index 0 for byte '\0'
..... array index 1 for byte '\1'
.....
0011 110 array index 97 for byte 'a' (3 bits)
0011 101 array index 98 for byte 'b' (3 bits)
.....
0011 100 array index 102 for byte 'f' (3 bits)
.....
0001 0 array index 111 for byte 'o' (1 bit)
.....
0011 101 array index 114 for byte 'r' (3 bits)
..... remaining bit combos - 255
100 0 0 101 110 111 foobar text
</code></pre>
<p>The implementation builds a binary tree from the code table. When it reads the data, it starts at the root of the tree; each bit moves down the tree, to the left or right, depending on the next bit value. When a leaf is reached, the corresponding byte is being output. This repeats until the length of the output stream is reached.</p>
<p>The related functions from the binary are these:</p>
<p><code>BECAA0</code>: decodes the archive data. Reads 16 bits for the length; then reads the encoding table into two arrays at offsets <code>080A</code> (bits) and <code>0E10</code> (bit lengths) within the decoder class. After this, call <code>BEC930</code> to decode the data bytes.</p>
<p><code>BEBF30</code>: One parameter (number of bits), gets this many bits from the input array. At the end of the function, the word at offset <code>1014</code> has these bits.</p>
<p><code>BEBAD0</code>: Builds the tree from the arrays at <code>080A</code> and <code>0E10</code></p>
<p><code>BEC930</code>: Calls <code>BEBAD0</code> to build the tree, then reads the remaining bits from the input stream. Walks the tree for each bit; emits a byte when a leaf is found. At the end, calls <code>BEBA90</code> to destroy the tree.</p>
<p><code>BEBA90</code>: Recursively delete a node by deleting the left and right children, the the node itself.</p>
<p>I don't think debugging the writer would be easier if you want to read the files; compression has a lot of logic and data structures, and knowing how 'one way' works doesn't neccesarily help you with the other way round. In this case, luckily, its a well known algorithm, but if the algorithm is unknown it can be quite hard to compress effectively if you just know how to decompress.</p>
|
8593
|
2015-03-29T17:10:07.170
|
<p>I work on the reverse engineering of the ChessBase archive (.cbv).</p>
<p>I found the general structure of the file and can already decompress some files.</p>
<p>You can see my current work <a href="https://github.com/antoyo/uncbv" rel="noreferrer">here</a>.</p>
<p>However, some .cbv files that are bigger seems to use a second compression algorithm.</p>
<p>I was able to find the first compression algorithm by debugging the <a href="http://download.chessbase.com/Download/ChessBaseReader/Setup.msi" rel="noreferrer">ChessBase Reader 2013</a> software, but I cannot make sense of the second compression algorithm.</p>
<p>I tried some tools like <code>signsrch</code> to find out what algorithm was used without any luck: it seems to be a custom algorithm.</p>
<p>Here is a <a href="http://en.chessbase.com/portals/4/files/news/2014/common/cbm/cbm163/CBM163D85.cbv" rel="noreferrer">file</a> that I am able to partly decompress with my <a href="https://github.com/antoyo/uncbv" rel="noreferrer">tool</a> (my tool will print <code>What to do?</code> when it detects that the unknown compression algorith was used).</p>
<p>Do you have any idea of what compression algorithm is used?</p>
<p>If not, do you have any way of finding it by looking at the compressed file?</p>
<p>I am able to create archives so I can have files that are both compressed and not: I wonder if there is any way to find a compression pattern in such a situation.</p>
|
Unknown decompression algorithm
|
|decompress|
|
<p>What Jason said. Consider this C code:</p>
<pre><code>int size;
int nelem=1;
struct whatever *data;
if (debugger_is_running)
nelem-=2; // pass an unreasonable value to malloc
size=sizeof (struct whatever)*nelem;
if ((data=malloc(size))==NULL)
abort_program("No memory");
......
// use data here
</code></pre>
<p>It's the <code>nelems-=2</code> instruction you want to patch out. If you just <code>nop</code> out the call to <code>abort_program</code>, your data will still be a NULL pointer and cause the program to crash whenever you use it, much later.</p>
<p>You really need to analyze everything between your code blocks, find out how the program detects the debugger, and change that piece of code.</p>
|
8597
|
2015-03-30T12:34:20.613
|
<p>I have some questions about how to reach an address by bypassing a few hundred lines. Assume that we have the following scenario:</p>
<pre><code> + -----------------------+
004019EF | | <----- we are here
| content of function |
| 004019EF |
| |
| |
+------------------------+
| |
| this area contains |
| lines which |
| I want to bypass |
| quickly |
| |
+------------------------+
00401E1F | | <-- we want to go here
| content which I |
| want to analyze |
| |
| |
+------------------------+
</code></pre>
<p>So, the situation is that I am for example at 004019EF and then I figured
out that the location at 00401E1F also seems to be important. And I decide to go there. For that reason, I click on Ctrl+G, type the target address and
set a breakpoint(clicking F2) at 00401E1F. Then I let it run. But the program doesn't reach the place. It terminates the process and ends at a location with RETN.
So, I started the process again. But this time, I step manually from line 004019EF to 00401E1F. On the way, I eliminate all the lines/instructions which leads to a termination by replacing them with a NOP instruction.
At the end, I reach the address 00401E1F.</p>
<p>My question would be : </p>
<p>When I replace instructions with a NOP or change the flags of jump-instructions to modify the execution flow of the programm, then will these modifications be a problem for the content of 00401E1F ? </p>
<p>I mean can I say the following : </p>
<p>"These instructions causing problems, so deleting them with NOP would be unproblematic" </p>
<p>OR</p>
<p>Am I going to miss some results of the area between 004019EF and 00401E1F which could be important for the content of 00401E1F ?
If yes, then:</p>
<p>Is there another way to bypass that lines to reach the target address without patching/changing lines or instructions? </p>
|
Reaching an address with ollydbg
|
|ollydbg|
|
<p>OllyDbg shows memory regions of all types, whereas your code doesn't show <code>MEM_IMAGE</code> regions.</p>
<p>Replace <code>if ((info.State == MEM_COMMIT) && ((info.Type & MEM_MAPPED) || (info.Type & MEM_PRIVATE)))</code> with just <code>if (info.State == MEM_COMMIT)</code>.</p>
|
8598
|
2015-03-30T12:35:34.110
|
<p>I used some code to read the process memory using the MEMORY_BASE_INFORMATION a little while back using the information provided <a href="https://reverseengineering.stackexchange.com/questions/8297/proc-self-maps-equivalent-on-windows">here</a>. However, when I list out the regions in memory, only the pages with RW pages seem to be listed out. More importantly, none of the pages with executable permissions are listed out. How could I rectify this?</p>
<p>Could it have something to do with the privilege at which the process runs?</p>
<p>I've attached a screenshot of the process memory in Ollydbg and what is printed out using the source below :-</p>
<pre><code>int main() {
HANDLE process = GetCurrentProcess();
MEMORY_BASIC_INFORMATION info;
unsigned char *p = NULL;
for ( p = NULL;
VirtualQueryEx(process, p, &info, sizeof(info)) == sizeof(info);
p += info.RegionSize )
{
if (info.State == MEM_COMMIT && (info.Type == MEM_MAPPED || info.Type == MEM_PRIVATE))
printf("%08x %08x %08x\n", info.BaseAddress, info.RegionSize, info.Protect);
}
}
</code></pre>
<p><img src="https://i.stack.imgur.com/JXnKB.png" alt="Output">
<img src="https://i.stack.imgur.com/hXRIl.png" alt="Ollydbg"></p>
|
Reading the process memory yields different results
|
|windows|ollydbg|process|virtual-memory|pages|
|
<p>In addition to creating the child process, <code>CreateProcess()</code> also causes the creation of the child process's primary thread. Your post makes it sound like the calls to <code>GetThreadContext()</code>, <code>SetThreadContext()</code>, and <code>ResumeThread()</code> all act on that primary thread.</p>
<blockquote>
<p>1st question: Why it is not in the list ?</p>
</blockquote>
<p>As you said in your post, you are seeing the process's main (primary) thread, on which the <code>*Thread*()</code> API functions above acted. No additional threads are created so you shouldn't expect to see additional threads in OllyDbg's view.</p>
<blockquote>
<p>2nd question: How can I find it?</p>
</blockquote>
<p>N/A</p>
<blockquote>
<p>Is there a way to analyze the new thread starting at 00401E1D in a separate ollydbg-session ?</p>
</blockquote>
<p>Yes -- check the "Debug child processes" checkbox in OllyDbg's options:</p>
<p><img src="https://i.stack.imgur.com/GDxO5.png" alt="OllyDbg"></p>
|
8607
|
2015-03-31T15:31:43.430
|
<p>i am analyzing a piece of code in which the main thread does the following steps:</p>
<p>First, it calls CreateProcess() to create a a process in suspended state. Then it changes the starting address of the thread by using a combination of GetThreadContext & SetThreadContext. The new start address of the thread is now 00401E1D. And at the end, it calls ResumeThread() start the thread.</p>
<p>So, what I did was: I set a BP at ResumeThread(), let it run, after hitting the BP I step over the ResumeThread()-function and open the window where all threads are listed by clicking on the big "T"-button in Ollydbg.</p>
<p>But there is only the main thread, not the newly started thread.
And now I have a couple of questions:</p>
<pre><code> 1st question: Why it is not in the list ?
2nd question: How can I find it?
3th question:
In the main thread, I can not step to 00401E1D
(starting address of the new thread) because ollydbg somehow
terminates itself. Maybe there is some anti-debugging tricks or
things like that. I do not know, because I did not analyze it yet
in detail. So, the question is: Is there a way to analyze the
new thread starting at 00401E1D in a separate ollydbg-session ?
Is it possible ?
</code></pre>
<p>best regards, </p>
|
Working with multi-threaded program but can not find created thread
|
|ollydbg|thread|process|
|
<p>Basically, your approach is a good first approach. Programs used to be easily crackable using it 10 years ago. But times have changed, and many programs try to detect if they are being cracked and implement countermeasures.</p>
<p>There's lots of things that could be happening. The program might use <code>IsDebuggerPresent()</code>. It may use other methods to detect a debugger. It might generate a checksum over its own memory and check that against a known value (setting the breakpoint modifies the instruction to <code>INT 3</code> unless you use a hardware/memory breakpoint, but if you put the breakpoint on a function in <code>user.dll</code>, you won't change the executable's checksum). The program might check the functions it calls if one of them begins with an <code>INT 3</code> instruction (but i'd assume this not to be the case for a mere <code>GetWindowTextW</code>). If the program crashes on a resume F9, not the first run-F9, it might be timing how long checking the password takes, and if it's more than 0.1 seconds, it assumes it was interrupted and crash.</p>
<p>There's literally dozens of possibilities, and you'd have to trace your way through the program to find out which is used - this is where experience kicks in.</p>
<p>You could try if the program works if you just load and run it - if it doesn't, it detects your debugger. There are stealth plugins to ollydbg that you might want to try.</p>
<p>A different approach that has sometimes worked for me is running Process Monitor to see where the program accesses its (file or registry-based) registration key; check the stack to see which function is calling that access, and statically analyze the program from there.</p>
|
8612
|
2015-03-31T21:08:14.277
|
<p>After solving few crackmes I tried to take one step further and move on "real life" reversing tasks, targeting a known win7 program's password check feature.</p>
<p>The program in question obviously doesn't store interesting strings in memory, so I tried another approach, that so far worked well in test-scenarios and in crackmes. The prompt for the password itself uses a simple edit control, so I instantly looked for executable modules -> USER32.dll and found the GetWindowTextW offset (I know it may be using alternative ways to retrieve text, but that was not the problem)
Setting a breakpoint there and trying to f9-run the program causes it to crash.</p>
<p>I'm new in reversing and debuggers, and I don't really know what may be causing the issue, or where should I look to solve it.</p>
<p>PS: could this be a good approach for the task ?</p>
|
Program crashes after resuming from breakpoint
|
|windows|assembly|debuggers|
|
<p>what you show looks a lot like PEDA (<a href="https://github.com/longld/peda" rel="nofollow" title="PEDA Github">PEDA Github repo</a>) a Python extension to GDB. Although PEDA is very good, it looks like it is not being actively developed anymore. </p>
<p>A newer incarnation of this idea is GEF (GDB Enhanced Features) (<a href="https://github.com/hugsy/gef" rel="nofollow">GEF Github repo</a>). It is written in Python as well and it has the advantage of bein <em>multi-architecture</em> (Intel, ARM, MIPS, etc.)</p>
<p>Both require a minimal change in your .gdbinit to work, no tedious installation, dependencies or anything like that.</p>
<p>Have fun debugging!</p>
|
8622
|
2015-04-02T05:52:07.683
|
<p>Yesterday i noticed a nice output from dbg while going through a write up on the internet. As am new to dbg i googled a lot as i wanted to make dbg work similar for me. As seen below this customisation would help me a lot with my work with all the data displayed instantaneously. I tried voltron from the below link but was unable to get it working with many errors. <a href="https://github.com/snare/voltron" rel="nofollow noreferrer">https://github.com/snare/voltron</a></p>
<p>Is there any extension other than voltron so that i can get the output as shown in the link below? Would editing the .dbginit file help in any way?</p>
<p><a href="https://i.stack.imgur.com/Pg9JH.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/Pg9JH.jpg</a></p>
<p>TIA</p>
<p>Regards</p>
|
Custom gdb output
|
|debuggers|linux|gdb|
|
<blockquote>
<p>WinDbg uses debugging information (pdb/symbol files) for debugging. So ,for example say I get a unknown exe (malicious) can I debug it since I'll not be having its .pdb</p>
</blockquote>
<p>Yes. Symbols are one of Windbg's main strength, but it can also debug anything <strong>without</strong> symbolic information.</p>
<blockquote>
<p>Is WinDbg best suited to analyze memory dumps and crash issues only?</p>
</blockquote>
<p>Once again, it can do that, but that's not its sole use.</p>
<blockquote>
<p>Ollydbg being a ring 3 debugger is good to analyze/debug malicious
exe's but doens't support unknown dlls(there is loaddll but you have
to know which function the dll exports and there parameters)</p>
</blockquote>
<p>If you need to analyse a DLL, you'll need a program to load it and then debug this program, thus you can't debug a DLL by itself (DLLs, as their name imply are dynamic libraries used by a main program). That's a system requirement.</p>
<blockquote>
<p>and rootkits(sys files).</p>
</blockquote>
<p>Yes, you'll need a ring0 debugger.</p>
<p>You can also mix static (disassembler) and runtime (debugger) analysis for your DLL and driver (*.sys) file. Hex rays has a free version of IDA.</p>
<hr>
<p>Both debuggers can be used for Ring3 (user-land) debugging, and only Windbg can do Ring0 (kernel-land) but they have their own strengths and weaknesses.</p>
<p>From my point of view (I'm using both a lot):</p>
<ul>
<li>OllyDbg:
<ul>
<li>Pros: great for displaying information to the end-user; Color schemes, Well organised displaying windows.</li>
<li>Cons: symbolic information is minimal; no command line; GUI only</li>
</ul></li>
<li>Windbg:
<ul>
<li>Pros: extremely powerful with symbolic information; Ring0 debugging; windows internals; bare metal stuffs</li>
<li>Cons: not really user-friendly; steep learning curve</li>
</ul></li>
</ul>
<p>They both have a native plugin system (C / C++); windbg have a scripting language which is a real PITA (but <a href="https://pykd.codeplex.com/" rel="nofollow">pykd</a> [Windbg scripting in python] can alleviate this problem).</p>
<p>Note that windbg can't do in-place live ring0 debugging (à la Softice or Syser) except with "livekd" (but this works on a system snpashot, not live): you need a host system (the debugger) and another machine which will be the debuggee (either a virtual machine or another physical machine).</p>
|
8623
|
2015-04-02T06:36:34.460
|
<p>According to what I know :WinDbg uses debugging information (pdb/symbol files) for debugging.So ,for example say I get a unknown exe (malicious) can I debug it since I'll not be having its .pdb. Is WinDbg best suited to analyze memory dumps and crash issues only?</p>
<p>Ollydbg being a ring 3 debugger is good to analyze/debug malicious exe's but doens't support unknown dlls(there is loaddll but you have to know which function the dll exports and there parameters) and rootkits(sys files).</p>
<p>So If I have a dll and a .sys file how can I debug it using olly or winDbg?</p>
<p>Note:I am a noob I may be wrong in what I know.I don't have the resources to buy IDAPro :-). </p>
|
When to use Windbg and Ollydbg?
|
|debugging|windbg|vulnerability-analysis|malware|
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.