diff --git "a/stack_exchange/RE/RE Q&A 2019.csv" "b/stack_exchange/RE/RE Q&A 2019.csv" new file mode 100644--- /dev/null +++ "b/stack_exchange/RE/RE Q&A 2019.csv" @@ -0,0 +1,49974 @@ +Id,PostTypeId,AcceptedAnswerId,ParentId,CreationDate,DeletionDate,Score,ViewCount,Body,OwnerUserId,OwnerDisplayName,LastEditorUserId,LastEditorDisplayName,LastEditDate,LastActivityDate,Title,Tags,AnswerCount,CommentCount,FavoriteCount,ClosedDate,CommunityOwnedDate,ContentLicense +20253,1,20256,,1/1/2019 20:21,,0,115,"

In this analysis of a Portable Executable linked using Microsoft Linker (6.0), down in the Imported Objects section, the website makes some very specific claims:

+ +
3 .OBJ Files (COFF) linked with LINK.EXE 5.12 (Visual Studio 5 SP2) (build: 9049)
+4 .OBJ Files (COFF) linked with LINK.EXE 6.00 (Visual Studio 6) (build: 8168)
+178 .C Files compiled with CL.EXE 12.00 (Visual Studio 6) (build: 8168)
+26 .CPP Files compiled with CL.EXE 12.00 (Visual Studio 6) (build: 8168)
+41 .ASM Files assembled with MASM 6.13 (Visual Studio 6 SP1) (build: 7299)
+12 .OBJ Files linked with ALIASOBJ.EXE 6.00 (Internal OLDNAMES.LIB Tool) (build: 7291)
+
+ +

As far as I know, all debug information is stripped from the executable, and there certainly aren't 178 embedded ascii strings ending in "".C"".

+ +

The sections in the PE are the usual .text, .rdata, .data, .rsrc.

+ +

What type of additional information or metadata in the EXE could be used to make guesses about the original object files?

+",26932,,,,,1/2/2019 3:00,How to determine number and/or boundaries of linked object files in a PE generated by Visual Studio 6?,,1,0,,,,CC BY-SA 4.0 +20254,1,,,1/1/2019 22:38,,2,875,"

I am trying to reverse engineer / research a black box system, this is, a system for which there is no public information at all. Let's say the system is a modern handheld console.

+ +

I have already gathered the followed information and data:

+ + + +

So, I have the memory dumps. What would be an efficient approach?

+ +

First I believe loading it with IDA (or r2) could be helpful. But I don't know how to set up a raw dump in IDA, do i have to load it manually? am i missing something?

+ +

Secondly. The dump is not encrypted. I can find strings, references to strings of programs that run in the system, etc... I guess I can also find code (like .text sections in PC but whatever are called in this system) which I should be able to reverse. Is this theory right? if so, how to put it in practice? how can I find pieces of code? I have tried entropy, which seems to be quite useful; code tends to have high entropy. Technically speaking, how would I load that code in IDA properly?

+ +

Everything is welcome

+ +

EDIT: Run binwalk over the ram dumps. Pretty interesting: +https://gist.github.com/pedro-javierf/2476a1f4f0db72b785e414f77c273512

+",16407,,16407,,1/12/2019 22:14,1/12/2019 22:14,How to reverse engineer a Black Box?,,1,0,,,,CC BY-SA 4.0 +20255,2,,4624,1/1/2019 23:45,,0,,"

According to this blog post, GikDbg seems like an Ollydbg mod to debug native Android libraries.

+ +

Unfortunatly, the website of GikDbg doesn't exist anymore.

+",11890,,,,,1/1/2019 23:45,,,,0,,,,CC BY-SA 4.0 +20256,2,,20253,1/2/2019 3:00,,2,,"

My guess is that the website is parsing the Rich Signature (see https://www.ntcore.com/files/richsign.htm for analysis and details). There is a shorter description here. Basically, Microsoft's linkers add some info that can be used to infer that information.

+",26921,,,,,1/2/2019 3:00,,,,2,,,,CC BY-SA 4.0 +20258,1,,,1/2/2019 7:37,,2,203,"
+

Why does -A (aaa) analysis show much more information, when using the -d (debug) CLI option in Radare2?

+
+ +

I'm using the newest version of Radare2 to analyze the Windows application.

+ +

As can be seen below, using the -d (debug) option with -A (aaa) yields more information on the application, e.g. symbols. Why is that?

+ +

Without the -d (debug) CLI option:

+ +
$ r2 -A WindowsService.exe
+Metadata Signature: 0x8bc 0x10001424a5342 12
+.NET Version: v4.0.30319
+[x] Analyze all flags starting with sym. and entry0 (aa)
+[x] Analyze function calls (aac)
+[x] Analyze len bytes of instructions for references (aar)
+[x] Constructing a function name for fcn.* and sym.func.* functions (aan)
+[x] Type matching analysis for all functions (afta)
+[x] Use -AA or aaaa to perform additional experimental analysis.
+ -- I didn't say that it was working, I said that it's implemented
+[0x00403e92]> afll
+address    size  nbbs edges    cc cost  min bound range max bound  calls locals args xref frame name
+========== ==== ===== ===== ===== ==== ========== ===== ========== ===== ====== ==== ==== ===== ====
+0x00403e92    6     1     0     1    3 0x00403e92     6 0x00403e98     0    0      0    1     0 entry0
+
+ +

With the -d (debug) CLI option:

+ +
$ r2 -d -A WindowsService.exe
+Process with PID 21499 started...
+= attach 21499 21499
+bin.baddr 0x561296b89000
+Using 0x561296b89000
+asm.bits 64
+[x] Analyze all flags starting with sym. and entry0 (aa)
+[x] Analyze function calls (aac)
+[x] Analyze len bytes of instructions for references (aar)
+[x] Constructing a function name for fcn.* and sym.func.* functions (aan)
+[TOFIX: afta can't run in debugger mode.ions (afta)
+[x] Type matching analysis for all functions (afta)
+[x] Use -AA or aaaa to perform additional experimental analysis.
+= attach 21499 21499
+21499
+ -- Use zoom.byte=entropy and press 'z' in visual mode to zoom out to see the entropy of the whole file
+[0x7fb177974090]> afll
+address            size  nbbs edges    cc cost          min bound range max bound          calls locals args xref frame name
+================== ==== ===== ===== ===== ==== ================== ===== ================== ===== ====== ==== ==== ===== ====
+0x0000561296b89000  285     3     2     3  134 0x0000561296b89000   292 0x0000561296b89124     0    0      1    0    24 sym.imp.__libc_start_main
+0x0000561296b8d290    6     1     0     1    3 0x0000561296b8d290     6 0x0000561296b8d296     0    0      0    0     0 sym.imp.sigprocmask
+0x0000561296b8d2a0    6     1     0     1    3 0x0000561296b8d2a0     6 0x0000561296b8d2a6     0    0      0    0     0 sym.imp.raise
+0x0000561296b8d2b0    6     1     0     1    3 0x0000561296b8d2b0     6 0x0000561296b8d2b6     0    0      0    0     0 sym.imp.free
+0x0000561296b8d2c0    6     1     0     1    3 0x0000561296b8d2c0     6 0x0000561296b8d2c6     0    0      0    0     0 sym.imp.strcasecmp
+0x0000561296b8d2d0    6     1     0     1    3 0x0000561296b8d2d0     6 0x0000561296b8d2d6     0    0      0    0     0 sym.imp.abort
+0x0000561296b8d2e0    6     1     0     1    3 0x0000561296b8d2e0     6 0x0000561296b8d2e6     0    0      0    1     0 sym.imp.__errno_location
+0x0000561296b8d2f0    6     1     0     1    3 0x0000561296b8d2f0     6 0x0000561296b8d2f6     0    0      0    0     0 sym.imp._exit
+0x0000561296b8d300    6     1     0     1    3 0x0000561296b8d300     6 0x0000561296b8d306     0    0      0    0     0 sym.imp.strcpy
+0x0000561296b8d310    6     1     0     1    3 0x0000561296b8d310     6 0x0000561296b8d316     0    0      0    0     0 sym.imp.qsort
+0x0000561296b8d320    6     1     0     1    3 0x0000561296b8d320     6 0x0000561296b8d326     0    0      0    0     0 sym.imp.isatty
+0x0000561296b8d330    6     1     0     1    3 0x0000561296b8d330     6 0x0000561296b8d336     0    0      0    0     0 sym.imp.sigaction
+0x0000561296b8d340    6     1     0     1    3 0x0000561296b8d340     6 0x0000561296b8d346     0    0      0    0     0 sym.imp.strtod
+0x0000561296b8d350    6     1     0     1    3 0x0000561296b8d350     6 0x0000561296b8d356     0    0      0    0     0 sym.imp.strchrnul
+0x0000561296b8d360    6     1     0     1    3 0x0000561296b8d360     6 0x0000561296b8d366     0    0      0    0     0 sym.imp.faccessat
+0x0000561296b8d370    6     1     0     1    3 0x0000561296b8d370     6 0x0000561296b8d376     0    0      0    0     0 sym.imp.fcntl
+0x0000561296b8d380    6     1     0     1    3 0x0000561296b8d380     6 0x0000561296b8d386     0    0      0    0     0 sym.imp.write
+0x0000561296b8d390    6     1     0     1    3 0x0000561296b8d390     6 0x0000561296b8d396     0    0      0    1     0 sym.imp.getpid
+0x0000561296b8d3a0    6     1     0     1    3 0x0000561296b8d3a0     6 0x0000561296b8d3a6     0    0      0    0     0 sym.imp.__strtol_internal
+0x0000561296b8d3b0    6     1     0     1    3 0x0000561296b8d3b0     6 0x0000561296b8d3b6     0    0      0    0     0 sym.imp.__xstat64
+0x0000561296b8d3c0    6     1     0     1    3 0x0000561296b8d3c0     6 0x0000561296b8d3c6     0    0      0    0     0 sym.imp.wait3
+0x0000561296b8d3d0    6     1     0     1    3 0x0000561296b8d3d0     6 0x0000561296b8d3d6     0    0      0    0     0 sym.imp.opendir
+0x0000561296b8d3e0    6     1     0     1    3 0x0000561296b8d3e0     6 0x0000561296b8d3e6     0    0      0    0     0 sym.imp.stpcpy
+0x0000561296b8d3f0    6     1     0     1    3 0x0000561296b8d3f0     6 0x0000561296b8d3f6     0    0      0    0     0 sym.imp.strlen
+0x0000561296b8d400    6     1     0     1    3 0x0000561296b8d400     6 0x0000561296b8d406     0    0      0    0     0 sym.imp.chdir
+0x0000561296b8d410    6     1     0     1    3 0x0000561296b8d410     6 0x0000561296b8d416     0    0      0    0     0 sym.imp.__stack_chk_fail
+0x0000561296b8d420    6     1     0     1    3 0x0000561296b8d420     6 0x0000561296b8d426     0    0      0    1     0 sym.imp.getuid
+0x0000561296b8d430    6     1     0     1    3 0x0000561296b8d430     6 0x0000561296b8d436     0    0      0    0     0 sym.imp.dup2
+0x0000561296b8d440    6     1     0     1    3 0x0000561296b8d440     6 0x0000561296b8d446     0    0      0    0     0 sym.imp.strchr
+0x0000561296b8d450    6     1     0     1    3 0x0000561296b8d450     6 0x0000561296b8d456     0    0      0    0     0 sym.imp.warnx
+0x0000561296b8d460    6     1     0     1    3 0x0000561296b8d460     6 0x0000561296b8d466     0    0      0    0     0 sym.imp.__strtoul_internal
+0x0000561296b8d470    6     1     0     1    3 0x0000561296b8d470     6 0x0000561296b8d476     0    0      0    0     0 sym.imp.fnmatch
+0x0000561296b8d480    6     1     0     1    3 0x0000561296b8d480     6 0x0000561296b8d486     0    0      0    0     0 sym.imp.geteuid
+0x0000561296b8d490    6     1     0     1    3 0x0000561296b8d490     6 0x0000561296b8d496     0    0      0    0     0 sym.imp.getcwd
+0x0000561296b8d4a0    6     1     0     1    3 0x0000561296b8d4a0     6 0x0000561296b8d4a6     0    0      0    0     0 sym.imp.close
+0x0000561296b8d4b0    6     1     0     1    3 0x0000561296b8d4b0     6 0x0000561296b8d4b6     0    0      0    0     0 sym.imp.pipe
+0x0000561296b8d4c0    6     1     0     1    3 0x0000561296b8d4c0     6 0x0000561296b8d4c6     0    0      0    0     0 sym.imp.strspn
+0x0000561296b8d4d0    6     1     0     1    3 0x0000561296b8d4d0     6 0x0000561296b8d4d6     0    0      0    0     0 sym.imp.closedir
+0x0000561296b8d4e0    6     1     0     1    3 0x0000561296b8d4e0     6 0x0000561296b8d4e6     0    0      0    0     0 sym.imp.strcspn
+0x0000561296b8d4f0    6     1     0     1    3 0x0000561296b8d4f0     6 0x0000561296b8d4f6     0    0      0    0     0 sym.imp.read
+0x0000561296b8d500    6     1     0     1    3 0x0000561296b8d500     6 0x0000561296b8d506     0    0      0    1     0 sym.imp._setjmp
+0x0000561296b8d510    6     1     0     1    3 0x0000561296b8d510     6 0x0000561296b8d516     0    0      0    0     0 sym.imp.execve
+0x0000561296b8d520    6     1     0     1    3 0x0000561296b8d520     6 0x0000561296b8d526     0    0      0    0     0 sym.imp.__fxstat64
+0x0000561296b8d530    6     1     0     1    3 0x0000561296b8d530     6 0x0000561296b8d536     0    0      0    0     0 sym.imp.strcmp
+0x0000561296b8d540    6     1     0     1    3 0x0000561296b8d540     6 0x0000561296b8d546     0    0      0    0     0 sym.imp.signal
+0x0000561296b8d550    6     1     0     1    3 0x0000561296b8d550     6 0x0000561296b8d556     0    0      0    0     0 sym.imp.getpwnam
+0x0000561296b8d560    6     1     0     1    3 0x0000561296b8d560     6 0x0000561296b8d566     0    0      0    0     0 sym.imp.umask
+0x0000561296b8d570    6     1     0     1    3 0x0000561296b8d570     6 0x0000561296b8d576     0    0      0    0     0 sym.imp.strtol
+0x0000561296b8d580    6     1     0     1    3 0x0000561296b8d580     6 0x0000561296b8d586     0    0      0    0     0 sym.imp.sigfillset
+0x0000561296b8d590    6     1     0     1    3 0x0000561296b8d590     6 0x0000561296b8d596     0    0      0    0     0 sym.imp.memcpy
+0x0000561296b8d5a0    6     1     0     1    3 0x0000561296b8d5a0     6 0x0000561296b8d5a6     0    0      0    0     0 sym.imp.kill
+0x0000561296b8d5b0    6     1     0     1    3 0x0000561296b8d5b0     6 0x0000561296b8d5b6     0    0      0    1     0 sym.imp.getgid
+0x0000561296b8d5c0    6     1     0     1    3 0x0000561296b8d5c0     6 0x0000561296b8d5c6     0    0      0    0     0 sym.imp.tcgetpgrp
+0x0000561296b8d5d0    6     1     0     1    3 0x0000561296b8d5d0     6 0x0000561296b8d5d6     0    0      0    0     0 sym.imp.__xstat
+0x0000561296b8d5e0    6     1     0     1    3 0x0000561296b8d5e0     6 0x0000561296b8d5e6     0    0      0    0     0 sym.imp.readdir
+0x0000561296b8d5f0    6     1     0     1    3 0x0000561296b8d5f0     6 0x0000561296b8d5f6     0    0      0    0     0 sym.imp.malloc
+0x0000561296b8d600    6     1     0     1    3 0x0000561296b8d600     6 0x0000561296b8d606     0    0      0    0     0 sym.imp.killpg
+0x0000561296b8d610    6     1     0     1    3 0x0000561296b8d610     6 0x0000561296b8d616     0    0      0    0     0 sym.imp.getegid
+0x0000561296b8d620    6     1     0     1    3 0x0000561296b8d620     6 0x0000561296b8d626     0    0      0    0     0 sym.imp.strpbrk
+0x0000561296b8d630    6     1     0     1    3 0x0000561296b8d630     6 0x0000561296b8d636     0    0      0    0     0 sym.imp.sigsuspend
+0x0000561296b8d640    6     1     0     1    3 0x0000561296b8d640     6 0x0000561296b8d646     0    0      0    0     0 sym.imp.__vsnprintf_chk
+0x0000561296b8d650    6     1     0     1    3 0x0000561296b8d650     6 0x0000561296b8d656     0    0      0    0     0 sym.imp.setrlimit
+0x0000561296b8d660    6     1     0     1    3 0x0000561296b8d660     6 0x0000561296b8d666     0    0      0    0     0 sym.imp.strsignal
+0x0000561296b8d670    6     1     0     1    3 0x0000561296b8d670     6 0x0000561296b8d676     0    0      0    0     0 sym.imp.realloc
+0x0000561296b8d680    6     1     0     1    3 0x0000561296b8d680     6 0x0000561296b8d686     0    0      0    0     0 sym.imp.sigsetmask
+0x0000561296b8d690    6     1     0     1    3 0x0000561296b8d690     6 0x0000561296b8d696     0    0      0    0     0 sym.imp.__longjmp_chk
+0x0000561296b8d6a0    6     1     0     1    3 0x0000561296b8d6a0     6 0x0000561296b8d6a6     0    0      0    0     0 sym.imp.open64
+0x0000561296b8d6b0    6     1     0     1    3 0x0000561296b8d6b0     6 0x0000561296b8d6b6     0    0      0    0     0 sym.imp.mempcpy
+0x0000561296b8d6c0    6     1     0     1    3 0x0000561296b8d6c0     6 0x0000561296b8d6c6     0    0      0    0     0 sym.imp.memmove
+0x0000561296b8d6d0    6     1     0     1    3 0x0000561296b8d6d0     6 0x0000561296b8d6d6     0    0      0    0     0 sym.imp.setgid
+0x0000561296b8d6e0    6     1     0     1    3 0x0000561296b8d6e0     6 0x0000561296b8d6e6     0    0      0    0     0 sym.imp.getpgrp
+0x0000561296b8d6f0    6     1     0     1    3 0x0000561296b8d6f0     6 0x0000561296b8d6f6     0    0      0    0     0 sym.imp.tcsetpgrp
+0x0000561296b8d700    6     1     0     1    3 0x0000561296b8d700     6 0x0000561296b8d706     0    0      0    0     0 sym.imp.open
+0x0000561296b8d710    6     1     0     1    3 0x0000561296b8d710     6 0x0000561296b8d716     0    0      0    0     0 sym.imp.times
+0x0000561296b8d720    6     1     0     1    3 0x0000561296b8d720     6 0x0000561296b8d726     0    0      0    0     0 sym.imp.strtok
+0x0000561296b8d730    6     1     0     1    3 0x0000561296b8d730     6 0x0000561296b8d736     0    0      0    0     0 sym.imp.sysconf
+0x0000561296b8d740    6     1     0     1    3 0x0000561296b8d740     6 0x0000561296b8d746     0    0      0    0     0 sym.imp.__lxstat64
+0x0000561296b8d750    6     1     0     1    3 0x0000561296b8d750     6 0x0000561296b8d756     0    0      0    0     0 sym.imp.setpgid
+0x0000561296b8d760    6     1     0     1    3 0x0000561296b8d760     6 0x0000561296b8d766     0    0      0    0     0 sym.imp.getppid
+0x0000561296b8d770    6     1     0     1    3 0x0000561296b8d770     6 0x0000561296b8d776     0    0      0    0     0 sym.imp.getrlimit
+0x0000561296b8d780    6     1     0     1    3 0x0000561296b8d780     6 0x0000561296b8d786     0    0      0    0     0 sym.imp.setuid
+0x0000561296b8d790    6     1     0     1    3 0x0000561296b8d790     6 0x0000561296b8d796     0    0      0    0     0 sym.imp.strdup
+0x0000561296b8d7a0    6     1     0     1    3 0x0000561296b8d7a0     6 0x0000561296b8d7a6     0    0      0    0     0 sym.imp.strerror
+0x0000561296b8d7b0    6     1     0     1    3 0x0000561296b8d7b0     6 0x0000561296b8d7b6     0    0      0    0     0 sym.imp.fork
+0x0000561296b8d7c0    6     1     0     1    3 0x0000561296b8d7c0     6 0x0000561296b8d7c6     0    0      0    0     0 sym.imp.__ctype_b_loc
+0x0000561296b8d7d0    6     1     0     1    3 0x0000561296b8d7d0     6 0x0000561296b8d7d6     0    0      0    1     0 sub.__cxa_finalize_7d0
+0x0000561296b8d850  455    25    42    17  155 0x0000561296b8d850   455 0x0000561296b8da17    20    6      2    1   280 main
+0x0000561296b8da20   43     1     0     1   17 0x0000561296b8da20    43 0x0000561296b8da4b     1    0      1    0     8 entry0
+0x0000561296b8da50   40     4     4     4   19 0x0000561296b8da50    50 0x0000561296b8da82     0    0      0    1     8 sub.__environ_32_a50
+0x0000561296b8da90   57     4     4     4   24 0x0000561296b8da90    66 0x0000561296b8dad2     0    0      0    1     8 loc.561296b8da90
+0x0000561296b8dae0   51     5     5     4   24 0x0000561296b8dae0    58 0x0000561296b8db1a     2    0      0    0     0 entry2.fini
+0x0000561296b8db20  124     5     5     4   30 0x0000561296b8da90    10 0x0000561296b8db2a     0    0      0    0     8 entry1.init
+0x0000561296da5fd8   72     1     0     1   33 0x0000561296da5fd8    72 0x0000561296da6020     0    0      0    1     0 reloc.__libc_start_main
+
+",25753,,,,,1/6/2019 20:08,"Why does -A (aaa) analysis show much more information, when using the -d (debug) CLI option in Radare2?",,1,0,,,,CC BY-SA 4.0 +20259,2,,20233,1/2/2019 8:25,,1,,"

From here the structure of a private key looks like

+ +
RSAPrivateKey ::= SEQUENCE {
+  version           Version,
+  modulus           INTEGER,  -- n
+  publicExponent    INTEGER,  -- e
+  privateExponent   INTEGER,  -- d
+  prime1            INTEGER,  -- p
+  prime2            INTEGER,  -- q
+  exponent1         INTEGER,  -- d mod (p-1)
+  exponent2         INTEGER,  -- d mod (q-1)
+  coefficient       INTEGER,  -- (inverse of q) mod p
+  otherPrimeInfos   OtherPrimeInfos OPTIONAL
+}
+
+ +

If analyzed the base64 data in the ASN.1 decoder

+ +
SEQUENCE (9 elem)
+  INTEGER 0
+  INTEGER (2048 bit) 226871413225308095515915826394392101638242887434378121570998515897193…
+  INTEGER 65537
+  INTEGER (2048 bit) 194320763995749647278490303169550120288709068819771754524412632427072…
+  INTEGER (1024 bit) 134355954175703308272730070638862721054431606752282500957493356998331…
+  INTEGER (1024 bit) 168858473461189648019451140006978906971949575614563598413430805554687…
+  INTEGER (1023 bit) 501346546129182660757986157052258700182511397092797741873369248728839…
+  INTEGER (1023 bit) 467538315673092658034539326878959861744205105375874857990160580678909…
+  INTEGER (1024 bit) 994358373821297873423986022178929159513641342137481304248109111567867…
+
+ +

All the values n,e(65537), d, p, q, exponent1, exponent2 and coefficient are present with probably proper lengths. +So this is a private key. As already mentioned in other answer, see how you can load this in python

+ +
In [1]    from Crypto.PublicKey import RSA  
+          from Crypto.Util.number import long_to_bytes, bytes_to_long
+          
+          k_raw = ""MIIEpAIBAAKCAQEAs7d+tTj2F6hEHNzx+xM8HnMVaJTx4ElALVw8p8dLacao6BkT3Prq7j5GvuBZNO0hwjrcmJcpwYm/eR2nW1lu9BoyWTggU5nsDKOs7qkCOPNYm1uEJ/i654uAHmXQCk/dSQW/xlCnnVlgNLPcIP2JQgKp9xh5nXQuffXe/eVT46uOlS4PMEf3P+HhyMqKZlNs8vB0ag9gfebboKjjVw74PANCCpGalQpaAHWXvy9crI0JbzyssMoiinNQDdK9CEUe/7erAMB9kvImB6dAo5RQaghasPtWJ6IOb78SKpqzae4vthyYNiDYSKcrFgR/JlRoNprESem08HNhr44QGd99VwIDAQABAoIBAQCZ7oOjKaTv4npk1oKVcYY+9ofRyjHa0CMeNzDk7HkVoskt87zlvC3Z3pGuEG+YO7x8pvon4OItGZVdYh7kyZeVkZKqhL57nQ1oThFjYnO64AR3HU33Br7gcMZOQxqMmpeJYlk+vfqzdchHm/7iawdT+QAn21jfmpHv5dcYVYMjL27auk0sbHl/8Xfu1+buZCStw6+DUuYRNCZVIvChM0dhhFIx5nCLYwyvDKJKd/WXs+wuA4FyAX9msedsHNmdK1pqKfqrm6QqiexEsf8g7mBvnn+VVr2adOXBuD2HMX8gCMp3kLTwIYKS9ITKQKPD1kxUFjS7zJA/HCysWXGm+VfxAoGBAL9USGVp4v93pPrU6X79AEiXix0tXntCIcPe8q1soEJ69Cu/WSzyQ5BI2Q7/JIgQ6/b69nhRxLHH3WRvU3Lm6etGNg9zfO26LMC1oojO789Ajldug1LJkMJHCjYwhTKLSnZzLDklGha6fTfgrBS87IeQgSFLvbVDrOyzGn0+Zw+FAoGBAPB2Yv7oSi4F5pl6KN+su8FgQXZAyyhdIjYmtlbg5sIjCdWt7ziIs4rRcgF9RnRT7lPoMeKod/eDaqGlwZ50QxQtXB3K/AkqL1w5UUWO4MnPoVP47v4iuU5RYI6YvVs2CaPJ+HDwngjHgw33Sdlr8O3tYz+xMY2gg78qRA/sSPorAoGAR2Tk6urbKKb1qh+ezaMM4wmhgI64bdgcj2F3Pt2E46nLyTNKzGnOal20mVL9x8RAuNWm+PjSI+DHrT2ZbwvZh9CYRaW7nV3Wa0ab0t8dP0IAm4GCgXbzjHtDxTrPyS+O5qpNezlsBcUrCpnMvKROwrtaZBlGPgh105F1tfx+Kp0CgYBClGUAs4ymhZe98ycSF5+9AUve1D3sJS1t1PYzw/3gzxbQBWLxQliEHU31v5wcZYjdzrLRUVg2PjruGxkrKIHSOmUBEs0KNJX8cRphqhfviP/gYlK6Jx8r4jhcA0qa0LGGmkuh6d24DJXq7geSneKN3mbWoddYoZMZATjrN79VFQKBgQCNmfDwvv+o+tI3VA7XAZnefG2TJFBRdBFeQQMZV+wpmQF+ixx9X5iJpi/njh1TLcXvQfppTkmspdUph9j3D5ZBNQbkcU4RAG287DwxjWIR3n+FSLSzer7dKy+Ws2ew68/QFmxlgqZgzp95t074O7C7yHYE/e/Dsr/LEhWy+codNQ==""
+          
+          k = RSA.importKey(""-----BEGIN RSA PRIVATE KEY-----\n%s\n-----END RSA PRIVATE KEY-----\n"" % k_raw)
+          ciphertext = ""4c0605e901b09d75c5f5befe7438d7246f988531cc7a39a59f24b9488d47dfae9fc8beb5117f34a316f9380607bf239ba6eca84da47a12d720986a8a0100a7e9d7028d7e423557055b9e250f271d6436018c58e79a8f26bac10768776f06dc1786dd7428b3c445b8993e884630b36cb2d300fa5dc1fe0eba9e433062d9d8a58f33bf6f93aa37298a5703ccbf71c93adea447f018e9f75bb43dbc528cfc9bed865a9ba43f926071dabc89ccca2e000f1a966855cc9816e45c0113edb55a700198d346a90487b5ff1191994973eb1b5252b22c6410aa70ea4e9c3ebd468ef273d7cf9d15b5824244cd25f252886d1edfe2d6f2caa5d5e00fd84597e3de192db41b"".decode('hex')
+
+ +

Now decryption is simply a pow operation

+ +
print long_to_bytes(pow(bytes_to_long(ciphertext), k.d, k.n))
+          
+gFmqI4XpJBjprHFWrVqkaQ==
+
+",14622,,,,,1/2/2019 8:25,,,,0,,,,CC BY-SA 4.0 +20262,1,20263,,1/2/2019 12:20,,2,932,"

I am trying to learn how to use IDA Pro 6.8 to analyze binaries. However, there are much more functions in ida function list than my code. For example, there is a function in source code that calls four callee functions, two global functions and two public function of a class. But, in ida, it has more than ten callees, if I print the line.points.size(). It is recognized as a function in ida. line is my class, points is a vector variable of line. The function in ida is named std::vector<std::vector<Point *,std::allocator<Point *>>,std::allocator<std::vector<Point *,std::allocator<Point *>>>>::size(void). So it caused that the number of callee is not equal to the number in source. Why are there so much more functions that are not defined as function in my source? How can I recognize which function in ida is the function I define and which one is added by ida?

+",26799,,,,,1/3/2019 0:56,Why are there so much more functions in ida than my source code?,,2,3,,,,CC BY-SA 4.0 +20263,2,,20262,1/2/2019 14:49,,2,,"

You just discovered why templates are accused of code bloat.

+ +

That function is not added by IDA but instead by the compiler when it expanded the templated class std::vector<std::vector<Point*>> and generated all its member functions. Every std::vector with a different template parameter is considered a separate type. So std::vector<int>::size() and std::vector<float>::size() are separate functions however a sufficiently smart compiler/linker with high enough optimization settings will see that the code of the two is the exact same and be able to combine them.

+",14025,,,,,1/2/2019 14:49,,,,1,,,,CC BY-SA 4.0 +20264,1,,,1/2/2019 15:01,,1,518,"

When analysing mach-o binaries IDA seems to interpret const/literal part of x86 mov instruction(0x8B) as an offset.

+ +

Hex rerpresentation: 8B 40 0A

+ +

Correct assembly: mov eax,DWORD PTR [eax+0x0A] ; 8B 40 0A

+ +

IDA assembly:mov eax, dword ptr ds:(loc_1DF4B8 + 3 - 1DF4B1h)[eax]

+ +

loc_1DF4B8 + 3 - 1DF4B1 = 0x0A so its basicaly the same but the offset part throws of further analysis on the binary.

+ +

Is there any option i'm missing to prevent this from happening or any scriptable way to fix it?

+ +

EDIT: individual instructions can be fixed with s # shortcut

+",26945,,26945,,1/2/2019 17:25,1/17/2022 2:01,IDA Interpreting mov instructions in a unusual way,,1,0,,,,CC BY-SA 4.0 +20265,2,,20264,1/2/2019 21:55,,1,,"

it seems this is due to the heuristic applied by IDA. Could you tell us how eax is initialized? +Regarding your issue, and if IDA is wrong every times, I think your answer is on the IDA options: +

+ +

But I didn't test it.

+",26176,,,,,1/2/2019 21:55,,,,1,,,,CC BY-SA 4.0 +20266,2,,20254,1/2/2019 22:10,,2,,"

First I believe loading it with IDA (or r2) could be helpful. But I don't know how to set up a raw dump in IDA, do i have to load it manually? am i missing something?

+ +

IDA directly handles raw image, all you have to do is specify the ARM little-endian [ARM] in the processor type. +Once it's loaded, your first challenge is to identify the memory layout.

+ +

Secondly. The dump is not encrypted. I can find strings, references to programs that run in the system, etc... I guess I can also find code (like .text sections in PC but whatever are called in this system) which I should be able to reverse. Is this theory right? if so, how to put it in practice? how can I find pieces of code? I have tried entropy, which seems to be quite useful; code tends to have high entropy. Technically speaking, how would I load that code in IDA properly?

+ +

The information requires is to know what kind of dump do you have, if you dump memory from a vulnerability, or from a JTAG, or whatever. The layout might be different.

+ +

Few examples:

+ +
    +
  • If this is a raw dump, I would suggest to start with the address 0x0 and look for the Arm exception vector.
  • +
  • If you dump it from a flash memory, you might find files embedded inside with binwalker.
  • +
  • If there's a MMU, you could retrieve the page tables and recreate the virtual layout.
  • +
  • You could look for strings which are used by open source software (e.g. u-Boot, linux, ...) and retrieve function pointers to start to reconstruct the image.
  • +
  • And so on.
  • +
+ +

Hopefully you can provide further information about the target, that's sound interesting. :)

+",26176,,,,,1/2/2019 22:10,,,,7,,,,CC BY-SA 4.0 +20268,2,,20245,1/2/2019 23:32,,2,,"

Interesting topic.

+ +

The first thing I do to simplify obfuscation, is to determine if the obfuscator works in assembly or IR level. +In assembly level, you usually have a finer granularity and tricky instructions, where in an IR level you find better looking functions and standard instructions from a compiler.

+ +

This case should be on assembly language level, because there are lot of useless stack displacement and assignment, I suggest to start to simplify it. I manually did that, it's a way to figure out the pattern (if possible) and then automatize the process:

+ +
esp=0255ff78 jmp     0040aeb1
+esp=0255ff78 pushfd                                 ;; 0255ff74 = flags
+esp=0255ff74 mov     dword ptr [esp],580B8317h      ;; 0255ff74 = 0x580B8317
+esp=0255ff74 jmp     0040892d
+esp=0255ff74 mov     byte ptr [esp],dl              ;; 0255ff74 = 0x580B8300
+esp=0255ff74 mov     dword ptr [esp],1B2F9632h      ;; 0255ff74 = 0x1B2F9632
+esp=0255ff74 jmp     0040e0cf
+esp=0255ff74 pushfd                                 ;; 0255ff70 = flags
+esp=0255ff70 pushad                                 ;; 0255ff6c = eax = ffff8001
+                                                    ;; 0255ff68 = ecx = 77781e4c
+                                                    ;; 0255ff64 = edx = 00000000
+                                                    ;; 0255ff60 = ebx = 001603b6
+                                                    ;; 0255ff5c = esp = 0255ff70
+                                                    ;; 0255ff58 = ebp = 0255ff80
+                                                    ;; 0255ff54 = esi = 00401233
+                                                    ;; 0255ff50 = edi = 00401233
+
+esp=0255ff50 call    00408cfb                       ;; 0255ff4c = 0040e0d1 + 5 = 0x40e0d6
+esp=0255ff4c mov     dword ptr [esp+24h],7ECAB5C8h  ;; 0255ff70 = 0x7ECAB5C8
+esp=0255ff4c mov     byte ptr [esp],88h             ;; 0255ff4c = (0x40e0d6 & 0xffffff00) | 0x88 = 0x40e088
+esp=0255ff4c push    4EE1A112h                      ;; 0255ff48 = 0x4EE1A112
+esp=0255ff48 push    eax                            ;; 0255ff44 = ffff8001
+esp=0255ff44 lea     esp,[esp+2Ch]                  ;; esp = 0255ff70
+esp=0255ff70 jmp     00406089
+
+ +

I agree with you about the two push instructions. Between the beginning and the end, the stack was decremented of 4 + 4, and the assignment at these offsets give the value of the push. +It doesn't mean these values will be eventually used, though.

+ +
+

I was trying to convert these functions to LLVM IR and then optimize + it but all of known to me tools weren't able to do that. As far as I + remember only llvm-mctoll was generating suitable IR (but it was + failing in most cases, probably because of lack of supported + instructions), other generated a lot of useless junk code and after + optimization it looked even worse.

+
+ +

The main issue is how an instruction is actually converted to the IR and how it'll react with the compiler's passes. Some obfuscations could be optimized by a compiler, others don't. +An example is, how a compiler is supposed to interact with the pushf or pushad instruction? If you can remap the stack usage as alloca, you could easily remove useless access. If esp access is viewed as a non-volatile write on memory, the compiler will have to keep it every time. +Compilers are better to perform well-known optimization like constant propagation.

+ +
+

Other tools like Miasm or Angr optimized only IR, and that's not what + I'm looking for.

+
+ +

What's the problem with the IR?

+ +
+

How am I supposed to do that? Optimizing it by hand is pretty easy but + it's time consuming (it has about 4k asm instructions).

+
+ +

I recommend a tool which works on the IR level and you define your own optimization. If you can simplify the stack usage and useless jmp / call, you will get a better view of the original code.

+ +
+

Does any tools that might help with such kind of optimising exists?

+
+ +

Yes, but I think you already know them. +In case of: triton and medusa (disclaimer: I'm the author of the latter, and it's kinda broken at the moment)

+ +
+

Where is the problem with creating them?

+
+ +

Most of these tools work with an IR, the first issue is to convert assembly code to an IR language to work with. +The next step is to implement simplification passes (like a compiler). +The final step is to construct expression by executing symbolically the code, the complexity grows very quickly and you end with poor performances / memory exhaustion. +Usually, you have to simplify these expressions manually by concreting some inputs and applying optimizations.

+ +
+

As far as I understand theory it's quite easy, especially that I'm + not analysing binary but trace so I don't have to care about proper + flow paths, disassembling etc.

+
+ +

Analyzing a trace is usually easier, but there's a catch. +Storing the trace could be very heavy, the overhead could be excessive, you can't easily build expressions from the trace, ... +If you want to stay with a trace, I think you should probably write a custom tool which parse the code and optimize it. For instance: for each assignment on the stack, keep the exact address and value. At the end of each piece of code (e.g. call to a imported function, address is already executed, ...) you can remove useless write on the stack. +I can't guarantee it'll work on this case. :)

+ +

BTW, can you share the executable?

+",26176,,,,,1/2/2019 23:32,,,,1,,,,CC BY-SA 4.0 +20269,2,,20262,1/3/2019 0:56,,0,,"

A compiler has to translate the language that you know (C++) to the language that the computer knows. A linker then links together your code with referenced libraries and creates an executable. In order to turn it back into a form that you can read, IDA reads the computer's language and translates it into a disassembly. Both compilation and disassembly are complicated processes. Disassembly itself is a hard problem, including function identification and boundary detection. In addition to inaccuracies in the disassembly process, the executable building process does several things.

+ +

First, your source code is translated into machine code, and all modern compilers have various heuristics and rules they use to optimize the code. Take a look at the docs for gcc and the docs for Visual Studio. Sometimes this means decreasing the number of functions (for example, inlining), and sometimes it means increasing (for example, thunks).

+ +

Second, either implicitly or explicitly, your source code is referencing lots of other source code, with includes, and includes within those included files, and includes within those included files... some of which cause the linker to dynamically link (add references to) libraries, and some of which cause the linker to statically link (copy and append to your code) those libraries.

+",26921,,,,,1/3/2019 0:56,,,,0,,,,CC BY-SA 4.0 +20272,1,,,1/3/2019 12:34,,0,573,"

I'm trying to reverse engineer an ARM Thumb2 firmware binary, and I've come across a few oddities. Parts of the file when treated as RGB binary data form perfect images, which seems unusual for a firmware file, and when visualised by turning each byte into a greyscale pixel (0x00 as magenta for clarity) around the middle of the file there's a large section of nulls with 64 strips of data that seem to line up perfectly with a width of 404px: These strips are exactly 8x76 and appear to form pairs. Attempting to extract them and decode as raw image data resulted in garbage, and I'm at a bit of a loss as to what they are and what they're doing in a firmware binary.

+ +

The target processor for this binary is a Xilinx 7000, and the start of the binary does appear to contain FPGA data for this. The binary is at https://drive.google.com/open?id=1rmCRP_mdGLx4QQ4HurL7a3TEiXe_kHn3 and if anyone has any idea as to what those strips (or other parts of the file too, to be honest) might be, that would be amazing.

+",,user26954,,,,1/5/2019 0:15,Confused about a firmware binary,,1,4,,,,CC BY-SA 4.0 +20273,2,,11184,1/3/2019 13:22,,0,,"

You can use the following function in order to get the local variable value by its name(IDA 7+):

+ +
import idc 
+import ida_frame 
+import ida_struct 
+
+def get_local_var_value_64(loc_var_name):
+    frame = ida_frame.get_frame(idc.here())
+    loc_var = ida_struct.get_member_by_name(frame, loc_var_name)
+    loc_var_ea = loc_var.soff + idc.GetRegValue(""RSP"")
+    # In case the variable is 32bit, use get_wide_dword() instead:
+    loc_var_value = idc.read_dbg_qword(loc_var_ea) 
+    return loc_var_value
+
+",26955,,,,,1/3/2019 13:22,,,,2,,,,CC BY-SA 4.0 +20274,2,,19261,1/3/2019 15:51,,3,,"

What you are asking for is called "Differential Debugging". Take a look to this tutorial to see how to do so with IDA without requiring any kind of plugins, just built-in functionality.

+",111,,111,,8/27/2020 9:17,8/27/2020 9:17,,,,2,,,,CC BY-SA 4.0 +20276,2,,14207,1/3/2019 23:34,,2,,"

Here are symbol prefixes with examples, as output by the Radare2 command ""axj"" from C:\Windows\system32\gdi32.dll:

+ +
    +
  • sym.imp.* : ""sym.imp.KERNEL32.dll_UnhandledExceptionFilter""
  • +
  • sub.* : ""sub.KERNEL32.dll_RtlCaptureContext_614+410"" or ""sym.imp.ole32.dll_ReleaseStgMedium+56"" (Note the library name in upper- or lowercase)
  • +
  • fcn.* : ""fcn.18000587c+41""
  • +
  • str.* : ""str.._AUIDropTarget+584"" or ""str.PyShellExt::GetArguments___failed_to_lock_CF_HDROP_hGlobal+124"" or ""str.memset"" (One or two dots)
  • +
  • section.* : ""section..data+16""
  • +
  • switch.* : ""switch.0x180004860""
  • +
  • case.* : ""case.default.0x180004820""
  • +
  • resource.* : ""resource.1""
  • +
+ +

The only explanation I could find is:

+ +

""Flags generally have a prefix in their name, such as str., sym., sub., fcn.""

+ +

Those names are called ‘flags’. Flags can be grouped into ‘flag spaces’.

+ +

As suggested, ""fs"" command displays:

+ +
[0x180005218]> fs
+0  247 * strings
+1    5 * symbols
+2    8 * sections
+3    0 * segments
+4   79 * relocs
+5   79 * imports
+6    2 * resources
+7  104 * functions
+
+ +

More information about flags and flagspaces here: +Radare2, basic commands, flags

+",26962,,26962,,1/4/2019 8:14,1/4/2019 8:14,,,,0,,,,CC BY-SA 4.0 +20277,2,,20226,1/4/2019 0:29,,1,,"

Hexrays sells a decompiler plugin for IDA Pro. If you have a supported (purchased or renewed within the last year) version of IDA Pro, then you can purchase one of the ARM decompiler plugins.

+ +

I have not tried the following, but have heard of them (so add a comment about how well it works if you do try one!)...

+ +

There's the opensource snowman decompiler. It has been around for a few years now. Its website says it supports ARM and is available for radare2, x64dbg, multiple versions of IDA Pro, and as a standalone application.

+ +

Another opensource one is RetDec. Looks like it was just released late last year, but is from a well regarded AV company (Avast) and supposedly has been in development and use privately for several years.

+ +

I've also heard of the commercial Hopper product, which specializes in macOS executables, but not sure how good the built-in decompiler is.

+",26921,,,,,1/4/2019 0:29,,,,2,,,,CC BY-SA 4.0 +20278,1,20547,,1/4/2019 9:58,,1,783,"

While learning RE I have come across this large segment of instructions that contains a majority of mov [ebp+offset], value instructions. I believe that ebp + offset are local variables? I think? Could it really just be a lot of local variables? Or could it actually be a data structure and this is how IDA represents it? I have a theory of what this might be but if anyone knows what this could mean that would be sweet.

+

Here's a screenshot: +

+

My guess is this is actually a data structure. ebp is the base address of the structure. The mov instructions between the mov [...], offset value are padding bytes. I'm guessing they are just padding bytes since esi doesn't contain a value (it was xor-ed with itself at the top of the screenshot) and is mov'd epb + offset quite a lot in this block.

+

Any ideas and advice on what is happening in this screenshot would be appreciated. Thanks.

+",19294,,-1,,6/17/2020 9:54,2/4/2019 12:20,Lots of mov instructions into ebp+offset - What is happening?,,2,1,,,,CC BY-SA 4.0 +20280,2,,20025,1/4/2019 14:22,,1,,"

A nice framework to look at is Triton which does a good job in Dynamic Symbolic Execution. I ended up looking at the code and implementing my own solution with their same approach.

+",12793,,,,,1/4/2019 14:22,,,,0,,,,CC BY-SA 4.0 +20281,2,,20278,1/4/2019 14:36,,0,,"

The mov ebp, esp sets EBP at top of stack, sub esp, 0F34h allocates 0xF34 bytes on stack. EBP is used as a base for writing and reading the bytes. This is standard x86 stack frame you can see in many Windows executables.

+ +

It looks like the 0xF34 bytes allocates variables and various structures, perhaps also array of 20-bytes structures after reviewing it, this doesn't look right:

+ +
DWORD pointer to name
+DWORD - no idea what
+DWORD pointer to - no idea what -, can be NULL
+DWORD - no idea what -
+DWORD pointer to DWORD - no idea what -
+
+ +

ESI has value of zero. The mov [...], esi is used instead of mov [...], 0 because the latter one has longer opcode.

+ +

Don't get confused by the addition in ebp+var. All the bytes are actually located at lower addresses, below EBP.

+ +

You can learn more about the stack frame for example here:

+ +

https://en.wikibooks.org/wiki/X86_Disassembly/Functions_and_Stack_Frames

+",4192,,,,,1/4/2019 14:36,,,,0,,,,CC BY-SA 4.0 +20282,1,,,1/4/2019 16:35,,2,338,"

I have a function of the format:

+ +
sub_ABCDEF(&global, ""stringName"", unimportantValue)
+
+push    offset string
+mov     ecx, offset global
+call    sub_410010
+
+ +

That is called in several places, each varying the &global and string location.

+ +

I am wondering if it's possible in IDAPython to bulk rename all the &global's to the string value.

+ +

I used XrefsTo(410010, 0) to obtain a list of places the function is called from, but I am unsure how to get the parameters it was called with.

+",25559,,,,,1/4/2019 16:35,IDA rename argument in all xrefs to function,,0,1,,,,CC BY-SA 4.0 +20283,1,,,1/4/2019 18:43,,1,214,"

I'am trying to unpack Android game archive file (.NPK).

+ +

The game is ""Nvidia Glowball demo"" (it has been pre-installed on my android tablet)

+ +

Archive structure seems to be simple, but I can't decompress the data.

+ +

Archive structure:

+ +
4 bytes - ""BE EF CA FE"" signature
+4 bytes - File headers count (little-endian)
+[File headers]
+4 bytes - ""BE EF CA FE"" signature
+[Files data]
+
+ +

File header structure:

+ +
4 bytes - File name length (little-endian)
+[File name]
+8 bytes - Unknown (not a checksum, signature?)
+8 bytes - File offset (little-endian)
+8 bytes - Compressed size (little-endian)
+8 bytes - Uncompressed size? (little-endian)
+
+ +

File examples:

+ +

initprescenecommon.txt

+ +

Header (10 bytes compressed, 2 bytes uncompressed, unknown field= 1033E64E):

+ +
A373h: 16 00 00 00 69 6E 69 74 70 72 65 73 63 65 6E 65  ....initprescene 
+A383h: 63 6F 6D 6D 6F 6E 2E 74 78 74 10 33 E6 4E 00 00  common.txt.3.N.. 
+A393h: 00 00 F3 45 41 01 00 00 00 00 0A 00 00 00 00 00  ...EA........... 
+A3A3h: 00 00 02 00 00 00 00 00 00 00                    ..........
+
+ +

Data:

+ +
141:45F3h: 1A F3 84 8A 6F 6F 6A 49 62 77                    ....oojIbw
+
+ +

teleporter1_enter.txt

+ +

Header (10 bytes compressed, 2 bytes uncompressed, unknown field= 1933E64E):

+ +
A490h: 15 00 00 00 74 65 6C 65 70 6F 72 74 65 72 31 5F  ....teleporter1_ 
+A4A0h: 65 6E 74 65 72 2E 74 78 74 19 33 E6 4E 00 00 00  enter.txt.3.N... 
+A4B0h: 00 58 52 41 01 00 00 00 00 0A 00 00 00 00 00 00  .XRA............ 
+A4C0h: 00 02 00 00 00 00 00 00 00                       .........
+
+ +

Data:

+ +
141:5258h: 1A F3 84 8A 6F 6F 6A 49 62 77                    ....oojIbw
+
+ +

grate_enter.txt

+ +

Header (19 bytes compressed, 11 bytes uncompressed, unknown field= 1033E64E):

+ +
A1A8h: 0F 00 00 00 67 72 61 74 65 5F 65 6E 74 65 72 2E  ....grate_enter. 
+A1B8h: 74 78 74 10 33 E6 4E 00 00 00 00 8E 33 41 01 00  txt.3.N.....3A.. 
+A1C8h: 00 00 00 13 00 00 00 00 00 00 00 0B 00 00 00 00  ................ 
+A1D8h: 00 00 00                                         ...
+
+ +

Data:

+ +
141:338Eh: 1A F3 94 40 25 A2 19 40 28 43 2E 8A 88 6D 6A 77  ...@%..@(C...mjw 
+141:339Eh: 10 6C FA                                         .l.
+
+ +

Theese three files have compressed size bigger than uncompressed. I think this happens because theese are text files. +For example balltextures_entrance.nma file has 338 bytes compressed and 3263 bytes uncompressed.

+ +

Note that initprescenecommon.txt and teleporter1_enter.txt have same data, but differ ""unknown field"".

+ +

Does anyone have some ideas?

+",26971,,,,,1/4/2019 18:43,Detect compression algorithm in .NPK archive,,0,2,,,,CC BY-SA 4.0 +20284,1,20291,,1/4/2019 20:01,,3,178,"

I am doing this reverse engenering challenge. I executed theses commands to analyse the main function :

+ +
radare2.exe ch15.exe
+aaa
+s main
+pdf
+
+ +

This is the output of the pdf command :

+ +
[0x004017b8]> pdf
+/ (fcn) main 80
+|   main (int argc, char **argv, char **envp);
+|           ; arg signed int arg_8h @ ebp+0x8
+|           ; arg char **s @ ebp+0xc
+|           ; var size_t local_4h @ esp+0x4
+|           ; CALL XREF from section..text (+0x3f4)
+|           0x004017b8      55             push ebp
+|           0x004017b9      89e5           mov ebp, esp
+|           0x004017bb      83e4f0         and esp, 0xfffffff0
+|           0x004017be      83ec10         sub esp, 0x10
+|           0x004017c1      e87a0d0000     call fcn.00402540
+|           0x004017c6      837d0801       cmp dword [arg_8h], 1       ; [0x8:4]=-1 ; 1
+|       ,=< 0x004017ca      7e28           jle 0x4017f4
+|       |   0x004017cc      8b450c         mov eax, dword [s]          ; [0xc:4]=-1 ; 12
+|       |   0x004017cf      83c004         add eax, 4
+|       |   0x004017d2      8b00           mov eax, dword [eax]
+|       |   0x004017d4      890424         mov dword [esp], eax        ; const char *s
+|       |   0x004017d7      e894100000     call sub.msvcrt.dll_strlen_870 ; size_t strlen(const char *s)
+|       |   0x004017dc      89c2           mov edx, eax
+|       |   0x004017de      8b450c         mov eax, dword [s]          ; [0xc:4]=-1 ; 12
+|       |   0x004017e1      83c004         add eax, 4
+|       |   0x004017e4      8b00           mov eax, dword [eax]
+|       |   0x004017e6      89542404       mov dword [local_4h], edx
+|       |   0x004017ea      890424         mov dword [esp], eax
+|       |   0x004017ed      e834ffffff     call sub.Gratz_man_:_726    ; sub.Usage:__s_pass_700+0x26
+|      ,==< 0x004017f2      eb0d           jmp 0x401801
+|      ||   ; CODE XREF from main (0x4017ca)
+|      |`-> 0x004017f4      8b450c         mov eax, dword [s]          ; [0xc:4]=-1 ; 12
+|      |    0x004017f7      8b00           mov eax, dword [eax]
+|      |    0x004017f9      890424         mov dword [esp], eax
+|      |    0x004017fc      e8fffeffff     call sub.Usage:__s_pass_700
+|      |    ; CODE XREF from main (0x4017f2)
+|      `--> 0x00401801      b800000000     mov eax, 0
+|           0x00401806      c9             leave
+\           0x00401807      c3             ret
+[0x004017b8]>
+
+ +

I can see that a function is called named sub.Usage:__s_pass_700, probably the password. I go to this function with this command :

+ +
s sub.Usage:__s_pass_700
+pdf
+
+ +

The output is :

+ +
[0x00401700]> pdf
+/ (fcn) sub.Usage:__s_pass_700 184
+|   sub.Usage:__s_pass_700 (int arg_8h, unsigned int arg_ch);
+|           ; var int local_ch @ ebp-0xc
+|           ; arg int arg_8h @ ebp+0x8
+|           ; arg unsigned int arg_ch @ ebp+0xc
+|           ; var int local_4h @ esp+0x4
+|           ; CALL XREF from main (0x4017fc)
+|           0x00401700      55             push ebp
+|           0x00401701      89e5           mov ebp, esp
+|           0x00401703      83ec18         sub esp, 0x18
+|           0x00401706      b844404000     mov eax, str.Usage:__s_pass ; 0x404044 ; ""Usage: %s pass""
+|           0x0040170b      8b5508         mov edx, dword [arg_8h]     ; [0x8:4]=-1 ; 8
+|           0x0040170e      89542404       mov dword [local_4h], edx
+|           0x00401712      890424         mov dword [esp], eax        ; const char *format
+|           0x00401715      e896110000     call sub.msvcrt.dll_printf_8b0 ; int printf(const char *format)
+|           0x0040171a      c70424000000.  mov dword [esp], 0
+|           0x00401721      e87a110000     call sub.msvcrt.dll_exit_8a0
+|           ;-- sub.Gratz_man_:_726:
+|           ; CALL XREF from main (0x4017ed)
+|           0x00401726      55             push ebp
+|           0x00401727      89e5           mov ebp, esp
+|           0x00401729      83ec28         sub esp, 0x28               ; '('
+|           0x0040172c      c745f4000000.  mov dword [local_ch], 0
+|           0x00401733      837d0c07       cmp dword [arg_ch], 7       ; [0xc:4]=-1 ; 7
+|       ,=< 0x00401737      7571           jne 0x4017aa
+|       |   0x00401739      8b4508         mov eax, dword [arg_8h]     ; [0x8:4]=-1 ; 8
+|       |   0x0040173c      0fb600         movzx eax, byte [eax]
+|       |   0x0040173f      3c53           cmp al, 0x53                ; 'S' ; 83
+|      ,==< 0x00401741      7567           jne 0x4017aa
+|      ||   0x00401743      8b4508         mov eax, dword [arg_8h]     ; [0x8:4]=-1 ; 8
+|      ||   0x00401746      83c001         add eax, 1
+|      ||   0x00401749      0fb600         movzx eax, byte [eax]
+|      ||   0x0040174c      3c50           cmp al, 0x50                ; 'P' ; 80
+|     ,===< 0x0040174e      755a           jne 0x4017aa
+|     |||   0x00401750      8b4508         mov eax, dword [arg_8h]     ; [0x8:4]=-1 ; 8
+|     |||   0x00401753      83c002         add eax, 2
+|     |||   0x00401756      0fb600         movzx eax, byte [eax]
+|     |||   0x00401759      3c61           cmp al, 0x61                ; 'a' ; 97
+|    ,====< 0x0040175b      754d           jne 0x4017aa
+|    ||||   0x0040175d      8b4508         mov eax, dword [arg_8h]     ; [0x8:4]=-1 ; 8
+|    ||||   0x00401760      83c003         add eax, 3
+|    ||||   0x00401763      0fb600         movzx eax, byte [eax]
+|    ||||   0x00401766      3c43           cmp al, 0x43                ; 'C' ; 67
+|   ,=====< 0x00401768      7540           jne 0x4017aa
+|   |||||   0x0040176a      8b4508         mov eax, dword [arg_8h]     ; [0x8:4]=-1 ; 8
+|   |||||   0x0040176d      83c004         add eax, 4
+|   |||||   0x00401770      0fb600         movzx eax, byte [eax]
+|   |||||   0x00401773      3c49           cmp al, 0x49                ; 'I' ; 73
+|  ,======< 0x00401775      7533           jne 0x4017aa
+|  ||||||   0x00401777      8b4508         mov eax, dword [arg_8h]     ; [0x8:4]=-1 ; 8
+|  ||||||   0x0040177a      83c005         add eax, 5
+|  ||||||   0x0040177d      0fb600         movzx eax, byte [eax]
+|  ||||||   0x00401780      3c6f           cmp al, 0x6f                ; 'o' ; 111
+| ,=======< 0x00401782      7526           jne 0x4017aa
+| |||||||   0x00401784      8b4508         mov eax, dword [arg_8h]     ; [0x8:4]=-1 ; 8
+| |||||||   0x00401787      83c006         add eax, 6
+| |||||||   0x0040178a      0fb600         movzx eax, byte [eax]
+| |||||||   0x0040178d      3c53           cmp al, 0x53                ; 'S' ; 83
+| ========< 0x0040178f      7519           jne 0x4017aa
+| |||||||   0x00401791      b853404000     mov eax, str.Gratz_man_:    ; 0x404053 ; ""Gratz man :)""
+| |||||||   0x00401796      890424         mov dword [esp], eax        ; const char *format
+| |||||||   0x00401799      e812110000     call sub.msvcrt.dll_printf_8b0 ; int printf(const char *format)
+| |||||||   0x0040179e      c70424000000.  mov dword [esp], 0
+| |||||||   0x004017a5      e8f6100000     call sub.msvcrt.dll_exit_8a0
+| |||||||   ; XREFS: CODE 0x00401737  CODE 0x00401741  CODE 0x0040174e  CODE 0x0040175b  CODE 0x00401768
+| |||||||   ; XREFS: CODE 0x00401775  CODE 0x00401782  CODE 0x0040178f
+| ```````-> 0x004017aa      c70424604040.  mov dword [esp], str.Wrong_password ; [0x404060:4]=0x6e6f7257 ; ""Wrong password"" ; const char *s
+|           0x004017b1      e802110000     call sub.msvcrt.dll_puts_8b8 ; int puts(const char *s)
+|           0x004017b6      c9             leave
+\           0x004017b7      c3             ret
+[0x00401700]>
+
+ +

Now I can see that the instruction | ========< 0x0040178f 7519 jne 0x4017aa compare the password with the parameter passed as argument. +I would like now put a breakpoint on the jne instruction but I can't because the memory is unmapped. I execute the command to execute the program :

+ +
ood ABadPassword
+db 0x0040178f
+dc
+
+ +

The result is :

+ +
[0x771ece30]> dc
+(5448) loading library at 77180000 (C:\Windows\SysWOW64\ntdll.dll) ntdll.dll
+(5448) unloading library at 000C0000 (not cached) not cached
+(5448) unloading library at 75580000 (not cached) not cached
+(5448) unloading library at 00610000 (not cached) not cached
+(5448) loading library at 75580000 (C:\Windows\SysWOW64\kernel32.dll) kernel32.dll
+(5448) loading library at 73A60000 (C:\Windows\SysWOW64\KernelBase.dll) KernelBase.dll
+(5448) loading library at 74060000 (C:\Windows\SysWOW64\msvcrt.dll) msvcrt.dll
+
+ +

I don't understand why I don't hit the break point. Also, I am obligated to execute twice the dc command to see : wrong password. +My goal is to change the rip next addess.

+",26974,,,,,1/5/2019 21:18,Debug point not hit with radare2,,1,0,,,,CC BY-SA 4.0 +20285,1,,,1/4/2019 22:31,,1,5677,"

Looking to find the meaning of this statement. From what I understand its comparing 0 with value of EBP register - 9, but I don't understand what the byte ptr does.

+",26975,,245,,1/6/2019 20:36,1/6/2019 20:38,"Meaning of cmp byte ptr [EBP-9], 0",,1,2,,,,CC BY-SA 4.0 +20286,2,,20272,1/5/2019 0:15,,1,,"

After searching for the constant 'XLNX', it turns out this firmware file format is defined here. You're lucky because the encryption field is set to 0x0 (None).

+ +

Now the question is, what do you really want to do with this image? You only want to extract image files?

+",26176,,,,,1/5/2019 0:15,,,,0,,,,CC BY-SA 4.0 +20287,2,,20285,1/5/2019 4:46,,11,,"

Let's break this down.

+ +

First, we have the mnemonic: cmp

+ +

As you state, it performs a compare, though in truth it performs a subtraction (first operand minus the second) without storing the result, but still setting flags.

+ +

Next, we have the first operand: byte ptr [EBP-9]

+ +

This itself needs to be broken down. EBP-9 is simple math, take the value of the EBP register and subtract nine from it. The square brackets mean to then take that result and treat it like an address to a location in memory. The byte ptr tells you how large of a value to grab from that memory location, in this case a single byte. If it were a word ptr, then you would dereference two bytes (in little-endian byte-order, since this is Intel architecture I think).

+ +

And the second operand is a straightforward immediate value: 0

+ +

So, all together, that instruction is saying to compare zero with the single byte at address pointed to by EBP-9.

+ +

If your next question is ""why"", then you'll need to look at the other instructions before and maybe after that for context of where EBP is getting its value from (often, though not always, as a base pointer for the current function's stack frame). Sometimes you can tell from just looking at the the disassembly, sometimes it's easier to run it in a debugger and set a breakpoint on or before the instructions you want to inspect.

+",26921,,245,,1/6/2019 20:38,1/6/2019 20:38,,,,0,,,,CC BY-SA 4.0 +20288,2,,20258,1/5/2019 8:03,,2,,"

It is probably due to the fact that you are trying to use r2 - a native disassembler/debugger to a .NET assembly which written in managed language and executed under CLR - Common Language Runtime. This line from your output gives that away

+ +
+

.NET Version: v4.0.30319

+
+ +

How .NET works is, that before execution, there should be no user provided native code (there are some exceptions that one can force compilation to a native platform) and only an entry point is visible - which you see without debugging. After running the file - it starts from the entry point and by using a JIT (Just-in-time compiler) compiling the IL to native code on the platform you are running on. This might be the reason you see all those methods when you list them while debugging.

+ +

I suggest you use a decompiler/debugger suited for .NET assemblies such as dnSpy.

+",18014,,18014,,1/6/2019 20:08,1/6/2019 20:08,,,,2,,,,CC BY-SA 4.0 +20289,1,20292,,1/5/2019 8:07,,0,814,"

I am modifying PIN's proccount sample to get the memory access information per function

+ +
 VOID Routine(RTN rtn, VOID *v)
+{
+
+    // Allocate a counter for this routine
+    RTN_COUNT * rc = new RTN_COUNT;
+    rc->_name = RTN_Name(rtn);
+    rc->_image = StripPath(IMG_Name(SEC_Img(RTN_Sec(rtn))).c_str());
+    rc->_address = RTN_Address(rtn);
+
+    rc->_next = RtnList;
+    RtnList = rc;
+
+    RTN_Open(rtn);
+fprintf(trace,""%s\n"",rc->_name.c_str());( writing functio name )
+     RTN_InsertCall(rtn, IPOINT_BEFORE, (AFUNPTR)docount, IARG_PTR, &(rc->_rtnCount), IARG_END);
+       // RTN_InsertCall(rtn, IPOINT_BEFORE, (AFUNPTR)RecordMemRead1, &(rc->_name),rc->_address, IARG_END);(this gave an error)
+        // For each instruction of the routine
+        for (INS ins = RTN_InsHead(rtn); INS_Valid(ins); ins = INS_Next(ins))
+        {
+
+        UINT32 memOperands = INS_MemoryOperandCount(ins);
+    // Iterate over each memory operand of the instruction.
+         for (UINT32 memOp = 0; memOp < memOperands; memOp++)
+    {
+        if (INS_MemoryOperandIsRead(ins, memOp))
+        {
+            INS_InsertPredicatedCall(
+                ins, IPOINT_BEFORE, (AFUNPTR)RecordMemRead,
+                IARG_INST_PTR,
+                IARG_MEMORYOP_EA,memOp,IARG_END); (file trace is modified here)
+
+        }
+    }
+    }
+
+    RTN_Close(rtn);
+}
+
+ +

I am getting output like:

+ +
dl_find_dso_for_object
+__get_cpu_features
+__libc_memalign
+malloc
+calloc
+free
+realloc
+0   0x7fcecff419dd  :R  0x7fced0165e70
+0   0x7fcecff419e7  :R  0x7fced0166000
+0   0x7fcecff41a57  :R  0x7fced0165e80
+0   0x7fcecff41a57  :R  0x7fced0165e90
+0   0x7fcecff41a57  :R  0x7fced0165ea0
+0   0x7fcecff41a57  :R  0x7fced0165eb0
+0   0x7fcecff41a57  :R  0x7fced0165ec0
+
+ +

I need per-function memory list like:

+ +
dl_find_dso_for_object
+0   0x7fcecff419dd  :R  0x7fced0165e70
+    0   0x7fcecff419e7  :R  0x7fced0166000
+    0   0x7fcecff41a57  :R  0x7fced0165e80
+    0   0x7fcecff41a57  :R  0x7fced0165e90
+;;;
+malloc
+0x7fcecff41a57  :R  0x7fced0165ea0
+    0   0x7fcecff41a57  :R  0x7fced0165eb0
+    0   0x7fcecff41a57  :R  0x7fced0165ec0
+
+ +

How can I achieve it?

+",26981,,60,,1/5/2019 16:39,1/7/2019 6:38,how to get per-function memory accesses using PIN tool,,1,0,,,,CC BY-SA 4.0 +20290,2,,20076,1/5/2019 17:58,,2,,"

This may either be packed multiple times or contain additional obfuscations or anti-analysis. Use the ""PUSHAD, breakpoint on ESP, run"" method to find the tail transition, as you have. Then set a breakpoint on the tail transition (in your case, JMP 0002A99E) and run to that. The single-step to take the jmp and you'll be at the OEP, or the next stage of packing.

+ +

One way to figure out if you have it unpacked is to dump at this point (using OllyDumpEx, for example) and load it in your typical tools (IDA, exeinfo, PEiD, etc) to see what it looks like.

+ +

When I do this with your binary, I'm seeing what looks like some typical setup code, but then after the call to initterm, at 0040A7F2 there is a call using a memory address that contains zeros (hover over the dword_xxxx value to see). If you look back just a little bit, you'll see a call to a sub_xxxx that takes as an argument that dword_xxxx address. Diving into that function and the functions it calls, it looks like there is some parsing of the PE header (see cmp's with immediate values 5A4Dh and 4550h). In malware, this is typically done to find where kernel32 or other modules are in memory.

+ +

In addition to that, look at the Imports and you can see that there are references to LoadLibrary and GetProcAddress. If you look for those cross-references (aka xrefs), then you'll find functions that look like they have encoded values (a bunch of xor instructions in a row with immediates), so possibly dynamically rebuilding the IAT.

+ +

That's more info than you need to get past the UPX unpacking stage, but this malware has more anti-analysis techniques than just UPX packing, so you might have additional questions. The Practical Malware Analysis book has a good description of what you'll want to do next, and is generally a good reference, but feel free to start more questions on stackexchange if you want more help!

+",26921,,,,,1/5/2019 17:58,,,,0,,,,CC BY-SA 4.0 +20291,2,,20284,1/5/2019 21:18,,3,,"

Your breakpoint doesn't work as it is put in the part of the code that is not executed with the pass your provided. I'll try not to give too much hint so that you can still solve it by yourself.

+ +

You wrote

+ +
+

Now I can see that the instruction | ========< 0x0040178f 7519 jne 0x4017aa compare the password with the parameter passed as argument.

+
+ +

This is wrong. It doesn't not compare 'the password', it compare one of the character of the password. If you check the code there are some other instructions that are being executed and already validated your password as wrong so the line at 0x40178f is not even reached with 'ABadPassword' passed as an argument.

+ +

You need to analyse code more carefully and see where earlier in the code the breakpoint should be put.

+ +

As for your second problem

+ +
+

Also, I am obligated to execute twice the dc command to see : wrong password.

+
+ +

There might be some debug event that radare2 responds to with the break of your code execution, thus require you to decide what to do. If it's not exceptional then dc should get execution further.

+",18014,,,,,1/5/2019 21:18,,,,0,,,,CC BY-SA 4.0 +20292,2,,20289,1/6/2019 7:29,,0,,"

You can pass an additional argument to INS_InsertPredicatedCall with the string name and construct a map with function names with (instruction, addr). Parse that map in PIN_AddFiniFunction added callback. Here's a simple example. Implement your mapping in RecordMemRead

+ +
map<string, vector<pair<UINT64, UINT64>>> RtnToRead;
+
+VOID RecordMemRead(ADDRINT address, UINT64 memOp, string rname) {
+    RtnToRead[rname].pb(mp(address, memOp));
+}
+
+VOID Routine(RTN rtn, VOID *v) {
+
+    RTN_Open(rtn);
+
+    string name = RTN_Name(rtn);
+
+    for (INS ins = RTN_InsHead(rtn); INS_Valid(ins); ins = INS_Next(ins)) {
+
+        UINT32 memOperands = INS_MemoryOperandCount(ins);
+        for (UINT32 memOp = 0; memOp < memOperands; memOp++) {
+            if (INS_MemoryOperandIsRead(ins, memOp)) {
+                INS_InsertPredicatedCall(ins, IPOINT_BEFORE,
+                                         (AFUNPTR)RecordMemRead, IARG_INST_PTR,
+                                         IARG_MEMORYOP_EA, memOp, IARG_PTR,
+                                         new string(name), IARG_END);
+            }
+        }
+    }
+
+    RTN_Close(rtn);
+}
+
+VOID Fini(INT32 code, VOID *v) {
+    for (auto &rtn : RtnToRead) {
+        cout << rtn.fs << "" :"" << endl;
+        for (auto &e : rtn.second) {
+            cout << ""\t"" << hex << e.fs << "" : "" << e.sc << endl;
+        }
+    }
+}
+
+ +

I have added a simple example here

+ +

EDIT : I have copied code from the gist which fits your case perfectly.

+",14622,,14622,,1/7/2019 6:38,1/7/2019 6:38,,,,5,,,,CC BY-SA 4.0 +20293,1,,,1/6/2019 14:17,,2,304,"

I recently got a UE Megaboom Bluetooth speaker. Apart from various audio profiles, I noticed the speaker also exposes a Serial Port BT profile. I suspect this is the channel the app uses to control the speaker’s advanced features.

+ +

I have tried to connect to the port using a terminal app, using various baud rates and sending it ?<CR><LF> and AT?<CR><LF>, respectively—to no avail. The speaker will not return a single bit of data.

+ +

A web search on the most common terms did not return any useful information on the protocol used.

+ +

Is there any information out there on the protocol used by the Megaboom? Or does anyone know of any attempts at decoding it?

+ +
+ +

I now have some captured traffic from the official app. BTW, if another device is holding the serial port connection, the app will not recognize the speaker, corroborating my suspicion that SPP is the control channel.

+ +

In two captures I see that initially the app sends 02 00 06 (hex) over the SPP connection, to which the speaker responds with <CR><NUL><BEL>MEGABOOM (three control characters followed by the product name as a string).

+ +

When I connect to the speaker’s SPP and send these three characters (using moserial, sending input as hex), the speaker does not respond at all. Any ideas?

+",26989,,26989,,1/11/2019 0:24,1/11/2019 0:24,UE Megaboom serial protocol,,1,3,,,,CC BY-SA 4.0 +20295,1,,,1/7/2019 0:57,,4,1386,"

I have a VW Radio which has the possibility to upgrade software via USB. Unfortunately I am not able to find any updates, nor any information regarding the current Software version on the whole internet. So I decided to try to dump the files directly from the unit. My question is how can I perform the dump without physically removing the EEPROM from the board. Is there any possibility to access something through the USB port?

+ +

Its market name is RCD 320 on european Market and RCN 210 on Asian market. I do not know what is inside of the unit - as far as I have seen searching the internet, some VW units are using ARM processors and Linux 3.0.5, but this is everything I know so far, as there is no information about these units (neither regarding the SW, nor the HW).

+ +

Any guidance would be appreciated as I am a new in this domain, but I have some electronic skills and also programming skills.

+",26993,,245,,1/9/2019 11:14,6/2/2020 15:03,How to dump firmware from car head-unit (VW Radio),,1,3,,,,CC BY-SA 4.0 +20296,1,,,1/7/2019 14:46,,0,459,"

I am a developer but I do not have much experience with IDA/reverse-engineering. Now I have to analyse a compiled program. +Currently I try to debug a simple wininet.dll:wininet_InternetReadFile-function and I wonder: where can I see the concrete arguments for this function while debugging?

+ +

Currently I am at this point:

+ +

+ +

I am pretty sure you can (almost) see the arguments (or at least its address) in this screenshot. But I am a beginner in reverse engineering. I don't get it/don't see it.

+ +

What is the easiest/best way to get the URL that should be downloaded in this case?

+",26779,,,user12114,1/19/2019 8:54,10/16/2019 11:01,Show arguments while debugging,,1,0,,,,CC BY-SA 4.0 +20297,1,,,1/7/2019 15:48,,0,472,"

When a program is executed, some processes may be created by the parent process. Especially, if a program is malware, created (or forked or even injected) sub-processes will be named as a systemic process such as svchost.exe. +Is there any way to capture the PID of sub-processes in windows?

+",21812,,,,,3/13/2019 10:01,capturing the sub processes's PID of a process,,2,0,,,,CC BY-SA 4.0 +20299,1,20304,,1/7/2019 17:07,,0,2156,"

How to identify in assembly base 64 encode/decode with Ida. Is there any magic constant that I can search? Or maybe a plugin that find that?

+ +

FindCrypt2 Ida plugin not find that

+",23993,,,,,1/10/2019 0:33,How to identify base64 encode/decode in assembly,,2,0,,,,CC BY-SA 4.0 +20300,2,,20299,1/7/2019 17:22,,3,,"

The common base64 key contains ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/. However, remember that IDA Pro will convert ASCII text for you, so you should have no reason to go looking through the raw bytes of the file in hex. In fact, even a hex editor such as HxD or 010 Editor will convert the string data from hex bytes to chars and display them on the right side of the screen. See below an example in 010 Editor of such key:

+ +

+ +

And in IDA Pro IDA View window looking at segments:

+ +

+ +

IDA Pro Strings window (can use Ctrl+F here): +

+ +

Nevertheless, if you need to go looking for a constant, use the ASCII table and convert the above string into bytes manually. E.G. 'A' is 41h, 'B' is 42h, so if we were looking for AB, we'd be looking for 41 42. Don't forget to take into account the endianness of the target architecture of the software system you are working with; if the bytes are stored on disk in little endian for the file format, than the base64 key's bytes will be encoded backwards and you will need to search for it as such.

+ +

One caveat here is that the aforementioned Base64 key is the standard Base64 key. You may need to search for modified Base64 keys, meaning that instead of ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ we have +something like FGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/ABCDE. You can see that with this modified Base64 key, we've simply rotated the key to the left 5 times so that if a decoding algorithm were to attempt to decode this as standard Base64, it would not work.

+",18507,,18507,,1/7/2019 17:45,1/7/2019 17:45,,,,1,,,,CC BY-SA 4.0 +20301,1,,,1/7/2019 21:04,,-2,1563,"

Why using memcpy can cause to stack overFlow?

+ +

memcpy get the number of bytes to copy, so what is the problem , and how memcpy_s fix it?

+",23993,,,,,1/8/2019 0:08,Why dont use memcpy?,,1,0,,1/8/2019 2:05,,CC BY-SA 4.0 +20302,2,,20301,1/8/2019 0:08,,1,,"

A buffer overflow happens when a program tries to write too much data into a buffer, or other data structure. The extra data ""overflows"" the buffer writes over the data structure immediately following the buffer in memory. memcpy allows you to specify the number of bytes to copy, but if that value varies, such as when it is dependent on user input, then your destination buffer might not be big enough. + The wikipedia page has a good example.

+ +

memcpy_s has an additional parameter, where you can specify the destination buffer size. This allows memcpy_s to perform additional checks on the input, and error if the number of bytes to copy is greater than the destination buffer size.

+ +

For a good introduction to exploit analysis, see this course material and videos. Full disclosure: I am a contributor to that website, though not to that particular class material.

+",26921,,,,,1/8/2019 0:08,,,,0,,,,CC BY-SA 4.0 +20303,2,,20297,1/8/2019 0:24,,0,,"

As mentioned by anion, you can use several graphical applications to see this information. One such application built-in to Windows is the Task Manager. Right-click on the task bar and you will see it in that menu.

+ +

If you prefer command-line, you can use tasklist (again, built-in to Windows).

+ +

If you are trying to perform malware analysis, and you are looking for an automated solution, then I suggest using a sandbox. A popular free and opensource one is Cuckoo Sandbox.

+ +

If you are analyzing the malware by hand, then you will have to look for the different ways that you mention.

+ +

CreateProcess takes a pointer to a PROCESS_INFORMATION structure as its tenth argument. After CreateProcess returns, you can look at this structure to find the PID of the child. A simpler way would be to breakpoint on CreateProcess, modify the dwCreationFlags to include SUSPENDED, step-over the CreateProcess call, then run either Task Manager or tasklist to see the child process's PID.

+ +

OpenProcess is easier. It takes the PID as the third argument. So when you see a call to OpenProcess, just look at the arguments to find the PID.

+ +

Depending on which tools you are using, you may be able to script this, such as with IDA Python, OllyScript, or x64dbg's or WinDbg's built-in scripting.

+",26921,,,,,1/8/2019 0:24,,,,2,,,,CC BY-SA 4.0 +20304,2,,20299,1/8/2019 0:37,,1,,"

One of the ways that I have taught (see Day 1 Part 11) to find a base64 alphabet is to look for a sequence of 64 bytes with an Shannon entropy of 6 (on a scale of 1-8). Beware that in addition to Base64 alphabets, that will also find other high-entropy data, such as compressed or encrypted code or strings, as well as encryption constants.

+ +

For your standard Base64 alphabet, using IDA, press alt-B, then enter (including the double-quotes) ""ABCDEFGHIJKLMNOPQRSTUV"" or some other subset of the standard alphabet. I recommend also selecting the ""find all"" option, which makes it easier to see and skip false matches.

+",26921,,26921,,1/10/2019 0:33,1/10/2019 0:33,,,,6,,,,CC BY-SA 4.0 +20306,2,,20296,1/8/2019 7:36,,1,,"

Since eax,ebx etc are used instead of rax,rbx etc in your screen shot
+i assume it is some x86 code and not x64 code

+ +

since there doesnt appear a push {} for arguments prior to the call
+i assume this code is not compiled with msvc

+ +

it appears to use a mov arguments to stack kind which ida doesnt seem to decode
+(ida should usually show the hFile,etc args if it was standard vs compiled exe

+ +

(screenshot shows the disassembly of src code compiled from here using vs2017 15.8.1 x86 32bit

+ +

+ +

the prototype for this function is

+ +
BOOLAPI InternetReadFile(
+  HINTERNET hFile,
+  LPVOID    lpBuffer,
+  DWORD     dwNumberOfBytesToRead,
+  LPDWORD   lpdwNumberOfBytesRead
+);
+
+ +

in your screenshot var 47c,478,474,470 are the arguments to this specific function

+ +

take a look at VIEW ESP window in your screen shot
+cc0xxx is your HINTERNET hFile argument
+var 454 is your LPVOID lpBuffer
+0x3E8 is the DWORD dwNumberOfBytesToRead,
+var_458 is the pointer to recieve the number of bytes read LPDWORD lpdwNumberOfBytesRead

+",3473,,,,,1/8/2019 7:36,,,,0,,,,CC BY-SA 4.0 +20307,1,,,1/8/2019 11:10,,1,668,"

I've an iPhone7 running iOS11.3 (15E216). The ipsw for this build version contains two separate kernelcache files named kernelcache.release.iphone9 and kernelcache.release.iphone10. Neither file is an exact match for the kernel installed at /System/Library/Caches/com.apple.kernelcaches/kernelcache. What process does Apple perform on the ipsw kernelcache to produce the installed kernelcache? How do I identify which kernelcache is the one installed on my phone?

+",4211,,,,,6/7/2019 22:03,How to identify which iOS kernelcache is installed?,,1,1,,,,CC BY-SA 4.0 +20308,2,,20307,1/8/2019 12:42,,1,,"

The /System/Library/Caches/com.apple.kernelcaches/kernelcache and the IPSW's kernelcache.release.iphone9 files have the same payload content but the former uses the IMG4 file format (containing a wrapper + payload) whereas the latter uses the IM4P file format (containing just the payload).

+",4211,,4211,,1/8/2019 21:25,1/8/2019 21:25,,,,0,,,,CC BY-SA 4.0 +20309,2,,20105,1/8/2019 13:28,,-1,,"

The API key is maybe just a random hard coded secret. Take a look here: +https://github.com/ikarulus/nextbike-api-reverse-engineering#obtaing-api-key

+",27017,,,,,1/8/2019 13:28,,,,0,,,,CC BY-SA 4.0 +20310,2,,20295,1/8/2019 13:58,,1,,"

It is a bit of a chicken and egg issue here. While it may be possible that there is some custom USB command to dump the firmware, you’re unlikely to discover it by chance without analyzing actually running firmware.

+ +

About the only possibility I can think of is DFU (Device Firmware Update) which is a semi-standard protocol for updating firmware of USB devices. If there is a known process for putting the device into update mode, you can try using dfu-util to see if it can communicate with the device.

+",60,,,,,1/8/2019 13:58,,,,0,,,,CC BY-SA 4.0 +20311,2,,20293,1/8/2019 15:15,,2,,"

If the device doesn’t respond to unsolicited traffic, it probably needs some specific commands to return results. You could try bruteforcing it by sending random data but it’s a chancy business.

+ +

A more likely approach is to sniff the traffic from the official app or at least try to analyze it statically.

+",60,,,,,1/8/2019 15:15,,,,0,,,,CC BY-SA 4.0 +20312,1,20314,,1/8/2019 21:36,,1,190,"

I just finished this challenge. This is the content of main function :

+ +
[0x08048a86]> pdf
+/ (fcn) main 417
+|   main (int argc, char **argv, char **envp);
+|           ; var int local_16h @ ebp-0x16
+|           ; var int local_15h @ ebp-0x15
+|           ; var int local_14h @ ebp-0x14
+|           ; var int local_10h @ ebp-0x10
+|           ; var int local_ch @ ebp-0xc
+|           ; var int local_8h_2 @ ebp-0x8
+|           ; var char *local_4h @ esp+0x4
+|           ; var int local_8h @ esp+0x8
+|           ; DATA XREF from entry0 (0x80488a7)
+|           0x08048a86      8d4c2404       lea ecx, [local_4h]         ; 4
+|           0x08048a8a      83e4f0         and esp, 0xfffffff0
+|           0x08048a8d      ff71fc         push dword [ecx - 4]
+|           0x08048a90      55             push ebp
+|           0x08048a91      89e5           mov ebp, esp
+|           0x08048a93      53             push ebx
+|           0x08048a94      51             push ecx
+|           0x08048a95      83ec20         sub esp, 0x20
+|           0x08048a98      89cb           mov ebx, ecx
+|           0x08048a9a      833b01         cmp dword [ebx], 1
+|       ,=< 0x08048a9d      7f4f           jg 0x8048aee
+|       |   0x08048a9f      8b4304         mov eax, dword [ebx + 4]    ; [0x4:4]=-1 ; 4
+|       |   0x08048aa2      8b18           mov ebx, dword [eax]
+|       |   0x08048aa4      c7442404b18d.  mov dword [local_4h], str.usage_: ; [0x8048db1:4]=0x67617375 ; ""usage : ""
+|       |   0x08048aac      c7042460b004.  mov dword [esp], obj._ZSt4cerr__GLIBCXX_3.4 ; [0x804b060:4]=0
+|       |   0x08048ab3      e838fdffff     call sym.std::basic_ostream_char_std::char_traits_char___std::operator___std::char_traits_char___std::basic_ostream_char_std::char_traits_char____charconst
+|       |   0x08048ab8      895c2404       mov dword [local_4h], ebx
+|       |   0x08048abc      890424         mov dword [esp], eax
+|       |   0x08048abf      e82cfdffff     call sym.std::basic_ostream_char_std::char_traits_char___std::operator___std::char_traits_char___std::basic_ostream_char_std::char_traits_char____charconst
+|       |   0x08048ac4      c7442404ba8d.  mov dword [local_4h], str.password ; [0x8048dba:4]=0x73617020 ; "" password""
+|       |   0x08048acc      890424         mov dword [esp], eax
+|       |   0x08048acf      e81cfdffff     call sym.std::basic_ostream_char_std::char_traits_char___std::operator___std::char_traits_char___std::basic_ostream_char_std::char_traits_char____charconst
+|       |   0x08048ad4      c74424045088.  mov dword [local_4h], sym.std::basic_ostream_char_std::char_traits_char___std::endl_char_std::char_traits_char___std::basic_ostream_char_std::char_traits_char ; [0x8048850:4]=0xb04425ff
+|       |   0x08048adc      890424         mov dword [esp], eax
+|       |   0x08048adf      e85cfdffff     call sym.std::ostream::operator___std::ostream_____std::ostream
+|       |   0x08048ae4      bb05000000     mov ebx, 5
+|      ,==< 0x08048ae9      e92b010000     jmp 0x8048c19
+|      ||   ; CODE XREF from main (0x8048a9d)
+|      |`-> 0x08048aee      8d45eb         lea eax, [local_15h]
+|      |    0x08048af1      890424         mov dword [esp], eax
+|      |    0x08048af4      e867fdffff     call sym.std::allocator_char_::allocator
+|      |    0x08048af9      8d45eb         lea eax, [local_15h]
+|      |    0x08048afc      89442408       mov dword [local_8h], eax
+|      |    0x08048b00      c7442404c48d.  mov dword [local_4h], 0x8048dc4 ; [0x8048dc4:4]=0xca15d618
+|      |    0x08048b08      8d45f4         lea eax, [local_ch]
+|      |    0x08048b0b      890424         mov dword [esp], eax
+|      |    0x08048b0e      e80dfdffff     call sym.std::basic_string_char_std::char_traits_char__std::allocator_char__::basic_string_charconst__std::allocator_char_const
+|      |    0x08048b13      8d45ea         lea eax, [local_16h]
+|      |    0x08048b16      890424         mov dword [esp], eax
+|      |    0x08048b19      e842fdffff     call sym.std::allocator_char_::allocator
+|      |    0x08048b1e      8d45ea         lea eax, [local_16h]
+|      |    0x08048b21      89442408       mov dword [local_8h], eax
+|      |    0x08048b25      c7442404cc8d.  mov dword [local_4h], 0x8048dcc ; [0x8048dcc:4]=0xaf67b350
+|      |    0x08048b2d      8d45f0         lea eax, [local_10h]
+|      |    0x08048b30      890424         mov dword [esp], eax
+|      |    0x08048b33      e8e8fcffff     call sym.std::basic_string_char_std::char_traits_char__std::allocator_char__::basic_string_charconst__std::allocator_char_const
+|      |    0x08048b38      8d45ec         lea eax, [local_14h]
+|      |    0x08048b3b      8d55f4         lea edx, [local_ch]
+|      |    0x08048b3e      89542408       mov dword [local_8h], edx
+|      |    0x08048b42      8d55f0         lea edx, [local_10h]
+|      |    0x08048b45      89542404       mov dword [local_4h], edx
+|      |    0x08048b49      890424         mov dword [esp], eax
+|      |    0x08048b4c      e83cfeffff     call sym.plouf_std::string_std::string
+|      |    0x08048b51      83ec04         sub esp, 4
+|      |    0x08048b54      8d45f0         lea eax, [local_10h]
+|      |    0x08048b57      890424         mov dword [esp], eax
+|      |    0x08048b5a      e8a1fcffff     call sym.std::basic_string_char_std::char_traits_char__std::allocator_char__::_basic_string
+|      |    0x08048b5f      8d45ea         lea eax, [local_16h]
+|      |    0x08048b62      890424         mov dword [esp], eax
+|      |    0x08048b65      e8c6fcffff     call sym.std::allocator_char_::_allocator
+|      |    0x08048b6a      8d45f4         lea eax, [local_ch]
+|      |    0x08048b6d      890424         mov dword [esp], eax
+|      |    0x08048b70      e88bfcffff     call sym.std::basic_string_char_std::char_traits_char__std::allocator_char__::_basic_string
+|      |    0x08048b75      8d45eb         lea eax, [local_15h]
+|      |    0x08048b78      890424         mov dword [esp], eax
+|      |    0x08048b7b      e8b0fcffff     call sym.std::allocator_char_::_allocator
+|      |    0x08048b80      8b4304         mov eax, dword [ebx + 4]    ; [0x4:4]=-1 ; 4
+|      |    0x08048b83      83c004         add eax, 4
+|      |    0x08048b86      8b00           mov eax, dword [eax]
+|      |    0x08048b88      89442404       mov dword [local_4h], eax
+|      |    0x08048b8c      8d45ec         lea eax, [local_14h]
+|      |    0x08048b8f      890424         mov dword [esp], eax
+|      |    0x08048b92      e860010000     call sym.boolstd::operator___char_std::char_traits_char__std::allocator_char___std::basic_string_char_std::char_traits_char__std::allocator_char__const__charconst
+|      |    0x08048b97      84c0           test al, al
+|      |,=< 0x08048b99      744a           je 0x8048be5
+|      ||   0x08048b9b      c7442404fc8d.  mov dword [local_4h], str.Bravo__tu_peux_valider_en_utilisant_ce_mot_de_passe... ; [0x8048dfc:4]=0x76617242 ; ""Bravo, tu peux valider en utilisant ce mot de passe...""
+|      ||   0x08048ba3      c7042400b104.  mov dword [esp], obj._ZSt4cout__GLIBCXX_3.4 ; [0x804b100:4]=0
+|      ||   0x08048baa      e841fcffff     call sym.std::basic_ostream_char_std::char_traits_char___std::operator___std::char_traits_char___std::basic_ostream_char_std::char_traits_char____charconst
+|      ||   0x08048baf      c74424045088.  mov dword [local_4h], sym.std::basic_ostream_char_std::char_traits_char___std::endl_char_std::char_traits_char___std::basic_ostream_char_std::char_traits_char ; [0x8048850:4]=0xb04425ff
+|      ||   0x08048bb7      890424         mov dword [esp], eax
+|      ||   0x08048bba      e881fcffff     call sym.std::ostream::operator___std::ostream_____std::ostream
+|      ||   0x08048bbf      c7442404348e.  mov dword [local_4h], str.Congratz._You_can_validate_with_this_password... ; [0x8048e34:4]=0x676e6f43 ; ""Congratz. You can validate with this password...""
+|      ||   0x08048bc7      c7042400b104.  mov dword [esp], obj._ZSt4cout__GLIBCXX_3.4 ; [0x804b100:4]=0
+|      ||   0x08048bce      e81dfcffff     call sym.std::basic_ostream_char_std::char_traits_char___std::operator___std::char_traits_char___std::basic_ostream_char_std::char_traits_char____charconst
+|      ||   0x08048bd3      c74424045088.  mov dword [local_4h], sym.std::basic_ostream_char_std::char_traits_char___std::endl_char_std::char_traits_char___std::basic_ostream_char_std::char_traits_char ; [0x8048850:4]=0xb04425ff
+|      ||   0x08048bdb      890424         mov dword [esp], eax
+|      ||   0x08048bde      e85dfcffff     call sym.std::ostream::operator___std::ostream_____std::ostream
+|     ,===< 0x08048be3      eb24           jmp 0x8048c09
+|     |||   ; CODE XREF from main (0x8048b99)
+|     ||`-> 0x08048be5      c7442404658e.  mov dword [local_4h], str.Password_incorrect. ; [0x8048e65:4]=0x73736150 ; ""Password incorrect.""
+|     ||    0x08048bed      c7042400b104.  mov dword [esp], obj._ZSt4cout__GLIBCXX_3.4 ; [0x804b100:4]=0
+|     ||    0x08048bf4      e8f7fbffff     call sym.std::basic_ostream_char_std::char_traits_char___std::operator___std::char_traits_char___std::basic_ostream_char_std::char_traits_char____charconst
+|     ||    0x08048bf9      c74424045088.  mov dword [local_4h], sym.std::basic_ostream_char_std::char_traits_char___std::endl_char_std::char_traits_char___std::basic_ostream_char_std::char_traits_char ; [0x8048850:4]=0xb04425ff
+|     ||    0x08048c01      890424         mov dword [esp], eax
+|     ||    0x08048c04      e837fcffff     call sym.std::ostream::operator___std::ostream_____std::ostream
+|     ||    ; CODE XREF from main (0x8048be3)
+|     `---> 0x08048c09      bb00000000     mov ebx, 0
+|      |    0x08048c0e      8d45ec         lea eax, [local_14h]
+|      |    0x08048c11      890424         mov dword [esp], eax
+|      |    0x08048c14      e8e7fbffff     call sym.std::basic_string_char_std::char_traits_char__std::allocator_char__::_basic_string
+|      |    ; CODE XREF from main (0x8048ae9)
+|      `--> 0x08048c19      89d8           mov eax, ebx
+|       ,=< 0x08048c1b      eb75           jmp 0x8048c92
+..
+|       |   ; CODE XREF from main (0x8048c1b)
+|       `-> 0x08048c92      8d65f8         lea esp, [local_8h_2]
+|           0x08048c95      59             pop ecx
+|           0x08048c96      5b             pop ebx
+|           0x08048c97      5d             pop ebp
+|           0x08048c98      8d61fc         lea esp, [ecx - 4]
+\           0x08048c9b      c3             ret
+
+ +

I solved it by placing a breakpoint to 0x08048b99 adress and printing the stack when I hit it using the command pxr @ esp +The result was :

+ +

0xffe4a170 0xffe4a184 .... @esp stack R W 0x9f61c8c --> (Here_you_have_to_understand_a_little_C++_stuffs) +0xffe4a174 0xffe4b367 g... edx stack R W 0x43007373 (ss) --> ascii

+ +

So now, I would like to solve this challenge again in a different way. I have two questions.

+ +

First question : At first, before solve it by this way, I tried to put breakpoint on each comparaison function and my idea was to change the rip adress like in this video. +The problem in my case is when I enter the command dr, I don't have the rip adress. This is the output I have :

+ +
hit breakpoint at: 8048b99
+[0x08048b99]> dr
+eax = 0xffffff00
+ebx = 0xffceafa0
+ecx = 0x00000004
+edx = 0xffceb365
+esi = 0xf7d54000
+edi = 0xf7d54000
+esp = 0xffceaf60
+ebp = 0xffceaf88
+eip = 0x08048b99
+eflags = 0x00000246
+oeax = 0xffffffff
+
+ +

Why I don't have the rip value ? Can you explain me how can I do that if is it possible ?

+ +

Second question : Is there a command in radare2 which I don't know and which allows me to print directly the value of obj._ZSt4cout__GLIBCXX_3.4

+",26974,,,,,1/9/2019 21:24,rip adress not visible with dr command,,1,1,,,,CC BY-SA 4.0 +20313,1,20318,,1/9/2019 5:05,,0,129,"

Introduction

+ +

So I have a peer to peer app that allows customers to request jobs at their own price and have the job fulfilled by a freelancer in the community. The common jobs requested as of recent are home improvement gigs and lawn care things. We plan on releasing a new feature that allows customers to request groceries through the app to be delivered to them as well.

+ +

Summary of The Problem

+ +

The grocery company we are using has open source documentation for parts of their api, however some of the documentation is missing components we need to successfully integrate the feature into our app. So for the missing components I have reverse engineered some components of the software that aren't included within the public documentation and plan on integrating it into our app. I haven't fully finished the reverse engineering, as I am a quarter of the way done but:

+ +
    +
  • What legal implications does this hold?
  • +
  • If it is unlawful, what is the severity of the repercussions?
  • +
  • How long can I utilize this reverse engineering software before being +caught?
  • +
  • Will I the implementer of the software be held accountable, or would +the company be accountable on my behalf?
  • +
+ +

Thanks in advance.

+",27025,,245,,1/9/2019 10:40,1/9/2019 14:15,Reverse Engineering Grocery Software API,,1,2,,,,CC BY-SA 4.0 +20314,2,,20312,1/9/2019 6:26,,3,,"

rip = x64 +eip = x86 +dr shows eip in your case

+ +

it is probably some demangled name (not sure why radare2 inserts the GLIBC part )

+ +

but if you strip the GLIBC part you can use iD Command to demangle it to std::cout

+ +
[0x01012d6c]> iD cxx _ZSt4cout__GLIBCXX_3.4
+[0x01012d6c]> iD cxx _ZSt4cout__GLIBCXX_
+[0x01012d6c]> iD cxx _ZSt4cout__GLIBCXX
+[0x01012d6c]> iD cxx _ZSt4cout__GLIBC
+[0x01012d6c]> iD cxx _ZSt4cout__GL
+[0x01012d6c]> iD cxx _ZSt4cout__
+[0x01012d6c]> iD cxx _ZSt4cout_
+[0x01012d6c]> iD cxx _ZSt4cout
+std::cout
+[0x01012d6c]> iD cxx _ZSt4cou
+[0x01012d6c]>
+
+ +

btw i don't know why you get all that unintelligible thingies

+ +

did you analyse the executable prior to loading or after loading it ?

+ +

radare2 does a better job than what you posted as a result of pdf

+ +

just so i wasn't deceived by some long forgotten memory i ran through hoops to fetch the 4th challenge :( and loaded it in radare2 and i am sure it really does a better job than you posted in case after analysis you don't get intelligible output check

+ +

e asm.demangle and set it to true reanlyze and do pdf

+ +

here is a screenshot the first _Z blah blah in your screen shot is std::cerr auto demangled by radare2

+ +

+ +

my radare2 version atm is 2.8.xxx i see latest is 3.2.xxx if the latest version differs in output try contacting the radare2 team +maybe someone from the team or a more avid user like megabeets might chime here too

+",3473,,3473,,1/9/2019 21:24,1/9/2019 21:24,,,,0,,,,CC BY-SA 4.0 +20315,1,20327,,1/9/2019 7:11,,1,439,"

I have come across the following jump table with a large amount of cases (160+). There seems to be cases missing from IDAs analysis though. For example it skips from cases 22 -> 38 -> 91, and I can see about 10 cases total.

+ +

+ +
    +
  1. Can I expect all switch cases to take up sequential memory? Is it possible the cases aren't missing, just located elsewhere in memory?
  2. +
  3. If they are normally sequential, is IDA just misinterpreting the cases?
  4. +
  5. Can anyone please explain why there are a large amount of cases belonging to this jumptable but I only see a select few?
  6. +
+ +

Instructions around 0052B970, it is the disasm located immediately above the screenshot:

+ +
.text:0052B932                loc_52B932:                             ; CODE XREF: sub_52B920+9↑j
+.text:0052B932 8A 01                          mov     al, [ecx]
+.text:0052B934 3C B5                          cmp     al, 0B5h
+.text:0052B936 73 F3                          jnb     short loc_52B92B
+.text:0052B938 0F B6 D0                       movzx   edx, al
+.text:0052B93B 8B 04 95 E8 0A+                mov     eax, dword_730AE8[edx*4]
+.text:0052B942 85 C0                          test    eax, eax
+.text:0052B944 57                             push    edi
+.text:0052B945 8B 7D 08                       mov     edi, [ebp+arg_0]
+.text:0052B948 89 07                          mov     [edi], eax
+.text:0052B94A 75 06                          jnz     short loc_52B952
+.text:0052B94C 5F                             pop     edi
+.text:0052B94D 5E                             pop     esi
+.text:0052B94E 5D                             pop     ebp
+.text:0052B94F C2 04 00                       retn    4
+.text:0052B952                ; ---------------------------------------------------------------------------
+.text:0052B952
+.text:0052B952                loc_52B952:                             ; CODE XREF: sub_52B920+2A↑j
+.text:0052B952 85 C0                          test    eax, eax
+.text:0052B954 53                             push    ebx
+.text:0052B955 0F 8D DC 01 00+                jge     loc_52BB37
+.text:0052B95B 8D 42 EA                       lea     eax, [edx-16h]  ; switch 158 cases
+.text:0052B95E 3D 9D 00 00 00                 cmp     eax, 9Dh
+.text:0052B963 0F 87 C8 01 00+                ja      loc_52BB31      ; jumptable 0052B970 default case
+.text:0052B969 0F B6 80 80 BB+                movzx   eax, ds:byte_52BB80[eax]
+.text:0052B970 FF 24 85 44 BB+                jmp     ds:off_52BB44[eax*4] ; switch jump
+.text:0052B977                ; ---------------------------------------------------------------------------
+.text:0052B977
+.text:0052B977                loc_52B977:                             ; CODE XREF: sub_52B920+50↑j
+.text:0052B977                                                        ; DATA XREF: .text:off_52BB44↓o
+.text:0052B977 83 FE 0D                       cmp     esi, 0Dh        ; jumptable 0052B970 case 22
+.text:0052B97A 72 4A                          jb      short loc_52B9C6
+.text:0052B97C 0F B7 49 01                    movzx   ecx, word ptr [ecx+1]
+.text:0052B980 5B                             pop     ebx
+.text:0052B981 89 0F                          mov     [edi], ecx
+.text:0052B983 5F                             pop     edi
+.text:0052B984 B8 01 00 00 00                 mov     eax, 1
+.text:0052B989 5E                             pop     esi
+.text:0052B98A 5D                             pop     ebp
+.text:0052B98B C2 04 00                       retn    4
+
+ +

Thanks.

+",19294,,19294,,1/10/2019 19:49,1/10/2019 19:49,"IDA - large jump table, missing cases in analysis",,1,2,,,,CC BY-SA 4.0 +20316,1,20320,,1/9/2019 8:19,,4,497,"


+I'm reversing the BIOS of my laptop, for fun and for learning something new.
+Inside it, I just stepped into this piece of code:

+ +
mov     ecx, 13Ah
+rdmsr
+and     eax, 1
+jnz     SkipCacheAsRAM
+
+ +

Looking on the Intel datasheet ""Intel 64 and IA-32 Architectures Software Developer’s Manual"", I couldn't find any clue about it, but seems like that in this BIOS release, its value is essential the determine if a key feature such as 'cache as RAM' have to be initialized using an approach or another. +I checked also on the AMD equivalent datasheet, even though I'm sure the MotherBoard is only for Intel CPUs.
+Does anyone indicate me an alternative source(s) where to search what this 0x13a register does?

+",17411,,,,,1/9/2019 18:12,Undocumented MSR Machine Specific register,,1,0,,,,CC BY-SA 4.0 +20318,2,,20313,1/9/2019 14:15,,1,,"

I (a random bloke on the internet) would do these:

+ +
    +
  • read the EULA and terms&conditions. Do they explicitly prohibit/allow all/some parts of the API?
  • +
  • is the API you're using internal or merely undocumented?
  • +
  • depending on the country/jurisdiction you might not be able to use the results of RE. It can be questionable how much of an RE it is to guess the API endpoint.
  • +
  • contact the grocery API authors, maybe they're planning a public API for the features you need or maybe they can point you in the right direction without the need to call their private API.
  • +
  • talk to a lawyer. I don't want to make assumptions when I can end up with a fine or in jail.
  • +
+ +

As @Amirag mentioned the private API might be very unstable and if they break the compatibility your users will suffer blaming your app. And most likely leave a negative review and uninstall it.

+",25796,,,,,1/9/2019 14:15,,,,1,,,,CC BY-SA 4.0 +20319,1,,,1/9/2019 14:32,,3,1552,"

Related to UE Megaboom serial protocol: I am trying to get some insights on the serial protocol spoken by the UE Megaboom, which I suspect is how the app controls the advanced features of the speaker.

+ +

One approach would be to install the app on an Android VM, connect to the speaker and capture the traffic exchanged.

+ +

With VirtualBox, I would probably need to connect a Bluetooth dongle as a USB device and let the VM control it.

+ +

How can I capture the serial traffic exchanged between the speaker and the app?

+",26989,,,,,1/11/2019 0:28,Sniffing serial Bluetooth traffic on Android,,1,0,,,,CC BY-SA 4.0 +20320,2,,20316,1/9/2019 18:12,,5,,"

GitHub is a good place to search for such stuff, e.g.:

+ +

https://github.com/search?q=0x13A+IA32+MSR&type=Code (may require logging in)

+ +

Produces results like:

+ +
#define MSR_BOOT_GUARD_SACM_INFO                                      0x13A
+#define B_NEM_INIT                                                    BIT0
+
+ +

There is no comment, but from the name it look like the bit 0 determines whether the processor is already in NEM (Non-evict mode, another name for Cache-as-RAM).

+",60,,,,,1/9/2019 18:12,,,,1,,,,CC BY-SA 4.0 +20323,1,,,1/9/2019 21:07,,0,3037,"

I open exe file (running on Windows) in Ida , and saw a function (for example sub_ABC) that I want to export , so I can call this function from c# code.

+ +
    +
  1. How can I export function that I Know the name that Ida gave to it , (by the offset) ?

  2. +
  3. Do I need to see how the arguments pass to this function (stack/register) so I will know the calling convention when I call it via c# , yes? Ida can tell me what is the calling convention of spesific function?

  4. +
+",26837,,26837,,1/9/2019 21:15,1/10/2019 12:49,How to export function from exe file?,,1,0,,,,CC BY-SA 4.0 +20324,1,,,1/10/2019 2:49,,1,111,"

Im hoping somebody here can give me some advice. Im trying to read the flash contents of a Mpc564 Motorola MCU. The flash size is 512KB The processor was removed from a bad circuit board. Is there a way to read the flash after the MCU has been removed from the board. Any help would be appreciated. +

+",27037,,245,,1/10/2019 9:04,1/10/2019 9:04,Motorola Freescale mpc564 microcontroller,,0,0,,,,CC BY-SA 4.0 +20325,2,,20319,1/10/2019 11:28,,2,,"

According to this StackOverflow answer, Android has a setting in Developer Options from 4.4 onwards. You first need to enable Developer Settings (if you have not done so already), then enable “Enable Bluetooth HCI snoop log”.

+ +

I have not tried this myself yet, but according to the information I could find:

+ +
    +
  • Communication should be logged to a file called /sdcard/btsnoop_hci.log.
  • +
  • If your external storage dir is something else than /sdcard, modify the path accordingly.
  • +
  • Some flavors of Android may use an entirely different path. Look for the FileName parameter in /etc/bluetooth/bt_stack.conf to find the correct path. (Some flavors of Android may put this file in /system/etc or /vendor/etc.)
  • +
  • On some flavors of Android (including Android x86_64 CM 14.1), none of the above will work but you will find the log in /data/misc/bluetooth/logs/btsnoop_hci.log (you need to have root permissions to get the file).
  • +
  • The resulting file can then be analyzed with Wireshark or similar.
  • +
+ +

To get Bluetooth from an Android VM running on VirtualBox:

+ +
    +
  • If you are on Linux (tried on Ubuntu 18.04): + +
      +
    • Add yourself to the vboxusers group, e.g. by running sudo usermod -a -G vboxusers your_user_name
    • +
    • Log out and back in for the new group membership to take effect.
    • +
  • +
  • Start your Android VM.
  • +
  • In Devices > USB Devices, connect the Bluetooth adapter to the VM. It may have an inconspicuous name (mine is just called Intel [0001]).
  • +
  • Optionally, add a USB filter to have the VM grab the BT device automatically whenever it starts.
  • +
  • Be aware that the host system will lose access to the BT adapter while it is in use by the VM. If you have a BT mouse or keyboard, either replace it with a wired one, or get an additional BT adapter and use that for your VM.
  • +
+ +

In practice, however, I was unable to get a reliable Bluetooth connection from the Android VM. I can scan for devices and managed to pair the BT device (though that took multiple attempts), but I never managed to connect to the device. I suspect that is because Android is quite resource-hungry, and the overhead of virtualization along with a restriction to 2 out of 4 processor cores (which I have set this way to keep VMs from hogging my entire CPU) does not leave enough room for Android to run smoothly. Will need to retry with Android x86_64 on a USB stick, running on physical hardware.

+",26989,,26989,,1/11/2019 0:28,1/11/2019 0:28,,,,0,,,,CC BY-SA 4.0 +20326,2,,20323,1/10/2019 12:49,,1,,"
    +
  1. calling functions and procedures from executable file are not easy as dlls. dlls have Export Table that maps address of functions to names or ordinals. so while loading dll with LoadLibrary this table is corrected based on Image base and then by calling GetProcessAddress you can get function address with name or ordinal. if you want to load exe as library you need correct Import Table and in most cases do initials. for example if a function needs to know file handle before calling, you must initialize variables requires to that function. in many cases the functions inside exe file are not independent and there is calling other functions before calling them. finding this functions and dependency of them is not as easy as looking!
  2. +
+ +

2a. Analyzing in IDA can solve calling conventions issue. if before calling of a function, the stack should be prepared, you may find some [push]/[sub esp,X] right before call to that function. maybe calling with registers has been done (as in many cases of x64-bit). so you should know which register used for what parameter. this needs documentation of that function otherwise you have to analyse yourself!

+ +

2b. invoking methods from dotNet assemblies is possible, nevertheless you need initialize/provide function requirements also. look at here.

+",12687,,,,,1/10/2019 12:49,,,,5,,,,CC BY-SA 4.0 +20327,2,,20315,1/10/2019 14:06,,1,,"

This is an example of so called sparse switch table - large range of case values with gaps in them. You can see how it first determines the case index by indexing a byte table then jumps to the handler using an index into the address table. So missing values are normal and expected; they’re handled by the default case.

+ +

You can check Rolf’s research into compiler switch implementations and their variations in this article series:

+ +

https://www.msreverseengineering.com/blog/2014/6/23/switch-as-binary-search-part-0

+",60,,,,,1/10/2019 14:06,,,,0,,,,CC BY-SA 4.0 +20328,1,20330,,1/9/2019 15:20,,3,181,"

I have an unbranded LED lamp with a remote control. I would like to reverse the protocol of the remote but unfortunately I can't create my own packages. The frequency of the remote transceiver is 2.4GHz (PA = 6dBm, channel = 1) so I used an NRF24 for collecting the frames from a button. When I 'replay' the collected messages the lamp reacts as expected.
+As I observed the preamble is 5 bytes long and in the end of packet there is a 2 bytes long hash, probably a CRC16. (I think it should be some kind of hash because one bit change in the packet generates totally different value in last 2 bytes position.) Unfortunately I couldn't identify the type of transceiver so I cannot figure out the packet format. I tried to reverse the hash with various methods but without luck.

+ +

Do you have any idea what is the hash algorithm?

+ +

There are some test vectors from the same button.

+ +
aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  00 21  00 60 1f 55  57  84 c1
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  00 e1  00 60 1f 55  56  c4 cc
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  01 21  00 60 1f 55  56  86 95
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  01 e1  00 60 1f 55  55  c4 de
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  02 41  00 60 1f 55  55  75 64
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  02 61  00 60 1f 55  55  40 6c
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  02 81  00 60 1f 55  55  25 48
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  02 c1  00 60 1f 55  54  f5 6d
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  02 c1  00 60 1f 55  54  f5 6d
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  03 61  00 60 1f 55  54  42 38
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  04 01  00 60 1f 55  53  b8 9b
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  04 01  00 60 1f 55  53  b8 9b
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  04 21  00 60 1f 55  53  8d 93
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  04 41  00 60 1f 55  53  78 9f
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  04 61  00 60 1f 55  53  4d 97
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  04 61  00 60 1f 55  53  4d 97
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  04 81  00 60 1f 55  53  28 b3
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  04 81  00 60 1f 55  53  28 b3
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  05 01  00 60 1f 55  52  ba cf
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  05 81  00 60 1f 55  52  2a e7
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  05 a1  00 60 1f 55  52  1f ef
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  06 61  00 60 1f 55  51  49 3e
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  06 61  00 60 1f 55  51  49 3e
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  07 21  00 60 1f 55  50  8b 6e
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  07 a1  00 60 1f 55  50  1b 46
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  07 c1  00 60 1f 55  4f  e3 88
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  08 e1  00 60 1f 55  4e  c4 58
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  08 e1  00 60 1f 55  4e  c4 58
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  08 e1  00 60 1f 55  4e  c4 58
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  08 01  00 60 1f 55  4f  b1 5d
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  08 61  00 60 1f 55  4f  44 51
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  09 41  00 60 1f 55  4e  73 0d
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  09 21  00 60 1f 55  4e  86 01
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0a 41  00 60 1f 55  4d  75 f0
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0a 61  00 60 1f 55  4d  40 f8
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0a 81  00 60 1f 55  4d  25 dc
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0b 01  00 60 1f 55  4c  b7 a0
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0b 21  00 60 1f 55  4c  82 a8
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0b 41  00 60 1f 55  4c  77 a4
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0b 41  00 60 1f 55  4c  77 a4
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0b 61  00 60 1f 55  4c  42 ac
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0c 21  00 60 1f 55  4b  8d 07
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0c 61  00 60 1f 55  4b  4d 03
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0c 61  00 60 1f 55  4b  4d 03
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0c 81  00 60 1f 55  4b  28 27
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0c c1  00 60 1f 55  4a  f8 02
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0c c1  00 60 1f 55  4a  f8 02
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0c e1  00 60 1f 55  4a  cd 0a
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0c e1  00 60 1f 55  4a  cd 0a
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0d 01  00 60 1f 55  4a  ba 5b
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0d 81  00 60 1f 55  4a  2a 73
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0e 01  00 60 1f 55  49  bc a6
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0e 21  00 60 1f 55  49  89 ae
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0e 61  00 60 1f 55  49  49 aa
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0e 81  00 60 1f 55  49  2c 8e
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0e a1  00 60 1f 55  49  19 86
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0e c1  00 60 1f 55  48  fc ab
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0e e1  00 60 1f 55  48  c9 a3
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0f 01  00 60 1f 55  48  be f2
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0f 21  00 60 1f 55  48  8b fa
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0f 61  00 60 1f 55  48  4b fe
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0f 61  00 60 1f 55  48  4b fe
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0f 61  00 60 1f 55  48  4b fe
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0f a1  00 60 1f 55  48  1b d2
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0f c1  00 60 1f 55  47  f1 2d
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  0f c1  00 60 1f 55  47  f1 2d
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  10 01  00 60 1f 55  47  b6 87
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  10 21  00 60 1f 55  47  83 8f
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  10 21  00 60 1f 55  47  83 8f
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  10 41  00 60 1f 55  47  76 83
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  10 61  00 60 1f 55  47  43 8b
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  10 e1  00 60 1f 55  46  c3 82
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  10 e1  00 60 1f 55  46  c3 82
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  11 81  00 60 1f 55  46  24 fb
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  11 a1  00 60 1f 55  46  11 f3
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  11 a1  00 60 1f 55  46  11 f3
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  11 a1  00 60 1f 55  46  11 f3
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  11 e1  00 60 1f 55  45  c3 90
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  11 e1  00 60 1f 55  45  c3 90
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  12 41  00 60 1f 55  45  72 2a
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  12 41  00 60 1f 55  45  72 2a
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  12 61  00 60 1f 55  45  47 22
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  12 61  00 60 1f 55  45  47 22
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  12 c1  00 60 1f 55  44  f2 23
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  12 c1  00 60 1f 55  44  f2 23
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  13 21  00 60 1f 55  44  85 72
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  13 21  00 60 1f 55  44  85 72
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  13 21  00 60 1f 55  44  85 72
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  13 61  00 60 1f 55  44  45 76
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  13 81  00 60 1f 55  44  20 52
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  13 e1  00 60 1f 55  43  c3 b5
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  14 a1  00 60 1f 55  43  1a f5
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  14 e1  00 60 1f 55  42  ca d0
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  15 81  00 60 1f 55  42  2d a9
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  15 a1  00 60 1f 55  42  18 a1
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  16 61  00 60 1f 55  41  4e 70
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  16 a1  00 60 1f 55  41  1e 5c
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  16 c1  00 60 1f 55  40  fb 71
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  16 e1  00 60 1f 55  40  ce 79
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  18 01  00 60 1f 55  5f  b6 13
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  18 c1  00 60 1f 55  5e  f6 1e
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  19 81  00 60 1f 55  5e  24 6f
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  19 a1  00 60 1f 55  5e  11 67
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1a 01  00 60 1f 55  5d  b2 ba
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1a c1  00 60 1f 55  5c  f2 b7
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1b 21  00 60 1f 55  5c  85 e6
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1b 81  00 60 1f 55  5c  20 c6
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1c 01  00 60 1f 55  5b  bf 41
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1d 01  00 60 1f 55  5a  bd 15
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1d 81  00 60 1f 55  5a  2d 3d
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1d a1  00 60 1f 55  5a  18 35
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1e 41  00 60 1f 55  59  7b ec
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1e c1  00 60 1f 55  58  fb e5
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1f 21  00 60 1f 55  58  8c b4
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1f 41  00 60 1f 55  58  79 b8
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1f 61  00 60 1f 55  58  4c b0
+aa aa aa aa aa 90 8e 7c 64 ce 20 33 b8 a0 26 3f c0  1f e1  00 60 1f 55  57  c3 6b
+
+",27051,Babud Imre,27051,,1/11/2019 6:59,1/14/2019 8:27,Identification of RF hash algorithm,,1,6,,,,CC BY-SA 4.0 +20329,1,,,1/10/2019 17:32,,3,171,"

I'm in a situation where I have an executable file. When I start it within the debugger (x32dbg), with breakpoints set to every occasion (DLL entry, DLL load, Thread start,..), to restrict the amount of actions that get executed right after the file is ran,

+ +

in the dump I see some bytes which are different from those at the same location in the exe file.

+ +

Why is this happening and how to prevent this? +

+ +

My thought is it has something to do with dynamic linking of some sort. The values change when: the exe is saved(EVEN WITH THE EXACTLY SAME CONTENT AS BEFORE) and ran. Thus the offset where the code is placed and the specific bytes are recalculated. The only thing that loads, however, is ntdll.dll an then the first breakpoint is hit. So I guess the content of the exe is copied to the ram, that time is everything allright, then the magic part happens, where the subroutine or what knows what bytes to change and it changes them, and then the debugger gets the control.

+",27049,,27049,,1/11/2019 21:31,1/13/2019 19:41,Certain bytes in the memory (RAM) get changed after the program starts. Why?,,1,0,,,,CC BY-SA 4.0 +20330,2,,20328,1/10/2019 18:11,,6,,"

As explained there for a similar problem, facing an unknown Frame Check Sequence, the first thing should be to determine if it is an affine function of the frame data, for the sense that has in cryptography. This can be defined by the property:

+ +
+

For any set with an odd number of frames of equal length, the XOR of the Frame Check Sequences for these frames is also the FCS for the (often, other) frame obtained by XOR-ing the data portion of the frames in the set.

+
+ +

All CRCs are affine (including non-standard variations); secure cryptographic hashes and Message Authentication Codes are not.

+ +

There is evidence that indeed that FCS is affine: it is easy to isolate blocks of four (or larger even number) of different lines such that one is the XOR of the others, and that allows prediction of the last two bytes for most lines. Two examples:

+ +
aaaaaaaaaa908e7c64ce2033b8a0263fc0 0241 00601f55 55 7564
+aaaaaaaaaa908e7c64ce2033b8a0263fc0 0261 00601f55 55 406c
+aaaaaaaaaa908e7c64ce2033b8a0263fc0 0401 00601f55 53 b89b
+aaaaaaaaaa908e7c64ce2033b8a0263fc0 0421 00601f55 53 8d93
+
+aaaaaaaaaa908e7c64ce2033b8a0263fc0 0441 00601f55 53 789f
+aaaaaaaaaa908e7c64ce2033b8a0263fc0 0501 00601f55 52 bacf
+aaaaaaaaaa908e7c64ce2033b8a0263fc0 0661 00601f55 51 493e
+aaaaaaaaaa908e7c64ce2033b8a0263fc0 0721 00601f55 50 8b6e
+
+ +

Using Gaussian elimination, I verified that all the question's 93 given distinct lines are consistent with an affine function, and determined the influence on the rightmost two bytes of the 13 bits that vary in the rest of the frame. Therefore, the whole data set becomes equivalent to (any) one of it lines, and the following short table telling the influence on the FCS of toggling each of the 13 bits:

+ +
byte  byte    FCS influence
+index mask    (bytes 24 and 25)
+ 17   0x10    0x157F
+ 17   0x08    0x1BBD
+ 17   0x04    0x0DDE
+ 17   0x02    0x06EF
+ 17   0x01    0x1275
+ 18   0x80    0x9028
+ 18   0x40    0xC004
+ 18   0x20    0x3508
+ 23   0x10    0x1231
+ 23   0x08    0x0918
+ 23   0x04    0x048C
+ 23   0x02    0x0246
+ 23   0x01    0x1021
+
+ +

This is enough to compute the FCS of 213 different frames, starting from that of the reference frame, and XORing its FCS with the FCS influence for any bit that differs from the reference frame. The code is only a few lines of C. That works for any affine function when we have adequate examples. We need one example frame per frame bit excluding FCS when we can choose the example frames, and typically only a few more frames for uniformly random frames.

+ +
+ +

There is further regularity in there! The FCS influence for the 5 bits of byte 23 is precisely that expected for the CRC-16-CCITT polynomial x16+x12+x5+1 (when using big-endian convention): the influence of bit i counting from the right (here 26*8-1-n with n from the left and 0-based) is the value obtained by computing the remainder of the polynomial division of xi by x16+x12+x5+1, and turning the remainder polynomial to a value by evaluating it for x=2.

+ +

E.g., for influence of byte 23 mask 0x10, evaluating the remainder of the polynomial division of x20 by x16+x12+x5+1 , or equivalently 0x100000 by 0x011021, goes 0x100000^(0x011021<<4) = 0x010210 then 0x010210^(0x011021<<0) = 0x1231.

+ +
+ +

One possibility is that this FCS is one of countless failed attempts to implement CRC-16-CCITT; though one that went unusually out of track, in a way that still puzzles me. I'm tempted to incriminate a partial or misaligned capture, but that tends to conflicts with the statement:

+ +
+

When I 'replay' the collected messages the lamp reacts as expected.

+
+ +

More samples might help. Perhaps, put this into a pastebin linked in the question or a comment. Perhaps, give settings of the NRF24L01 device and/or software used for the capture.

+",3035,,3035,,1/14/2019 8:27,1/14/2019 8:27,,,,3,,,,CC BY-SA 4.0 +20332,1,,,1/10/2019 20:31,,2,391,"

I am trying to get a ROP exploit to work on Ubuntu 18.04 LTS 64bit.

+ +

I have a 64 bit binary (Nx enabled, ASLR disabled) with vuln function as follows:

+ +
public vuln
+vuln proc near
+
+var_100= byte ptr -100h
+
+push    rbp
+mov     rbp, rsp
+sub     rsp, 100h
+lea     rdi, s          ; ""Gimme some data!""
+call    _puts
+lea     rax, [rbp+var_100]
+mov     rdi, rax
+mov     eax, 0
+call    _gets
+nop
+leave
+retn
+vuln endp
+
+ +

I need to overwrite the return pointer of vuln function with the libc base address where I will write parameters for execve call.

+ +

The buffer is 264 bytes long. So with 272 'A' I get the following position:

+ +
0x55555555471d <vuln+45>    ret    <0x4141414141414141>
+
+ +

Stack:

+ +
00:0000│ rsp  0x7fffffffe2c8 ◂— 'AAAAAAAA'
+
+ +

But when I try to overflow with the libc address(0x7ffff7a3a000) it is giving a SIGSEGV and it is behaving the following way:

+ +
0x55555555471d <vuln+45>    ret    <0x3061785c3030785c>
+
+ +

Stack:

+ +
00:0000│ rsp r11-6  0x7fffffffe2c8 ◂— 0x3061785c3030785c ('\\x00\\xa0')
+01:0008│            0x7fffffffe2d0 ◂— 0xefbdbfef3361785c
+02:0010│            0x7fffffffe2d8 ◂— 0x3030785cbdbf
+
+ +

I dont know where am I going wrong!!!! I have put so many days in it but to no extent. I have done buffer overflow before but never encountered this problem.

+ +

Following is my python script that is generating the payload (this is only to overflow the return address):

+ +
#! /usr/bin/env python2
+
+from pwn import *
+
+payload = 'A' * 264
+payload += p64(0x7ffff7a3a000)
+
+print(payload)
+
+",27008,,27008,,1/10/2019 20:37,1/12/2019 4:43,ROP chain: Buffer Overflow Return Pointer,,1,1,,,,CC BY-SA 4.0 +20333,1,,,1/10/2019 23:31,,1,332,"

I'm disassembling a 16-bit DOS executable, and looking at the following three instructions:

+ +
mov dx,0x3ce
+mov ax,0xff08
+out dx,ax
+
+ +

I know it writes the value 0xff08 to I/O port 0x3ce. I also know that port 0x3ce is the ""Graphics 1 & 2 Address"" register on an IBM EGA card. Problem is, according to the manual, this port should take a byte value, not a word.

+ +

What I'm guessing is happening is that the word 0xff08 is taken as two different bytes, where one byte ends up in the specified register and the other goes to an adjacent one. Or maybe the offending byte gets thrown out? Either way it's a guess, as I can't seem to find much info about this specific behavior.

+ +

I don't have a good intuitive sense about which direction the I/O address space flows, or how the little-endian storage of the word may come into play. After this snippet executes, which ports got which bytes?

+",25711,,,,,1/11/2019 0:06,How is the I/O address space on the PC arranged?,
,1,0,,,,CC BY-SA 4.0 +20334,1,,,1/11/2019 0:05,,1,54,"

I have 4 different types of USB 3G modems from Europe. They're not operator locked. I'm trying to use them on an American network for 3G connectivity.

+ +

Even though they state ""850, 900, 1800, 1900 MHz"" bands in their specs, and my network supposedly has UMTS on 850 MHz, I can only get a 2G (EDGE) connection and furthermore, they all detect my SIM card as out of network and put me in ""roaming"" mode.

+ +

I've found out that the radios in these things are usually universal but the band limits are only in software. Therefore I was wondering if there would be any way (through undocumented AT commands or firmware flashing) I could get either one of these modems to switch allowed bands and let me get 3G speeds in North America.

+ +

Are there any resources where I can get AT command lists and/or different region firmware for these devices? Or is there anyone that could maybe point me in the right direction?

+ +

These are the devices I have:

+ +
    +
  • Huawei E3131
  • +
  • Huawei E353
  • +
  • ZTE MF190
  • +
  • D-Link DWM-156
  • +
+ +

I tried flashing different versions of firmware and/or googling AT commands to change bands on some of these, but at the end, the moment I switch mode to 3G I get ""no service""

+ +

Any help would be greatly appreciated...

+",27053,,,,,1/11/2019 0:05,USB 3G Stick changing frequency bands,,0,0,,1/12/2019 18:22,,CC BY-SA 4.0 +20335,2,,20333,1/11/2019 0:06,,2,,"

Port I/O works similar to memory I/O, so the low byte (08) will be written to the port 3CE and the high byte (0xFF) to the port 3CF.

+ +

Example from Use of bitplanes in mode 12h:

+ +
+

The index port of the Graphics Controller (part of the VGA interface) is at + $3CE. The data port is at (index+1), so $3CF. If we want to write a 4 to index + 2, we do: Port[$3CE]:=2; { index } Port[$3CF]:=4; { data } + But there is a way to do it with one Port[]. There's also a PortW[] 'array', + and if the addressed port isn't a 16-bit one, it sends the lo byte to + address, and the high byte to address+1. Just what we need. The example + becomes: PortW[$3CE]:=$0402; { index in low byte, data in high byte }

+
+",60,,,,,1/11/2019 0:06,,,,0,,,,CC BY-SA 4.0 +20336,1,20337,,1/11/2019 3:48,,0,1132,"

I'm new to radare2 here. Just started learning and I was trying out a challenge. What does the 3 columns in the radare2 visual mode represent?

+ +

May I know how the command below:

+ +

wa je 0x400976 @0x00400968

+ +

changes 760c to 740c and jne 0x400976 to je 0x400976?

+ +

Also, what does that accomplish? +Does it just bypass the function

+ +

Thank you!

+ +

full program +

+ +

command +

+",27055,,18014,,1/11/2019 6:51,1/11/2019 7:50,How does this command modify the condition?,,2,2,,,,CC BY-SA 4.0 +20337,2,,20336,1/11/2019 6:50,,0,,"
+

What does the 3 columns in the radare2 visual mode represent?

+
+ +

The first one is an address of the instruction, then opcodes followed by mnemonic. On the far left you have also some arrows indicating jumps and on the far right there are comments.

+ +
+

May I know how the command below:
+ wa je 0x400976 @0x00400968
+ changes 760c to 740c and jne 0x400976 to je 0x400976?

+
+ +

wa command, which you could check by requesting help in r2, is a command that writes the opcode of the provided mnemonic.

+ +
| wa[?] push ebp       write opcode, separated by ';' (use '""' around the command)
+
+ +

So executing wa je 0x400976 @0x00400968 will write the opcodes for the je 0x400976 at the address of 0x400968.

+ +

And actually it changes from 750c, and that is the opcode of the jump-not-equal with the offset of 0xC bytes. You requested (by issuing the command wa) to write on that spot the jump-if-equal and the opcode of this is 74. The offset stays the same.

+ +
+

Also, what does that accomplish? Does it just bypass the function

+
+ +

It changes the condition so from now on the jump will be taken when the strings that are being compared (@0x400961) are equal and not taken if they are different. This also happens to the string being printed at offset 0x400971.

+ +

Apart from the first question this is nor really radare2 specific stuff. It looks like you should start with some basic assembly and/or RE topics/tutorials that are plenty on the internet.

+",18014,,,,,1/11/2019 6:50,,,,0,,,,CC BY-SA 4.0 +20338,1,20343,,1/11/2019 7:33,,5,1917,"

I have been trying to figure out exactly what is happening with these instructions and can't make sense of them. I can see that the PSHUFLW instruction acts upon the first 16 bytes of the XMM register but can not figure it out. I have read the decription in the Intel® Architecture Instruction Set Extensions Programming Reference but just can't seem to get it. I am a very visual person so any help would be greatly appreciated. I have run some tests using the code

+ +
xxm0 = 00000000000000000000000000003E2D
+PSHUFLW xmm0, xmm0, N
+
+ +

and have the following results

+ +
 N = 0, output = 00000000000000003E2D3E2D3E2D3E2D
+ N = 1, output = 00000000000000003E2D3E2D3E2D0000
+ N = 2, output = 00000000000000003E2D3E2D3E2D0000
+ N = 3, output = 00000000000000003E2D3E2D3E2D0000
+ N = 4, output = 00000000000000003E2D3E2D00003E2D
+ N = 5, output = 00000000000000003E2D3E2D00000000
+ N = 6, output = 00000000000000003E2D3E2D00000000
+ N = 7, output = 00000000000000003E2D3E2D00000000
+ N = 8, output = 00000000000000003E2D3E2D00003E2D
+ N = 9, output = 00000000000000003E2D3E2D00000000
+ N = 10, output = 00000000000000003E2D00003E2D3E2D
+ N = 11, output = 00000000000000003E2D00003E2D0000
+ N = 12, output = 00000000000000003E2D00003E2D0000
+ N = 13, output = 00000000000000003E2D00003E2D0000
+ N = 14, output = 00000000000000003E2D000000003E2D
+ N = 15, output = 00000000000000003E2D000000000000
+ N = 16, output = 00000000000000003E2D000000000000
+ N = 17, output = 00000000000000003E2D000000000000
+ N = 18, output = 00000000000000003E2D000000003E2D
+ N = 19, output = 00000000000000003E2D000000000000
+ N = 20, output = 00000000000000003E2D00003E2D3E2D
+
+ +

I would like to know how these instructions work, and maybe a visual guide on future instructions similar to this. I have only been reversing for a couple of weeks so I am very fresh. Thanks for any help you can provide.

+",27056,,,,,1/12/2019 21:33,How do the PSHUFLW and PSHUFD instructions work?,,1,2,,,,CC BY-SA 4.0 +20339,2,,20336,1/11/2019 7:50,,0,,"

You can check the official Radare 2 Book where you should find the first steps as well as the basic command to go. The write command is described here

+ +

Another resouce I found so useful when I started learning r2 is the two part tutorial Megabeets wrote about a simple crackme.

+",27057,,,,,1/11/2019 7:50,,,,0,,,,CC BY-SA 4.0 +20340,1,20342,,1/11/2019 14:01,,1,3201,"

I have created a very basic golang program which display a message with fmt.Println().

+ +

Here is what is see in radare2:

+ +
lea rcx, obj.main.statictmp_0 ; 0x4c84b0 ; ""y[K""
+mov qword [local_48h], rcx
+lea rcx, [local_40h]        ; 0x40 ; '@' ; 64
+mov qword [rsp], rcx
+mov qword [local_8h], 1
+mov qword [local_10h], 1
+call sym.fmt.Println
+
+ +

I suppose obj.main.statictmp_0 contains my string message.

+ +

I have tried:

+ +
ps @obj.main.statictmp_0
+
+ +

but it does not display my message. +Any idea ?

+ +

Thanks

+",18590,,,,,1/11/2019 18:19,Print string at address with radare2,,1,2,,,,CC BY-SA 4.0 +20342,2,,20340,1/11/2019 18:19,,0,,"

use pf S @obj.main.statictmp_0. string length is at address @obj.main.statictmp_0+8 if using 64bit or @obj.main.statictmp_0+4 if using 32bit!

+ +
pf S @obj.main.statictmp_0   ; gives you string
+pf p @obj.main.statictmp_0+8 ; gives you string length
+
+",12687,,,,,1/11/2019 18:19,,,,0,,,,CC BY-SA 4.0 +20343,2,,20338,1/11/2019 20:27,,6,,"

The visual story of PSHUFLW is as follows:

+ +

+ +
    +
  • I will use Position as same mean as Order here and starts from Zero (Zero-Indexed).
  • +
+ +

As you can see it selects words from source based on value of N. The Order/Position of selection will be chosen by 2 bit values of N. for example when N=4,

+ +
    +
  1. According to first bite (2-bits) of N (= 00), it will select word at position/order 0 of source and copies it in Position 0 of destination.
  2. +
  3. According to second bite (2-bits) of N (= 01), it will select word at position/order 1 of source and copies it in 1st Position of destination.
  4. +
  5. According to third bite (2-bits) of N (= 00), it will select word at position/order 0 of source and copies it in 2nd Position of destination.
  6. +
  7. According to fourth bite (2-bits) of N (= 00), it will select word at position/order 0 of source and copies it in 3rd Position of destination.
  8. +
+ +

Next example when N=17,

+ +
    +
  1. According to first bite (2-bits) of N (= 01), it will select word at position/order 1 of source and copies it in Position 0 of destination.
  2. +
  3. According to second bite (2-bits) of N (= 00), it will select word at position/order 0 of source and copies it in 1st Position of destination.
  4. +
  5. According to third bite (2-bits) of N (= 01), it will select word at position/order 1 of source and copies it in 2nd Position of destination.
  6. +
  7. According to fourth bite (2-bits) of N (= 00), it will select word at position/order 0 of source and copies it in 3rd Position of destination.
  8. +
+ +

PS: your output for N=17 in above question is wrong! PSHUFD is just same except it will select doublewords from source and copies in destination. so low and high quadword in PSHUFD will be used while in PSHUFLW the low quadword used.

+",12687,,12687,,1/12/2019 21:33,1/12/2019 21:33,,,,4,,,,CC BY-SA 4.0 +20344,2,,20332,1/12/2019 4:43,,1,,"

The zero in the address that you are passing is causing the string to be terminated and the following values to not be stored. You won't be able to return directly to libc that way. Instead, you'll need a different address that can either branch to libc directly (but contains no zeroes in the address), or which can push that value for you before performing a ret itself.

+",1323,,,,,1/12/2019 4:43,,,,1,,,,CC BY-SA 4.0 +20349,1,20350,,1/12/2019 19:12,,0,6774,"

I am new with IDA assembler and i used to work with hopper app. +the problem is i can't change instruction in IDA from something like CBNZ to NOP. +is there any button to do this? i can't find anything on the internet and I have been searching for it all day. +I have tried many options from the edit menu.

+",27070,,245,,1/14/2019 9:43,7/25/2022 19:32,how should i change an instruction to NOP in IDA?,,1,1,,,,CC BY-SA 4.0 +20350,2,,20349,1/13/2019 3:41,,4,,"

NOTE: I'm assuming you're using IDA 7.X, although this should work equally well for 6.X versions.

+ +

The option you're looking for is called Patch Program. For your specific question, you'd do the following:

+ +
    +
  1. Select the instruction you want to change
  2. +
  3. Go to Edit -> Patch Program -> Assemble
  4. +
  5. Replace the instruction in the text box with the instruction you'd like it to be.
  6. +
  7. Click OK
  8. +
+ +

The original instruction will now have been replaced with the new one.

+ +

This article has more info and examples of using the other options in the Patch Program submenu.

+",18563,,,,,1/13/2019 3:41,,,,2,,,,CC BY-SA 4.0 +20352,1,,,1/13/2019 9:27,,2,436,"

Here is a very basic golang program:

+ +
package main
+import ""fmt""
+
+func main() {
+    var s1 string
+    fmt.Scanln(&s1)
+
+    if s1==""goodpassword"" {
+        fmt.Println(""Good"")
+    } else {
+        fmt.Println(""Wrong"")
+    }
+}
+
+ +

I have compiled this program (elf64 linux binary).

+ +

I have diasssembled the binary and i have found the addresses of the 2 fmt.Println calls:

+ +
...
+0x00490d4f     lea rax, obj.main.statictmp_1    ; wrong
+...
+0x00490d99     lea rax, obj.main.statictmp_0    ; good
+...
+
+ +

Now, i have wrote this python program:

+ +
import angr
+from angr.state_plugins import SimSystemPosix
+
+p = angr.Project('./mybinary')
+
+sm = p.factory.simulation_manager()
+sm.explore(find= 0x00490d99, avoid= 0x00490d4f)
+
+print(sm.found[0].posix.dumps(0))
+
+ +

I do not understand why angr does not return ""goodpassword"" string. +I have something wrong but i do not understand what...

+ +

Thanks for your help

+",18590,,,,,1/13/2019 11:26,angr with a golang target,,1,0,,,,CC BY-SA 4.0 +20353,1,,,1/13/2019 9:32,,0,2462,"

What is the meaning of the following pseudo-code?:

+ +
    +
  1. BYTE1(v2) or BYTE1(v2)

  2. +
  3. HIBYTE(v2)

  4. +
+ +

Is there any explanation for those macros? How can I implement those macros in C code?

+",27074,,245,,1/14/2019 9:46,1/15/2021 20:33,Understanding Hex-Rays pseudo code,,3,0,,,,CC BY-SA 4.0 +20355,2,,20352,1/13/2019 11:26,,3,,"

The Go run time is fairly complicated that symbolic solvers will not run out-of-the-box as-is. You are asking angr to figure out everything on it's own which may be feasible for simple and uncomplicated C programs but not for something like Go binaries.

+ +

For example, the fmt.Scanln function will call multiple Go functions before you reach libc.read. Angr has SimProcedures for read but not for fmt.Scanln. To figure out what fmt.Scanln does it has to symbolically execute after which only it may able to discover the dependency between stdin and the program output. Symbolically executing Scanln is by no way a simple task.

+ +

Instead, you should break down the problem in parts which you can ask angr to solve. Like if you have identified the buffer where the user input is stored you can mark that as symbolic and instruct angr to find the path to the ""good password"" branch.

+ +

Further resources on Go reversing:

+ + +",1413,,,,,1/13/2019 11:26,,,,3,,,,CC BY-SA 4.0 +20356,2,,20353,1/13/2019 12:26,,3,,"

BYTE1(v2) is the second byte of value v2. according to the reference it's Zero-Indexed. defined as:

+ +
#define BYTEn(x, n)   (*((_BYTE*)&(x)+n))
+#define BYTE1(x)   BYTEn(x,  1)         // byte 1 (counting from 0)
+
+ +

for example BYTE1(0x1213141516) is 0x15. (according to Little Endian Byte Order)

+ +

HIBYTE(v2) is the higher byte of value v2. defined as:

+ +
#define HIBYTE(x)   (*((_BYTE*)&(x)+1))
+
+ +

for example HIBYTE(0x1213) is 0x12. (according to Little Endian Byte Order)

+",12687,,12687,,1/13/2019 12:31,1/13/2019 12:31,,,,1,,,,CC BY-SA 4.0 +20359,1,20370,,1/13/2019 18:14,,2,735,"

Radare2's afl command returns function names with a specific syntax that I could not find documentation on:

+ +

For example:

+ +
radare2 -2 -A -q -c ""aflj"" C:/Windows/system32/advapi32.dll
+
+0x77cce13c   22 280          sub.ntdll.dll_RtlNtStatusToDosError_13c
+0x77cce259    7 62           fcn.77cce259
+0x77cce29c   10 88           sub.KERNEL32.dll_lstrcmpiW_29c
+0x77cce2f9   24 463          sub.KERNEL32.dll_lstrlenW_2f9
+0x77c617b4    1 40           sym.imp.KERNEL32.dll_LocalAlloc
+0x77c6abe5    5 92   -> 130  sub.KERNEL32.dll_LocalAlloc_be5
+0x77c7edd5    1 20           sub.KERNEL32.dll_LocalAlloc_dd5
+
+ +
    +
  • What is the meaning of the hexadecimal number after the function name ?
  • +
  • Why is the core difference between the prefixes ""sym."" and ""sub."" of DLL function names ?
  • +
  • What is the difference between library names in lower or uppercase ?
  • +
+ +

The DLL file names are all in lowercase:

+ +
    +
  • C:\Windows\System32\ntdll.dll
  • +
  • C:\Windows\System32\kernel32.dll
  • +
+",26962,,26962,,1/13/2019 18:52,1/14/2019 15:11,Function names syntax returned by radare2's afl?,,1,2,,,,CC BY-SA 4.0 +20361,2,,20329,1/13/2019 19:41,,2,,"

The magic might be TLS callbacks that run before entry point is reached. This behavior is well documented, see for example the following article:

+ +

https://isc.sans.edu/diary/How+Malware+Defends+Itself+Using+TLS+Callback+Functions/6655

+",4192,,,,,1/13/2019 19:41,,,,1,,,,CC BY-SA 4.0 +20362,1,20374,,1/13/2019 22:54,,1,128,"

I'm planning to read a MX25U1635E chip using the CH341a reader.

+ +

The specs for that chip say it has a max voltage of 1.6-2.0 volts. The reader has an output of 3.3-5.0 volts.

+ +

Most tutorials for the reader instruct you to just clamp it on the chip and start reading.

+ +

Can I do that in my case, or do I have tweak the CH341a voltage down somehow before reading the chip?

+",27086,,,,,1/14/2019 22:12,Flash ROM has lower max voltage than read device?,,1,0,,,,CC BY-SA 4.0 +20363,1,20365,,1/14/2019 0:34,,-1,6497,"

I have just converted this piece of code in assembly:

+ +
#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char** argv) {
+    return (1);
+}
+
+ +

Here are my questions:

+ +
    +
  1. Once you push the base-pointer value on to the stack, RSP will decrement automatically (to a lower address). This will also happen when memory was allocated for argc and argv (""mov dword"" and ""mov qword""). Is this correct? I don't see any instruction to move the stack-pointer up the stack, so I am assuming this is done implicitly.
  2. +
  3. The instruction ""mov dword [rbp-4H], edi"" is 4 bytes less than the address in RBP, this is as expected since DWORD is 4 bytes in length. What I am confused about is why ""mov qword [rbp-10H], rsi"" is 10H (16 bytes)? Isn't QWORD 8 bytes in length? I was expecting the instruction to be ""mov qword [rbp-CH], rsi"", since 4+8=12 bytes.
  4. +
  5. Can you explain to me what the comments on the right-side are?
  6. +
+ +

Below is the assembly code generated from my c program:

+ +
SECTION .text   align=1 execute                         ; section number 1, code
+
+main:   ; Function begin
+push    rbp                                     ; 0000 _ 55
+mov     rbp, rsp                                ; 0001 _ 48: 89. E5
+mov     dword [rbp-4H], edi                     ; 0004 _ 89. 7D, FC
+mov     qword [rbp-10H], rsi                    ; 0007 _ 48: 89. 75, F0
+mov     eax, 1                                  ; 000B _ B8, 00000001
+pop     rbp                                     ; 0010 _ 5D
+ret                                             ; 0011 _ C3
+; main End of function
+
+
+SECTION .data   align=1 noexecute                       ; section number 2, data
+
+SECTION .bss    align=1 noexecute                       ; section number 3, bss
+
+",27078,,,,,1/14/2019 6:20,"Understanding assembly code: ""mov dword"" and ""mov qword"" in main.c",,1,0,,,,CC BY-SA 4.0 +20365,2,,20363,1/14/2019 6:20,,2,,"

Variables are aligned to some extent to help faster access to them. The alignment value is usually an implementation detail, but compilers usually follow Intel's recommendations to align/place variables next to each other.

+

According to Intel® 64 and IA-32 Architectures Optimization Reference Manual, section 3.6.7 Stack Alignment*:

+
+

Performance penalty of unaligned access to the stack happens when a +memory reference splits a cache line. This means that one out of eight +spatially consecutive unaligned quadword accesses is always penalized, +similarly for one out of 4 consecutive, non-aligned double-quadword +accesses, etc.

+

Aligning the stack may be beneficial any time there are +data objects that exceed the default stack alignment of the system. +For example, on 32/64bit Linux, and 64bit Windows, the default stack +alignment is 16 bytes, while 32bit Windows is 4 bytes.

+

Assembly/Compiler Coding Rule 55. (H impact, M generality) Make sure +that the stack is aligned at the largest multi-byte granular data type +boundary matching the register width.

+
+

In your case on x64 the registers are 8 bytes wide and argc being an int is 4 bytes wide. Following the guideline above the variables are aligned to 8-byte boundary.

+
 ► 0x5555555545fe <main+4>                   mov    dword ptr [rbp - 4], edi
+   0x555555554601 <main+7>                   mov    qword ptr [rbp - 0x10], rsi
+   0x555555554605 <main+11>                  mov    eax, 0x2a
+   0x55555555460a <main+16>                  pop    rbp
+   0x55555555460b <main+17>                  ret    
+
+

edi stores argc a 32 bit value - packed in a 64 bit boundary with the upper 32 bits of no use for you.

+
pwndbg> tele rbp-0x10
+00:0000│          0x7fffffffdf10 —▸ 0x7fffffffe000 ◂— 0x1
+01:0008│          0x7fffffffdf18 ◂— 0x0
+02:0010│ rbp rsp  0x7fffffffdf20 —▸ 0x555555554610 (__libc_csu_init) ◂— push   r15
+
+

So the argv starts 8 bytes above argv

+",14622,,-1,,6/17/2020 9:54,1/14/2019 6:20,,,,0,,,,CC BY-SA 4.0 +20366,1,,,1/14/2019 6:44,,4,431,"

I'm working on reverse engineering an embedded system which uses a Z80 processor. I'm using IDA as the disassembler. I ran upon an absolute jump (JP) that seems to jump to the middle of another instruction. I undefined and redefined the target location as code, and it disassembled into valid instructions, but they don't appear to do anything. I was wondering if I could get some help making sense of this or if I'm overlooking something.

+ +

Edit: +This jump is an exit point for a loop.

+ +

Source + Bin + IDB file can be found here

+ +

Jump code:

+ +

+ +

Jump target with IDA auto disassembly:

+ +

+ +

Jump target after undefining and redefining 121 as code:

+ +

+",27091,,27091,,1/14/2019 22:00,12/3/2021 12:57,Z80 Absolute Jump to offset in middle of instruction,,2,1,,,,CC BY-SA 4.0 +20367,1,,,1/14/2019 8:16,,1,765,"

Lets suppose I have a very big binary and I want to reverse just a part of this binary.

+ +

Is there a way to tell angr to start symbolic analysis at a given address ?

+",18590,,53,,1/15/2019 14:29,1/15/2019 14:29,Start Symbolic Analysis at a Given Address with Angr,,1,0,,,,CC BY-SA 4.0 +20368,2,,20366,1/14/2019 8:24,,1,,"

without any context we can only guess...

+ +

However jp (hl) was commonly used for:

+ +
    +
  1. jump to pointer

    + +

    this one is obvious hl points to a memory location that you want to jump to. You can do many things with this like for example you want to decide how to handle some input and you got more choices of handlers so you evaluate which to use in hl and at the end just jump to it. The same goes for mode of a program... For example you got more ways of rendering text or something and you want easily switch between them for the whole program ... then simply store the selected routine in some pointer and when needed jump to it...

    + +

    I do not have any context to your code but this is the most likely scenario:

    + +

    286Eh is the selected mode handler, hl read that position using ix and lastly routine jump to it. I am guessing the final ret is in the routine somewhere.

  2. +
  3. call/return to/from subroutine with non standard calling convention

    + +

    sometimes operands are passed to subroutines in non standard ways (not on stack) which prevent to use call or ret directly. In such cases jp (hl) can solve such issues.

    + +

    For example take a look at this x86 example:

    + + + +

    the printl is expecting printed string directly after the call ...

    + +
    call printl
    +db  'SPEKTRA software & hardware',0
    +
    + +

    this spares the input data pointer setting and also its more comfortable as the printed text is directly where it is used (not in some table in data section) also you do not need labels. As you can see the printl can not ret directly to the address stored in stack. Instead it needs to jump after the text which is ideal usage of jp (hl) example (however my x86 code does it differently due to different instruction set).

  4. +
  5. resolve self modify code issues

    + +

    configurable programs do not have static jump/call addresses so jp (hl) can be used for configurable jumps...

  6. +
+ +

Now getting back to jumping into middle of instruction

+ +

This might be or might not be true. If you use disassembler then it does not know where the ORG statement of each code segment is. So it instead translates from start of the file. When you are tracing then it takes the PC as the starting position and translates from it relatively so if you scroll the listing you might got wrongly disassembled other parts of code. However after few continuous single byte instructions the code is aligned again so most of the code would be translated correctly.

+ +

But there are also cases when we deliberately jump to middle of instruction. Sometimes time sensitive code needs exact number of [T] tacts to spend on some routine and jumping in the middle of some instruction can resolve missing [T] states after some conditional behavior.

+",4709,,,,,1/14/2019 8:24,,,,3,,,,CC BY-SA 4.0 +20370,2,,20359,1/14/2019 15:11,,5,,"

I will start by answering your specific three questions, and then will shed more light about the naming structure of functions in radare2.

+ +
+

What is the meaning of the hexadecimal number after the function name?

+
+ +

The meaning of the 3 hexadecimal digits at the end of function names like ""sub.KERNEL32.dll_lstrlenW_2f9"" are the last 3 digits of the function address. The confusion here is because this is not an imported function name, but a regular function. This naming caused by the aan command which you probably used when you executed aaa or opened a file with th -A flag: $ r2 -A <filename>.

+ +

As stated in the radare2 documentation:

+ +
...
+aan                 autoname functions that either start with fcn.* or sym.func.*
+...
+
+ +

The aan command will auto-generate a name, based on the flags being used in the function. This should ease the analysis for the user before analyzing the function.

+ +

So let's have a look at a function which is called sub.KERNEL32.dll_DisableThreadLibraryCalls_18002a860. You can see that an import function called ""DisableThreadLibraryCalls"" is being called. This is why the function was renamed by aan:

+ +
[0x18002a860]> pdf
+╭ (fcn) sub.KERNEL32.dll_DisableThreadLibraryCalls_18002a860 35
+│   sub.KERNEL32.dll_DisableThreadLibraryCalls_18002a860 ();
+│           ; arg unsigned int arg3 @ rdx
+│           0x18002a860      4883ec28       sub rsp, 0x28
+│           0x18002a864      83fa01         cmp edx, 1
+│       ╭─< 0x18002a867      7510           jne 0x18002a879
+│       │   0x18002a869      48833dff1f00.  cmp qword [0x18002c870], 0 ; [0x18002c870:8]=0
+│      ╭──< 0x18002a871      7506           jne 0x18002a879
+│      ││   0x18002a873      ff159f170000   call qword sym.imp.KERNEL32.dll_DisableThreadLibraryCalls 
+│      ╰╰─> 0x18002a879      b801000000     mov eax, 1
+│           0x18002a87e      4883c428       add rsp, 0x28
+╰           0x18002a882      c3             ret
+[0x18002a860]>
+
+ +
+ +
+

Why is the core difference between the prefixes ""sym."" and ""sub."" of DLL function names?

+
+ +

sym stands for ""Symbol"". This is a symbol taken from the binary's Symbol Table. +sub. stands for ""Subroutine"". This can by a standalone function but most likely a part of a function, like JMPTABLE blocks, addresses in pointer table, etc.

+ +
+ +
+

What is the difference between library names in lower or uppercase?

+
+ +

In general, radare2 keeps the case of the libraries as shown in the Import Address Tables. But I think sometimes it is being modified in favor of readability and to make it easier to differentiate between an import function, and a renamed function (aan).

+ +
+ +

ASCII-ART Time

+ +

I made some ASCII-arts for you, hope this would make things clearer.

+ +

Regular Function

+ +
fcn.77cce259
+|      |
+|      |__ The function's address
+|
+|__ stands for ""Function""
+
+ +

Imported function

+ +
sym.imp.KERNEL32.dll_LocalAlloc
+ |   |     |            |
+ |   |     |            |__ The imported function name, ""LocalAlloc""
+ |   |     |
+ |   |     |__ the Library name. In this case, ""kernel32.dll""
+ |   |
+ |   |
+ |   |___ ""Import"", this is an imported function
+ |
+ |___ ""Symbol"", taken from the Symbol Table
+
+ +

Auto-Generated Name

+ +
sub.ntdll.dll_RtlNtStatusToDosError_13c
+ |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ |                   |
+ |                   |__ auto-generated name based on flags that being used
+ |                       the 3 digits at the end are the function's address
+ |__ ""Subroutine""
+
+",18698,,,,,1/14/2019 15:11,,,,2,,,,CC BY-SA 4.0 +20371,1,,,1/14/2019 17:33,,2,1065,"

When I do dynamic analyze of exe file I have few option , and I want to know what are the advantages and disadvantages.

+ +

I know that Ida designated for static analyze , but there are some debugger in Ida and lot of time I do dynamic analyze with those debuggers

+ +
    +
  1. When I choose Ida I can choose between Win32 debugger or WinDbg debugger, what is the difference ?

  2. +
  3. What is the difference between debug with Ida and debug with OllyDbg?

  4. +
+",26837,,,,,1/14/2019 22:25,Debugger Win32 Local vs WinDbg in Ida vs Ollydbg,,1,0,,,,CC BY-SA 4.0 +20372,1,20420,,1/14/2019 21:38,,0,87,"

I'm a bit confused about what ""system"" refers to when looking at the callstack in x64dbg. Does it mean the code is currently being executed in ring0? I thought that only system calls are executed in ring0? (Which would mean that only code in ntdll would be executed by the system?) The word system seems to appear next to functions in user32 etc. Any help in correcting my misunderstanding would be very much appreciated. Thanks a bunch

+",22004,,,,,1/19/2019 18:43,"x64dbg ""System"" meaning",,1,0,,,,CC BY-SA 4.0 +20373,1,,,1/14/2019 22:07,,2,493,"

I am asking here hoping that someone may have experience identifying these kind of old chips. Googling the reference just shows some forums with people in same situation as me.

+ +

IC reference: 25072478 REV D +

+ +

This is an Opel LCD dashboard design from the mid 80s. So the chip should have been available at that time.

+ +

8 of the pins are connected to the main controller, which is a known part: +SAB80515 +

+ +

I am also trying to get at least a part of the board schematic.

+ +

Thank you.

+ +

EDIT 1: The chips connects this way, I have to check the other pins left blank at the moment.

+ +

+",27102,,27102,,1/15/2019 22:12,2/14/2019 23:03,Help to identify unknown IC from Microchip,,1,0,,,,CC BY-SA 4.0 +20374,2,,20362,1/14/2019 22:12,,2,,"

The MX25U1635E is designed for 1.8 volt logic, whereas your programmer is designed for 3.3 or 5.0 volt logic. You're going to need a 1.8 volt adapter for the programmer or you will damage the MX25U1635E.

+ +

If you google CH341A 1.8 volt adapter, you can find them for relatively cheap.

+",27091,,,,,1/14/2019 22:12,,,,3,,,,CC BY-SA 4.0 +20375,2,,20371,1/14/2019 22:25,,3,,"
    +
  1. Win32 debugger is IDA's internal debugger, whereas WinDbg is Microsoft's debugger. They both effectively do the same thing. IDA's debugger is probably better integrated with IDA.

  2. +
  3. I'm going to make a recommendation here to use x64dbg. Ollydbg is outdated and unsupported. IDA's debugger works but the interface is clunky and isn't as easy to use as x64dbg. Plus if IDA's debugger crashes, you risk corrupting your IDA database. If x64dbg crashes you don't lose anything except a few minutes of time.

  4. +
+",27091,,,,,1/14/2019 22:25,,,,1,,,,CC BY-SA 4.0 +20376,2,,20373,1/14/2019 22:33,,1,,"

The small chip is probably a one off chip made for whoever manufactured this board. Your best best bet is examining what the pins connect to and analyzing what they may do. Since its a one off chip the chance of finding a datasheet is slim to none.

+ +

The big chip is a variation of the Intel 8051 which is common in 80's car technology. The datasheet can be found here.

+",27091,,,,,1/14/2019 22:33,,,,1,,,,CC BY-SA 4.0 +20377,2,,20353,1/14/2019 22:38,,0,,"

Open your IDA installation folder open plugins\defs.h, this file contains all of the macros used by the hexrays decompiler. It can also be found at the github in arman's answer.

+",27091,,,,,1/14/2019 22:38,,,,0,,,,CC BY-SA 4.0 +20380,2,,20367,1/15/2019 8:05,,3,,"

There sure is.

+ +
p = angr.Project(""target_binary"")
+state = p.factory.blank_state(addr=0x400770)
+
+ +

I strongly recommend reading the State Presets section of the docs for more information. Crucially, all of the state preset constructors can take the addr argument; depending what you're doing, there may be a better preset to use than blank_state.

+ +

Further resources:

+ +

API docs

+ +

Examples from the angr team that include starting analysis at a specific address:

+ + +",18563,,18563,,1/15/2019 8:12,1/15/2019 8:12,,,,1,,,,CC BY-SA 4.0 +20381,1,,,1/15/2019 9:08,,1,661,"

In Ida when I use debugger, but I can't step back.

+ +

Is there any debugger that allow go backwards?

+",27108,,53,,1/15/2019 9:28,1/15/2019 9:28,Is there any debugger that supports step-back?,,1,1,,1/15/2019 12:28,,CC BY-SA 4.0 +20382,2,,20381,1/15/2019 9:27,,1,,"

In general, stepping back for a debugger is a hard problem. gdb has a limited step back feature but it comes with a cost, see here.

+ +

But, when you think about it, the whole difficulty solved by the programmer when debugging is to step-back until it reach the bug. This is the whole difficulty and we do not have a nice and automated solution for it right now.

+",53,,,,,1/15/2019 9:27,,,,0,,,,CC BY-SA 4.0 +20384,1,,,1/15/2019 16:45,,5,1166,"

I would like to use Radare2 to learn about how C is assembled into assembly but I am having trouble with the layout. I think the V! mode would be very handy as you can watch the registers update as the instruction pointer moves through the program, but I don't understand the layout.

+ +

This is an example of they layout I would like: +

+ +

It seems when I add a window (like Stack or Registers in this photo) it appears offscreen and I have to try closing different and splitting windows until the layout kind of falls into place. Is there an easy way to change exactly what is in each window?

+ +

I know 'X' closes a window, 'z' switches the current window to the front, and '-' / '|' split a window.

+ +

I have tried looking at the help but can't seem to figure out any other commands related to this issue.

+",27110,,28285,,4/30/2019 7:24,4/30/2019 7:24,Radare2 Disassembler How Do You Organize Visual Panels (V!)?,,1,1,,,,CC BY-SA 4.0 +20387,1,,,1/15/2019 20:18,,1,1394,"

This is assembly code that can catch debugger with int 3 :

+ +
MOV ECX, ExceptionHandler
+
+MOV DWORD PTR FS:[0], ExceptionHandler
+
+INT3
+      ///there is debugger!!!
+
+ExceptionHandler:
+       ////no debugger
+
+ +

When programmer write a C program , which code he write that compile to this trap?

+ +

I use Windows with x86

+",26837,,26837,,1/16/2019 17:09,1/16/2019 19:55,How int3 looks like in C,,1,4,,,,CC BY-SA 4.0 +20388,1,20391,,1/16/2019 10:17,,0,216,"

Let's say we have this simple ""hello world"" nasm code that will be compiled to an ELF executable:

+ +
global main
+
+section .data
+    message db ""Hello World!"", 0x00
+
+section .text
+
+main:
+    call    hello
+    ret
+
+hello:
+    lea     rdi, [rel message]
+    call    puts
+    ret
+.end:
+
+ +

Is it possible to add a label called decrypt into the compiled ELF executable and then subsequently call it (with/without the source code)?

+ +
global main
+
+section .data
+    message db ""Hello World!"", 0x00
+
+section .text
+
+main:
+    call    decrypt                              <---------------Addition
+    call    hello
+    ret
+
+decrypt:                                         <---------------Addition
+    DECRYPTOR_SECTION hello, hello.end-hello     <---------------Addition
+    ret                                          <---------------Addition
+
+hello:
+    lea     rdi, [rel message]
+    call    puts
+    ret
+.end:
+
+",27117,,,,,1/19/2019 6:08,"Is it possible to add a label to an ELF executable and then call that label? If so, how?",,1,1,,,,CC BY-SA 4.0 +20389,2,,20384,1/16/2019 10:31,,6,,"

Use TAB to move between the windows, use e to change name and command of a specific panel you are on. Use w to enter the window mode. ""Window mode"" allows you to control how the panels look like. In window-mode you can use HJKL to resize the window's height and width.

+ +

This should answer your question ""Is there an easy way to change exactly what is in each window?"". Because you can simply select a panel and use e to change its content :)

+ +

Don't forget to use ? in the different visual screens to get more help

+",18698,,,,,1/16/2019 10:31,,,,0,,,,CC BY-SA 4.0 +20391,2,,20388,1/16/2019 13:17,,0,,"

I am not sure what your intent is.

+ +

If you mean you have to add a function and call it before main after the source is compiled, then yes it is definitely possible. All you have to do is run through some hoops like finding a code cave, assembling the new code in code cave, and detouring the first instruction of main to call your new function and return back to main's next instruction.

+ +

If you mean I want the function to be sequential then it might be possible if you can destroy and recreate the assembly in-place (kinda tough).

+ +

And no there is no label you need to calculate relative address / absolute address of the newly added function and use one form of e8 or ff25 call

+ +

Having source can help you in understanding the assembly but you have to play in assembly only if you have to patch a compiled executable.

+ +

A program prior to addition of encrypt proc will look like this (a simple msgbox in windows notice both caption and text are pointing to a string which is unintelligible)

+ +

+ +

You may need to implement the commented out source code inline for decrypting

+ +
.386
+.model flat, stdcall
+option casemap:none
+include \masm32\include\windows.inc
+include \masm32\include\kernel32.inc
+includelib kernel32.lib
+include \masm32\include\user32.inc
+includelib user32.lib
+
+.data
+Encrypted   db 217,243,234,245,252,249,255,254,183,227,176,228,229
+            db 228,255,226,249,241,252,176,254,255,190,162,144
+
+.code
+start:
+    ;call decrypt
+    call hello
+    invoke ExitProcess,NULL
+
+; decrypt proc
+    ; xor ecx,ecx
+    ; complete:
+    ; lea esi , Encrypted 
+    ; add esi,ecx
+    ; movzx eax , byte ptr ds:[esi]
+    ; xor eax ,090h
+    ; mov byte ptr ds:[Encrypted + ecx], al
+    ; add ecx,1
+    ; cmp byte ptr ds:[Encrypted + ecx - 1 ],0
+    ; jne complete
+    ; ret
+; decrypt endp
+
+
+hello proc
+    invoke MessageBox, NULL,addr Encrypted, addr Encrypted, MB_OK
+    ret
+hello endp 
+
+end start
+
+ +

After you implement your decrypt proc some where in existing free space (called code cave) it may look like this

+ +

Now you have to destroy the first call jmp here decrypt +add the code that you destroyed and jump back to the next correct sequential instruction post the destroyed code

+ +
CPU Disasm
+Address       Command                                            Comments
+00152000      XOR     ECX, ECX
+00152002      /LEA     ESI, [154000]
+00152008      |ADD     ESI, ECX
+0015200A      |MOVZX   EAX, BYTE PTR DS:[ESI]
+0015200D      |XOR     EAX, 00000090
+00152012      |MOV     BYTE PTR DS:[ECX+154000], AL
+00152018      |ADD     ECX, 1
+0015201B      |CMP     BYTE PTR DS:[ECX+153FFF], 0
+00152022      \JNE     SHORT 00152002
+00152024      RETN
+
+",3473,,,user12114,1/19/2019 6:08,1/19/2019 6:08,,,,2,,,,CC BY-SA 4.0 +20393,2,,20387,1/16/2019 19:55,,2,,"
#include <stdio.h>
+#include <windows.h>
+#include <intrin.h>
+void main (void) 
+{
+    __try 
+    {
+        __debugbreak();
+    } 
+    __except( GetExceptionCode() == 
+        EXCEPTION_BREAKPOINT ? EXCEPTION_EXECUTE_HANDLER :EXCEPTION_CONTINUE_SEARCH ) 
+    {
+        printf(""executed out of debugger\n"");
+        exit(1);
+    }
+    printf(""executed inside debugger\n"");
+    exit(2);
+}
+
+ +

disassembly of main() without handler

+ +
0:000> uf .
+int3!main [xxx\int3.cpp @ 6]:
+    6 01381000 55              push    ebp
+    6 01381001 8bec            mov     ebp,esp
+    6 01381003 6afe            push    0FFFFFFFEh
+    6 01381005 68d0573c01      push    offset int3!__rtc_tzz+0x8 (013c57d0)
+    6 0138100a 6820213801      push    offset int3!_except_handler4 (01382120)
+    6 0138100f 64a100000000    mov     eax,dword ptr fs:[00000000h]
+    6 01381015 50              push    eax
+    6 01381016 83c4f0          add     esp,0FFFFFFF0h
+    6 01381019 53              push    ebx
+    6 0138101a 56              push    esi
+    6 0138101b 57              push    edi
+    6 0138101c a104703c01      mov     eax,dword ptr [int3!__security_cookie (013c7004)]
+    6 01381021 3145f8          xor     dword ptr [ebp-8],eax
+    6 01381024 33c5            xor     eax,ebp
+    6 01381026 50              push    eax
+    6 01381027 8d45f0          lea     eax,[ebp-10h]
+    6 0138102a 64a300000000    mov     dword ptr fs:[00000000h],eax
+    6 01381030 8965e8          mov     dword ptr [ebp-18h],esp
+    7 01381033 c745fc00000000  mov     dword ptr [ebp-4],0
+    9 0138103a cc              int     3
+   10 0138103b c745fcfeffffff  mov     dword ptr [ebp-4],0FFFFFFFEh
+   10 01381042 eb45            jmp     int3!main+0x89 (01381089)
+
+int3!main+0x89 [xxx\int3.cpp @ 17]:
+   17 01381089 68bce13b01      push    offset int3!__xt_z+0x2c (013be1bc)
+   17 0138108e e85d000000      call    int3!printf (013810f0)
+   17 01381093 83c404          add     esp,4
+   18 01381096 6a02            push    2
+   18 01381098 e8dec00100      call    int3!exit (0139d17b)
+   0:000> da 13be1bc
+   013be1bc  ""executed inside debugger.""
+
+ +

handler will be called if there is no debugger

+ +
:\>int3.exe
+executed out of debugger
+
+:\>cdb  -g -c ""g;q"" int3.exe  | grep -i executed
+executed inside debugger
+
+:\>
+
+",3473,,,,,1/16/2019 19:55,,,,0,,,,CC BY-SA 4.0 +20394,2,,283,1/17/2019 4:00,,4,,"

Another option is Fireye's Windows-based Flare VM.

+ +

Unlike the Linux-based examples on this page, Flare VM only provides an installer script, not the VM itself. Fortunately, you can get a free Windows VM straight from Microsoft.

+ +

Their GitHub page has the full (very long) list of tools; here is a snippet:

+ +
+

Debuggers

+ +
    +
  • flare-qdb
  • +
  • scdbg
  • +
  • OllyDbg + OllyDump + OllyDumpEx
  • +
  • OllyDbg2 + OllyDumpEx
  • +
  • x64dbg
  • +
  • WinDbg + OllyDumpex + pykd
  • +
+ +

Decompilers

+ +
    +
  • RetDec
  • +
  • Jd-gui and bytecode-viewer
  • +
  • dnSpy
  • +
  • IDR
  • +
  • VBDecompiler
  • +
  • Py2ExeDecompiler
  • +
+ +

Disassemblers

+ +
    +
  • IDA Free (5.0 & 7.0)
  • +
  • Binary Ninja Demo
  • +
  • Radare2 + and Cutter
  • +
+
+",18563,,18563,,1/17/2019 13:18,1/17/2019 13:18,,,,0,,,,CC BY-SA 4.0 +20395,1,20399,,1/17/2019 4:24,,0,463,"

To be specific, I cannot recompile this binary, nor do I have access to the sourcecode.

+ +

The functions are not defined within a shared library.

+ +

So, how can I go about changing a function, or preferably detouring it to a new function?

+ +

And if it's possible, use dlsym/dlopen to get my new modified code from a shared library, so I don't have to edit the binary by hand every time I want to change something.

+ +

Oh, one more thing, editing the actual binary is something I can do/I have access to.

+ +

And just for extra info, I have Radare2 installed, as well as GDB with pwndbg, so any solutions using those tools, or builtin GNU/Linux debugging tools would be appreciated.

+ +

EDIT:

+ +

I am a beginner to reverse engineering things, but not to the point I have zero idea what I'm doing.

+",27126,,,,,1/21/2019 18:38,How do I go about overriding a function internally defined in a binary on Linux?,,1,4,,,,CC BY-SA 4.0 +20396,2,,12054,1/17/2019 4:24,,3,,"

As mentioned here, IDArling was released recently and is still being actively maintained (last commit was just over a week ago). Notably, it also won the 2018 IDA Plugin Contest.

+

EDIT July 2021 +From the IDArling README:

+
+

This project is no longer under active development and the more featured and up-to-date fork is probably something more interesting for new comers. Also, IDA has announced an official support for collaborative reverse engineering session and one could also wait for this.

+
+

EDIT June 2022

+

IDA Teams is now in beta.

+",18563,,18563,,6/25/2022 15:01,6/25/2022 15:01,,,,0,,,,CC BY-SA 4.0 +20397,2,,11621,1/17/2019 10:02,,6,,"

COERCE_TYPE(x) is the same thing as *(TYPE *)&x. Hex-Rays uses COERCE_... macros when &x is illegal. For example:

+ +
COERCE_DOUBLE(__PAIR__(i1,i2))
+
+ +

Is the same as *(double *)&__PAIR__(i1, i2), but since & can not be applied to calls, we end up seeing COERCE.

+ +

Its name correctly conveys its meaning.

+",27130,,53,,1/17/2019 16:15,1/17/2019 16:15,,,,1,,,,CC BY-SA 4.0 +20399,2,,20395,1/17/2019 15:26,,2,,"

You have several options here, but I like this one.

+ +

Since the code is already inside the executable, so you have to patch the entrypoint to jump to a new function. +To do so, I suggest to use a shared object (.so). In this module you will both: the new function and a 'patcher function'. The latter function must be defined with __attribute__((constructor)), this attribute will force the ELF loader to call this function before the main function from your original executable is called.

+ +

The patcher function will set write access at the entrypoint of the old function with mprotect (2), encode the jump instruction, and it's probably better to remove the write access you needed for the patch.

+ +

Once you have your shared object, you can inject it using the LD_PRELOAD variable.

+ +

Edit with an example, since you didn't mentioned the architecture, I assumed this is for x86-64:

+ +

First this is a target, we want to change the function my_rand to return 0xdeadbeef.

+ +
#include <stdlib.h>
+#include <stdio.h>
+#include <time.h>
+
+int my_rand(void)
+{
+        srand(time(NULL));
+        return rand() + rand() ^ rand();
+}
+
+int main(void)
+{
+        printf(""random value: %08x\n"", my_rand());
+}
+
+ +

To find the RVA, we can use nm because we have the symbol. You might have to find it manually.

+ +
nm target|grep my_rand
+0000000000001169 T my_rand
+
+ +

Finally, the code of the patcher:

+ +
#include <sys/mman.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <link.h>
+
+static int new_random(void)
+{
+        return 0xdeadbeef;
+}
+
+static void emit_jump_to_address(uint64_t address, uint64_t jump_destination)
+{
+        long page_size = sysconf(_SC_PAGESIZE);
+        void* aligned_address = (void*)(address & ~(page_size - 1));
+        if (mprotect(aligned_address, page_size, PROT_READ|PROT_WRITE|PROT_EXEC) < 0)
+        {
+                perror(""mprotect"");
+                return;
+        }
+        *(uint16_t*)(address + 0x0) = 0xb848;           // mov rax, Iv
+        *(uint64_t*)(address + 0x2) = jump_destination; // mov rax, jump_destination
+        *(uint16_t*)(address + 0xa) = 0xe0ff;           // jmp rax
+        if (mprotect(aligned_address, page_size, PROT_READ|PROT_EXEC) < 0)
+        {
+                perror(""mprotect"");
+                return;
+        }
+}
+
+// ref: https://stackoverflow.com/questions/19451791/get-loaded-address-of-a-elf-binary-dlopen-is-not-working-as-expected
+uint64_t get_image_base(void)
+{
+        struct link_map* lm = dlopen(NULL, RTLD_NOW);
+        return (uint64_t)lm->l_addr;
+}
+
+__attribute__((constructor)) void patcher(void)
+{
+        uint64_t target;
+
+        target = get_image_base();
+        target += 0x1169; // RVA
+        printf(""[!] targeted function is at %p\n"", (void const*)target);
+        printf(""[!] new function is at %p\n"", (void const*)&new_random);
+        emit_jump_to_address(target, (uint64_t)&new_random);
+}
+
+ +

This source code was compiled with clang and injected using LD_PRELOAD:

+ +
$ clang patcher.c  -o patcher.so -shared -ldl
+$ env LD_PRELOAD=./patcher.so ./target
+[!] targeted function is at 0x7fe05f907169
+[!] new function is at 0x7fe05f8c11f0
+random value: deadbeef
+
+ +

Note, I'm using fish, so the env is required.

+",26176,,26176,,1/21/2019 18:38,1/21/2019 18:38,,,,4,,,,CC BY-SA 4.0 +20401,1,20406,,1/17/2019 16:20,,0,185,"

After clicking a button or doing anything which might generate a message to be translated and dispatched, why is that the callstack might not show the message handler?

+ +

Say I am reversing an application, I hit the Ok button and then it generates a window. Pausing the application after that window is generated should show the message handler in the call stack right? I see a callstack with one of the last entries being the message loop itself (get translate and dispatch) but I don't see the callback function. Should I just try and go through dispatchmessage to get the message handler? Is there some resource which tells me where exactly the messagehandler is in dispatchmessage?

+",22004,,,user12114,1/19/2019 11:26,1/19/2019 11:26,The callstack does not show the message handler,,1,0,,,,CC BY-SA 4.0 +20402,1,,,1/17/2019 16:49,,1,158,"

There are lot of crack me site.

+ +

I looking for site that have lot of hard crack me/ malware to research anti debug/anti vm... but with full solution

+",23993,,53,,1/17/2019 19:59,1/17/2019 19:59,Looking for crackme with full solutions,,0,2,,1/18/2019 0:13,,CC BY-SA 4.0 +20403,1,,,1/17/2019 19:31,,7,536,"

I am looking for journals to keep track of the latest advances in reverse engineering, binary analysis, malware, binary exploitation, etc.

+",26363,,53,,1/17/2019 20:00,6/25/2022 15:22,Academic journals for latest RE/Malware/Exploitation research?,,3,2,,,,CC BY-SA 4.0 +20404,2,,20403,1/17/2019 19:58,,5,,"

You have a few academic workshops and conferences about the topic (or close to the topic). But, most of them are appearing and disappearing quite often unfortunately. So, it is difficult to come with a long lasting list of conferences. Anyway, here is an attempt:

+ +

Still Alive Conferences

+ +
    +
  • RAID (International Symposium on Research in Attacks, Intrusions and Defenses) (21 years old)
  • +
  • Journal of Computer Virology and Hacking Techniques (Springer) (15 years old)
  • +
  • WOOT (Workshop on Offensive Technologies) (12 years old)
  • +
  • SSPREW (Software Security, Protection, and Reverse Engineering / Software Security and Protection Workshop) (8 years old)
  • +
  • CODASPY (ACM Conference on Data and Application Security and Privacy) (8 years old)
  • +
  • BotConf (Botnet fighting Conference) (6 years)
  • +
  • EuroS&P (IEEE European Symposium on Security and Privacy) (4 years old)
  • +
  • ROOTS (Reversing and Offensive-oriented Trends Symposium) (2 years old)
  • +
+ +

Discontinued Conferences

+ +
    +
  • WCRE (Working Conference on Reverse Engineering)
  • +
  • SPRO (Workshop on Software PROtection)
  • +
+ +

These lists are definitely non-exhaustive, so feel free to tell me if I forget something!

+",53,,,,,1/17/2019 19:58,,,,0,,,,CC BY-SA 4.0 +20405,2,,20403,1/17/2019 19:59,,7,,"

This is an indirect answer to your question, but hopefully still useful. There are multiple conferences that feature state-of-the-art work in this space. If anyone knows of more, feel free to add on to this list.

+

(links are to the archives of the conferences, whenever possible)

+ +

There are of course the juggernauts: DEF CON (full media archive, YouTube playlists of talks) and Black Hat (site archive with slides + white papers, YouTube playlists of talks). Neither is exclusively focused on what you asked about, but they both have plenty of good content on these topics.

+

Bonus: PoC||GTFO is a completely different style of research than any conference listed above, but it's full of great information and is lots of fun to read.

+

Bonus 2: InfoCon is the best archive of hacking conference content that exists.

+
+

InfoCon is a community supported, non-commercial archive of all the past hacking related convention material that can be found.

+
+",18563,,18563,,6/25/2022 15:22,6/25/2022 15:22,,,,1,,,,CC BY-SA 4.0 +20406,2,,20401,1/17/2019 20:45,,3,,"

prototype of DispatchMessage() is

+ +
LRESULT DispatchMessage(
+  const MSG *lpMsg
+);
+
+ +

it takes only a pointer to struct MSG which has a hwnd as its first

+ +
typedef struct tagMSG {
+  HWND   hwnd;
+  UINT   message;
+  WPARAM wParam;
+  LPARAM lParam;
+  DWORD  time;
+  POINT  pt;
+  DWORD  lPrivate;
+} MSG, *PMSG, *NPMSG, *LPMSG;
+
+ +

this hwnd is validated and the appropriate callback is called by internal functions of +user32.dll and comctl32.dll

+ +

you can get the window proc in the handles window in x64dbg

+ +

here is a screenshot of windows calc.exe paused at a breakpoint in user32.DispatchMessageW()

+ +

+ +

you can get the hwnd parameter by looking at the stack +with log {x:[[esp+4]]} +and following it up in handles window the screenshot shows the hwnd in status bar +command in command window and the window proc in handles window

+ +

+ +

setting a breakpoint on the proc and hitting f9 will land us in the windowproc

+ +
Address   To        From      Size      Comment        
+0012EFB4  770C5F9F  00631EDE  78        calc.00631EDE
+0012F02C  770C4F0E  770C5F9F  5C        user32._GetRealWindowOwner@4+54
+0012F088  770C4F7D  770C4F0E  28        user32._DispatchClientMessage@20+4B
+0012F0B0  777B702E  770C4F7D  74        user32.___fnDWORD@4+24
+0012F124  770CCC70  777B702E  10        ntdll.777B702E 
+0012F134  00631CAC  770CCC70  D70       user32._DispatchMessageW@4+F
+0012FEA4  0064219A  00631CAC  90        calc.00631CAC 
+0012FF34  7748ED6C  0064219A  C         calc.0064219A
+0012FF40  777D37EB  7748ED6C  40        kernel32.7748ED6C 
+0012FF80  777D37BE  777D37EB  18        ntdll.777D37EB
+0012FF98  00000000  777D37BE            ntdll.777D37BE 
+
+",3473,,,,,1/17/2019 20:45,,,,0,,,,CC BY-SA 4.0 +20407,2,,20403,1/18/2019 5:51,,2,,"

There is also malware conference which has been running since at least 2011. +https://www.malwareconference.org/

+",2954,,,,,1/18/2019 5:51,,,,0,,,,CC BY-SA 4.0 +20409,1,,,1/18/2019 10:30,,3,4556,"

In IDA, when I want to see the address of code, I must switch to Text view.

+

How can I see the address of code in Graph view?

+

By the way, is there Graph view in OllyDbg?

+",26837,,60,,2/14/2022 18:52,2/14/2022 18:52,How to see addresses in Graph view in IDA,,1,1,,,,CC BY-SA 4.0 +20410,1,,,1/18/2019 10:59,,1,102,"

This is the example code:

+ +
_start:
+LDR r0, =n
+LDR r0, [r0]
+LDR r1, =array1
+MOV r2, #0
+LDR r4, =array2
+loop:
+LDR r3, [r1], #4
+CMP r3, #58
+BGT a_point
+CMP r3, #47
+BLT a_point
+SUB r3, r3, #0x30
+STR r3, [r4], #4
+
+a_point:
+    subs r0, r0, #1
+    BGT loop
+
+stop:
+    b stop
+
+.Data
+n: .word 6
+array1: .word 0x30, 0xFFFFFFF5, 0x37, 0x4b, 0x18, 0x40
+array2: .word 0x01, 0x0, 0x0, 0x0, 0x0, 0x0
+
+ +

I'm having trouble understanding how the loop works, what it does and specifically how the branch instruction work on pair with the -lt and -gt suffixes. What is the purpose of this simple program? Thanks in advance for your help.

+",27140,,,,,1/18/2019 10:59,"Help understanding ARM Assembly example code - loops, set flags and code mnemonics",,0,4,,,,CC BY-SA 4.0 +20411,1,20413,,1/18/2019 11:01,,0,3567,"

How can I set a conditional breakpoint based on the argument of a function?

+ +

I am trying to break on the windows function LoadLibraryExW: https://docs.microsoft.com/en-us/windows/desktop/api/libloaderapi/nf-libloaderapi-loadlibraryexw

+ +

I want to break on this function only when the first argument (lpLibFileName) is equal to L""Test.dll"". When I break on the function I can see that L""Test.dll"" is esp+4.

+ +

I've tried a few different variations without success. They either break on every LoadLibraryExW calls or none. Variations like:

+ +
Break Condiditon: [esp+4]==L""Test.dll""
+Break Condition: esp+4==L""Test.dll""
+etc..
+
+ +

What is the proper way of setting a conditional breakpoint based on function arguments? Or register offsets?

+",19294,,,,,1/18/2019 22:55,x64dbg - Conditional breakpoint based on function argument,,1,2,,,,CC BY-SA 4.0 +20412,2,,20409,1/18/2019 14:47,,8,,"

Switch to graph mode, then go to menu Options-General, Disassembly tab and enable

+ +
    +
  • [x] Line Prefixes (graph)
  • +
+ +

Other disassembly options : https://www.hex-rays.com/products/ida/support/idadoc/605.shtml.

+ +

You can also check the status bar, it displays the current address.

+",60,,,,,1/18/2019 14:47,,,,0,,,,CC BY-SA 4.0 +20413,2,,20411,1/18/2019 21:19,,0,,"

As commented by @mrexodia you can set a DLL breakpoint

+ +
Typ Address  Module/La State   Disassembly H Summa
+DLL                               
+    76850000 gdi32.dll Enabled  0 all()
+
+ +

Go to breakpoint window (alt+b) -> Right Click Add Dll BreakPoint

+ +

Type test.dll

+ +

This will break when test.dll is loaded

+ +

String compare as such isn't yet implemented. A bug report exists from 2017 and a workaround exists which states using a third party plugin
+which you can check out.

+ +

Or simply split the string into bytes and compare the bytes +like

+ +
Type     Address  Module/Label/Exception     State   Disassembly H Summary                                                                                         
+Software                                                           
+         76ACE8A5 <kernel32.dll.CreateFileW> Enabled mov edi,edi 5 breakif((1:[[esp+4]+0xc] == 66) &&  (1:[[esp+4]+0xe] == 69)), log(""brk hit   { 1:[[esp+4]+c] }"")
+
+ +

+ +

x64dbg has broken when file testmefive.txt was opened for source code below with above byte compare method

+ +
#include <stdio.h>
+
+int main(void)
+{
+    char *filenames[] = {
+        ""testmeone.txt"",
+        ""testmetwo.txt"",
+        ""testmethree.txt"",
+        ""testmefour.txt"",
+        ""testmefive.txt""};
+    for (int i = 0; i < 5; i++)
+    {
+        FILE *fp = NULL;
+        errno_t err = fopen_s(&fp, filenames[i], ""r"");
+        if (err == 0 && fp != 0)
+        {
+            char buff[0x50] = {0};
+            fread_s(buff, 0x50, 1, 0x50, fp);
+            printf(""%s\n"", buff);
+            fclose(fp);
+        }
+    }
+}
+
+",3473,,,user12114,1/18/2019 22:55,1/18/2019 22:55,,,,0,,,,CC BY-SA 4.0 +20414,1,,,1/18/2019 23:34,,2,421,"

I have a 2 MB executable that I'm attempting to reverse engineer. It's executed on a 16-bit 8086 CPU.

+ +

The segments go from 4000 (0x140000) to F000 (0x1F0000).

+ +

I'm attempting to map the segments in the Program Segmentation window, but when doing so, addresses for call / jump operations fail to resolve when converting the entrypoint to code.

+ +

Taking the final segment as an example, I set the Start Address to 0x1F0000, and the End Address to 0x200000. I set the base to 0xF000, as this is how it's referred to in the machine code.

+ +

I do the same with the other segments, including the problem segment (0xD000 -> 0x1D0000).

+ +

When converting to code, the resulting line is resolved as follows:

+ +
jmp far ptr 0D000h:1Ah
+
+ +

This is as expected, jumping to segment 0xD000, with an offset of 0x1A, however IDA is not happy with this, complaining about it with the NONAME and BOUNDS errors.

+ +

I have no idea how to properly map this in IDA. Can someone point me in the right direction?

+ +

[edit]

+ +

For reference, I already have the full list of segments I want to map along with their binary addresses:

+ +

2000:0x1F0000

+ +

3000:0x1F0000

+ +

4000:0x140000

+ +

5000:0x150000

+ +

6000:0x160000

+ +

7000:0x170000

+ +

8000:0x180000

+ +

9000:0x190000

+ +

A000:0x1A0000

+ +

B000:0x1B0000

+ +

C000:0x1C0000

+ +

D000:0x1D0000

+ +

E000:0x1E0000

+ +

F000:0x1F0000

+",27146,,27146,,1/19/2019 11:35,1/21/2019 7:07,Unable to figure out how to map segments in IDA,,0,7,,,,CC BY-SA 4.0 +20417,1,,,1/19/2019 15:18,,1,440,"

I'm attempting to reverse engineer a private API used by an Android app that makes use of WebSockets. These requests are made from JavaScript inside a WebView.

+ +

I use Charles to intercept both HTTP and WebSocket requests, with it I'm able to see how the app successfully connects and speaks to the API with WebSockets. +The API uses cookies to authorize connections, the cookies responsible for it are ""ts.default"" and ""ts.default.sig"".

+ +

This is how the request looks in Charles:

+ +

+ +

My goal is to be able to speak with the API from a Python script. However, when making the same Upgrade request, making sure to keep all relevant headers, I get a 401 Unauthorized status code:

+ +

+ +

I've uploaded the relevant JavaScript code responsible for such requests here.

+ +

I'm not very proficient with WebSockets and seeing how I've been stuck here for the past few hours I thought maybe someone here could be able to spot what I'm missing.

+",27153,,27153,,1/19/2019 18:37,1/19/2019 18:37,"WebSocket debugging in Javascript app gives ""401 Unauthorized""",,1,0,,1/29/2019 22:42,,CC BY-SA 4.0 +20418,1,,,1/19/2019 17:25,,1,662,"

When I looking on Ida with static analyze I see that buffer pass to function/ function fill data in buffer.

+ +

How can I know if this buffer allocate in stack/ heap?

+",23993,,23993,,1/19/2019 19:57,3/22/2019 1:00,How to identify if buffer allocate on stack or heap?,,2,0,,,,CC BY-SA 4.0 +20419,2,,20417,1/19/2019 17:57,,1,,"

Ok, I figured it out. The websocket-client library I use for python writes its own Origin header by default and I was ending up with two Origin headers, which may have been tipping off the server.

+ +

I found out you can disable it by adding supress_origin=True when calling connect on the WebSocket.

+",27153,,,,,1/19/2019 17:57,,,,0,,,,CC BY-SA 4.0 +20420,2,,20372,1/19/2019 18:43,,1,,"

It simply means that the location of the module is inside a “system” directory (c:\windows). For example kernel32.dll is a system module and your debuggee is usually a user module.

+",2221,,,,,1/19/2019 18:43,,,,0,,,,CC BY-SA 4.0 +20421,2,,20418,1/19/2019 18:49,,1,,"

If it's address is above or equal to the stack pointer (esp/rsp), it's on the stack
+otherwise, it's on the heap or was on a previous stack-frame (and now is out of scope and should not be used)

+ +

If you want to know but just looking at the address: if the address starts with 0x7f, it's on the stack.
+That might not always be right though, a program can control the value of the stack pointer and can decide to change it (not likely but feasible)

+",,user22970,,,,1/19/2019 18:49,,,,1,,,,CC BY-SA 4.0 +20422,1,,,1/19/2019 19:54,,1,367,"

So I have an installed application on my Android phone and it stores some data in an password protected SQLite database in the /data/data//databases/ folder. I used adb shell to move the database to my PC and unlocked it, modified some data and then moved it back to it's original location. However, when I run the application it keeps crashing and throw SQLiteExceptions ""Couldn't open database"".

+ +

If I remove the modified database and restart the application everything works fine and a new, empty database is created, as expected. But if I move that database to another location and then move it back the application crashes and give the same exceptions again, even though the database isn't modified.

+ +

Why can't I move around the database without making the application unable to read it? I would really appreciate some help here!

+",27157,,27157,,1/22/2019 18:41,2/16/2020 22:01,Android application can't open pasted SQLite database,,1,2,,,,CC BY-SA 4.0 +20423,1,,,1/20/2019 6:46,,3,1749,"

I am trying to decompile a dylib called libConfigurer64.dylib, which is loaded from the environment variable ""DYLD_INSERT_LIBRARIES""

+ +

I want to analyze what it really does, so I dragged it in to IDA, and found that it exported ""_sub_06adf"",""_sub_06bdf"",""InitFunc_0""

+ +

In _sub_06adf:

+ +
db 'VfhT2zwxQpLeHRL6j4Oe4mrsmrjEAW',0
+align 10h
+
+ +

In _sub_06bdf

+ +
db '(c) 2014 - Cryptic Apps SARL - Disassembling not allowed.',0
+db    0
+db    0
+db    0
+db    0
+
+ +

They aren't correct asm code! And I have no clue what tool obfuscated this file.
+And I'm also curious about how can this dylib overwrite exisiting functions?

+ +

Note: I've read https://alexomara.com/blog/a-silly-anti-disassembly-trick/, however this dylib isn't that trick, but is really obfuscated XD

+",27148,,27148,,1/20/2019 13:22,9/23/2019 23:06,How to decompile a obfuscated mach-o dylib?,,0,2,,,,CC BY-SA 4.0 +20424,1,20425,,1/20/2019 13:32,,0,263,"

I have those opcodes on 64 bits:

+ +
48 8D 35 45 CE FF FF >>> lea rsi, [rip - 0x31bb].
+
+ +

How can I get the 0x31bb value from those opcodes and how can I know if I have a + sign or a - sign beetween operands ( rip - 0x31bb or rip + 0x31bb ) ?

+",27166,,27166,,1/20/2019 14:15,1/20/2019 14:15,Calculate LEA operand,,1,0,,,,CC BY-SA 4.0 +20425,2,,20424,1/20/2019 14:15,,0,,"

You can get that value from the last 4 bytes of the opcode.

+ +
45 CE FF FF
+
+ +

You need to reverse the order of bytes and the the value is written as 2's complement. Since the highest bit is 1 it will be negative.

+ +
(0xFFFFCE45) in 2's = -0x31BB
+
+",18014,,,,,1/20/2019 14:15,,,,0,,,,CC BY-SA 4.0 +20426,1,20427,,1/20/2019 17:35,,3,131,"

I can't understand the meaning of ascii-art color bars.
+what is the meaning of the # charaters?

+ +
[0x08000210]> iS=
+00  0x08000000 |---------------------------------| 0x08000000     0 ---      
+01  0x08000200 |--------------------#------------| 0x0800020d    13 rw-  .data
+02* 0x08000210 |---------------------##----------| 0x08000237    39 r-x  .text
+03  0x08000240 |-----------------------###-------| 0x08000272    50 ---  .shstrtab
+04  0x08000280 |-------------------------#######-| 0x08000310   144 ---  .symtab
+05  0x08000310 |-------------------------------##| 0x0800032a    26 ---  .strtab
+06  0x08000330 |--------------------------------#| 0x08000348    24 ---  .rela.text
+07  0x08000000 |###------------------------------| 0x08000040    64 rw-  ehdr
+=>  0x08000210 |---------------------------------| 0x0800020f
+
+",24392,,,,,1/20/2019 18:56,radare2 how to interpret ascii-art color bars?,,1,0,,,,CC BY-SA 4.0 +20427,2,,20426,1/20/2019 18:56,,2,,"

This chart describes the different Sections and Memory Segments in your binary.

+ +

Each row in the chart is a different section where its name is in the rightest column. From the left, you can see its start address, from the right you can see its end-address and next to it you can see the sections' size (decimal). That means, Start-Address + Size = End-Address.

+ +

The ASCII bar itself is an imaginary range of addresses and the hash sign # will mark where on this range the section appears. In your example, the chart begins at 0x08000000 which is the lowest address and ends at 0x08000348 which is the highest. The .symtab is the biggest section in your example since it in size of 144. This is why it has the biggest amount of # characters.

+",18698,,,,,1/20/2019 18:56,,,,0,,,,CC BY-SA 4.0 +20428,1,,,1/20/2019 20:53,,0,77,"

I want to build a ""force feedback chair"" for Need for Speed: Payback, so I thought about hooking the function responsible for the controller vibration and sending the motor speed parameter to a motor over Serial (to an arduino). +I successfully hooked the XInputSetState function (responsible for Controller Vibration) and sent the parameters over usb, and everything worked fine. +The problem is, I want to play the game with a Wheel (Logitech g29). +The ""XInputSetState"" function still gets called, but the motor speed parameter is always 0 (makes sense, if you have two controllers connected to your pc, only the one you're driving with vibrates not the other one). +My Wheel also has no Vibration feedback (so no function that i can hook there).

+ +

So my thought was, that if you for example drive against a wall, the game checks if a Controller is connected, and if it's the case, calls the XInputSetState function with the correct motor speed parameter (so the Controller vibrates).

+ +

For now I tried setting a breakpoint on XInputSetState and moving up the Callstack, to see what function still gets called with the correct motor speed parameter (even if no Controller is present), but my knowledge with reveersing is still very limited so no luck there.

+ +

So how would you go about looking for such a function? +Any tips and hints are welcome.

+",27172,,,,,1/21/2019 3:14,"Finding ""controller vibration"" function in game",,1,0,,,,CC BY-SA 4.0 +20429,2,,20428,1/21/2019 3:14,,1,,"

I think your approach of looking up the callstack is generally sound, but might be too time consuming.

+ +

As you have no doubt experienced, without debugging information it can be challenging even to piece together what the different frames are, before trying to determine if any of those functions are relevant.

+ +

The crucial function deciding whether to call the vibration logic based on the controller type might not even be on the stack if the system is built around an asynchronous event loop.

+ +

My suggestion would be to look into the DirectInput APIs to figure out what functions the game would call to query information about the controller. This is likely necessary for the game to decide whether it should run the vibration logic or not.

+ +

Keep in mind that the game is likely querying the controller info very early (either at launch or just before entering the game from the menu), and then storing the necessary information somewhere in its memory. If you can find that, you might be able to find where in the callstack leading up to XInputSetState that memory location is being checked.

+",27175,,,,,1/21/2019 3:14,,,,0,,,,CC BY-SA 4.0 +20431,1,,,1/21/2019 10:06,,2,1262,"

I am reading brute-forcing stack canary. But I am confused why the server can be brute-forced one byte at a time on a crashable-server and what does mean this fork-and-accept ?

+",27178,,53,,1/21/2019 10:18,1/21/2019 10:18,Why stack canary can be brute-force one byte at a time?,,1,1,,,,CC BY-SA 4.0 +20432,2,,20431,1/21/2019 10:16,,2,,"

A common mistake, while programming a server, is to use a fork() to start it and respawn it when it crashes.

+ +

The problem with a fork() is that is uses a copy of the memory to start over. Of course, using a copy means that the respawned server will be stuck with the exact same canaries even if it has been crashed and respawn. Somehow, it's memory layout and it's canaries are frozen until it is really re-run from the executable file.

+ +

The good way to program a server would be to systematically use an execve() in place of the fork(). This ensure that the memory start from scratch an re-initialize all the memory settings (ASLR, canaries, and so on).

+ +

But, indeed, most of the servers in the wild are using an execve(), we can only find fork() on old implementations or on educational security challenges.

+",53,,,,,1/21/2019 10:16,,,,0,,,,CC BY-SA 4.0 +20434,1,,,1/21/2019 16:19,,1,1283,"

In gdb i can backtrace with core file and executable file.
+It seems radare2 can read core file. like this

+ +
$ r2 core
+Setting up coredump: asm.arch <-> x86 and asm.bits <-> 64
+Setting up coredump: Registers have been set
+Setting up coredump: 22 maps have been found and created
+[0x00000000]> 
+
+ +

but after that i don't know what to do next?
+I can't find any documentation about using core file in radare2.

+",24392,,,,,2/10/2021 2:03,how to use core file in radare2?,,1,0,,,,CC BY-SA 4.0 +20436,1,20439,,1/21/2019 18:14,,1,4872,"

I need some help and advice here. +I am privately learning on how to reverse engineer +our teachers custom file archive +file that have other files stored inside of them. +for school project.

+ +

But, I am kinda lost on where I need to start with the file. +What do I look for in the file after loading it into ida-pro +To, be able to create my own self extracting Tool for my project.

+ +

The File format is .crackme that has been compressed with files inside of it +from our teacher at school but when I double click on the file it says the file is ""archive either unknown format or damaged"".

+ +

So, yeah the file extension he gave us is not any known on the web +he created his own extension for us to crack it and make an extractor tool +to get all the data from the archive his extension name is "".crackme"" +so yeah.

+ +

Any Advice, here any help to is much appreciated by me.

+",27184,,2147,,1/22/2019 11:28,1/22/2019 11:32,Extracting the contents of an unknown archive file format,,2,3,,,,CC BY-SA 4.0 +20437,2,,20434,1/21/2019 21:37,,1,,"

It's more regular programming question than RE. Core dump file is a state of the process when the file was created (usually due to a crash) so debugger commands are the most suitable in such case. In Radare2 those are the ones from d? category.

+ +
Usage: d   # Debug commands
+| db[?]                    Breakpoints commands
+| dbt[?]                   Display backtrace based on dbg.btdepth and dbg.btalgo
+| dc[?]                    Continue execution
+| dd[?]                    File descriptors (!fd in r1)
+| de[-sc] [perm] [rm] [e]  Debug with ESIL (see de?)
+| dg <file>                Generate a core-file (WIP)
+| dH [handler]             Transplant process to a new handler
+| di[?]                    Show debugger backend information (See dh)
+| dk[?]                    List, send, get, set, signal handlers of child
+| dL[?]                    List or set debugger handler
+| dm[?]                    Show memory maps
+| do[?]                    Open process (reload, alias for 'oo')
+| doo[args]                Reopen in debugger mode with args (alias for 'ood')
+| dp[?]                    List, attach to process or thread id
+| dr[?]                    Cpu registers
+| ds[?]                    Step, over, source line
+| dt[?]                    Display instruction traces (dtr=reset)
+| dw <pid>                 Block prompt until pid dies
+| dx[?]                    Inject and run code on target process (See gs)
+
+ +

You can get values of registers when coredump was created by issuing dr command or show the backtrace by one of the dbt.

+ +
+

but after that i don't know what to do next?

+
+ +

What are the next steps are really dependent on your case - what you want to obtain from this dump.

+ +
+

I can't find any documentation about using core file in radare2.

+
+ +

Probably this is not the most used function in r2 ;)

+",18014,,,,,1/21/2019 21:37,,,,0,,,,CC BY-SA 4.0 +20438,2,,20436,1/22/2019 5:49,,0,,"

Many archive formats contain headers. gzip headers for instance begin with 1f 8b. Use a hex-editor to check for known magic numbers in the header first.

+",11818,,,,,1/22/2019 5:49,,,,0,,,,CC BY-SA 4.0 +20439,2,,20436,1/22/2019 11:25,,5,,"

I hope you'll find your experience in RE.SE enjoyable and educating :) +Reverse engineering is often studied as a hobby, so you're in good company!

+ +

IDA pro is a disassembler, which is focused on reverse engineering / reading assembly/machine code. that is - the code actually executed by the CPU. Since it appears you were only given a format file, without any executable code to manipulate / process the file, IDA will prove less useful.

+ +

Instead, the only tool you should require for such a task, assuming the format is indeed proprietary, is a hex-editor / reader. 010 Editor is a great one, and it has a trial version.

+ +

To eliminate the possibility of a known format, try running a couple file identification tools such as the linux file command, TrID, binwalk, etc. These will try to identify common file formats (binwalk is specifically focused on archive formats), which if provide any insights should point you in the right direction.

+ +

To reverse engineer a file format solely based on a single file content, you'll need to map out the the file's apparent structure and you don't have a lot to go with. Excluding textual and very simply file formats, this should be kinda difficult without any additional resources (more files, a program that handles the format in any way, etc).

+ +

Here's a list of pointers/tips, although you'll probably find more information available online:

+ +
    +
  1. As most files begin with a header, you should begin with mapping what are the different members of the header structure.
  2. +
  3. Things that are magic values, strings, offsets and sizes are quite easy to recognize. Most decent hex editors will show different representations of every few bytes, so it'll be easy to recognize.
  4. +
  5. Start by dividing the bytes to different members, before you try to understand their meaning. For example, given the following hex stream: 00 05 00 00 00 01 BE F1 CA D7 it is easy to notice the members are a word (2 bytes), a dword (4 bytes) and another dword. It is also likely that the first two are integers while the third is either a magic value or a CRC.
  6. +
  7. If the file has any recurring delimiter values, those should also be easily identifiable (although less likely to be present in an active file format).
  8. +
  9. If you manage to recognize any other file headers (probably using their own magic values), those are good leads to figuring out where the actual file content is placed. This will also mean the archive file does not compress the contained files, linux's tar, for example, can do that. Alternatively, if you encounter long streams of smooth or random looking binary streams those can be the actual compressed data. I tend to believe your teacher did not invent he's own compression algorithm, so there you'll need to find similarities to other compression algorithms, perhaps running those streams under TrID and file again could help.
  10. +
  11. Common looking patterns, for example, may be a useful way to uncover recurring structures (for which you'll have more than one reference point, yay!). For example, if you recognize every file-name string is followed by a sequence of bytes with a similar structure, those are probably two instances of the same structure.
  12. +
+",2147,,2147,,1/22/2019 11:32,1/22/2019 11:32,,,,4,,,,CC BY-SA 4.0 +20441,1,20444,,1/22/2019 17:53,,0,91,"

Sorry if this is a duplicate and please point me in the right direction if so. I have a strong foundation in C programming and I know how memory is allocated on the stack for variables/arrays/pointers (of all datatypes) etc. I also understand how to use malloc and free to put data on the heap. What I do NOT understand is how all the registers and the call stack fit together with this picture and what each registers is supposed to point to. I am trying to learn this before I start messing with GDB so I actually know what I am looking at. Any good references out there?

+ +

Ultimately this is so I can do a project for my masters where I need to run shellcode by exploiting a buffer overflow vulnerability in a given program. I know how to do a basic buffer overflow by feeding the program more data than allocated but I don't know what/how much data I need to feed the program so that it gets put at the right place in memory in order to execute what is required.

+",4466,,,,,1/22/2019 23:18,What is a good resource to learn about how the call stack works while programming in C?,,1,0,,,,CC BY-SA 4.0 +20442,2,,20422,1/22/2019 18:41,,1,,"

I managed to solve it and I will write it here so that it hopefully can help someone more facing the same issue. +A more detailed description of the problem: +On my rooted Galaxy S5 I had an application installed which had a encrypted SQLite database in the /data/data//database/ folder. If I moved the database outside of the /data/ and then pasted it back into it's original location the app would crash instantly on start up, and I still don't know why (I didn't change anything in the file itself and i restored the original file permissions and ownerships since they had automatically(?) been altered during the move) but the app would still crash.

+ +

The solution (and I don't really know why it works) would be to use the dd command to make a copy of the database, use adb to pull that copy to my PC, edit it with DB Browser for SQLite and then push that manipulated copy back into /data/data//database and lastly use dd to copy the content of the manipulated database into the original database.

+ +

Step by step:

+ +
dd if=database of=database_copy
+adb pull /data/data/<package-name>/database/database_copy
+[Edit and then save the database_copy]
+adb push database_copy /data/data/<package-name>/database/
+dd if=database_copy of=database
+
+ +

Thats it! The app starts fine this time and reads the database with my own values!

+",27157,,,,,1/22/2019 18:41,,,,1,,,,CC BY-SA 4.0 +20444,2,,20441,1/22/2019 23:18,,1,,"
+

What I do NOT understand is how all the registers and the call stack fit together with this picture and what each registers is supposed to point to.

+
+ +

It's great that you are competent in C, but there is no way around reading disassembled object code and writing assembly code (practical experience).

+ +

The compiler toolchain is responsible for generating object code that targets a particular CPU. This means that it is the compiler that is responsible for managing all of the registers based on details such as process layout in memory (which is OS-specific), calling convention, optimization level, application binary interface (also OS-specific), etc.

+ +

You did not give any information about the environment you are working in aside from mentioning GDB, so I am guessing you are going to be doing Linux x86 binary exploitation.

+ +
    +
  • A good theoretical foundation for understanding the stack is provided by Chapter 8 ""Subroutines and Control Abstraction"" in Programming Language Pragmatics by Michael L. Scott.

  • +
  • A good practical introduction to Linux x86 stack structure and management is provided in section 3.7 ""Procedures"" in Computer Systems: A Programmer's Perspective by Bryant and O'Hallaron.

  • +
+ +

Lastly, there is the following Q&A regarding the stack over at the CS.SE site:

+ +

How are variables stored in and retrieved from the program stack? +

+",18317,,,,,1/22/2019 23:18,,,,7,,,,CC BY-SA 4.0 +20447,1,,,1/23/2019 8:06,,0,601,"

I want to debug a Linux program (ELF), but my IDA Pro is on a Windows 10 VM and I want to use remote debugging to debug the program on Ubuntu (also in a VM).

+ +

So, is it possible to debug if both machines are VMs?

+",27201,,245,,1/23/2019 19:47,1/25/2019 15:03,Remote debugger for Linux from one VM (IDA) to another (running the debuggee),,1,0,,,,CC BY-SA 4.0 +20450,1,,,1/23/2019 11:32,,1,248,"

I'm relatively new to reverse engineering, and I've decided to practise using the challenges from pwnable.tw. Currently, I am working on the ""Silver Bullet"" challenge.

+ +

While testing, I have noticed that if the program is run and the user selects option 4, then the program crashes with a segfault instead of exiting cleanly. Testing in GDB confirms that this happens during the ""call exit"" instruction at 0x08048954.

+ +

Reading the manpage for exit, I can see that undefined behaviour can occur in certain circumstances when functions are registered with atexit(3) or on_exit(3). However, I can't see any functions being registered in this way, and I can't see any other way which exit would fail to execute successfully. Why is a segfault happening during the exit call?

+ +

For reference, the surrounding code is:

+ +
0x080489F1: 
+push    offset aDonTGiveUp ; ""Don't give up !""
+call    puts
+add     esp, 4
+push    0
+call    exit
+push    offset aInvalidChoice ; ""Invalid choice""
+call    puts
+add     esp, 4
+nop
+
+ +

Thank you for taking the time to read this.

+",27205,,,,,1/23/2019 11:32,How can a segfault happen during the libc exit call on Linux?,,0,1,,,,CC BY-SA 4.0 +20452,1,,,1/23/2019 18:08,,1,749,"

I had recently this situation where in a program I was debugging I found:

+ +
03CD38D4:  8B15 8C5FF703  MOV EDX, DWORD PTR DS:[3F75F8C]
+
+ +

If I look for these bytes in the physical file I found nothing. I assumed this is because the reference to 3F75F8C, which might change over each instance of the program, is being randomised by Windows. So I could not change the value directly in an hexed - say change 3F75F8C to 3F75F88 (I suppose I can do it with some math involving the base, though).

+ +
    +
  • Can someone explain in detail how Windows proceeds when loading the PE file to randomise all these bytes? I have found posts and info on how ASLR works, but I am more thinking on the steps that the OS makes to put the file in memory with the randomised addresses - i.e. how it goes from the actual bytes in the executable ""8B15 XXXX"" to ""8B15 8C5FF703"" as in my example.
  • +
  • How the OS knows where the bytes that have to be randomised are (which exact addresses), and do it in a timely fashion?
  • +
  • Will this OS process breaks if I NOP the whole instruction? (I am asking because I do not know if there is some sort of predefined index table, I only know there is a flag in the PE to mark ASLR)
  • +
+ +
+ +

EDIT

+ +

As per the answer, what I undestood is that Windows will look into the .reloc section and will change one by one the references pointed in the section based on the random base. Then, if I modify the bytes of the instruction, since they have been defined in the .reloc section, my new bytes will be modified (probably I am wrong, but this is what I understood)

+ +

However, I am not able to find out how Windows ""obtains"" the instruction:

+ +
03CD38D4:  8B15 8C5FF703  MOV EDX, DWORD PTR DS:[3F75F8C]
+
+ +

Which is in file offset 482CD4 stored as:

+ +
MOV EDX, DWORD PTR DS:[B25F8C]
+
+ +

The image base is 400000 and base of code 1000.

+ +

I cannot find anything in the .reloc section that points to 03CD38D4,482CD4 or similar.

+",18064,,18064,,1/27/2019 2:37,1/27/2019 2:37,How does ASLR in Windows work?,,1,0,,,,CC BY-SA 4.0 +20453,1,20456,,1/23/2019 19:51,,1,120,"
   0x0000000008001946:  mov    0xa8(%rdx),%rax
+   0x000000000800194d:  lea    0x28(%rdx),%rsi
+   0x0000000008001951:  lea    0x2(%rax),%rdi
+   0x0000000008001955:  add    $0xe,%rax
+   0x0000000008001959:  mov    %rax,0xa8(%rdx)
+   0x0000000008001960:  jmpq   0x8001ee0
+
+ +

Above is the full disassembly of a signal handler which is customarily set by the program which I'm looking into, i.e., the program registers the signal handler and immediately invokes it by raising a SIGILL using the opcode ud2.

+ +

The signal handler is registered here:

+ +
   0x8001965:   push   %rbx
+   0x8001966:   xor    %eax,%eax
+   0x8001968:   mov    $0x26,%ecx
+   0x800196d:   sub    $0xa0,%rsp
+   0x8001974:   lea    0x8(%rsp),%rdi
+   0x8001979:   rep stos %eax,%es:(%rdi)
+   0x800197b:   lea    -0x3c(%rip),%rax        # 0x8001946
+   0x8001982:   lea    0x10(%rsp),%rdi
+   0x8001987:   movl   $0x8000004,0x90(%rsp)
+   0x8001992:   mov    %rax,0x8(%rsp)
+   0x8001997:   callq  0x8000f60 <sigfillset@plt>
+   0x800199c:   xor    %edx,%edx
+   0x800199e:   test   %eax,%eax
+   0x80019a0:   jne    0x80019bb
+   0x80019a2:   lea    0x8(%rsp),%rbx
+   0x80019a7:   xor    %edx,%edx
+   0x80019a9:   mov    $0x4,%edi
+   0x80019ae:   mov    %rbx,%rsi
+   0x80019b1:   callq  0x8000f90 <sigaction@plt>
+
+ +

Where 0x8001946 is the address of the handler, as disassembled prior to that in the first code-block.

+ +

My question is regarding the first instruction of the signal handler which appears to make no sense at all, and I can't debug it since I can't put a breakpoint on it:

+ +
0x0000000008001946:  mov    0xa8(%rdx),%rax
+
+ +

%rdx is defined by the ABI as the third parameter passed to a function, and as defined by sigaction the third argument of sa_sigaction is a void * (a casted ucontext_t structure) but there is no 0xa8th index into the definition of a struct ucontext_t, which leads me to believe it's something else.

+ +

I thought it might be an %rdx set before the ud2 instruction is called:

+ +
   0x0000000008000fde:  test   %al,%al
+   0x0000000008000fe0:  mov    $0x2,%edx
+   0x0000000008000fe5:  je     0x8001028
+   0x0000000008000fe7:  movslq %ebx,%rdi
+   0x0000000008000fea:  mov    %rbp,%rsi
+   0x0000000008000fed:  callq  0x8001190
+
+ +

But prior to the call to 0x80001190 (the bug), %rdx only contains $0x2. So I'm even more confused.

+ +

Could anyone shed some light on what %rdx could contain at 0x8001946 after a SIGILL is raised, and the signal is passed off to the custom handler defined at that address?

+",27209,,,,,1/24/2019 9:07,Unknown parameters in custom signal handler on Linux,,1,0,,,,CC BY-SA 4.0 +20454,2,,20452,1/24/2019 5:15,,3,,"

ASLR does not peer inside executable
+it is a system wide exploit mitigation technique
+basically and simply put it assigns a random base address on every load of every executable

+ +

that is if you run say calc.exe five times you may see calc.exe load at five different addresses

+ +
C:\>cdb -c ""lm m calc;q"" calc | grep ""calc.*deferred
+00dd0000 00e90000   calc       (deferred)
+
+C:\>cdb -c ""lm m calc;q"" calc | grep ""calc.*deferred
+00250000 00310000   calc       (deferred)
+
+C:\>cdb -c ""lm m calc;q"" calc | grep ""calc.*deferred
+00370000 00430000   calc       (deferred)
+
+C:\>cdb -c ""lm m calc;q"" calc | grep ""calc.*deferred
+00860000 00920000   calc       (deferred)
+
+C:\>cdb -c ""lm m calc;q"" calc | grep ""calc.*deferred
+00110000 001d0000   calc       (deferred)
+
+ +

the information to fix-up lies within your executable under .reloc section

+ +

the loader when it loads an executable takes the base address assigned to the load and performs fix-ups based on the details provided in the .reloc section of an executable

+ +

you can look at fix-ups using dumpbin and other innumerable pe editors

+ +
C:\>dumpbin /relocations c:\Windows\System32\calc.exe | wc -l
+7346
+
+C:\>dumpbin /relocations c:\Windows\System32\calc.exe | head -n 20
+Microsoft (R) COFF/PE Dumper Version 14.15.26726.0
+Copyright (C) Microsoft Corporation.  All rights reserved.
+
+
+Dump of file c:\Windows\System32\calc.exe
+
+File Type: EXECUTABLE IMAGE
+
+BASE RELOCATIONS #4
+    1000 RVA,       B4 SizeOfBlock
+     641  HIGHLOW            01054064  ___security_cookie
+     652  HIGHLOW            01001194  __imp__GetModuleHandleW@4
+     6A5  HIGHLOW            010013F4  __imp__LoadStringW@16
+     6B3  HIGHLOW            010540AC  ?calcSQM@@3PAVCCalculatorSQM@@A (class CCalculatorSQM * calcSQM)
+     6BD  HIGHLOW            01054A70  _Microsoft_Windows_CalculatorHandle
+     6C2  HIGHLOW            010551F8  _Microsoft_Windows_Calculator_Context
+     6C7  HIGHLOW            010321A3  _McGenControlCallbackV2@36
+     6CC  HIGHLOW            01001D5C  _Microsoft_Windows_Calculator
+     6D7  HIGHLOW            0105521C
+     707  HIGHLOW            01001EDE  ?WndProc@@YGJPAUHWND__@@IIJ@Z (long __stdcall WndProc(struct HWND__ *,unsigned in
+t,unsigned int,long))
+
+C:\>
+
+ +

RVA is relative virtual address related to base address

+ +

so if base address = 0x10000000 then absolute will be 0x10001000
+so the address that needs fixup is 0x10001641 in the dump above

+ +

you can find what the preferred base of address is from the headers
+most of the static analysis tools will load the pe in this address only

+ +
C:\>dumpbin /headers c:\Windows\System32\calc.exe | grep -i ""image base""
+         1000000 image base (01000000 to 010BFFFF)
+
+ +

you can dump the bytes at some specified position inside executable using any of the hexeditors (using the HIGHLOW of first entry in dump above 0x641) +you can see the bytes are a1 0x10054064

+ +

using a40 instead of 1640 because the Base of code is 0x400 in physical file

+ +

which will be mapped to 0x1000 (Virtual Address) in the process address space

+ +
C:\>xxd -s 0xa40 -l 10 -g 5 c:\Windows\System32\calc.exe
+0000a40: a164400501 33c58945fc                .d@..3..E.
+
+ +

you can see the disassembly with (using virtual address here as this is a mapped layout not physical file )

+ +
C:\>dumpbin /disasm /range:0x1001640,0x1001645 c:\Windows\System32\calc.exe
+
+  01001640: A1 64 40 05 01     mov         eax,dword ptr [___security_cookie]
+  01001645: 33
+
+ +

if you now load this in a ASLR enabled machine and look at the disassembly at the same virtual address you will see the 0x1000000 (preferred load address) +has been fixed up

+ +
C:\>cdb -c ""? calc;u calc+1640 l1;q"" calc | grep -i -A 3 Reading
+0:000> cdb: Reading initial command '? calc;u calc+1640 l1;q'
+Evaluate expression: 5177344 = 004f0000
+calc!WinMain+0xb:
+004f1640 a164405400      mov     eax,dword ptr [calc!__security_cookie (00544064)]
+
+C:\>python -c ""print ( \""%x\"" % (0x4f0000 + 0x54064) )""
+544064
+
+",3473,,18064,,1/24/2019 7:52,1/24/2019 7:52,,,,2,,,,CC BY-SA 4.0 +20455,1,20459,,1/24/2019 8:43,,2,230,"

All right, Actually I am manually mapping a module into a process, actually my mapper calls DllEntryPoint from standard struct IMAGE_NT_HEADERS thus IMAGE_NT_HEADERS::OptionalHeader::AddressOfEntryPoint etc...

+ +

The problem: +consider following code:

+ +
void Log(const char*, ...);
+
+
+class Test
+{
+    private:
+        struct List_t
+        {
+            const uint32_t x;
+            const uint32_t y; 
+        } List;
+
+    public:
+        Test(List_t z) : List(z) { Log(""Called event 0! \n""); }
+        ~Test() {}
+};
+
+
+
+void Entry()
+{
+    Test Instance
+    (
+        {
+            0x200,
+            0x400
+        }
+    );
+
+    Log(""Called! \n"");  
+}
+
+
+BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
+{
+
+    if(fdwReason == 1)
+        Entry();
+
+    return TRUE;
+}
+
+ +

so if the module entry point gets called through IMAGE_NT_HEADERS::OptionalHeader::AddressOfEntryPoint from mapper, the constructor Test() never gets executed, while that Entry() function gets executed successfully, now if the module it's loaded with standard LoadLibraryA(); so Test() constructor gets called successfully...

+ +

Where i would find some information about this?

+ +

I have heard something about CRT initializers, but i can't find anything deeply...

+",17950,,245,,1/24/2019 10:56,1/24/2019 11:15,"There is something else than a ""DllMain"" in a module for its initialization?",,1,0,,,,CC BY-SA 4.0 +20456,2,,20453,1/24/2019 9:07,,2,,"

It seems to be %rip (the address of the ud2):

+ +
#include <signal.h>
+#include <stdio.h>
+#include <ucontext.h>
+
+void handler(int signo, siginfo_t *info, void *context) {
+    ucontext_t *uc = (ucontext_t*)context;
+    printf(""%llx\n"", uc->uc_mcontext.gregs[REG_RIP]);
+}
+
+ +

compiles to:

+ +
handler(int, siginfo_t*, void*):
+        movq    168(%rdx), %rsi
+        movl    $.L.str, %edi
+        xorl    %eax, %eax
+        jmp     printf
+.L.str:
+        .asciz  ""%llx\n""
+
+ +

(https://gcc.godbolt.org/z/RC064L)

+",12017,,,,,1/24/2019 9:07,,,,0,,,,CC BY-SA 4.0 +20457,1,,,1/24/2019 9:26,,3,735,"

Why disassemble multi-thread binary is hard? I also know that some obfuscation techniques are to create unnecessary threads. But why reverse engineering multi-thread program is hard.

+",27179,,,,,1/24/2019 10:12,Why disassemble multi-thread binary is hard?,,1,0,,,,CC BY-SA 4.0 +20458,2,,20457,1/24/2019 10:12,,3,,"

The technique you are referring to is called 'nanomites'. I would advise you the reading of this article as a full example of reverse of a nanomite crack-me.

+

Never the less, the problem of multi-thread or multi-process reverse-engineering is that in place of one sequence of events (with only one program), you have to follow in parallel multiple programs that interact (possibly in a non-deterministic way) with each others. It raise up exponentially the complexity of the reverse-engineering process.

+

References

+ +",53,,-1,,6/17/2020 9:54,1/24/2019 10:12,,,,0,,,,CC BY-SA 4.0 +20459,2,,20455,1/24/2019 11:07,,3,,"

In case of programs you'd also have to watch out for TLS callbacks. These run prior to the entry point, but I have only ever seen those on .exe files, never on DLLs. Still, Peter Ferrie stated that TLS callbacks exist for DLL files. I'd trust his expertise on this, even though I've never seen one of those myself, when reverse engineering a DLL.

+ +

Anyway, DllMain in your case has that fdwReason parameter. That one is kind of important here and you should not have used a literal 1 there but the proper symbolic name: DLL_PROCESS_ATTACH.

+ +

DLL_PROCESS_ATTACH, DLL_PROCESS_DETACH, DLL_THREAD_ATTACH, DLL_THREAD_DETACH are the currently defined values. A switch statement would therefore be much more sensible here.

+ +

Depending on the reason for which you're being called back in DllMain you can act.

+ +

Now while I don't know if that class is meant to be a singleton, it's clear that all that happens inside Entry() is the creation and destruction of an instance of that class on the stack. Once the scope of that function is left, the instance will be destroyed. You should be able to verify this by adding something like a Log() invocation to the dtor.

+ +

As for the CRT initializers, yes these exist. Kindly read this other answer by me before reading on.

+ +

...

+ +

Okay, assuming you read my answer, the difference between DllMain as expected by the CRT when you build with the default CRT is that it already includes that CRT initialization code you likely mean. Whereas if you told the linker to use an alternative /entry you would still use the same prototype for the DLL entry function, but you'd have to deal with initialization. Literally all the information you may need is in the above linked answer to that related question and inside the files mentioned in said answer.

+",245,,245,,1/24/2019 11:15,1/24/2019 11:15,,,,1,,,,CC BY-SA 4.0 +20460,1,,,1/24/2019 11:10,,0,500,"

How come the following code executes if buf* is @ rodata segment ?

+ +
#include <stdio.h>
+
+char *buf[] = {
+""\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\
+\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\
+\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\
+\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\
+\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\
+\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\
+\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\
+\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\
+\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\x90\
+\xc3 IS THIS DATA?""
+};
+char arr_chr[500] = ""I AM READ_WRITE"";
+
+int main(){
+    ((void (*)()) buf[0])();
+
+    printf(""%s\n"", buf[0]);
+    printf(""%s\n"", arr_chr);
+}
+
+ +

compiled with gcc version 7.3.0 without flags @ x86_64-linux-gnu

+ +

file's output:

+ +

check: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, not stripped

+ +

+",22071,,22071,,1/24/2019 11:35,1/24/2019 21:53,why code at .rodata executes,,1,3,,1/25/2019 19:34,,CC BY-SA 4.0 +20461,1,,,1/24/2019 17:57,,-1,3112,"

I'm trying to solve a crackme which basically uses a XOR encryption scheme in which the password is used as the key to an encrypted buffer which is subsequently executed. The following is the encrypted buffer:

+ +
0x4F, 0x12, 0x85, 0x7C, 0x96, 0x2E, 0x29, 0x54, 0x45, 0x41, 0x15, 0x10, 
+
+0xF1, 0x12, 0x87, 0x1C,
+0xF3, 0x27, 0x27, 0x46, 0x56, 0x2D, 0x54, 0x2D, 0x41, 0x5D, 0x23, 0x31, 0x49, 0x5C, 0x2F, 0x21,
+0x46, 0xF6, 0x92, 0x2E, 0x6D, 0x54, 0xBA, 0x90, 0x25, 0x23, 0x36, 0x21, 0x5C, 0x47, 0x21, 0x46,
+0x4F, 0x46, 0x16, 0x94, 0x98, 0x2D, 0x01, 0x4D, 0xDC, 0xE0, 0xE7, 0x5C, 0x76, 0xE7, 0xC6, 0x4E,
+0x46, 0x46, 0x2D, 0x3B, 0x83, 0xC1, 0x4F, 0x23, 0x31, 0x21, 0x29, 0xE9, 0xA1, 0x45, 0x4F, 0x46,
+0x46, 0x0D, 0x92, 0xC5, 0x45, 0x4D, 0x23, 0x31, 0x45, 0x9A, 0xAF, 0x24, 0x46, 0x4F, 0x46, 0x2F,
+0xEB, 0xD4, 0x43, 0x41, 0x4D, 0x23, 0x55, 0xE7, 0xDC, 0x28, 0x21, 0x46, 0x4F, 0x66, 0x80, 0xAD,
+0x5C, 0x45, 0x41, 0x4D, 0x4A, 0xF7, 0xA1, 0x55, 0x2F, 0x21, 0x46, 0x3B, 0x80, 0xC6, 0x27, 0x54,
+0x45, 0x41, 0x6C, 0xE5, 0xB1, 0x2A, 0x5C, 0x2F, 0x21, 0x46, 0x89, 0xC6, 0x56, 0x2D, 0x54, 0x45,
+0x09, 0x8B, 0xA3, 0x20, 0x21, 0x5C, 0x2F, 0x40, 0x80, 0xCF, 0x54, 0x46, 0x2D, 0x54, 0x31, 0x87,
+0xCD, 0x30, 0x31, 0x21, 0x5C, 0x5C, 0xE7, 0xC6, 0x5B, 0x46, 0x46, 0x2D, 0x74, 0x83, 0xC1, 0x58,
+0x23, 0x31, 0x21, 0x33, 0xE9, 0xA1, 0x50, 0x4F, 0x46, 0x46, 0x4B, 0x92, 0xC5, 0x56, 0x4D, 0x23,
+0x31, 0x47, 0x9A, 0xAF, 0x39, 0x46, 0x4F, 0x46, 0x66, 0xEB, 0xD4, 0x5C, 0x41, 0x4D, 0x23, 0x45,
+0xE7, 0xDC, 0x35, 0x21, 0x46, 0x4F, 0x29, 0x80, 0xAD, 0x4F, 0x45, 0x41, 0x4D, 0x03, 0xF7, 0xA1,
+0x40, 0x2F, 0x21, 0x46, 0x36, 0x80, 0xC6, 0x30, 0x54, 0x45, 0x41, 0x22, 0xE5, 0xB1, 0x3F, 0x5C,
+0x2F, 0x21, 0x33, 0x89, 0xC6, 0x59, 0x2D, 0x54, 0x45, 0x61, 0x8B, 0xA3, 0x11, 0x21, 0x5C, 0x2F,
+0x4C, 0x80, 0xCF, 0x67, 0x46, 0x2D, 0x54, 0x24, 0x87, 0xCD, 0x01, 0x31, 0x21, 0x5C, 0x5B, 0xE7,
+0xC6, 0x6C, 0x46, 0x46, 0x2D, 0x31, 0x83, 0xC1, 0x69, 0x23, 0x31, 0x21, 0x72, 0xE9, 0xA1, 0x63,
+0x4F, 0x46, 0x46, 0x0D, 0x92, 0xC5, 0x67, 0x4D, 0x23, 0x31, 0x71, 0x9A, 0xAF, 0x06, 0x46, 0x4F,
+0x46, 0x2A, 0xEB, 0xD4, 0x6D, 0x41, 0x4D, 0x23, 0x54, 0xE7, 0xDC, 0x06, 0x21, 0x46, 0x4F, 0x27,
+0x80, 0xAD, 0x7E, 0x45, 0x41, 0x4D, 0x50, 0xF7, 0xA1, 0x77, 0x2F, 0x21, 0x46, 0x2A, 0x80, 0xC6,
+0x01, 0x54, 0x45, 0x41, 0x6D, 0xE5, 0xB1, 0x0C, 0x5C, 0x2F, 0x21, 0x35, 0x89, 0xC6, 0x68, 0x2D,
+0x54, 0x45, 0x24, 0x8B, 0xA3, 0x1E, 0x21, 0x5C, 0x2F, 0x4F, 0x80, 0xCF, 0x76, 0x46, 0x2D, 0x54,
+0x21, 0x87, 0xCD, 0x12, 0x31, 0x21, 0x5C, 0x0F, 0xE7, 0xC6, 0x7D, 0x46, 0x46, 0x2D, 0x2D, 0x83,
+0xC1, 0x7E, 0x23, 0x31, 0x21, 0x33, 0xE9, 0xA1, 0x72, 0x4F, 0x46, 0x46, 0x58, 0x92, 0xC5, 0x74,
+0x4D, 0x23, 0x31, 0x53, 0x9A, 0xAF, 0x17, 0x46, 0x4F, 0x46, 0x66, 0xEB, 0xD4, 0x72, 0x41, 0x4D,
+0x23, 0x42, 0xE7, 0xDC, 0x17, 0x21, 0x46, 0x4F, 0x29, 0x80, 0xAD, 0x6D, 0x45, 0x41, 0x4D, 0x4F,
+0xF7, 0xA1, 0x66, 0x2F, 0x21, 0x46, 0x3A, 0x80, 0xC6, 0x16, 0x54, 0x45, 0x41, 0x39, 0xE5, 0xB1,
+0x1D, 0x5C, 0x2F, 0x21, 0x2F, 0x89, 0xC6, 0x7B, 0x2D, 0x54, 0x45, 0x2E, 0x8B, 0xA3, 0x0F, 0x21,
+0x5C, 0x2F, 0x4F, 0x80, 0xCF, 0x79, 0x46, 0x2D, 0x54, 0x65, 0x87, 0xCD, 0x63, 0x31, 0x21, 0x5C,
+0x5B, 0xE7, 0xC6, 0x0E, 0x46, 0x46, 0x2D, 0x3B, 0x83, 0xC1, 0x0F, 0x23, 0x31, 0x21, 0x7C, 0xE9,
+0xA1, 0x05, 0x4F, 0x46, 0x46, 0x49, 0x92, 0xC5, 0x05, 0x4D, 0x23, 0x31, 0x42, 0x9A, 0xAF, 0x64,
+0x46, 0x4F, 0x46, 0x34, 0xEB, 0xD4, 0x03, 0x41, 0x4D, 0x23, 0x50, 0xE7, 0xDC, 0x68, 0x21, 0x46,
+0x4F, 0x25, 0x80, 0xAD, 0x1C, 0x45, 0x41, 0x4D, 0x48, 0xF7, 0xA1, 0x15, 0x2F, 0x21, 0x46, 0x7D,
+0x80, 0xC6, 0x67, 0x54, 0x45, 0x41, 0x7D, 0xE5, 0xB1, 0x6A, 0x5C, 0x2F, 0x21, 0x76, 0x89, 0xC6,
+0x0A, 0x2D, 0x54, 0x45, 0x76, 0x8B, 0xA3, 0x7C, 0x21, 0x5C, 0x2F, 0x61, 0x80, 0xCF, 0x08, 0x46,
+0x2D, 0x54, 0x22, 0x87, 0xCD, 0x6C, 0x31, 0x21, 0x5C, 0x42, 0xE7, 0xC6, 0x1F, 0x46, 0x46, 0x2D,
+0x35, 0x83, 0xC1, 0x1C, 0x23, 0x31, 0x21, 0x35, 0xE9, 0xA1, 0x14, 0x4F, 0x46, 0x46, 0x41, 0x92,
+0xC5, 0x12, 0x4D, 0x23, 0x31, 0x0F, 0x9A, 0xAF, 0x75, 0x46, 0x4F, 0x46, 0x25, 0xEB, 0xD4, 0x10,
+0x41, 0x4D, 0x23, 0x5E, 0xE7, 0xDC, 0x79, 0x21, 0x46, 0x4F, 0x2B, 0x80, 0xAD, 0x03, 0x45, 0x41,
+0x4D, 0x23, 0x59, 0x21, 0x5C, 0x2F, 0x21, 0x16, 0xCC, 0x86, 0x56, 0x7D, 0x3C, 0x45, 0x41, 0x4D,
+0x23, 0x88, 0x05, 0x33, 0x6F, 0x21, 0xB9, 0x9E, 0x85, 0x8D, 0x40, 0x00, 0x30, 0x74, 0x40, 0x00,
+0x50, 0x73, 0x40, 0x00, 0x5C, 0x0F, 0x41, 0x00, 0x98, 0x73, 0x40, 0x00, 0x98, 0x72, 0x40, 0x00,
+0x80, 0x74, 0x40, 0x00, 0xC0, 0x74, 0x40, 0x00, 0x28, 0x75, 0x40, 0x00, 0x0C, 0xD3, 0x41, 0x00,
+0x34, 0x00, 0x46, 0x00, 0x50, 0x74, 0x40, 0x00, 0x94, 0xD3, 0x41, 0x00, 0xAC, 0xD3, 0x41, 0x00,
+0x64, 0xD2, 0x41, 0x00, 0x28, 0x00, 0x46, 0x00, 0xD0, 0x73, 0x40, 0x00, 0xE4, 0xD2, 0x41, 0x00,
+0x10, 0xE0, 0x45, 0x00, 0x38, 0x75, 0x40, 0x00, 0x44, 0x00, 0x46, 0x00, 0x08, 0x00, 0x46, 0x00,
+0x2C, 0xD2, 0x41, 0x00, 0x8C, 0xD3, 0x41, 0x00, 0x10, 0x75, 0x40, 0x00, 0x7C, 0xD3, 0x41, 0x00
+
+ +

Upon receiving user input, the program checks its length and if it's different than 15 it aborts execution. So I know for a fact that the key is 15 characters long, so far so good. After the decrypting the buffer the following sequence of comparations takes place:

+ +
mov     eax, [ebp+decrypted_buffer]
+mov     [ebp+var_4], eax
+mov     eax, [ebp+decrypted_buffer]
+cmp     byte ptr [eax], 60h ; 
+jnz     short invalid_key
+
+mov     eax, [ebp+decrypted_buffer]
+cmp     byte ptr [eax+4], 0D0h
+jnz     short invalid_key
+mov     eax, [ebp+decrypted_buffer]
+cmp     byte ptr [eax+9], 0
+jnz     short invalid_key
+
+ +

Since the 1st, 5th and 10th bytes of the decrypted buffer are expected to be 0x60, 0x0D0, 0x0 we can find the 1st, 5th and 9th bytes of the key, namely: 0x2F, 0x46, 0x41

+ +

So the right key should be something like: ""/***F****A*******""

+ +

My question is: How do I find the rest of the key?

+",27220,,14622,,1/25/2019 11:17,10/1/2021 8:41,XOR encryption - How to find the key?,,2,7,,,,CC BY-SA 4.0 +20463,2,,20460,1/24/2019 21:53,,1,,"

I think you mixed up segments and sections on ELF. Unlike PE where sections define how the application is mapped and page permissions, ELF loaders only use segments PT_LOAD to do that. Segments don't have name, so there's nothing like .rodata segment, only .rodata section. You can verify that be setting 0x0 to the field ElfN_Ehdr::e_shoff, it'll still work.

+ +

Now regarding the initial question, it seems ELF executable used to have only two PT_LOAD segments, one is R-X and RW-. If a data is const, it'll be stored inside the first segment which is also executable. It's not true anymore on my archlinux.

+",26176,,,,,1/24/2019 21:53,,,,0,,,,CC BY-SA 4.0 +20464,1,20491,,1/25/2019 2:19,,0,722,"

I am using IDA pro to follow along a youtube video of RE from OALabs. https://www.youtube.com/watch?v=kdNQhfgoQoU&t=1575s

+ +

I am facing a problem when i try to put a break point on functions in ntdll, when i double click c:\windows\system32\ntdll.dll in the modules windows I get warning saying ""Module c:\windows\system32\ntdll.dll has no names"". When i right click on c:\windows\system32\ntdll.dll in the modules window and select load debug symbols, it downloads something but I am still not able to see the functions i would like to put break point on like NtResumeThread.

+ +

Appreciate any assistance or suggestions. Pic attached for reference.

+",27224,,,,,1/28/2019 10:47,ida pro issue debugging issues with ntdll,,1,2,,2/5/2019 3:38,,CC BY-SA 4.0 +20465,2,,20461,1/25/2019 9:53,,2,,"

You have to gather more constraints

+ +
    +
  • The key has to be 15 bytes long
  • +
  • 1st, 5th and 9th bytes of the decrypted buffer are expected to be 0x60, 0x0D0, 0x0
  • +
  • The Block should be executable!
  • +
+ +

And you should start with the last one. I assume this is an x86 executable, so 0x60 would correspond to an PUSHA instruction, which does does seem reasonable.

+ +

You could run a bruteforce with different keys and check if the result resolves to valid assembler, for example utilizing a stream disassembler such as diStorm or even CPU enumation with tools such as Unicorn.

+ +

Since you know 3 Bytes for sure, you have 12 bytes of entropy, resulting in 256^12 possible combinations to check. This is still too much, but you got even more information!

+ +

Since the xor key is repeated all 15 bytes, you already know 1/5 of all decrypted data. Have a look at it and try to see if you can make up reasonable contexts for it, such as common instruction sequences (prologes, epiloges, dataflow based).

+ +

For example, when the 5th byte is supposed to be 0xd0, this would evalute to a kind of shift operation. it that reasonable? When yes, where does the data come from? Maybe the four bytes between could indicate that.

+ +

Another point is the comment by sudhackar - What does the code do which yields the execution to this block? Which registers are set? Does it push a return location to the stack or is there a hard coded return location? Reversing this information would yield some bytes of the key.

+ +

edit:

+ +

Just realized you have even more information. When you limit the xor key to the range of printable ASCII characters, they will have to be in a range ox 0x20 to 0x7e. Reducing the base problem to 94^12.

+",3162,,14622,,1/25/2019 10:43,1/25/2019 10:43,,,,0,,,,CC BY-SA 4.0 +20466,1,,,1/25/2019 11:17,,1,1904,"

Fortnite has a feature that records your gameplay and saves it as a .replay file, now I don't believe these files are encrypted, only compressed.

+ +

I wasn't able to find a way online to decompress such files and I'd like to know how, and if there's a possibility of decompressing then re-compressing the files again. +I'd like to also know if there's any suggestions to programs that does the job

+ +

Here's the beginning of the file in HexEditor +

+ +

Link for the file (mediafire)

+ +

I've done some testing (replacing values and checking if anything changes) and found a few things: + +(Not sure if they would be any useful but thought I'd still share)

+ +

EDIT: I'm trying to end up with something like this +

+",27227,,27227,,1/25/2019 14:30,11/2/2019 5:11,Decompressing a .replay file,,1,5,,,,CC BY-SA 4.0 +20467,2,,20466,1/25/2019 11:49,,1,,"

This file does not seem encrypted (lots of ASCII).

+ +

This is most likely based on the Unreal Engine 4's replay mechamisms

+ +

According to its documentation, is describes a starting state as well as any changes to this state in chronological order.

+ +

https://docs.unrealengine.com/en-us/Engine/Replay/Streamers#replaydataformat +https://docs.unrealengine.com/en-us/Engine/Replay +https://wiki.unrealengine.com/Replay_System_Tutorial +https://api.unrealengine.com/INT/Engine/Replay/index.html

+ +

Since the source code of UE4 is available online, you could have a look at the sections writing and parsing those replays.

+ +

https://www.unrealengine.com/en-US/ue4-on-github

+ +

-> What exactly do you want to extract from these replays? If you want to generate videos, I recommend capturing the parts you want with third party software.

+",3162,,,,,1/25/2019 11:49,,,,3,,,,CC BY-SA 4.0 +20468,1,,,1/25/2019 13:25,,1,1307,"

I am using x32dbg to debug a program. I want to find the line which corresponds to a pop up message in my program to put a Break point. +But everytime that I set ""Pause"" after the pop up window's opening the program stops in Kifastsystemcallret in ntdll module. +I succeed one time to set a Break point and to work it fine, but I can't do it anymore... +I don't understand... +Thanks for advance for answering and sorry for my bad english and capacities in debugging...

+ +
+ +

Thanks for your answer... I've uploaded two photos... The first shows the call stacks ; the second the KiFastSystemCallRet... I don't know where down the line I will return. +I've tried to type all the expression adresses without any success...

+ +

+",26598,,18317,,1/26/2019 2:28,6/19/2020 4:08,Debugger always paused in ntdll.Kifastsystemcallret,,1,1,,,,CC BY-SA 4.0 +20469,2,,20468,1/25/2019 13:48,,1,,"

when any app is performing a system call it is normal to pause on KiFastSystemCallRet ( windbg callstack for 4 threads when application is paused windbg uses a seperate thread to breakin so the current thread is paused at DoDebugBreak

+ +
0:003> ~*k2
+
+   0  Id: da4.a8c Suspend: 1 Teb: 7ffdf000 Unfrozen
+ChildEBP RetAddr
+0019ead4 75c1cde0 ntdll!KiFastSystemCallRet
+0019ead8 75c1ce13 USER32!NtUserGetMessage+0xc
+
+   1  Id: da4.a24 Suspend: 1 Teb: 7ffde000 Unfrozen
+ChildEBP RetAddr
+00b6fce8 77456a44 ntdll!KiFastSystemCallRet
+00b6fcec 755e6a36 ntdll!NtWaitForMultipleObjects+0xc
+
+   2  Id: da4.ce8 Suspend: 1 Teb: 7ffdd000 Unfrozen
+ChildEBP RetAddr
+029ffec0 77456a44 ntdll!KiFastSystemCallRet
+029ffec4 73e5a41c ntdll!NtWaitForMultipleObjects+0xc
+
+#  3  Id: da4.d8c Suspend: 1 Teb: 7ffdc000 Unfrozen
+ChildEBP RetAddr
+02b9f7f8 774af20f ntdll!DbgBreakPoint
+02b9f828 75a1ed6c ntdll!DbgUiRemoteBreakin+0x3c
+0:003>
+
+ +

a system call is a call which transitions from user mode to kernel mode

+ +

using sysenter instruction normally

+ +

when you issue a pause (f12 , esc) and when paused in that function take a look at call stack to see where down the line you will return

+ +

(you can type printstack in x64dbg commandline also to dump the call stack to log window)

+ +
17 call stack frames (EIP = 774570F4 , ESP = 000AE8EC , EBP = 000AE8FC ):
+000AE900 ntdll._KiFastSystemCallRet@0
+000AE910 uxtheme.74371A62
+000AE920 uxtheme.74371A2F
+000AE970 uxtheme.74371D38
+000AE98C uxtheme.74371F20
+000AE9D4 user32._GetRealWindowOwner@4+78
+000AEE60 calc.00F51F4F
+000AEE8C user32._InternalCallWinProc@20+23
+000AEF04 user32._UserCallWinProcCheckWow@32+B3
+000AEF60 user32._DispatchClientMessage@20+4B
+000AEF88 user32.___fnDWORD@4+24
+000AEFD4 ntdll._KiUserCallbackDispatcher@12+2E
+000AFD50 calc.00F51CBC
+000AFDE0 calc.00F6219A
+000AFDEC kernel32.75A1ED6C
+000AFE2C ntdll.___RtlUserThreadStart@8+27
+000AFE44 ntdll.__RtlUserThreadStart@8+1B
+
+",3473,,3473,,1/25/2019 13:53,1/25/2019 13:53,,,,0,,,,CC BY-SA 4.0 +20471,2,,20447,1/25/2019 15:03,,1,,"

Yes, you can actually debug remotely using 2 Virtual Machines as long as they have network connection.

+ +

Just copy the server file in the dbgsrv folder from IDA directory and choose what type of architecture you will debug.

+ +

+ +

+ +

Just make sure you have to change the permission of the file to executable using chmod +x

+ +

+ +

+",23113,,,,,1/25/2019 15:03,,,,1,,,,CC BY-SA 4.0 +20473,1,20479,,1/26/2019 1:36,,0,548,"

How can I print the opcodes in a trace log?

+ +

I can use {x:bswap([cip])} but this will print a fix amount of bytes (which most of the time will end up as either more or less number of bytes), regardless of the ones that the instruction does have

+",18064,,18064,,1/26/2019 5:08,1/27/2019 9:39,Print opcodes in trace - x64dbg,,2,0,,,,CC BY-SA 4.0 +20477,2,,20473,1/26/2019 17:29,,0,,"

trace record log file already logs opcodes
+select the trace window
+select start run trace
+accept the file name
+and start tracing
+it will trace 50000 steps (default can be configured in preferences) and stop

+ +

and the format of trace file is documented so you can code some utility to parse it if you want

+ +

+",3473,,,,,1/26/2019 17:29,,,,1,,,,CC BY-SA 4.0 +20478,1,,,1/26/2019 18:14,,1,66,"

Is there a tool which can profile the .NET binaries (32-bit and 64-bit) during execution to generate an API trace providing details of the methods called and the parameters passed to each method?

+ +

Since .NET is JIT based, I think it should be feasible to do.

+ +

An API trace in the following format would be desirable:

+ +
<Address 1> <Method 1> <Parameter 1, Parameter 2>
+<Address 2> <Method 2> <Parameter 1, Parameter 2>
+....
+<Address N> <Method N> <Parameter 1, Parameter 2>
+
+ +

And an extension of this question. Is there a tool which can provide the similar information for each Windows API called by the .NET Binary as well?

+",2673,,,,,1/26/2019 18:14,.NET Method Tracing with Parameters,<.net>,0,1,,,,CC BY-SA 4.0 +20479,2,,20473,1/27/2019 9:39,,2,,"

You can use {mem;dis.len(cip)@cip}. See http://help.x64dbg.com/en/latest/introduction/Formatting.html for the relevant documentation.

+",2221,,,,,1/27/2019 9:39,,,,5,,,,CC BY-SA 4.0 +20481,1,20499,,1/27/2019 15:19,,1,139,"

Why does the function not get hooked when called with instance member obj.myFunc() ?

+ +
class Myclass
+{
+
+public:
+    virtual void myFunc() = 0;
+
+};
+class Derived : public Myclass
+{
+public:
+    void myFunc()
+    {
+        std::cout << ""Actual method is called"" << std::endl;
+    }
+};
+
+    void __fastcall hk_myFunc(void* thisPtr, int edx)
+    {
+        std::cout << ""Hooked method is called"" << std::endl;
+    }
+
+typedef void(__thiscall *fPtr)();
+
+int main()
+{
+    Derived* ptr = new Derived();
+    ptr->myFunc();// Output : Actual method is called.
+    void** vTPtr = *(reinterpret_cast<void ***>(ptr));
+    DWORD oldProtection;
+    VirtualProtect(vTPtr, 4, PAGE_EXECUTE_READWRITE, &oldProtection);
+    *vTPtr = reinterpret_cast<fPtr>(&hk_myFunc);
+    VirtualProtect(vTPtr, 4, oldProtection, 0);
+    ptr->myFunc(); //Output: Hooked method is called
+    Derived obj = *ptr;
+    obj.myFunc(); // Output : Actual method is called. Why ??
+    return 0;
+}
+
+",27250,,,,,1/30/2019 5:40,Why does vmt hooking not work with instance member in the following case?,,1,1,,,,CC BY-SA 4.0 +20484,1,20485,,1/27/2019 19:59,,1,1161,"

I am creating a CAN Bus on-bench testing solution which replicates the entire vehicle to test a single module. I have a number of messages that require a CRC byte in order to be valid. The messages are in little-endian byte order, and the CRC value is held in byte 0. I have collected valid messages with a changing 4 bit alive-counter along with their CRC byte with the hope someone can help. I have tried CRC reveng, but either do not know hot to use it correctly or it is unable to find the polynomial, as it shows ""No models found"" when searching.

+ +

For reference, I found documentation that suggests the polynomial used is the standard SAE J1850 CRC8 polynomial x^8 + x^4 + x^3 + x^2 + 1, with a CRC-ID in decimal of 166 (stated as used for the low byte). I have also tried with the online calculator available here: http://www.sunshine2k.de/coding/javascript/crc/crc_js.html, but cannot get the correct result.

+ +

If anyone could provide some assistance, I would greatly appreciate it. I would like help in clarifying the correct polynomial, along with any other relevant parameters. Here are a list of values captured:

+ +

CRC in Byte0

+ +

This is the text version of above. I've separated the CRC value in byte 0 from the rest of the message for clarity.

+ +
57   0000C0F0C1FFFF
+0A   0100C0F0C1FFFF
+ED   0200C0F0C1FFFF
+B0   0300C0F0C1FFFF
+3E   0400C0F0C1FFFF
+63   0500C0F0C1FFFF
+84   0600C0F0C1FFFF
+D9   0700C0F0C1FFFF
+85   0800C0F0C1FFFF
+D8   0900C0F0C1FFFF
+3F   0A00C0F0C1FFFF
+62   0B00C0F0C1FFFF
+EC   0C00C0F0C1FFFF
+B1   0D00C0F0C1FFFF
+56   0E00C0F0C1FFFF
+
+",27246,,27246,,1/27/2019 20:11,1/27/2019 22:40,CRC8 reverse engineering,,1,0,,,,CC BY-SA 4.0 +20485,2,,20484,1/27/2019 22:40,,1,,"

Use that same page, and select CRC_SAE_J1850, but then switch to 'Custom' and change the 'Final Xor Value' to 0x7a.

+ +

The settings should be:

+ +
    +
  • Input Reflected: No
  • +
  • Output Reflected: No
  • +
  • Polynomial: 0x1d
  • +
  • Initial Value: 0xff
  • +
  • Final Xor Value: 0x7a
  • +
+ +

Use Byte1-Byte7 as input.

+ +

Given:

+ +
    +
  • crc_data[n] is the crc from your provided data for dataset n
  • +
  • crc_sae_j1850[n] is the standard CRC SAE J1850 value for dataset n
  • +
+ +

I noticed that for any i, j:

+ +
crc_data[i] ^ crc_data[j] = crc_sae_j1850[i] ^ crc_sae_j1850[j]
+
+ +

e.g. for i=0, j=1:

+ +
0x57 ^ 0x0a = 0xd2 ^ 0x8f
+0x5d        = 0x5d
+
+ +

This means that the final xor value can be adjusted to get the desired values:

+ +
new_final_xor = original_final_xor ^ crc_data[i] ^ crc_sae_j1850[i]
+              = 0xff               ^ 0x57        ^ 0xd2
+              = 0x7a
+
+",12017,,,,,1/27/2019 22:40,,,,1,,,,CC BY-SA 4.0 +20487,1,,,1/28/2019 1:11,,2,129,"

I'm trying to reverse an ARM executable. It's for an embedded system, but I don't have any details about the normally targeted environment.

+ +

Here's what file shows: ELF 32-bit LSB executable, ARM, EABI4 version 1 (SYSV), statically linked, stripped

+ +

I've tried running it on Linux using qemu and the process immediately terminates with the message ""Killed"". Running strace ./executable returns this:

+ +

execve(""./executable"", [""./executable""], [/*13 vars */] <unfinished ...> ++++ killed by SIGKILL +++ +Killed

+ +

I'm using the Debian Wheezy image from here: https://people.debian.org/~aurel32/qemu/armel/

+ +

Any ideas why this is happening?

+",27261,,,,,1/28/2019 11:28,Process Immediately Killed,,1,1,,,,CC BY-SA 4.0 +20488,2,,20461,1/28/2019 3:52,,2,,"

I used a less smart approach. I wrote the hex blob to a file, wrote a quick Python script to add a padding byte after every 15th byte so the whole file is nicely aligned when opening it in a hex editor with standard 16 byte width and just had a look at it.

+ +

With the padding done, all columns share the same key so I just looked at what letter appeared the most in each of the 15 columns, hoping/assuming the most frequent byte in each column (in the plaintext) would be a 0 byte and thus leak a key byte.

+ +

Every column seemed to have a printable character as the most used which fits the context of a crackme where you enter a printable key, so it appeared this worked.

+ +

To verify, I googled for the supposed key and some writeup from 2008 had the same. If that writeup didn't exist I'd have to decode the blob and see if the assembly makes sense of course.

+",23277,,,,,1/28/2019 3:52,,,,2,,,,CC BY-SA 4.0 +20491,2,,20464,1/28/2019 10:47,,0,,"

Simply set the breakpoint on ZwResumeThread (also shown in your screenshot). From user mode the only difference between NtResumeThread and ZwResumeThread is the name prefix. In kernel mode these functions (of ntoskrnl.exe instead of ntdll.dll) have implementation differences indeed.

+ +

You may want to brush up on Windows internals a bit. This article by Geoff Chappell may help.

+",245,,,,,1/28/2019 10:47,,,,0,,,,CC BY-SA 4.0 +20492,2,,20487,1/28/2019 11:28,,3,,"

The process may send itself (or it's child processes) the SIGTERM signal as part of an anti-debugging trick. Hunting for that will require you to search for signal-sending APIs like kill and how/when they're being used by the application.

+ +

A more simple solution, that is not necessarily RE related, could be that the process is killed by the OOM killer.

+ +

To test that, you can run mesg | egrep -i “killed process” inside the emulated machine.

+ +

If that's the case, you can easily disable it (add vm.oom-kill = 0 in /etc/sysctl.conf).

+",2147,,,,,1/28/2019 11:28,,,,0,,,,CC BY-SA 4.0 +20493,1,,,1/28/2019 17:14,,1,1339,"

Am using the free version of IDA pro, and have loaded the program with no apparent problems. I see assembler and stuff.

+ +

The parts of the program I am interested in is where it reads a file. This is a binary file that (I assume) goes into some data structure. I am trying to find out the binary format used in the file.

+ +

Is there some simple way to find the relevant parts of the code?

+ +

Edit: it is a Windows program, not very old, and I am using Linux (if that matters).

+",19805,,19805,,1/28/2019 17:35,10/19/2020 22:02,finding file I/O in IDA Pro (actually IDA free),,1,3,,,,CC BY-SA 4.0 +20494,2,,20493,1/28/2019 18:35,,1,,"

You need to focus on imported functions which access to file. +In your case it could be WinAPI (CreateFileA/W, ReadFile), libc (fopen, fread), libc++ (std::fstream, be careful about the name mangling), etc. +However, the executable could also rely on 3rd parties DLL to do that. +Then you can use the cross-references to see where your program calls these functions.

+",26176,,,,,1/28/2019 18:35,,,,2,,,,CC BY-SA 4.0 +20495,1,20504,,1/28/2019 18:59,,2,747,"

Look at this c program:

+ +
#include <stdio.h>
+
+int my_function(int a, int b);
+
+int my_function(int a, int b)
+{
+    // Imagine a very complex calculation on 'a' and 'b'
+    if (a==0x41 && b==0x42)
+    {
+        return 1;
+    }
+    return 0;
+}
+
+
+int main(int argc , char *argv[])
+{
+    int c = 10;
+    int d = 10;
+    // Lot of stuff, including UI
+    if (my_function(c,d)==1)
+    {
+        printf(""Good\n"");
+    }
+    else
+    {
+        printf(""Wrong !\n"");
+    }
+    return 0;
+}
+
+ +

Suppose i have compiled this program and i do not have source code.

+ +

Here is what is see with a disassembler:

+ +
...
+0x00001180      e8b0ffffff     call sym.my_function
+....
+
+|           ; var int local_8h @ rbp-0x8
+|           ; var int local_4h @ rbp-0x4
+|           ; CALL XREF from 0x00001180 (main)
+|           0x00001135      55             push rbp
+|           0x00001136      4889e5         mov rbp, rsp
+|           0x00001139      897dfc         mov dword [local_4h], edi
+|           0x0000113c      8975f8         mov dword [local_8h], esi
+|           0x0000113f      837dfc41       cmp dword [local_4h], 0x41  ; [0x41:4]=0x4000000 ; 'A'
+|       ,=< 0x00001143      750d           jne 0x1152
+|       |   0x00001145      837df842       cmp dword [local_8h], 0x42  ; [0x42:4]=0x40000 ; 'B'
+|      ,==< 0x00001149      7507           jne 0x1152
+|      ||   0x0000114b      b801000000     mov eax, 1
+|     ,===< 0x00001150      eb05           jmp 0x1157
+|     |||   ; JMP XREF from 0x00001143 (sym.my_function)
+|     |||   ; JMP XREF from 0x00001149 (sym.my_function)
+|     |``-> 0x00001152      b800000000     mov eax, 0
+|     |     ; JMP XREF from 0x00001150 (sym.my_function)
+|     `---> 0x00001157      5d             pop rbp
+\           0x00001158      c3             ret
+
+ +

What i want to do is to write a python/angr program which will try to solve this function and tell me which argument i should send to the function in order to return 1.

+ +

In other words, i want to ask angr this question:

+ +

""Start your analyse at 0x00001135 address. +Tell me what i should put in rbp-0x8 and rbp-0x4 memory addresses in order to reach 0x0000114b code"".

+ +

Thanks

+ +

* EDIT WITH STRING *

+ +
#include <stdio.h>
+#include <string.h>
+
+int my_function(char *s);
+
+int my_function(char *s)
+{
+        if (strlen(s)!=4)
+        {
+                return 0;
+        }
+
+        for (int i=0;i<4;i++)
+        {
+                s[i]++;
+        }
+
+        if (strncmp(s,""b{fs"",4)==0)
+        {
+                return 1;
+        }
+        return 0;
+}
+
+
+int main(int argc , char *argv[])
+{
+        if (my_function(argv[1])==1)
+        {
+                printf(""Good\n"");
+        }
+        else
+        {
+                printf(""Wrong !\n"");
+        }
+        return 0;
+}
+
+",18590,,18590,,1/30/2019 13:35,1/30/2019 13:35,Solve a function with angr,,1,3,,2/1/2019 12:53,,CC BY-SA 4.0 +20496,1,,,1/28/2019 20:31,,1,667,"

I use FindCrypt2 Ida plugin but it detect md4 and not md5 , and not detect sha256.

+ +
    +
  1. How can I detect md5 in assembly?

  2. +
  3. How can I detect sha256 in assembly?

  4. +
+ +

thanks

+",27273,,,,,10/22/2022 3:08,How to detect md5 and sha256?,,1,2,,,,CC BY-SA 4.0 +20497,2,,20496,1/28/2019 21:20,,0,,"

You can usually spot MD5 quite easily by looking for a huge function. It tends to be the biggest function in the whole binary. That's the MD5_Process() (if I recall the name correctly) function which compilers like to unroll completely, thus making it huge.

+ +

Generally, typical hash functions have 3 distinct functions:

+ +
    +
  • An init function setting up the hash context
  • +
  • An update function processing data and updating the hash context
  • +
  • A finish function generating the final hash from the hash context
  • +
+ +

Both MD5 and SHA256 use magic constants in their init function. You should try to find a C source for either, look for the init functions and the constants (usually hidden in some macro) and then search for those constants in your disassembly.

+ +

This is general advice for cryptographic stuff. Find sourcecode, look for distinct constants/patterns and then see if you can find them in disassembly.

+",23277,,,,,1/28/2019 21:20,,,,0,,,,CC BY-SA 4.0 +20499,2,,20481,1/29/2019 7:41,,2,,"

The problem is the way you reference this object with a new pointer.

+ +
Derived obj = *ptr;
+
+ +

This actually creates a new object utilizing the data of the old object. Yay! C++!

+ +

+ +

In line 27 you can see that a new object is generated by calling a constructor. If you have a look at the disassembly, you'll see the vtable is not used for the function call. Hence you end up with the non-modified function.

+ +

+ +

Btw, when you change the line referenced above to

+ +
(*ptr).myFunc();
+
+ +

The output works as expected

+",3162,,3162,,1/30/2019 5:40,1/30/2019 5:40,,,,0,,,,CC BY-SA 4.0 +20501,1,,,1/29/2019 16:45,,4,630,"

I'm reverse-engineering a particular dylib on Mac OS X. The dylib is highly obfuscated, but I suspect it's from some well-known technique that I'm not aware of.

+ +

I'd like to describe it in the hope that someone here could identify it:

+ +
    +
  1. There are junk instructions inserted everywhere, and every basic block is split by a lot of unconditional jump (but no opaque predicate is used).

  2. +
  3. At its core, it looks like a obfuscated VM. It behaves like this:

  4. +
+ +

At entry, it push a starting value on the stack, then call an entry point:

+ +
000000010013E070 68 5C 98 42 11                          push    1142985Ch
+000000010013E075 E8 B5 B4 0E 00                          call    sub_10022952F
+
+ +

The entry (e.g. sub_10022952F) isn't a usual function. It will save all registers and point rsi to an embedded data location that is determined by the push (i.e. the push 1142985Ch above), then starts reading rsi array and jumping accordingly:

+ +
000000010013EED7 8B 06                                   mov     eax, [rsi]
+000000010013EED9 F5                                      ;; cmc
+000000010013EEDA 45 84 FD                                ;; test    r13b, r15b
+000000010013EEDD 48 81 C6 04 00 00 00                    add     rsi, 4
+000000010013EEE4 66 41 81 FA 1C 3B                       ;; cmp     r10w, 3B1Ch
+000000010013EEEA 33 C3                                   xor     eax, ebx
+000000010013EEEC D1 C0                                   rol     eax, 1
+000000010013EEEE E9 FD 8E 15 00                          jmp     loc_100297DF0
+
+0000000100297DF0 FF C0                                   inc     eax
+0000000100297DF2 0F C8                                   bswap   eax
+0000000100297DF4 F8                                      ;; clc
+0000000100297DF5 E9 F2 D6 E4 FF                          jmp     loc_1000E54EC
+
+00000001000E54EC C1 C0 03                                rol     eax, 3
+00000001000E54EF 0F C8                                   bswap   eax
+00000001000E54F1 53                                      push    rbx
+00000001000E54F2 31 04 24                                xor     [rsp], eax
+00000001000E54F5 0F B7 D8                                ;; movzx   ebx, ax
+00000001000E54F8 0F BA F3 82                             ;; btr     ebx, 82h
+00000001000E54FC 5B                                      pop     rbx
+00000001000E54FD F5                                      ;; cmc
+00000001000E54FE 49 F7 C7 E5 0F 9B 74                    ;; test    r15, 749B0FE5h
+00000001000E5505 F9                                      ;; stc
+00000001000E5506 48 63 C0                                movsxd  rax, eax
+00000001000E5509 48 03 F8                                add     rdi, rax
+00000001000E550C E9 D0 49 08 00                          jmp     loc_100169EE1
+
+0000000100169EE1 FF E7                                   jmp     rdi
+
+ +

I've commented out junk code. The code will fetch value from [rsi] into rax, and do some bit-level-operation with rbx; then advance rdi <- rdi + rax; then jump to rdi.

+ +

This structure is everywhere in the dylib, and in a chain connected by jmp rdi, the bit-level-operations are also the same. But chains from different entry point may have different bit operation for rax and rbx.

+ +

The VM doesn't have any central structure (like a dispatcher or something), and the jumps go everywhere, not restricted to some location.

+ +

To call external function like pthread_mutex_lock, it will go out of the VM loop first; then call the external function; then go to another entry point. There are many entry points (push xxxx / call xxxx) to enter VM loop.

+ +

I believe this is some well-known technique, because when the dylib is modified, it will prompt message:

+ +
+

File corrupted! This program has been manipulated and maybe it's + infected by a Virus or cracked. This file won't work anymore.

+
+ +

It's not a standard Mac OS X message, and Google search for this exact message gives a lot of result, but none of them explains the technique itself.

+ +

Some additional information:

+ +
    +
  • It has sections named UPX0/UPX1, but I think they are disguise and the technique has nothing to do with UPX. Because the code only does self-checking, no self-modifying. As a result, it's still obfuscated just as the original file after fully loaded.

  • +
  • I don't know how the it works exactly by now. But I think it's some sort of a VM, because I've traced the invoke of a function of the dylib, I only find the following normal function calls:

  • +
+ +

pthread_mutex_lock --> 3 new operator --> pthread_mutex_unlock.

+ +

And everything else is done inside by those jump rdi structures mentioned above and switches among many entries points. Therefore the rest of the code logic resides in the VM loop.

+",27283,,,,,1/9/2023 8:56,What's this obfuscation technique?,,2,1,,,,CC BY-SA 4.0 +20502,2,,20501,1/29/2019 19:17,,3,,"

I could be wrong, but it looks like VMProtect v3. For this version, this obfuscator inlines all handlers, so that's normal you don't find any dispatcher.

+",26176,,,,,1/29/2019 19:17,,,,1,,,,CC BY-SA 4.0 +20504,2,,20495,1/30/2019 7:50,,5,,"

thanks for your example scenario.

+ +

As a disclamer, I compiled your example source code with clang and my disassembly looks like this:

+ +

+ +

Then all you need is a small python script like this:

+ +
import angr
+
+function_start = 0x4004f0
+function_target = 0x40050e
+function_end = 0x400521
+
+p = angr.Project(""./a.out"")
+state = p.factory.blank_state(addr=function_start)
+a = state.solver.BVS('a', 32)
+b = state.solver.BVS('b', 32)
+state.regs.esi = b
+state.regs.edi = a
+
+sm = p.factory.simulation_manager(state)
+sm.explore(find=function_target, avoid=function_end)
+
+found_path = sm.found[0]
+print 'a: %d\nb: %d' % (found_path.state.se.eval(a), found_path.state.se.eval(b))
+
+ +

Please note this example is trivial, but in any other case you should try to add as many constraints on values as possible.

+ +

edit

+ +

Here we go again with stack variable conditions. For this sake, we just skip the first 4 instructions of the function:

+ +
import angr
+
+function_start = 0x4004fa
+function_target = 0x40050e
+function_end = 0x400521
+
+p = angr.Project(""./a.out"")
+state = p.factory.blank_state(addr=function_start)
+a = state.solver.BVS('a', 32)
+b = state.solver.BVS('b', 32)
+state.mem[state.regs.rbp - 0x8].uint32_t = a
+state.mem[state.regs.rbp - 0xc].uint32_t = b
+
+sm = p.factory.simulation_manager(state)
+sm.explore(find=function_target, avoid=function_end)
+
+found_path = sm.found[0]
+print 'a: %d\nb: %d' % (found_path.state.se.eval(a), found_path.state.se.eval(b))
+
+",3162,,3162,,1/30/2019 8:31,1/30/2019 8:31,,,,7,,,,CC BY-SA 4.0 +20506,1,20510,,1/30/2019 9:30,,1,180,"

This pastebin hosts current URLs hosting the fake invoice of Emotet malware, which is the dropper part of the malware.

+ +

The document is a Office Open XML, and there are two large non textual segments in it.

+ +

I can't make any sense of the other segment.

+ +

One of them is this:

+ +

I assume the other one contains at least some VB script and something else, but it decodes (assuming base64 like the jpg part) to nothing that file recognizes.

+",27293,,,,,1/30/2019 13:01,"Emotet invoice, what is the embedded file inside the word document",,2,1,,,,CC BY-SA 4.0 +20507,2,,20506,1/30/2019 9:56,,2,,"

Without reviewing the file itself, other than a VB script used as a macro, the second part is more likely an obfuscated/encrypted executable file of some sort.

+ +

However since it's evident macros are used, the executable file (either a PE or a script) is probably at least somewhat obfuscated and will only be decoded/decrypted before being it's dropped to disk or something similar.

+ +

Statically, your safest bet would be extracting the macro (that isn't hard, macros are pretty noticeable as far as the standard is concerned) and reversing the decoding/deobfuscating method used.

+ +

An easier approach would be to let the document drop the executable by opening it and letting the macros run inside a VM, optionally using something like process explorer/api monitor to catch the dropped file.

+",2147,,,,,1/30/2019 9:56,,,,2,,,,CC BY-SA 4.0 +20508,1,20512,,1/30/2019 10:41,,2,234,"


+I'm trying reverse engineer the firmware, apparently bare metal, of an industrial controller. The device is based on a Coldfire controller, to be more precise, the MCF5282. To track its behavior, I want to use Qemu in its M68k fashion which is supporting already the MCF5206 and the MCF5208. The Coldfire implementation of Qemu lacks in many places, and it seems targeted to run Linux after the bootloader has left the hardware in a particular state. To run my firmware, I had to patch it removing all the hardware initialization, and write a new Qemu file for the CPU I wanted to target, the MCF5282.

+So far, It seems that my code is working, and the CPU is initialized as the initialization code I have skipped would have done. +When I start my emulation, strangeness begins, and there I ask for your help for understanding what is going on. +When I run

+ +
qemu-system-m68k -nographic -cpu m5282 -kernel Firmware.bin.qemuPatched \
+-serial telnet:127.0.0.1:4444,server,nowait \
+-serial telnet:127.0.0.1:4445,server,nowait \
+-serial telnet:127.0.0.1:4446,server,nowait \
+-d in_asm -D execution.log
+
+ +

I expected all the instruction of the target CPU to be logged, and that's it is what's happened, at least until it reaches a branch instruction.
+That time forward, no more instructions are logged, though the emulation is continuing.

+I can say that emulation is continuing because if I add to the logged properties the target machine status, I see that the CPU state is changing after the that last instruction is logged and the PC is changing also.
+The strangeness does not stop here, and if I follow the PC values, I see that CPU is executing instructions in the firmware address space in an unexpected way, to make a long story short, it seems it is sampling the real flow without writing every single step.

+Does someone recognize in it the expected behavior?

+Also, at least one time, I found a call to a function (jsr) where the flow logged seems to indicate that function is not executed. +It just logs the next instruction, but looking at the CPU state it's clear that function has been executed. +Is Qemu which is malfunctioning, or it's just me who can not understand what is going on?

+ +
----------------
+IN:
+0x00004da6:  movel %fp@(8),%d6
+
+D0 = 00000064   A0 = 00082748   F0 = 7fff ffffffffffffffff  (         nan)
+D1 = 00000028   A1 = 00084778   F1 = 7fff ffffffffffffffff  (         nan)
+D2 = 00000025   A2 = 00000000   F2 = 7fff ffffffffffffffff  (         nan)
+D3 = 00000000   A3 = 00000000   F3 = 7fff ffffffffffffffff  (         nan)
+D4 = 00000000   A4 = 00000000   F4 = 7fff ffffffffffffffff  (         nan)
+D5 = 00000000   A5 = 00000000   F5 = 7fff ffffffffffffffff  (         nan)
+D6 = 00000000   A6 = 0008fe44   F6 = 7fff ffffffffffffffff  (         nan)
+D7 = 00000000   A7 = 0008fe34   F7 = 7fff ffffffffffffffff  (         nan)
+PC = 00004da6   SR = 2004 T:0 I:0 SI --Z--
+FPSR = 00000000 ----
+                                FPCR =     0000 X RN
+  A7(MSP) = 00000000 ->A7(USP) = 0008fe30   A7(ISP) = 00000000
+VBR = 0x00000000
+SFC = 0 DFC 0
+SSW 00000000 TCR 00000000 URP 00000000 SRP 00000000
+DTTR0/1: 00000000/00000000 ITTR0/1: 00000000/00000000
+MMUSR 00000000, fault at 00000000
+----------------
+IN:
+0x00004daa:  jsr 0x4ca0
+
+D0 = 00000064   A0 = 00082748   F0 = 7fff ffffffffffffffff  (         nan)
+D1 = 00000028   A1 = 00084778   F1 = 7fff ffffffffffffffff  (         nan)
+D2 = 00000025   A2 = 00000000   F2 = 7fff ffffffffffffffff  (         nan)
+D3 = 00000000   A3 = 00000000   F3 = 7fff ffffffffffffffff  (         nan)
+D4 = 00000000   A4 = 00000000   F4 = 7fff ffffffffffffffff  (         nan)
+D5 = 00000000   A5 = 00000000   F5 = 7fff ffffffffffffffff  (         nan)
+D6 = 00000064   A6 = 0008fe44   F6 = 7fff ffffffffffffffff  (         nan)
+D7 = 00000000   A7 = 0008fe34   F7 = 7fff ffffffffffffffff  (         nan)
+PC = 00004daa   SR = 2000 T:0 I:0 SI -----
+FPSR = 00000000 ----
+                                FPCR =     0000 X RN
+  A7(MSP) = 00000000 ->A7(USP) = 0008fe30   A7(ISP) = 00000000
+VBR = 0x00000000
+SFC = 0 DFC 0
+SSW 00000000 TCR 00000000 URP 00000000 SRP 00000000
+DTTR0/1: 00000000/00000000 ITTR0/1: 00000000/00000000
+MMUSR 00000000, fault at 00000000
+----------------
+IN:
+0x00004db0:  movew %d0,%d7
+
+D0 = 00000002   A0 = 000822c8   F0 = 7fff ffffffffffffffff  (         nan)
+D1 = 00000020   A1 = 00084778   F1 = 7fff ffffffffffffffff  (         nan)
+D2 = 0000007f   A2 = 00000000   F2 = 7fff ffffffffffffffff  (         nan)
+D3 = 00000000   A3 = 00000000   F3 = 7fff ffffffffffffffff  (         nan)
+D4 = 00000000   A4 = 00000000   F4 = 7fff ffffffffffffffff  (         nan)
+D5 = 00000000   A5 = 00000000   F5 = 7fff ffffffffffffffff  (         nan)
+D6 = 00000064   A6 = 0008fe44   F6 = 7fff ffffffffffffffff  (         nan)
+D7 = 00000000   A7 = 0008fe34   F7 = 7fff ffffffffffffffff  (         nan)
+PC = 00004db0   SR = 2000 T:0 I:0 SI -----
+FPSR = 00000000 ----
+                                FPCR =     0000 X RN
+  A7(MSP) = 00000000 ->A7(USP) = 0008fe30   A7(ISP) = 00000000
+VBR = 0x00000000
+SFC = 0 DFC 0
+SSW 00000000 TCR 00000000 URP 00000000 SRP 00000000
+DTTR0/1: 00000000/00000000 ITTR0/1: 00000000/00000000
+MMUSR 00000000, fault at 00000000
+
+",17411,,,,,1/30/2019 16:39,Weird qemu behaviour with Freescale Coldfire MCF5282,,1,2,,,,CC BY-SA 4.0 +20510,2,,20506,1/30/2019 13:01,,1,,"

the vba appears to be some thing like this +the functions appears to be useless the zillnp appears to take this string

+ +

+ +

you can copy paste the strings and concatentate it

+ +
Sub foo()
+zwrqd = ""c:\on"" + ""jzi"" + ""oi\"" + ""izwolr"" + ""\poic"" + ""wo\"" + ""..\"" + ""..\""
+szrtncm = ""..\win"" + ""dow"" + ""s\sys"" + ""tem32\"" + ""cmd."" + ""exe /c"" + "" %Pro"" + ""gram""
+uvkplhz = ""Data"" + "":~0,1"" + ""%%Pro"" + ""gra"" + ""mData:"" + ""~9,"" + ""2% /"" + ""V:ON/"" + ""C"" + Chr(34) + ""set""
+oujod = "" SiQ=;"" + ""'cjq"" + ""hpb'="" + ""qijm"" + ""nd$}}"" + ""{hct"" + ""ac}};""
+kbuitlk = ""kaerb"" + "";'bchk"" + ""zfb'="" + ""dqk"" + ""zr$"" + "";hkjzj"" + ""lz$ me"" + ""tI-e"" + ""kovnI{""
+bjzzhsa = "" )00"" + ""004 eg"" + ""- htg"" + ""nel.)h"" + ""kjzjlz"" + ""$ m"" + ""etI-t"" + ""eG(("" + "" fI;'""
+
+
+hzipdp = ""jrkj"" + ""ik'=ci"" + ""ikdj$"" + "";)hkjz"" + ""jlz$"" + "" ,qjc"" + ""aki$("" + ""eliFd"" + ""aoln""
+wcwhr = ""woD.ir"" + ""hwidj"" + ""${yrt"" + ""{)ujb"" + ""wa$ "" + ""ni qj"" + ""cak"" + ""i$(h""
+rmflwpm = ""caero"" + ""f;'"" + ""exe.'"" + Chr(43) + ""zbw"" + ""nifi$"" + Chr(43) + ""'\'"" + Chr(43) + ""pmet"" + "":vne""
+wuvcz = ""$=hkj"" + ""zjlz"" + ""$;'ziw"" + ""mvv'=p"" + ""zrifo""
+kqwok = ""h$;'9"" + ""04' = "" + ""zbw"" + ""nifi$;"" + ""'sc"" + ""jmbw'"" + ""=fm"" + ""sqvii$"" + "";)'@""
+wzkwjw = ""'(t"" + ""ilpS"" + "".'41"" + ""fpege"" + ""LDa""
+hrzqojk = ""jCgKn"" + ""c/mo"" + ""c.sse"" + ""nisub"" + ""rusoh.""
+zpftzo = ""www//:"" + ""ptth@"" + ""Mw6O6"" + ""3Df_"" + ""Cm066C"" + ""cdkU"" + ""7o/moc""
+
+rnncbhd = "".ai"" + ""cizy"" + ""hp.ww"" + ""w//:pt"" + ""th@j"" + ""7OEo_7""
+zihij = ""MhAbZ"" + ""p6jnH"" + ""p/z"" + ""t.oc.s"" + ""keeg""
+dwpit = ""t.liam"" + ""//:"" + ""ptt"" + ""h@8or1"" + ""uzsd"" + ""Z8vi"" + ""e/RXI/"" + ""sed"" + ""ulcni-""
+wccvfj = ""pw/moc"" + "".srev"" + ""ireht"" + ""ybkram"" + ""dnal//"" + "":ptth"" + ""@R8Fd3""
+zuvtjrq = ""N9U"" + ""mbY"" + ""BzI/te"" + ""n.en"" + ""onil""
+afactw = ""etoh."" + ""www/"" + ""/:ptt"" + ""h'=ujb"" + ""wa$;"" + ""tnei""
+worhm = ""lCbeW."" + ""teN t"" + ""cejbo-"" + ""wen"" + ""=ir"" + ""hwidj$"" + "";'imsi""
+vaipzq = ""zuu'=i"" + ""ijir"" + ""wb$ ll"" + ""%1,3-~"" + "":PME"" + ""T%h%"" + ""1,4-"" + ""~:EMA"" + ""NNOI""
+zcdjvo = ""SSES%r"" + ""%1,5~"" + "":CILB"" + ""UP%wo"" + ""p&&"" + ""for /""
+vwqmd = ""L %h i"" + ""n (65"" + ""7,-1"" + "",0)"" + ""do s"" + ""et "" + ""nu=!""
+tlpisj = ""nu!!S"" + ""iQ:~"" + ""%h,"" + ""1!&"" + ""&if %h"" + "" eq"" + ""u 0 e"" + ""cho !n""
+nsfmr = ""u:~-6"" + ""58!|"" + "" cmd"" + Chr(34) + "" ""
+
+
+uhdurz = zwrqd + szrtncm + uvkplhz + oujod + kbuitlk + bjzzhsa
+jitovh = hzipdp + wcwhr + rmflwpm + wuvcz + kqwok + wzkwjw + hrzqojk + zpftzo
+wwiqv = rnncbhd + zihij + dwpit + wccvfj + zuvtjrq + afactw + worhm + vaipzq + zcdjvo + vwqmd + tlpisj + nsfmr
+
+
+MsgBox (uhdurz + jitovh + wwiqv)
+
+End Sub
+
+",3473,,,,,1/30/2019 13:01,,,,0,,,,CC BY-SA 4.0 +20511,2,,12730,1/30/2019 16:25,,7,,"

Expensive commercial solutions: Beagle (400€), Ellisys (800 - 3200€), MQP, International Test Instruments (600€), Teledyne Lecroy (1000€), USBeee (1000 - 2000€).

+ +

Cheapest commercial solution I found : Keelog Morphstick, 125€, which is within your budget.

+ +

DIY solutions:

+ + + +

You might also dig into ""USB over IP"".

+",27300,,,,,1/30/2019 16:25,,,,0,,,,CC BY-SA 4.0 +20512,2,,20508,1/30/2019 16:39,,1,,"

I got the explanation by another source, and It seems to me to be appropriate post here the answer I received.

+ +

It is weird, in my eyes I mean, but it is expected behavior, and make also sense with the necessary explanation.
+The nature of Qemu, a JIT translator, implies that all code of the target CPU is translated into the code of the host CPU.
When My code branches to a code part which has been already translated, it just do not translate it again. For that reason, I don't see the istructions in the code log but I see the CPU state changing.

+",17411,,,,,1/30/2019 16:39,,,,0,,,,CC BY-SA 4.0 +20513,1,20565,,1/30/2019 17:11,,6,4499,"

Which operators in C language would result in assembly commands such as sal, shl, sar or shr for example?

+",27301,,3162,,1/31/2019 9:19,10/12/2019 4:55,"Which operators use sal, shl, sar or shr",,2,1,,,,CC BY-SA 4.0 +20514,2,,20513,1/30/2019 18:50,,3,,"
int main (void){
+    unsigned int    uin =  0x1000;
+    signed int      sin = -0x1000;
+   return (uin<<8)+(uin>>8)+(sin<<8)+(sin>>8);   
+}
+
+ +

compiled and linked with

+ +
cl /Zi /W4 /Od /analyze /nologo salsaar.cpp /link /release
+
+ +

disassembled

+ +
:\>cdb -c ""uf salsaar!main;q"" salsaar.exe | grep -A 20 Reading
+0:000> cdb: Reading initial command 'uf salsaar!main;q'
+salsaar!main:
+01121000 55              push    ebp
+01121001 8bec            mov     ebp,esp
+01121003 83ec08          sub     esp,8
+01121006 c745fc00100000  mov     dword ptr [ebp-4],1000h
+0112100d c745f800f0ffff  mov     dword ptr [ebp-8],0FFFFF000h
+01121014 8b45fc          mov     eax,dword ptr [ebp-4]
+01121017 c1e008          shl     eax,8
+0112101a 8b4dfc          mov     ecx,dword ptr [ebp-4]
+0112101d c1e908          shr     ecx,8
+01121020 03c1            add     eax,ecx
+01121022 8b55f8          mov     edx,dword ptr [ebp-8]
+01121025 c1e208          shl     edx,8
+01121028 03c2            add     eax,edx
+0112102a 8b4df8          mov     ecx,dword ptr [ebp-8]
+0112102d c1f908          sar     ecx,8
+01121030 03c1            add     eax,ecx
+01121032 8be5            mov     esp,ebp
+01121034 5d              pop     ebp
+01121035 c3              ret
+
+ +

note shl and sal are both same (opcodes are same and work same ) shr and sar are not same due to signed unsigned diffferences

+",3473,,,,,1/30/2019 18:50,,,,2,,,,CC BY-SA 4.0 +20516,1,20523,,1/30/2019 22:51,,3,1377,"

I'm currently browsing through RTTI information available in an MSVC++2003 executable (writing an IDAPython script to recreate structs for the class hierarchy). Apparently, as visualized here, the RTTI Type Descriptor stores something like the name of the classes or their constructor:

+ +
.?AVexception@@
+    .?AUescaped_list_error@boost@@
+    .?AVruntime_error@stlp_std@@
+
+ +

However, it sports a mangling scheme I do not recognize yet. The name starts with a . which, according to this wiki, is not even a valid start for a mangled MSVC name. IDA and an online name demangler also cannot demangle these names. According to these scripts (s. ms_rtti4.idc) these should map to:

+ +
typeid(struct exception)
+    typeid(struct boost::escaped_list_error)
+    typeid(struct stlp_std::runtime_error)
+
+ +

I tried removing the leading dot to get a valid start at least, but it is still invalid. Quickly writing an overly simplistic python line to at least fix namespaced class names...

+ +
return ""::"".join(reversed(name[4:-2].split(""@"")))
+
+ +

...it of course fails with generic type names, as with these classes here:

+ +
ns::FunctionBase             (.?AVFunctionBase@ns@@)
+    ns::Z::P6AXPAX::?$FunctionT  (.?AV?$FunctionT@P6AXPAX@Z@ns@@)
+    ns::Z::P6AHH::?$FunctionT    (.?AV?$FunctionT@P6AHH@Z@ns@@)
+    ns::Z::P6AHPB_W::?$FunctionT (.?AV?$FunctionT@P6AHPB_W@Z@ns@@)
+    ns::Z::P6AHI::?$FunctionT    (.?AV?$FunctionT@P6AHI@Z@ns@@)
+
+ +

I noticed removing the .?AU or .?AV prefix from those yields kinda useful results (missing the namespace sadly):

+ +
FunctionT@ns@@
+    FunctionT<void (__cdecl*)(void *)>
+    FunctionT<int (__cdecl*)(int)>
+    FunctionT<int (__cdecl*)(wchar_t const *)>
+    FunctionT<int (__cdecl*)(unsigned int)>
+
+ +

...but again that one now doesn't work for non-generic names.

+ +

I wonder if the RTTI Type Descriptor name scheme is documented, or if there is logic turning this into an actual RTTI name I can demangle with the usual tools?

+",6957,,6957,,1/31/2019 13:43,2/20/2022 23:30,How can I demangle the name in an RTTI Type Descriptor?,,2,4,,,,CC BY-SA 4.0 +20517,2,,20516,1/31/2019 5:09,,2,,"

vc++filt seems to demangle it

+ +
?AVexception@@
+ ?? AVexception
+?AUescaped_list_error@boost@@
+ ?? boost::AUescaped_list_error
+?AVruntime_error@stlp_std@@
+ ?? stlp_std::AVruntime_error
+?AUescaped_list_error@boost@@
+ ?? boost::AUescaped_list_error
+
+ +

src slightly edited to strip . in front

+ +
cat cpp.cpp
+#include <windows.h>
+#include <stdio.h>
+#include <dbghelp.h>
+#pragma comment(lib,""dbghelp.lib"")
+#define MAXLEN 0x1000
+char buff[MAXLEN];
+int main (int argc , char * argv[])
+{
+memset(buff,0,MAXLEN);
+if( argc !=2 )
+    {
+        printf (""usage %s undemsym"",argv[0]);
+        exit(-1); 
+    }
+    char *nodot;
+    if( *(char *) argv[1] == '.'  )
+    {
+        nodot = argv[1]+1;
+    }
+    else if (*(char *) argv[1] == '?')
+    {
+        nodot = argv[1];
+    }
+    else
+    {        
+        printf(""not a valid msvc mangled name\n"");
+        exit(-2);
+    }
+    if ( ( UnDecorateSymbolName(nodot , buff,MAXLEN,UNDNAME_COMPLETE)) !=0 )
+        {
+            printf (""%s\n"",buff);
+        }
+        else
+        {
+            printf(""error %x\n"" , GetLastError());
+        }
+}
+
+ +

compile link

+ +
cl /Zi /W4 /analyze /Od cpp.cpp /link /release
+
+ +

test

+ +
cpp.exe
+usage cpp.exe sym
+cpp.exe .?AVruntime_error@stlp_std@@
+.?AVruntime_error@stlp_std@@
+
+cpp.exe ?AVruntime_error@stlp_std@@
+ ?? stlp_std::AVruntime_error
+
+ +

edit for comment (add these lines to src above)

+ +
if ( ( UnDecorateSymbolName(nodot , buff,MAXLEN,  UNDNAME_NO_ARGUMENTS )) !=0 )
+{
+    printf (""%s\n"",buff);
+}
+else
+{
+    printf(""error %x\n"" , GetLastError());
+}
+
+ +

result

+ +
cppundem.exe .?AUescaped_list_error@boost@@
+ ?? boost::AUescaped_list_error
+struct boost::escaped_list_error
+
+ +

full results

+ +
:\cat mang.txt
+.?AVFunctionBase@ns@@
+.?AV?$FunctionT@P6AXPAX@Z@ns@@
+.?AV?$FunctionT@P6AHH@Z@ns@@
+.?AV?$FunctionT@P6AHPB_W@Z@ns@@
+.?AV?$FunctionT@P6AHI@Z@ns@@
+:\for /F %i in (mang.txt) do cppundem.exe %i
+
+:\cppundem.exe .?AVFunctionBase@ns@@
+ ?? ns::AVFunctionBase
+class ns::FunctionBase
+
+:\cppundem.exe .?AV?$FunctionT@P6AXPAX@Z@ns@@
+?AV?$FunctionT@P6AXPAX@Z@ns@@
+class ns::FunctionT<void (__cdecl*)(void *)>
+
+:\cppundem.exe .?AV?$FunctionT@P6AHH@Z@ns@@
+?AV?$FunctionT@P6AHH@Z@ns@@
+class ns::FunctionT<int (__cdecl*)(int)>
+
+:\cppundem.exe .?AV?$FunctionT@P6AHPB_W@Z@ns@@
+?AV?$FunctionT@P6AHPB_W@Z@ns@@
+class ns::FunctionT<int (__cdecl*)(wchar_t const *)>
+
+:\cppundem.exe .?AV?$FunctionT@P6AHI@Z@ns@@
+?AV?$FunctionT@P6AHI@Z@ns@@
+class ns::FunctionT<int (__cdecl*)(unsigned int)>
+
+:\
+
+",3473,,3473,,1/31/2019 17:48,1/31/2019 17:48,,,,3,,,,CC BY-SA 4.0 +20518,1,,,1/31/2019 7:11,,3,1292,"

I've checked several crack me sites and they're all on reverse engineering applications.

+ +

However, I would like to practice reverse engineering by manipulating game values. The cheat engine tool allows us to do this. There's also a bunch of other tools (ex. tsearch) but cheat engine is the most popular. It involves searching through the RAM for various values, and then manipulating the pointer, creating patches to have permanent effects in memory.

+ +

The normal sites aren't a good practice for this because games typically have lots of changing values, especially those that change with user input. Are there any crackme sites which allow me to practice reverse engineering using cheat engine?

+",27291,,,,,2/4/2019 19:51,Are there any crackme sites made for cheat engine or to practice game hacking particularly?,,2,4,,,,CC BY-SA 4.0 +20519,1,,,1/31/2019 9:28,,1,2285,"

I am writing a Pin tool with the following functionality:

+ +
    +
  1. It has to record instructions with arguments. (works well)
  2. +
  3. It has to record memory access operations associated with instructions. (works well)
  4. +
  5. It has to record a name of a function that is being called (if the name is available from external library). This functionality is based on calltrace.cpp from examples provided with Intel Pin. (Partially works well)
  6. +
  7. It has to record where a return instruction has landed (a function name, or, a main module of an instrumented executable). E.g. funcA is called, then funcB is called from funcA, then return from funcB lands in funcA. Recording of rets to functions partially works well, however I have no idea how to record return to the main module.
  8. +
+ +

Before providing a source code let me describe what (as I think) is wrong with the output of a tool that I get.

+ +
    +
  1. Recording begins with a set of instructions that ends with return to a function that has not been called (or at least my PinTool didn't record it).
  2. +
+ +
+

[mov esp, esi]

+ +

[pop ebx]

+ +

R

+ +

[pop edi]

+ +

R

+ +

[pop esi]

+ +

R

+ +

[pop ebp]

+ +

R

+ +

[ret 0x10]

+ +

R

+ +

InDirect RETURN to[RtlAnsiCharToUnicodeChar]

+
+ +
    +
  1. Sometimes it records names of the functions that are called without corresponding call instruction:
  2. +
+ +
+

[push 0x77736e7c]

+ +

W

+ +

[push dword ptr [ebp-0x110]]

+ +

RW

+ +

[call 0x7779a490]

+ +

W

+ +

[LdrGetProcedureAddress]

+ +

[LdrGetProcedureAddressForCaller]

+ +

[RtlAcquireSRWLockExclusive]

+
+ +
    +
  1. Similar is for rets. Even more sometimes it records return to the same function twice in a row (but it should not).
  2. +
+ +
+

[call 0x777a8b60]

+ +

W

+ +

[RtlRetrieveNtUserPfn]

+ +

InDirect RETURN to[RtlDeactivateActivationContextUnsafeFast]

+
+ +

////OR////

+ +
+

[mov ecx, dword ptr [edi]]

+ +

R

+ +

[call 0x7777e531]

+ +

W

+ +

[RtlAddAccessAllowedAce]

+ +

[RtlAcquireSRWLockExclusive]

+ +

InDirect RETURN to[RtlAddAccessAllowedAce]

+ +

[RtlReleaseSRWLockExclusive]

+ +

InDirect RETURN to[RtlAddAccessAllowedAce]

+ +

InDirect RETURN to[RtlAddAccessAllowedAce]

+ +

[mov esi, eax]

+
+ +

I feel like there is something fundamentally wrong in the way I handle these calls and rets ""decoding"". Can someone point me to where am I exactly wrong? Also two secondary questions.

+ +

1) How to record return to the main module of an executable based on the instruction?

+ +

2) Is there a way to get values of IARG_BRANCH_TARGET_ADDR and IARG_BRANCH_TAKEN outside of INS_InsertCall (or similar) functions?

+ +

Thank you.

+ +

The source code is below.

+ +
#include <stdio.h>
+//#include <chrono>
+#include ""pin.H""
+#include <string>
+#include <exception>
+
+FILE * ftrace;
+long long icount=0;
+long long ilimit=1000000;
+BOOL print_args=false;
+
+
+string invalid = ""invalid_rtn"";
+const string *Target2String(ADDRINT target)
+{
+    string name = RTN_FindNameByAddress(target);
+    if (name == """")
+        return &invalid;
+    else
+        return new string(name);
+}
+
+VOID  do_call_args(const string *s, ADDRINT arg0)
+{
+    fprintf(ftrace, ""\n[%s]\n"", (*s).c_str()); //(INS_Disassemble(ins)).c_str()
+    fflush(ftrace);
+}
+
+/* ===================================================================== */
+
+VOID  do_call_args_indirect(ADDRINT target, BOOL taken, ADDRINT arg0)
+{
+    if (!taken) return;
+
+    const string *s = Target2String(target);
+    do_call_args(s, arg0);
+
+    if (s != &invalid)
+        delete s;
+}
+
+/* ===================================================================== */
+
+VOID  do_call(const string *s)
+{
+    fprintf(ftrace, ""\n[%s]\n"", (*s).c_str()); //(INS_Disassemble(ins)).c_str()
+    fflush(ftrace);
+}
+
+VOID  do_ret(const string *s)
+{
+    fprintf(ftrace, ""\nDirect RETURN to[%s]\n"", (*s).c_str()); //(INS_Disassemble(ins)).c_str()
+    fflush(ftrace);
+}
+
+/* ===================================================================== */
+
+VOID  do_call_indirect(ADDRINT target, BOOL taken)
+{
+    if (!taken) return;
+
+    const string *s = Target2String(target);
+    do_call(s);
+
+    if (s != &invalid)
+        delete s;
+}
+
+VOID  do_ret_indirect(ADDRINT target, BOOL taken)
+{
+    if (!taken) return;
+
+    const string *s = Target2String(target);
+    fprintf(ftrace, ""\nInDirect RETURN to[%s]\n"", (*s).c_str()); //(INS_Disassemble(ins)).c_str()
+    fflush(ftrace);
+
+    if (s != &invalid)
+        delete s;
+}
+
+
+VOID Instruction(INS ins, VOID *v)
+{
+
+    //start = std::chrono::high_resolution_clock::now();
+    UINT32 memOperands = INS_MemoryOperandCount(ins);
+
+    fprintf(ftrace, ""\n[%s]\n"", (INS_Disassemble(ins)).c_str()); //(INS_Disassemble(ins)).c_str()
+    fflush(ftrace);
+    if (INS_IsCall(ins))
+    {
+        if (INS_IsDirectBranchOrCall(ins))
+        {
+            const ADDRINT target = INS_DirectBranchOrCallTargetAddress(ins);
+
+
+            INS_InsertPredicatedCall(ins, IPOINT_BEFORE, AFUNPTR(do_call_args),
+                IARG_PTR, Target2String(target), IARG_FUNCARG_CALLSITE_VALUE, 0, IARG_END);
+
+        }
+        else
+        {
+            INS_InsertCall(ins, IPOINT_BEFORE, AFUNPTR(do_call_indirect),
+                IARG_BRANCH_TARGET_ADDR, IARG_BRANCH_TAKEN, IARG_END);
+        }
+    }
+    else
+    {
+        if (INS_IsRet(ins))
+        {
+            if (INS_IsDirectBranchOrCall(ins))
+            {
+                const ADDRINT target = INS_DirectBranchOrCallTargetAddress(ins);
+
+
+                INS_InsertCall(ins, IPOINT_BEFORE, AFUNPTR(do_ret),
+                    IARG_PTR, Target2String(target), IARG_FUNCARG_CALLSITE_VALUE, 0, IARG_END);
+
+            }
+            else
+            {
+                INS_InsertCall(ins, IPOINT_BEFORE, AFUNPTR(do_ret_indirect),
+                    IARG_BRANCH_TARGET_ADDR, IARG_BRANCH_TAKEN, IARG_END);
+            }
+        }
+        else
+        {
+            // sometimes code is not in an image
+            RTN rtn = INS_Rtn(ins);
+
+            // also track stup jumps into share libraries
+            if (RTN_Valid(rtn) && !INS_IsDirectBranchOrCall(ins) && "".plt"" == SEC_Name(RTN_Sec(rtn)))
+            {
+                if (print_args)
+                {
+                    INS_InsertCall(ins, IPOINT_BEFORE, AFUNPTR(do_call_args_indirect),
+                        IARG_BRANCH_TARGET_ADDR, IARG_BRANCH_TAKEN, IARG_FUNCARG_CALLSITE_VALUE, 0, IARG_END);
+                }
+                else
+                {
+                    INS_InsertCall(ins, IPOINT_BEFORE, AFUNPTR(do_call_indirect),
+                        IARG_BRANCH_TARGET_ADDR, IARG_BRANCH_TAKEN, IARG_END);
+
+                }
+            }
+        }
+    }
+
+
+
+        for (UINT32 memOp = 0; memOp < memOperands; memOp++)
+        {
+
+            if (INS_MemoryOperandIsRead(ins, memOp))
+            {
+                fprintf(ftrace, ""R"");
+                icount++;
+
+            }
+
+            if (INS_MemoryOperandIsWritten(ins, memOp))
+            {
+
+                fprintf(ftrace, ""W"");
+                icount++;
+
+            }
+        }
+
+}
+VOID Fini(INT32 code, VOID *v)
+{    fprintf(ftrace, ""\n"");
+    fclose(ftrace);
+}
+INT32 Usage()
+{
+    PIN_ERROR( ""This Pintool prints a trace of memory addresses\n""
+              + KNOB_BASE::StringKnobSummary() + ""\n"");
+    return -1;
+}
+KNOB<string> KnobOutputFile(KNOB_MODE_WRITEONCE, ""pintool"",
+    ""o"", ""pinatrace2.out"", ""specify output file name"");
+
+KNOB<long long> KnobInsLimit(KNOB_MODE_WRITEONCE, ""pintool"",
+    ""i"", ""1000"", ""specify instruction limit"");
+
+KNOB<BOOL>   KnobPrintArgs(KNOB_MODE_WRITEONCE, ""pintool"", ""a"", ""0"", ""print call arguments "");
+
+int main(int argc, char *argv[])
+{
+    PIN_InitSymbols();
+    if (PIN_Init(argc, argv)) return Usage();   
+    ilimit=KnobInsLimit.Value();   
+    ftrace = fopen(KnobOutputFile.Value().c_str(), ""w"");
+    print_args = KnobPrintArgs.Value();
+    INS_AddInstrumentFunction(Instruction, 0);
+    //TRACE_AddInstrumentFunction(Trace, 0);
+    PIN_AddFiniFunction(Fini, 0);   
+    PIN_StartProgram();
+
+    return 0;
+}
+
+",15278,,,,,10/19/2021 2:00,"Tracing calls, rets and instructions with Intel Pin",,0,2,,,,CC BY-SA 4.0 +20520,1,,,1/31/2019 10:16,,1,757,"

Currently I am analyzing a .so file and there is a function which is supposed to be large (high number of nodes and edges). However, IDA Pro identified it as a small function, with various parts of the code being treated as individual sub routines and some of them have attributes of ""no return"".

+ +

I tried to use append_func_tail to combine the sub routines together but the function returns false.

+ +

I am trying to do these

+ +
    +
  • Combine the various sub routines together into one main sub routine
  • +
  • Calculate the cyclomatic complexity value of this big sub routine
  • +
+ +

Is there a way to do the above?

+",27105,,2147,,2/4/2019 12:31,2/4/2019 12:31,Combine various sub routines into one sub routine (IDA Pro),,1,4,,,,CC BY-SA 4.0 +20521,1,,,1/31/2019 11:02,,2,354,"

I am reverse-engineering an 8051 architecture program of a specific chip. +The disassembly naturally doesn't contain any function names, and the register names are minimal. For example, address 0xb3 is a specific register with the name ""RTC2CON"". since the register name is specific for the chip the disassembly doesn't show it but rather ""0xb3"".

+ +

My question is how can I set a rule that will replace every occurrence of a certain string in the disassembly (in this case 0xb3) with another string (the register name RTC2CON).

+ +

Another Example

+ +
|           0x0000393b      c2e9           clr 0xe8.1                  ; 
+|           0x0000393d      1239dd         lcall TRANSMIT_r7_AND_GET_r7=RF_STATUS
+|           0x00003940      e4             clr a
+|           0x00003941      ff             mov r7, a
+|           0x00003942      1239dd         lcall TRANSMIT_r7_AND_GET_r7=RF_STATUS
+|           0x00003945      8f36           mov 0x36, r7                ; 
+|           0x00003947      d2e9           setb 0xe8.1                 ; 
+\           0x00003949      22             ret
+
+ +

To be more clear the chip is the nRF24LE1. In this example there is a manipulation on the special function register on adress 0xe8 (RFCON) +Bit 1 is firstly cleared, and after some operation it is set again.

+ +

What I want is simply that the dissasembly will display RFCON.1 instead of 0xe8.1

+ +

Another problem I have is with a function that is called using ljmp instead of lcall. When I try to rename that function with afn the new name goes instead to the function calling it with ljmp. The function called has 58 XREFS and therefore it is very important to me to see it's name and not it's address when it is called. (functions default name is their fcn.address).

+",27309,,245,,2/28/2020 12:18,2/28/2020 12:18,Setting register names in Radare2,,1,0,,,,CC BY-SA 4.0 +20523,2,,20516,1/31/2019 14:09,,2,,"

Via Igor Skochinsky's classic IDA RTTI scripts, I found out that the names I posted are equivalent to typeid(struct xyz) (as I've added to my question).

+

Abusing creating a valid mangled dtor name from a substring of them and then stripping the ctor parts from the result yields great class names.

+

Here's my Python script and the results:

+
def demangle(name):
+    # Check if this even is a problematic typeid.
+    if name.startswith(".?A"):
+        # Remove the .?AU or .?AV prefix.
+        name = name[4:]
+        # Demangle it as a default public destructor call.
+        dtor_name = "??1" + name + "QAE@XZ"
+        name = your_default_msvc_demangler.demangle(dtor_name)
+        # Strip destructor pre and suffixes again (accessor / cconv and parameter list).
+        name = name[len("public: __thiscall "):name.rfind("(")]
+        # Remove dtor name.
+        parts = name.split("~")
+        return parts[0][:-2]
+    else:
+        return your_default_msvc_demangler.demangle(name)
+
+

And here are sample results for the names given in my question:

+
exception
+    boost::escaped_list_error
+    stlp_std::runtime_error
+
+ns::FunctionBase::FunctionBase
+    ns::FunctionT<void (__cdecl *)(void *)>
+    ns::FunctionT<int (__cdecl *)(int)>
+    ns::FunctionT<int (__cdecl *)(wchar_t const *)>
+    ns::FunctionT<int (__cdecl *)(unsigned int)>
+
+

Probably not very elegant, but working.

+",6957,,6957,,2/20/2022 23:30,2/20/2022 23:30,,,,0,,,,CC BY-SA 4.0 +20524,2,,20521,1/31/2019 18:18,,1,,"

not sure what b3 register is

+ +

as to naming the destination of calls / jumps you do something like this

+ +
[0x00000788]> pd~lcall
+|           0x00000797      124ef3         lcall 0x4ef3
+|       |   0x000007a7      124ac0         lcall 0x4ac0
+[0x00000788]> f loc.somefun @0x4ef3
+[0x00000788]> f loc.somefun2 @0x4ac0
+[0x00000788]> pd~ljmp
+        ,=< 0x000007cd      024ac4         ljmp 0x4ac4
+[0x00000788]> f loc.somejump @0x4ac4
+[0x00000788]> pd~ljmp
+        ,=< 0x000007cd      024ac4         ljmp loc.somejump
+[0x00000788]> pd~lcall
+|           0x00000797      124ef3         lcall loc.somefun
+|       |   0x000007a7      124ac0         lcall loc.somefun2
+[0x00000788]>
+
+ +

is it about special function register from 0x80 to 0xff

+ +

you can probably flag them as shown above

+ +
[0x000000b3]> s 0xb3
+[0x000000b3]> pd 2
+            ;-- reg.RTC2CON:
+            0x000000b3      00             nop
+            0x000000b4      00             nop
+[0x000000b3]> f reg.RTC2CONNED @ 0xb3
+[0x000000b3]> pd 2
+            ;-- reg.RTC2CON:
+            ;-- reg.RTC2CONNED:
+            0x000000b3      00             nop
+            0x000000b4      00             nop
+[0x000000b3]>
+
+ +

i remembered it flagged the sfr's automatically but it seems its implementation is not complete you may have to either add the required bits and submit a pull request or open an issue in

+ +

it decodes 8 bits out of possible 16 bits +src is here 8051 implementation

+ +

i just made simple test result as follows

+ +
>xxd sfrtest.bin
+0000000: c2e0 c2e1 c2e2 c2e3 c2e4 c2e5 c2e6 c2e7  ................
+0000010: c2e8 c2e9 c2ea c2eb c2ec c2ed c2ee c2ef  ................
+>radare2 -a 8051 sfrtest.bin
+ -- This software is sold for home use only and all other rights are expressly reversed by the copyleft owner.
+[0x00000000]> pd 10
+            0x00000000      c2e0           clr acc.0                   ; [0x100001e0:1]=0
+            0x00000002      c2e1           clr acc.1                   ; [0x100001e0:1]=0
+            0x00000004      c2e2           clr acc.2                   ; [0x100001e0:1]=0
+            0x00000006      c2e3           clr acc.3                   ; [0x100001e0:1]=0
+            0x00000008      c2e4           clr acc.4                   ; [0x100001e0:1]=0
+            0x0000000a      c2e5           clr acc.5                   ; [0x100001e0:1]=0
+            0x0000000c      c2e6           clr acc.6                   ; [0x100001e0:1]=0
+            0x0000000e      c2e7           clr acc.7                   ; [0x100001e0:1]=0
+            0x00000010      c2e8           clr 0xe8.0                  ; [0x100001e8:1]=0
+            0x00000012      c2e9           clr 0xe8.1                  ; [0x100001e8:1]=0
+[0x00000000]>
+
+",3473,,3473,,2/2/2019 8:49,2/2/2019 8:49,,,,4,,,,CC BY-SA 4.0 +20525,1,20527,,1/31/2019 21:54,,0,102,"

Can you explain to me the significance of link address 2000 8000 7C00? It's in a MACRO from the GRUB configure script, which checks whether OBJCOPY works for absolute addresses.

+ +

Here's the snippet of the code:

+ +
AC_DEFUN([grub_PROG_OBJCOPY_ABSOLUTE],
+[AC_MSG_CHECKING([whether ${OBJCOPY} works for absolute addresses])
+AC_CACHE_VAL(grub_cv_prog_objcopy_absolute,
+[cat > conftest.c <<\EOF
+void
+cmain (void)
+{
+   *((int *) 0x1000) = 2;
+}
+EOF
+
+if AC_TRY_EVAL(ac_compile) && test -s conftest.o; then :
+else
+  AC_MSG_ERROR([${CC-cc} cannot compile C source code])
+fi
+grub_cv_prog_objcopy_absolute=yes
+for link_addr in 2000 8000 7C00; do
+  if AC_TRY_COMMAND([${CC-cc} ${CFLAGS} -nostdlib -Wl,-N -Wl,-Ttext -Wl,$link_addr conftest.o -o conftest.exec]); then :
+  else
+    AC_MSG_ERROR([${CC-cc} cannot link at address $link_addr])
+  fi
+  if AC_TRY_COMMAND([${OBJCOPY-objcopy} -O binary conftest.exec conftest]); then :
+  else
+    AC_MSG_ERROR([${OBJCOPY-objcopy} cannot create binary files])
+  fi
+  if test ! -f conftest.old || AC_TRY_COMMAND([cmp -s conftest.old conftest]); then
+    mv -f conftest conftest.old
+  else
+    grub_cv_prog_objcopy_absolute=no
+    break
+  fi
+done
+
+",27078,,,,,2/1/2019 8:06,Significance of link address 2000 8000 7C00;,,1,1,,,,CC BY-SA 4.0 +20526,1,,,1/31/2019 23:37,,1,86,"

A program is loading an VB6 based ActiveX control that has several property, for example ConnectionString. +The application is dynamically generating the values it provides at runtime, so it is not straightforward to identify through static analysis. While I can dump memory of the process and find some of these values, some are not simple strings so not as straightforward to find this way.

+ +

I built a test VB6 program and compiled with symbols with code like this:

+ +
Private Sub SetConnectionString()
+aABCFeeList1.ConnectionString = ""Provider=SQLOLEDB;Trusted_Connection=Yes;initial catalog=sql;data source=sqlserver;""
+End Sub
+
+ +

In IDA this shows disassembled as:

+ +
.text:00401D20 ; void __stdcall Form1::SetConnectionString(Form1 *this)
+.text:00401D20 ?SetConnectionString@Form1@@AAGXXZ proc near ; CODE XREF: .text:004016E0j
+.text:00401D20
+.text:00401D20 var_20          = dword ptr -20h
+.text:00401D20 var_18          = dword ptr -18h
+.text:00401D20 var_14          = dword ptr -14h
+.text:00401D20 var_10          = dword ptr -10h
+.text:00401D20 var_8           = dword ptr -8
+.text:00401D20 var_4           = dword ptr -4
+.text:00401D20 this            = dword ptr  8
+.text:00401D20
+.text:00401D20                 push    ebp
+.text:00401D21                 mov     ebp, esp
+.text:00401D23                 sub     esp, 8
+.text:00401D26                 push    offset ___vbaExceptHandler
+.text:00401D2B                 mov     eax, large fs:0
+.text:00401D31                 push    eax
+.text:00401D32                 mov     large fs:0, esp
+.text:00401D39                 sub     esp, 28h
+.text:00401D3C                 push    ebx
+.text:00401D3D                 push    esi
+.text:00401D3E                 push    edi
+.text:00401D3F                 mov     [ebp+var_8], esp
+.text:00401D42                 mov     [ebp+var_4], offset dword_4010A0
+.text:00401D49                 sub     esp, 10h
+.text:00401D4C                 mov     ecx, 8
+.text:00401D51                 mov     edx, esp
+.text:00401D53                 mov     eax, offset ___vba@09EB2DB8
+.text:00401D58                 push    68030012h
+.text:00401D5D                 mov     [ebp+var_14], 0
+.text:00401D64                 mov     [edx], ecx
+.text:00401D66                 mov     ecx, [ebp+var_20]
+.text:00401D69                 mov     [edx+4], ecx
+.text:00401D6C                 mov     [edx+8], eax
+.text:00401D6F                 mov     eax, [ebp+var_18]
+.text:00401D72                 mov     [edx+0Ch], eax
+.text:00401D75                 mov     eax, [ebp+this]
+.text:00401D78                 push    eax
+.text:00401D79                 mov     ecx, [eax]
+.text:00401D7B                 call    dword ptr [ecx+2FCh]
+.text:00401D81                 lea     edx, [ebp+var_14]
+.text:00401D84                 push    eax
+.text:00401D85                 push    edx
+.text:00401D86                 call    ds:__imp____vbaObjSet
+.text:00401D8C                 push    eax
+.text:00401D8D                 call    ds:__imp____vbaLateIdSt
+.text:00401D93                 lea     ecx, [ebp+var_14]
+.text:00401D96                 call    ds:__imp____vbaFreeObj
+.text:00401D9C                 push    offset loc_401DAE
+.text:00401DA1                 jmp     short loc_401DAD
+.text:00401DA3 ; ---------------------------------------------------------------------------
+.text:00401DA3
+.text:00401DA3 loc_401DA3:                             ; DATA XREF: .text:004010ACo
+.text:00401DA3                 lea     ecx, [ebp+var_14]
+.text:00401DA6                 call    ds:__imp____vbaFreeObj
+.text:00401DAC                 retn
+.text:00401DAD ; ---------------------------------------------------------------------------
+.text:00401DAD
+.text:00401DAD loc_401DAD:                             ; CODE XREF: Form1::SetConnectionString(void)+81j
+.text:00401DAD                 retn
+.text:00401DAE ; ---------------------------------------------------------------------------
+.text:00401DAE
+.text:00401DAE loc_401DAE:                             ; CODE XREF: Form1::SetConnectionString(void):loc_401DADj
+.text:00401DAE                                         ; DATA XREF: Form1::SetConnectionString(void)+7Co
+.text:00401DAE                 mov     ecx, [ebp+var_10]
+.text:00401DB1                 pop     edi
+.text:00401DB2                 pop     esi
+.text:00401DB3                 xor     eax, eax
+.text:00401DB5                 mov     large fs:0, ecx
+.text:00401DBC                 pop     ebx
+.text:00401DBD                 mov     esp, ebp
+.text:00401DBF                 pop     ebp
+.text:00401DC0                 retn    4
+.text:00401DC0 ?SetConnectionString@Form1@@AAGXXZ endp
+
+ +

In this case the connection string is being set at line

+ +
  .text:00401D53                 mov     eax, offset ___vba@09EB2DB8
+
+ +

My question is how I can identify

+ +

1) Which ActiveX control this code is configuring +2) Which property on the ActiveX control it is setting

+ +

The program I need to find this in is much larger and more complex.

+ +

Some other reference:

+ +
dword_4010A0    dd 40004h, 2 dup(0)   
+
+ +

If I could find references to the ActiveX control in question I should be able to configure breakpoints.

+ +

I set a breakpoint on module load of the ActiveX control in WinDbg, as I suspect I will need to capture initialization:

+ +
0:000> sxe ld FeeList.ocx
+0:000> g
+ModLoad: 75f50000 75f76000   C:\WINDOWS\SysWOW64\IMM32.DLL
+ModLoad: 73cd0000 73cdf000   C:\WINDOWS\SysWOW64\kernel.appcore.dll
+ModLoad: 73c10000 73c8c000   C:\WINDOWS\SysWOW64\uxtheme.dll
+ModLoad: 5fd70000 5fdf6000   C:\WINDOWS\SysWOW64\SXS.DLL
+ModLoad: 74080000 741c3000   C:\WINDOWS\SysWOW64\MSCTF.dll
+ModLoad: 704a0000 704c3000   C:\WINDOWS\SysWOW64\dwmapi.dll
+ModLoad: 76b70000 76bf3000   C:\WINDOWS\SysWOW64\clbcatq.dll
+ModLoad: 615b0000 615cf000   C:\adv2000\FeeList.ocx
+eax=00000000 ebx=00800000 ecx=00000000 edx=00000000 esi=007db8d8 edi=007db820
+eip=7744ab5c esp=0019e034 ebp=0019e080 iopl=0         nv up ei pl nz na po nc
+cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00000202
+ntdll!NtMapViewOfSection+0xc:
+7744ab5c c22800          ret     28h
+0:000> kv
+ # ChildEBP RetAddr  Args to Child              
+00 0019e030 7741878f 000001cc ffffffff 007db8f0 ntdll!NtMapViewOfSection+0xc (FPO: [10,0,0])
+01 0019e080 7741856d 007db820 00000000 007db82c ntdll!LdrpMinimalMapModule+0xa0 (FPO: [Non-Fpo])
+02 0019e0a8 77415643 007db820 00000000 007db904 ntdll!LdrpMapDllWithSectionHandle+0x15 (FPO: [Non-Fpo])
+03 0019e0f8 7743418c 0019e2f8 007db820 00000000 ntdll!LdrpMapDllNtFileName+0x12f (FPO: [Non-Fpo])
+04 0019e228 7743393e 9e745ffd 0019e2f8 0019e2f4 ntdll!LdrpMapDllFullPath+0xbc (FPO: [0,71,4])
+05 0019e278 7742aff7 9e745f45 0019e438 0019e4c8 ntdll!LdrpProcessWork+0x10a (FPO: [SEH])
+06 0019e2c0 7741a8eb 00000600 00000004 00000000 ntdll!LdrpLoadDllInternal+0x17c (FPO: [SEH])
+07 0019e40c 77417d42 00000000 00000001 0019e430 ntdll!LdrpLoadDll+0x93 (FPO: [3,71,4])
+08 0019e490 76ee3b58 00002009 0019e4b8 0019e4c8 ntdll!LdrLoadDll+0x92 (FPO: [Non-Fpo])
+09 0019e4d4 762192c8 0019e598 00000000 00002008 KERNELBASE!LoadLibraryExW+0x148 (FPO: [Non-Fpo])
+0a 0019e4f8 76219245 00002008 0019e560 0019e598 combase!LoadLibraryWithLogging+0x1b (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\common\loadfree.cxx @ 160] 
+0b 0019e524 762190a2 0019e558 0019e55c 0019e560 combase!CClassCache::CDllPathEntry::LoadDll+0x50 (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\dllcache.cxx @ 2394] 
+0c 0019e56c 7621615b 0019e590 007db588 80004005 combase!CClassCache::CDllPathEntry::Create+0x35 (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\dllcache.cxx @ 2235] 
+0d 0019e7c4 761fd3de 00000001 0019eb3c 0019e814 combase!CClassCache::CClassEntry::CreateDllClassEntry+0xf3 (FPO: [Non-Fpo]) (CONV: thiscall) [onecore\com\combase\objact\dllcache.cxx @ 1070] 
+0e 0019eaf4 761b5239 0019eb1c f57d20f9 0019eb28 combase!CClassCache::GetClassObjectActivator+0x52e (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\dllcache.cxx @ 5516] 
+0f 0019eb28 761b507a 0019f164 761b4f50 0019f85c combase!CClassCache::GetClassObject+0x30 (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\dllcache.cxx @ 5284] 
+10 (Inline) -------- -------- -------- -------- combase!CCGetClassObject+0x3d (Inline Function @ 761b507a) (CONV: stdcall) [onecore\com\combase\objact\dllcache.cxx @ 8308] 
+11 0019eb94 762088ad 7633b4a4 0019f164 0019f85c combase!CServerContextActivator::GetClassObject+0x12a (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\actvator.cxx @ 719] 
+12 0019ebd0 7622173b 0019f164 0019f85c 00000000 combase!ActivationPropertiesIn::DelegateGetClassObject+0x8d (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\actprops\actprops.cxx @ 1832] 
+13 0019ebf8 76221056 7633b4a8 0019f164 0019f85c combase!CApartmentActivator::GetClassObject+0x6b (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\actvator.cxx @ 2089] 
+14 0019ec1c 762210d0 7633b4a0 00000001 00000000 combase!CProcessActivator::GCOCallback+0x56 (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\actvator.cxx @ 1569] 
+15 0019ec40 7622115b 7633b4a0 0019ef90 00000000 combase!CProcessActivator::AttemptActivation+0x40 (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\actvator.cxx @ 1524] 
+16 0019ec84 762213aa 7633b4a0 0019ef90 00000000 combase!CProcessActivator::ActivateByContext+0x7b (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\actvator.cxx @ 1390] 
+17 0019ecb4 762088c0 7633b4a0 0019f164 0019f85c combase!CProcessActivator::GetClassObject+0x6a (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\actvator.cxx @ 1213] 
+18 0019ecf0 76205907 0019f164 0019f85c 003a0043 combase!ActivationPropertiesIn::DelegateGetClassObject+0xa0 (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\actprops\actprops.cxx @ 1832] 
+19 0019ef44 7620888d 7633b49c 0019f164 0019f85c combase!CClientContextActivator::GetClassObject+0xd7 (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\actvator.cxx @ 451] 
+1a 0019ef80 76202204 0019f164 0019f85c 76124fa8 combase!ActivationPropertiesIn::DelegateGetClassObject+0x6d (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\actprops\actprops.cxx @ 1884] 
+1b 0019f99c 7618cd55 00000000 66030510 00000000 combase!ICoGetClassObject+0x834 (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\objact.cxx @ 1341] 
+1c 0019fa50 7618cc3e 00000000 66030510 0019fad0 combase!CComActivator::DoGetClassObject+0xef (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\immact.hxx @ 337] 
+*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\WINDOWS\SysWOW64\MSVBVM60.DLL - 
+1d 0019fa70 66070023 005b5cf4 00000003 00000000 combase!CoGetClassObject+0x4e (FPO: [Non-Fpo]) (CONV: stdcall) [onecore\com\combase\objact\actapi.cxx @ 84] 
+WARNING: Stack unwind information not available. Following frames may be wrong.
+1e 0019fa9c 66044e26 005b5cf4 00000003 00000000 MSVBVM60!IID_IVbaHost+0x419e3
+1f 0019fad4 66045557 0000002d 02392574 66012f70 MSVBVM60!IID_IVbaHost+0x167e6
+20 0019fb2c 66048e33 00000001 02392574 0019fb74 MSVBVM60!IID_IVbaHost+0x16f17
+21 0019fb3c 6606d2cc 0000002d 02392574 005b5c70 MSVBVM60!IID_IVbaHost+0x1a7f3
+22 0019fb74 66032695 02392ccc 02392574 02392b1c MSVBVM60!IID_IVbaHost+0x3ec8c
+23 0019fba0 6603291b 024a05bc 0019fbc4 02392ccc MSVBVM60!IID_IVbaHost+0x4055
+24 0019fbc8 6603295e 024a05bc 02392574 00000000 MSVBVM60!IID_IVbaHost+0x42db
+25 0019fbf8 66032737 024a05bc 02392501 00000000 MSVBVM60!IID_IVbaHost+0x431e
+26 0019fc30 660320a5 024a05bc 02392574 02392454 MSVBVM60!IID_IVbaHost+0x40f7
+27 0019fc90 66031ead 024a05bc 00000000 00000000 MSVBVM60!IID_IVbaHost+0x3a65
+28 0019fcb0 660648d1 024a05bc 005b5f9c 00000000 MSVBVM60!IID_IVbaHost+0x386d
+29 0019fd08 6606ff18 0019fd40 00000001 024a05bc MSVBVM60!IID_IVbaHost+0x36291
+2a 0019fd44 6601e703 02392454 00000001 00403010 MSVBVM60!IID_IVbaHost+0x418d8
+2b 0019fe94 66007b3e 024a05bc 00401358 005b05bc MSVBVM60!Zombie_Release+0xfcaa
+2c 0019feb8 66003981 00401358 00000000 00401358 MSVBVM60!BASIC_CLASS_QueryInterface+0xeca
+2d 0019fed8 660036fa 00400000 00400000 0040116c MSVBVM60!ThunRTMain+0x3dd
+2e 0019fef8 66003600 00000000 00400000 0040116c MSVBVM60!ThunRTMain+0x156
+2f 0019ff78 00401176 00401358 75f98484 00321000 MSVBVM60!ThunRTMain+0x5c
+30 0019ff94 77443ab8 00321000 9e744259 00000000 fee3!__vbaS+0xa
+31 0019ffdc 77443a88 ffffffff 7745f2f4 00000000 ntdll!__RtlUserThreadStart+0x2f (FPO: [SEH])
+32 0019ffec 00000000 0040116c 00321000 00000000 ntdll!_RtlUserThreadStart+0x1b (FPO: [Non-Fpo])
+
+",2229,,,,,1/31/2019 23:37,Set Breakpoint on ActiveX Property Being Set (No Symbols),,0,0,,,,CC BY-SA 4.0 +20527,2,,20525,2/1/2019 8:06,,3,,"

Taken from gnu.org - Hacking GRUB

+ +
+

GRUB consists of two distinct components, called stages, which are + loaded at different times in the boot process. Because they run + mutual-exclusively, sometimes a memory area overlaps with another + memory area. And, even in one stage, a single memory area can be used + for various purposes, because their usages are mutually exclusive.

+
+ +

0x7C00 Stage 1 is loaded here by BIOS or another boot loader

+ +

0x2000 The optional Stage 1.5 is loaded here / Command-line buffer for Multiboot kernels and modules

+ +

0x8000 Stage2 is loaded here

+",3162,,,,,2/1/2019 8:06,,,,0,,,,CC BY-SA 4.0 +20528,2,,20518,2/1/2019 8:32,,2,,"

TL;DR: (probably) No :(

+ +

I'm afraid I don't think there is some site like this, mainly because it is much harder to generate minimal example games for memory manipulation which resemble a real life scenario than in reverse engineering or debugging challenges.

+ +

Games are often quiet complex and feature multi threaded gameloops and complex engines which keep track of various property values.

+ +

Although there are games meant to be messed with (such as pwnadventure3), I'm afraid examples like these are rare.

+ +

I would like to encourage you to make use of the tutorials on youtube. Try to target a game with minimal / no security measures first (single player, maybe indies without a big engine backing them) and try to search for tutorials. When you find one, it will indicate the target (e.g. fix health, enable flying, ...) and you can try to do this yourself without watching the video in the first place. You may watch it afterwards and use it to streamline your workflow. Like with most reverse engineering related tasks, hands on experience is king.

+ +

You can always make the computer show you anything you'd like. The real challenge starts with finding vulnerabilities in multiplayer games, because this way your manipulation exceeds the scope of your own system. For example, one of the first things usually checked in game manipulation is whether the server performs sanity checks on manipulateable values such as loot, health etc.

+ +

For example, when the server accepts jumping packages from the client and does not check for sanity (e.g. that the character is grounded and didn't jump a millisecond ago) you could abuse this behavior to implement flying. If the game utilizes a thick client structure, it may even trust the coordinates send by the client.

+ +

You'll have to explore game functionality and find the loopholes. For example, if a game implements a quick travel system maybe there are checks missing whether you could actually utilize it at any given moment or whether you can just travel to locations which are currently unlocked. Basically there are always two kinds of checks: requests something from the server and show its answer, or disable / change the interface to render the functionality unavailable to the normal user.

+ +

At some point, you may even want to mess with anti-cheat systems which check memory sections for manipulation and implement other strategies such as network proxies. There is a nice youtube playlist of LiveOverflow trying to beat pwnadventure this way.

+ +

On Game Hacking:

+ +

/r/REGames

+ +

/r/gamehacks

+",3162,,3162,,2/1/2019 9:08,2/1/2019 9:08,,,,0,,,,CC BY-SA 4.0 +20530,2,,20127,2/1/2019 9:39,,4,,"

This problem was due to a corrupted dump: it turned out that dumping in-system, in some way, wakes up the main CPU that interfere with the eeprom on the SPI bus. Desoldering the chip and reading with the same tools, managed to give an extractable dump with Binwalk.

+",22655,,,,,2/1/2019 9:39,,,,1,,,,CC BY-SA 4.0 +20532,1,,,2/2/2019 11:34,,1,2315,"

My question is simple : When I enter into a function call, I can't go back to this same call. Is there a functionality which could permit me to do this in x64dbg? +Or for example if we want to trace back from a chosen address... +I hope I am clear enough...

+",26598,,245,,2/4/2019 11:39,8/26/2022 14:44,Go back to the function call address,,1,3,,,,CC BY-SA 4.0 +20534,1,20544,,2/2/2019 17:02,,2,536,"

I am trying to solve this ELF - Ptrace crack me. Here are the commands I use :

+ +

I start radare2 with the crack me as argument.

+ +
radare2 ch3.bin
+
+ +

I decide to go to the main and print the assembly code :

+ +
[0x080482f0]> s main 
+
+[0x080483f0]> pdf
+            ;-- main:
+/ (fcn) sym.main 175
+|   int sym.main (int argc, char **argv, char **envp);
+|           ; var char *s @ ebp-0x16
+|           ; var int var_ch @ ebp-0xc
+|           ; var int var_4h @ ebp-0x4
+|           ; arg int arg_4h @ esp+0x4
+|           ; DATA XREF from entry0 (0x8048307)
+|           0x080483f0      8d4c2404       lea ecx, [arg_4h]           ; sym._nl_current_LC_MONETARY
+|           0x080483f4      83e4f0         and esp, 0xfffffff0
+|           0x080483f7      ff71fc         push dword [ecx - 4]
+|           0x080483fa      55             push ebp
+|           0x080483fb      89e5           mov ebp, esp
+|           0x080483fd      51             push ecx
+|           0x080483fe      83ec14         sub esp, 0x14
+|           0x08048401      c745f488280c.  mov dword [var_ch], str.ksuiealohgy ; 0x80c2888 ; ""ksuiealohgy""
+|           0x08048408      6a00           push 0                      ; void*data
+|           0x0804840a      6a01           push 1                      ; loc._nl_current_LC_MONETARY_used ; void*addr
+|           0x0804840c      6a00           push 0                      ; pid_t pid
+|           0x0804840e      6a00           push 0                      ; __ptrace_request request
+|           0x08048410      e85b060100     call sym.ptrace
+|           0x08048415      83c410         add esp, 0x10
+|           0x08048418      85c0           test eax, eax
+|       ,=< 0x0804841a      791a           jns 0x8048436
+|       |   0x0804841c      83ec0c         sub esp, 0xc
+|       |   0x0804841f      6894280c08     push str.Debugger_detect___..._Exit ; 0x80c2894 ; ""Debugger detect\u00e9 ... Exit"" ; const char *s
+|       |   0x08048424      e8a70e0000     call sym.puts               ; int puts(const char *s)
+|       |   0x08048429      83c410         add esp, 0x10
+|       |   0x0804842c      b801000000     mov eax, 1
+|      ,==< 0x08048431      e9c3000000     jmp loc.080484f9
+|      ||   ; CODE XREF from sym.main (0x804841a)
+|      |`-> 0x08048436      83ec0c         sub esp, 0xc
+|      |    0x08048439      68b0280c08     push 0x80c28b0              ; ""############################################################"" ; const char *s
+|      |    0x0804843e      e88d0e0000     call sym.puts               ; int puts(const char *s)
+|      |    0x08048443      83c410         add esp, 0x10
+|      |    0x08048446      83ec0c         sub esp, 0xc
+|      |    0x08048449      68f0280c08     push str.Bienvennue_dans_ce_challenge_de_cracking ; 0x80c28f0 ; ""##        Bienvennue dans ce challenge de cracking        ##"" ; const char *s
+|      |    0x0804844e      e87d0e0000     call sym.puts               ; int puts(const char *s)
+|      |    0x08048453      83c410         add esp, 0x10
+|      |    0x08048456      83ec0c         sub esp, 0xc
+|      |    0x08048459      6830290c08     push 0x80c2930              ; ""############################################################\n"" ; const char *s
+|      |    0x0804845e      e86d0e0000     call sym.puts               ; int puts(const char *s)
+|      |    0x08048463      83c410         add esp, 0x10
+|      |    0x08048466      b86e290c08     mov eax, str.Password_:     ; 0x80c296e ; ""Password : ""
+|      |    0x0804846b      83ec0c         sub esp, 0xc
+|      |    0x0804846e      50             push eax
+|      |    0x0804846f      e8ec0a0000     call sym.__printf
+|      |    0x08048474      83c410         add esp, 0x10
+|      |    0x08048477      a19c540e08     mov eax, dword obj.stdin    ; obj._IO_stdin ; [0x80e549c:4]=0x80e5080 obj._IO_2_1_stdin
+|      |    0x0804847c      83ec04         sub esp, 4
+|      |    0x0804847f      50             push eax                    ; FILE *stream
+|      |    0x08048480      6a09           push 9                      ; 9 ; int size
+|      |    0x08048482      8d45ea         lea eax, [s]
+|      |    0x08048485      50             push eax                    ; char *s
+|      |    0x08048486      e8050b0000     call sym.fgets              ; char *fgets(char *s, int size, FILE *stream)
+|      |    0x0804848b      83c410         add esp, 0x10
+|      |    0x0804848e      8d0597840408   lea eax, loc._notng         ; 0x8048497
+|      |    0x08048494      40             inc eax
+\      |    0x08048495      ffe0           jmp eax
+       |    ;-- _notng:
+
+ +

That's where I find the code really strange. There are no more instructions after retrieving the string (the password).

+ +

Thanks to blabb, I am able to print the code directly with the command pd 100 @ main. The output is :

+ +
[0x080483f0]> pd 100 @ main
+            ;-- main:
+/ (fcn) sym.main 175
+|   int sym.main (int argc, char **argv, char **envp);
+|           ; var char *s @ ebp-0x16
+|           ; var int var_ch @ ebp-0xc
+|           ; var int var_4h @ ebp-0x4
+|           ; arg int arg_4h @ esp+0x4
+|           ; DATA XREF from entry0 (0x8048307)
+|           0x080483f0      8d4c2404       lea ecx, [arg_4h]           ; sym._nl_current_LC_MONETARY
+|           0x080483f4      83e4f0         and esp, 0xfffffff0
+|           0x080483f7      ff71fc         push dword [ecx - 4]
+|           0x080483fa      55             push ebp
+|           0x080483fb      89e5           mov ebp, esp
+|           0x080483fd      51             push ecx
+|           0x080483fe      83ec14         sub esp, 0x14
+|           0x08048401      c745f488280c.  mov dword [var_ch], str.ksuiealohgy ; 0x80c2888 ; ""ksuiealohgy""
+|           0x08048408      6a00           push 0                      ; void*data
+|           0x0804840a      6a01           push 1                      ; loc._nl_current_LC_MONETARY_used ; void*addr
+|           0x0804840c      6a00           push 0                      ; pid_t pid
+|           0x0804840e      6a00           push 0                      ; __ptrace_request request
+|           0x08048410      e85b060100     call sym.ptrace
+|           0x08048415      83c410         add esp, 0x10
+|           0x08048418      85c0           test eax, eax
+|       ,=< 0x0804841a      791a           jns 0x8048436
+|       |   0x0804841c      83ec0c         sub esp, 0xc
+|       |   0x0804841f      6894280c08     push str.Debugger_detect___..._Exit ; 0x80c2894 ; ""Debugger detect\u00e9 ... Exit"" ; const char *s
+|       |   0x08048424      e8a70e0000     call sym.puts               ; int puts(const char *s)
+|       |   0x08048429      83c410         add esp, 0x10
+|       |   0x0804842c      b801000000     mov eax, 1
+|      ,==< 0x08048431      e9c3000000     jmp loc.080484f9
+|      ||   ; CODE XREF from sym.main (0x804841a)
+|      |`-> 0x08048436      83ec0c         sub esp, 0xc
+|      |    0x08048439      68b0280c08     push 0x80c28b0              ; ""############################################################"" ; const char *s
+|      |    0x0804843e      e88d0e0000     call sym.puts               ; int puts(const char *s)
+|      |    0x08048443      83c410         add esp, 0x10
+|      |    0x08048446      83ec0c         sub esp, 0xc
+|      |    0x08048449      68f0280c08     push str.Bienvennue_dans_ce_challenge_de_cracking ; 0x80c28f0 ; ""##        Bienvennue dans ce challenge de cracking        ##"" ; const char *s
+|      |    0x0804844e      e87d0e0000     call sym.puts               ; int puts(const char *s)
+|      |    0x08048453      83c410         add esp, 0x10
+|      |    0x08048456      83ec0c         sub esp, 0xc
+|      |    0x08048459      6830290c08     push 0x80c2930              ; ""############################################################\n"" ; const char *s
+|      |    0x0804845e      e86d0e0000     call sym.puts               ; int puts(const char *s)
+|      |    0x08048463      83c410         add esp, 0x10
+|      |    0x08048466      b86e290c08     mov eax, str.Password_:     ; 0x80c296e ; ""Password : ""
+|      |    0x0804846b      83ec0c         sub esp, 0xc
+|      |    0x0804846e      50             push eax
+|      |    0x0804846f      e8ec0a0000     call sym.__printf
+|      |    0x08048474      83c410         add esp, 0x10
+|      |    0x08048477      a19c540e08     mov eax, dword obj.stdin    ; obj._IO_stdin ; [0x80e549c:4]=0x80e5080 obj._IO_2_1_stdin
+|      |    0x0804847c      83ec04         sub esp, 4
+|      |    0x0804847f      50             push eax                    ; FILE *stream
+|      |    0x08048480      6a09           push 9                      ; 9 ; int size
+|      |    0x08048482      8d45ea         lea eax, [s]
+|      |    0x08048485      50             push eax                    ; char *s
+|      |    0x08048486      e8050b0000     call sym.fgets              ; char *fgets(char *s, int size, FILE *stream)
+|      |    0x0804848b      83c410         add esp, 0x10
+|      |    0x0804848e      8d0597840408   lea eax, loc._notng         ; 0x8048497
+|      |    0x08048494      40             inc eax
+\      |    0x08048495      ffe0           jmp eax
+       |    ;-- _notng:
+       |    ; DATA XREF from sym.main (0x804848e)
+       |    0x08048497      b88a55ea8b     mov eax, 0x8bea558a
+       |    0x0804849c      45             inc ebp
+       |    0x0804849d      f4             hlt
+       |    0x0804849e      83c004         add eax, 4
+       |    0x080484a1      8a00           mov al, byte [eax]
+       |    0x080484a3      38c2           cmp dl, al
+       |,=< 0x080484a5      753d           jne 0x80484e4
+       ||   0x080484a7      8a55eb         mov dl, byte [ebp - 0x15]
+       ||   0x080484aa      8b45f4         mov eax, dword [ebp - 0xc]
+       ||   0x080484ad      83c005         add eax, 5
+       ||   0x080484b0      8a00           mov al, byte [eax]
+       ||   0x080484b2      38c2           cmp dl, al
+      ,===< 0x080484b4      752e           jne 0x80484e4
+      |||   0x080484b6      8a55ec         mov dl, byte [ebp - 0x14]
+      |||   0x080484b9      8b45f4         mov eax, dword [ebp - 0xc]
+      |||   0x080484bc      40             inc eax
+      |||   0x080484bd      8a00           mov al, byte [eax]
+      |||   0x080484bf      38c2           cmp dl, al
+     ,====< 0x080484c1      7521           jne 0x80484e4
+     ||||   0x080484c3      8a55ed         mov dl, byte [ebp - 0x13]
+     ||||   0x080484c6      8b45f4         mov eax, dword [ebp - 0xc]
+     ||||   0x080484c9      83c00a         add eax, 0xa
+     ||||   0x080484cc      8a00           mov al, byte [eax]
+     ||||   0x080484ce      38c2           cmp dl, al
+    ,=====< 0x080484d0      7512           jne 0x80484e4
+    |||||   0x080484d2      83ec0c         sub esp, 0xc
+    |||||   0x080484d5      687a290c08     push str.Good_password      ; 0x80c297a ; ""\nGood password !!!\n""
+    |||||   0x080484da      e8f10d0000     call sym.puts               ; int puts(const char *s)
+    |||||   0x080484df      83c410         add esp, 0x10
+   ,======< 0x080484e2      eb10           jmp 0x80484f4
+   ||||||   ; CODE XREFS from loc._notng (+0xe, +0x1d, +0x2a, +0x39)
+   |```-`-> 0x080484e4      83ec0c         sub esp, 0xc
+   |   |    0x080484e7      688e290c08     push str.Wrong_password.    ; 0x80c298e ; ""\nWrong password.\n""
+   |   |    0x080484ec      e8df0d0000     call sym.puts               ; int puts(const char *s)
+   |   |    0x080484f1      83c410         add esp, 0x10
+   |   |    ; CODE XREF from loc._notng (+0x4b)
+   `------> 0x080484f4      b800000000     mov eax, 0
+|- loc.080484f9 8
+|   loc.080484f9 ();
+|      |    ; var int var_4h @ ebp-0x4
+|      |    ; CODE XREF from sym.main (0x8048431)
+|      `--> 0x080484f9      8b4dfc         mov ecx, dword [var_4h]
+|           0x080484fc      c9             leave
+|           0x080484fd      8d61fc         lea esp, [ecx - 4]
+\           0x08048500      c3             ret
+            0x08048501      90             nop
+            0x08048502      90             nop
+            0x08048503      90             nop
+            0x08048504      90             nop
+            0x08048505      90             nop
+            0x08048506      90             nop
+            0x08048507      90             nop
+            0x08048508      90             nop
+            0x08048509      90             nop
+            0x0804850a      90             nop
+            0x0804850b      90             nop
+[0x080483f0]> 
+
+ +

Why I am obligated to enter this command and not pdf ?

+",26974,,26974,,2/3/2019 15:59,2/3/2019 22:23,Radare2 does not display the entire assembler code,,1,2,,,,CC BY-SA 4.0 +20535,2,,19767,2/2/2019 21:39,,2,,"

As a generic, incomplete answer: switch analysis is a common source of failure in using Hex-Rays (and even IDA). You can fix these errors by manually editing the switch information using Edit->Other->Specify switch idiom with your cursor somewhere near the beginning. However, I can't give you complete instructions on how to do this. My best advice is to search the disassembly listing for the word 'switch' using Alt-T, and use the edit command just mentioned to view the switch information. For each one, copy the information into a text editor, and compare it against the disassembly listing. This will start to give you an idea of what the fields mean. From there, experiment with the failing switch. Does something you learned from the process I just describe seem not to fit well with the information presented for the failing switch? Change it and see what happens.

+",182,,,,,2/2/2019 21:39,,,,0,,,,CC BY-SA 4.0 +20536,2,,20520,2/2/2019 22:08,,1,,"

If IDA has erroneously marked functions as ""noreturn"", you can manually edit this with Alt-P. ""Does not return"" is a checkmark that you can select. Once you've removed this attribute, IDA should properly disassemble the code following the function call -- though you may need to delete functions (as the comment said) if IDA is using obsolete information about the function boundaries.

+",182,,,,,2/2/2019 22:08,,,,3,,,,CC BY-SA 4.0 +20540,1,20541,,2/3/2019 13:22,,3,9236,"

I am trying to solve this ELF - Ptrace challenge. I use Radare 2. This is the commands I execute to print the assembly code.

+ +
radare2 ch3.bin
+[0x080482f0]> aaa
+[[anal.jmptbl] Missing cjmp bb in predecessor at 0x08057fca
+[anal.jmptbl] Missing cjmp bb in predecessor at 0x08057f4a
+[anal.jmptbl] Missing cjmp bb in predecessor at 0x0808fc43
+[anal.jmptbl] Missing cjmp bb in predecessor at 0x0808fc23
+[anal.jmptbl] Missing cjmp bb in predecessor at 0x0808fc63
+[anal.jmptbl] Missing cjmp bb in predecessor at 0x0808fc83
+[x] Analyze all flags starting with sym. and entry0 (aa)
+[x] Analyze function calls (aac)
+[x] Analyze len bytes of instructions for references (aar)
+[x] Constructing a function name for fcn.* and sym.func.* functions (aan)
+[x] Type matching analysis for all functions (aaft)
+[x] Use -AA or aaaa to perform additional experimental analysis.
+
+[0xf7f0b049]> pd 100 @ main
+            ;-- main:
+/ (fcn) sym.main 175
+|   int sym.main (int argc, char **argv, char **envp);
+|           ; var char *s @ ebp-0x16
+|           ; var int var_ch @ ebp-0xc
+|           ; var int var_4h @ ebp-0x4
+|           ; arg int arg_4h @ esp+0x4
+|           ; DATA XREF from entry0 (0x8048307)
+|           0x080483f0      8d4c2404       lea ecx, [arg_4h]           ; sym._nl_current_LC_MONETARY
+|           0x080483f4      83e4f0         and esp, 0xfffffff0
+|           0x080483f7      ff71fc         push dword [ecx - 4]
+|           0x080483fa      55             push ebp
+|           0x080483fb      89e5           mov ebp, esp
+|           0x080483fd      51             push ecx
+|           0x080483fe      83ec14         sub esp, 0x14
+|           0x08048401      c745f488280c.  mov dword [var_ch], str.ksuiealohgy ; 0x80c2888 ; ""ksuiealohgy""
+|           0x08048408      6a00           push 0                      ; void*data
+|           0x0804840a      6a01           push 1                      ; ecx ; void*addr
+|           0x0804840c      6a00           push 0                      ; pid_t pid
+|           0x0804840e      6a00           push 0                      ; __ptrace_request request
+|           0x08048410      e85b060100     call sym.ptrace
+|           0x08048415      83c410         add esp, 0x10
+|           0x08048418      85c0           test eax, eax
+|       ,=< 0x0804841a b    791a           jns 0x8048436
+|       |   0x0804841c      83ec0c         sub esp, 0xc
+|       |   0x0804841f      6894280c08     push str.Debugger_detect___..._Exit ; 0x80c2894 ; ""Debugger detect\u00e9 ... Exit"" ; const char *s
+|       |   0x08048424      e8a70e0000     call sym.puts               ; int puts(const char *s)
+|       |   0x08048429      83c410         add esp, 0x10
+|       |   0x0804842c      b801000000     mov eax, 1
+|      ,==< 0x08048431      e9c3000000     jmp loc.080484f9
+|      ||   ; CODE XREF from sym.main (0x804841a)
+|      |`-> 0x08048436      83ec0c         sub esp, 0xc
+|      |    0x08048439      68b0280c08     push 0x80c28b0              ; const char *s
+|      |    0x0804843e      e88d0e0000     call sym.puts               ; int puts(const char *s)
+|      |    0x08048443      83c410         add esp, 0x10
+|      |    0x08048446      83ec0c         sub esp, 0xc
+|      |    0x08048449      68f0280c08     push str.Bienvennue_dans_ce_challenge_de_cracking ; 0x80c28f0 ; ""##        Bienvennue dans ce challenge de cracking        ##"" ; const char *s
+|      |    0x0804844e      e87d0e0000     call sym.puts               ; int puts(const char *s)
+|      |    0x08048453      83c410         add esp, 0x10
+|      |    0x08048456      83ec0c         sub esp, 0xc
+|      |    0x08048459      6830290c08     push 0x80c2930              ; const char *s
+|      |    0x0804845e      e86d0e0000     call sym.puts               ; int puts(const char *s)
+|      |    0x08048463      83c410         add esp, 0x10
+|      |    0x08048466      b86e290c08     mov eax, str.Password_:     ; 0x80c296e ; ""Password : ""
+|      |    0x0804846b      83ec0c         sub esp, 0xc
+|      |    0x0804846e      50             push eax
+|      |    0x0804846f      e8ec0a0000     call sym.__printf
+|      |    0x08048474      83c410         add esp, 0x10
+|      |    0x08048477      a19c540e08     mov eax, dword obj.stdin    ; obj._IO_stdin ; [0x80e549c:4]=0x80e5080 obj._IO_2_1_stdin
+|      |    0x0804847c      83ec04         sub esp, 4
+|      |    0x0804847f      50             push eax                    ; FILE *stream
+|      |    0x08048480      6a09           push 9                      ; 9 ; int size
+|      |    0x08048482      8d45ea         lea eax, [s]
+|      |    0x08048485      50             push eax                    ; char *s
+|      |    0x08048486      e8050b0000     call sym.fgets              ; char *fgets(char *s, int size, FILE *stream)
+|      |    0x0804848b      83c410         add esp, 0x10
+|      |    0x0804848e      8d0597840408   lea eax, loc._notng         ; 0x8048497
+|      |    0x08048494      40             inc eax
+\      |    0x08048495      ffe0           jmp eax
+       |    ;-- _notng:
+       |    ; DATA XREF from sym.main (0x804848e)
+       |    0x08048497      b88a55ea8b     mov eax, 0x8bea558a
+       |    0x0804849c      45             inc ebp
+       |    0x0804849d      f4             hlt
+       |    0x0804849e      83c004         add eax, 4
+       |    0x080484a1      8a00           mov al, byte [eax]
+       |    0x080484a3      38c2           cmp dl, al
+       |,=< 0x080484a5 b    753d           jne 0x80484e4
+       ||   0x080484a7      8a55eb         mov dl, byte [ebp - 0x15]
+       ||   0x080484aa      8b45f4         mov eax, dword [ebp - 0xc]
+       ||   0x080484ad      83c005         add eax, 5
+       ||   0x080484b0      8a00           mov al, byte [eax]
+       ||   0x080484b2      38c2           cmp dl, al
+      ,===< 0x080484b4      752e           jne 0x80484e4
+      |||   0x080484b6      8a55ec         mov dl, byte [ebp - 0x14]
+      |||   0x080484b9      8b45f4         mov eax, dword [ebp - 0xc]
+      |||   0x080484bc      40             inc eax
+      |||   0x080484bd      8a00           mov al, byte [eax]
+      |||   0x080484bf      38c2           cmp dl, al
+     ,====< 0x080484c1 b    7521           jne 0x80484e4
+     ||||   0x080484c3      8a55ed         mov dl, byte [ebp - 0x13]
+     ||||   0x080484c6      8b45f4         mov eax, dword [ebp - 0xc]
+     ||||   0x080484c9      83c00a         add eax, 0xa
+     ||||   0x080484cc      8a00           mov al, byte [eax]
+     ||||   0x080484ce      38c2           cmp dl, al
+    ,=====< 0x080484d0 b    7512           jne 0x80484e4
+    |||||   0x080484d2      83ec0c         sub esp, 0xc
+    |||||   0x080484d5      687a290c08     push str.Good_password      ; 0x80c297a ; ""\nGood password !!!\n""
+    |||||   0x080484da      e8f10d0000     call sym.puts               ; int puts(const char *s)
+    |||||   0x080484df      83c410         add esp, 0x10
+   ,======< 0x080484e2      eb10           jmp 0x80484f4
+   ||||||   ; CODE XREFS from loc._notng (+0xe, +0x1d, +0x2a, +0x39)
+   |```-`-> 0x080484e4 b    83ec0c         sub esp, 0xc
+   |   |    0x080484e7      688e290c08     push str.Wrong_password.    ; 0x80c298e ; ""\nWrong password.\n""
+   |   |    0x080484ec      e8df0d0000     call sym.puts               ; int puts(const char *s)
+   |   |    0x080484f1      83c410         add esp, 0x10
+   |   |    ; CODE XREF from loc._notng (+0x4b)
+   `------> 0x080484f4      b800000000     mov eax, 0
+|- loc.080484f9 8
+|   loc.080484f9 ();
+|      |    ; var int var_4h @ ebp-0x4
+|      |    ; CODE XREF from sym.main (0x8048431)
+|      `--> 0x080484f9      8b4dfc         mov ecx, dword [var_4h]
+|           0x080484fc      c9             leave
+|           0x080484fd      8d61fc         lea esp, [ecx - 4]
+\           0x08048500      c3             ret
+            0x08048501      90             nop
+            0x08048502      90             nop
+            0x08048503      90             nop
+            0x08048504      90             nop
+            0x08048505      90             nop
+            0x08048506      90             nop
+            0x08048507      90             nop
+            0x08048508      90             nop
+            0x08048509      90             nop
+            0x0804850a      90             nop
+            0x0804850b      90             nop
+
+ +

I can see that there is an anti-debugging technic at instruction 0x0804841a, I can bypass it putting a break point and modifying eip adress on the fly. +I can also see that there is several tests before print Good Password!!! +I put all the breakpoints I need :

+ +
[0x00000000]> ood
+[0x080482f0]> db 0x0804841a
+[0x080482f0]> db 0x080484a5
+[0x080482f0]> db 0x80484e4
+[0x080482f0]> db 0x080484c1
+[0x080482f0]> db 0x080484d0
+[0x080482f0]> dc
+child stopped with signal 28
+[+] SIGNAL 28 errno=0 addr=0x00000000 code=128 ret=0
+[0x080482f0]> dc
+hit breakpoint at: 804841a
+[0x0804841a]> dr eip=0x08048436
+0x0804841a ->0x08048436
+[0x0804841a]> dc
+############################################################
+##        Bienvennue dans ce challenge de cracking        ##
+############################################################
+
+Password : badpassword 
+hit breakpoint at: 80484a5
+[0x080484a5]> dr eip=0x080484a7
+0x080484a5 ->0x080484a7
+[0x080484a5]> dc
+hit breakpoint at: 80484e4
+[0x080484a5]> dr eip=0x080484b6
+0x080484e4 ->0x080484b6
+[0x080484a5]> dc
+hit breakpoint at: 80484c1
+[0x080484a5]> dr eip=0x080484c3
+0x080484c1 ->0x080484c3
+[0x080484a5]> dc
+hit breakpoint at: 80484d0
+[0x080484a5]> ptr axt
+[0x080484a5]> dr
+eax = 0x080c2879
+ebx = 0x00000000
+ecx = 0xffffffff
+edx = 0x080e6515
+esi = 0x08048bc0
+edi = 0x08048b20
+esp = 0xffe51480
+ebp = 0xffe51498
+eip = 0x080484d0
+eflags = 0x00000297
+oeax = 0xffffffff
+
+ +

Now, at this point (and for each conditinal previous tests), I would like to print the value of the stack or adresses to see exactly what is compared. My problem is I can't understant what values are compared in the first test for example :

+ +
   |    ; DATA XREF from sym.main (0x804848e)
+   |    0x08048497      b88a55ea8b     mov eax, 0x8bea558a
+   |    0x0804849c      45             inc ebp
+   |    0x0804849d      f4             hlt
+   |    0x0804849e      83c004         add eax, 4
+   |    0x080484a1      8a00           mov al, byte [eax]
+   |    0x080484a3      38c2           cmp dl, al
+   |,=< 0x080484a5      753d           jne 0x80484e4
+
+ +

I think I use a bad way to solve this challenge because I modify each eip to print finally Good Password!!!, I can't see the password on the stack or something else. I use the command pxr @ esp. +What is the content of al and dl ?

+ +

I also tried to generate the source code with Snowman but it doesn't help me :

+ +
void fun_804849e(void** ecx) {
+    signed char dl2;
+    struct s2421* eax3;
+    int32_t ebp4;
+    int32_t ebp5;
+    int32_t ebp6;
+    int32_t ebp7;
+    int32_t ebp8;
+    int32_t ebp9;
+    int32_t v10;
+    int32_t v11;
+    int32_t v12;
+    int32_t v13;
+    int32_t v14;
+    int32_t v15;
+
+    if (dl2 != eax3->f4 || (*reinterpret_cast<signed char*>(ebp4 - 21) != (*reinterpret_cast<struct s2422**>(ebp5 - 12))->f5 || (*reinterpret_cast<signed char*>(ebp6 - 20) != (*reinterpret_cast<struct s2423**>(ebp7 - 12))->f1 || *reinterpret_cast<signed char*>(ebp8 - 19) != (*reinterpret_cast<struct s2424**>(ebp9 - 12))->f10))) {
+        _IO_puts(ecx, ""\nWrong password.\n"", v10, v11, v12, __return_address());
+    } else {
+        _IO_puts(ecx, ""\nGood password !!!\n"", v13, v14, v15, __return_address());
+    }
+}
+
+",26974,,26974,,2/3/2019 13:27,12/10/2021 21:32,How to print the value of register with Radare 2,,1,0,,,,CC BY-SA 4.0 +20541,2,,20540,2/3/2019 14:03,,11,,"

Printing the registry values in radare2 is quite simple.

+

All registers

+

You can print all the General Purpose registers using dr:

+
[0x55bea3305070]> dr
+rax = 0x55bea3305070
+rbx = 0x00000000
+rcx = 0x7fd7ee4f7578
+rdx = 0x7ffd63b54428
+r8 = 0x7fd7ee4f8be0
+r9 = 0x7fd7ee4f8be0
+r10 = 0x00000001
+r11 = 0x00000000
+r12 = 0x55bea3306ae0
+r13 = 0x7ffd63b54410
+r14 = 0x00000000
+r15 = 0x00000000
+rsi = 0x7ffd63b54418
+rdi = 0x00000001
+rsp = 0x7ffd63b54338
+rbp = 0x55bea33176f0
+rip = 0x55bea3305070
+rflags = 0x00000246
+orax = 0xffffffffffffffff
+
+

Telescoping

+

You can get even more information using drr which will also perform telescoping for the registers:

+
[0x55bea3305070]> drr
+   rax 0x55bea3305070      (.text) (/usr/bin/ls) rip program R X 'push r15' 'ls'
+   rbx 0x0                 r15
+   rcx 0x7fd7ee4f7578      (/usr/lib/libc-2.28.so) rcx library R W 0x7fd7ee4f8be0 -->  (/usr/lib/libc-2.28.so) r9 library R W 0x0 -->  r15
+   rdx 0x7ffd63b54428      rdx stack R W 0x7ffd63b54b6d -->  stack R W 0x622f3d4c4c454853 (SHELL=/bin/bash) -->  ascii
+    r8 0x7fd7ee4f8be0      (/usr/lib/libc-2.28.so) r9 library R W 0x0 -->  r15
+    r9 0x7fd7ee4f8be0      (/usr/lib/libc-2.28.so) r9 library R W 0x0 -->  r15
+   r10 0x1                 rdi
+   r11 0x0                 r15
+   r12 0x55bea3306ae0      (.text) (/usr/bin/ls) r12 program R X 'endbr64' 'ls'
+   r13 0x7ffd63b54410      r13 stack R W 0x1 -->  rdi
+   r14 0x0                 r15
+   r15 0x0                 r15
+   rsi 0x7ffd63b54418      rsi stack R W 0x7ffd63b54b65 -->  stack R W 0x736c2f6e69622f (/bin/ls) -->  ascii
+   rdi 0x1                 rdi
+   rsp 0x7ffd63b54338      rsp stack R W 0x7fd7ee35d223 -->  (/usr/lib/libc-2.28.so) library R X 'mov edi, eax' 'libc-2.28.so'
+   rbp 0x55bea33176f0      (.text) (/usr/bin/ls) rbp program R X 'endbr64' 'ls'
+   rip 0x55bea3305070      (.text) (/usr/bin/ls) rip program R X 'push r15' 'ls'
+    cs 0x33                ascii
+rflags 1PZI                rflags
+  orax 0xffffffffffffffff  orax
+    ss 0x2b                ascii
+fs_base 0x7fd7ee336740      (unk1) R W 0x7fd7ee336740
+gs_base 0x0                 r15
+    ds 0x0                 r15
+    es 0x0                 r15
+    fs 0x0                 r15
+    gs 0x0                 r15
+
+

A specific register

+

You can print a specific register using dr <reg>.

+
[0x55bea3305070]> dr rax
+0x55bea3305070
+
+

The registers al and dl are simply the lower 8 bits of the registers EAX and EDX respectively.

+
[0x55bea3305070]> dr rax
+0x55bea3305070
+[0x55bea3305070]> dr eax
+0xa3305070
+[0x55bea3305070]> dr al
+0x00000070
+
+
+
+[0x55bea3305070]> dr rdx
+0x7ffd63b54428
+[0x55bea3305070]> dr edx
+0x63b54428
+[0x55bea3305070]> dr dl
+0x00000028
+
+

Further reading

+

I recommend reading the radare2book, and more specifically, the chapter about Registers.

+",18698,,39592,,12/10/2021 21:32,12/10/2021 21:32,,,,1,,,,CC BY-SA 4.0 +20542,2,,18552,2/3/2019 18:30,,10,,"

You do not have to use another file, it is just redundant

+ +

You can do this by using ""Here strings"". +In your example you can do :

+ +
r <<< $(python -c ""print '\x90'*52"")
+
+ +

You can read about ""Here strings"" here

+",27340,,27340,,2/9/2019 22:22,2/9/2019 22:22,,,,1,,,,CC BY-SA 4.0 +20544,2,,20534,2/3/2019 22:23,,2,,"

I had some trouble really understanding your question so I'll try to answer this question as best as I can.

+ +

When you use pdf you instruct radare2 to print the disassembly of the whole function. Where each function begins and ends is identified when analysis is done (aaa). So if you don't have functions identified pdf won't work.

+ +

You run your analysis so you could run pdf @ main, but where function ends in this case was wrongly identified. If you check the last instructions of this function this is what you get:

+ +
0x0804848e      8d0597840408   lea eax, loc._notng         ;0x8048497
+0x08048494      40             inc eax
+0x08048495      ffe0           jmp eax  
+;-- _notng:
+
+ +

So it takes an address of _notng, adds one and jumps there and this what causes r2 to wrongly identify the end of the function. This is a simple trick that caused disassemblers to present invalid opcodes.

+ +

You can see it both in IDA and r2. This code that you get later

+ +
0x08048497      b88a55ea8b     mov eax, 0x8bea558a
+0x0804849c      45             inc ebp
+0x0804849d      f4             hlt
+
+ +

is wrong and it's due to the fact that jmp will land in the middle of this mov. The first byte (b8) is bogus and should not be treated as a code.

+ +

In order to fix this issue we can change the type of this byte. In radare you can use:

+ +
> Cd 1 1 @ 0x8048497
+
+ +

and in IDA you press d on the mov opcode and later c on the byte after b8.

+ +

After this you will see correct opcodes:

+ +
0x08048497      .byte 0xb8
+0x08048498      8a55ea         mov dl, byte [ebp - 0x16]
+0x0804849b      8b45f4         mov eax, dword [ebp - 0xc]
+
+ +

Now you could resize the main function for the following basic block by doing afb+, but for some reason pdf still doesn't print correctly the function. Need to check if that's not a bug.

+",18014,,,,,2/3/2019 22:23,,,,0,,,,CC BY-SA 4.0 +20545,1,20546,,2/4/2019 2:47,,1,1294,"

I am on the hook to analysis some ""timing channels"" of some x86 binary code. I am posting one question to comprehend bsf/bsr opcode.

+ +

So high-levelly, these two opcodes can be modeled as a ""loop"", which counts the leading and trailing zeros of a given operand. The x86 manual has a good formalization of these opcodes, something like the following:

+ +
IF SRC = 0
+  THEN
+    ZF ← 1;
+    DEST is undefined;
+  ELSE
+    ZF ← 0;
+    temp ← OperandSize – 1;
+    WHILE Bit(SRC, temp) = 0
+    DO
+      temp ← temp - 1;
+    OD;
+    DEST ← temp;
+FI;
+
+ +

But to my suprise, bsf/bsr instructions seem to have fixed cpu cycles. According to some documents I found here: https://gmplib.org/~tege/x86-timing.pdf, seems that they always take 8 CPU cycles to finish.

+ +

So here are my questions:

+ +
    +
  1. I am confirming that these instructions have fixed cpu cycles. In other words, no matter what operand is given, they always take the same amount of time to process, and there is no ""timing channel"" behind. I cannot find corresponding specifications in Intel's official documents.

  2. +
  3. Then why it is possible? Apparently this is a ""loop"" or somewhat, at least high-levelly. What is the design decision behind? Easier for CPU pipelines?

  4. +
+",3215,,,,,2/4/2019 6:13,Understand the CPU cycles of x86 instruction bsr/bsf,,1,0,,,,CC BY-SA 4.0 +20546,2,,20545,2/4/2019 6:13,,3,,"

I've found a site which seems to indicate this was implemented as a loop when the instructions were introduced:

+ +
BSF scans forward across bit pattern (0-n) while BSR scans in reverse (n-0).
+
+                             Clocks                 Size
+    Operands         808x  286   386   486          Bytes
+
+    reg,reg           -     -   10+3n  6-42           3
+    reg,mem           -     -   10+3n  7-43          3-7
+    reg32,reg32       -     -   10+3n  6-42          3-7
+    reg32,mem32       -     -   10+3n  7-43          3-7
+
+ +

Thankfully, they seem to optimized it starting with 486 (1989). As you already noticed, they seem to have improved the run time even further. Indeed, the current Intel Optimization Manual lists it with pretty low fixed clock cycles (3+1).

+ +

There is a much more in detail answer on stackexchange

+",3162,,,,,2/4/2019 6:13,,,,3,,,,CC BY-SA 4.0 +20547,2,,20278,2/4/2019 11:58,,0,,"

Data structures (structs, unions, classes, etc) are higher level elements that completely disappear after the compilation step takes place. Meaning that the concepts themselves are completely invisible in the binary. Of course, certain code patterns may still suggest or imply that a data structure was present in the code, there are no assembly equivalent (nor one is needed) to the struct, union or class keywords.

+ +

After providing the above context, I'll address the specific questions and statements you've made throughout the question:

+ +
+

I believe that ebp + offset are local variables?

+
+ +

You accurately understand that ebp is used to reference the stack and that therefore any ebp based reference is probably a reference to a stack-based variable.

+ +
+

Could it really just be tonnes of local variables?

+
+ +

It could. However as I've explained in the first paragraph it is impossible to know for sure whether the original source code had a lot of local variables or a single, a few, or maybe even nested structures.

+ +

It is however, unnecessary (unless your goal is to reach binary identical code reconstruction) to specifically use the same constructs used in the original code. If your goal is to gain a decent understanding of the code, you should feel free to implement those data structures as you see fit and will be the most intuitive representation for you. You should rely on IDA's structure definitions you make the assembly code as readable to you as possible, without putting too much thought as to how the original source code was written.

+ +
+

Or could it actually be a data structure and this is how IDA is representing it?

+
+ +

Therefore, this is not how ""IDA represents it"", but how any compiler will translate the code to assembly. IDA just helps with an interactive interface to the disassembled machine code.

+ +
+

ebp is the base address of the structure

+
+ +

As the function starts with a rather standard mov ebp, esp / sub esp, IMM it is unlikely that ebp itself points to a structure. It points to the stack offset at where a new stack frame was created. This is a very common practice. It is very likely, however, that a structure begins at a certain offset on the stack, and ebp is used to reference it, using the offset from the start of the stack frame.

+ +
+

The mov instructions between the mov [...], offset value are padding bytes

+
+ +

Assuming you're talking about the mov, REG, IMM instructions, these are probably register initializations that are used further down the line. They are spread between the stack-based mov instructions for performance reasons. To oversimplify, pipeline optimizations allow modern processors to assign register values somewhat in parallel to slower RAM write operations, resulting in an overall faster execution.

+ +
+

I'm guessing they are just padding bytes since esi doesn't contain a value (it was xor at the top of the screenshot) and is mov ebp + offset quite a lot in this block.

+
+ +

The esi register does contain a value, that value is simply zero. xoring a register with itself is a common way to set it to zero, which is shorter than a mov REG, 0 instruction to encode. Additionally, mov OFFSET, REG is shorter than mov OFFSET, 0, so overall the compiler saves us a few bytes of code.

+",2147,,,,,2/4/2019 11:58,,,,0,,,,CC BY-SA 4.0 +20548,2,,20532,2/4/2019 13:09,,4,,"

You have two options, assuming the function is not inlined:

+ +
    +
  • at the beginning of the function look at the stack, it should point to the caller. In some cases it can be possible to optimise the invocation of the function and instead of using call use jmp. For example when one function is a subset of another or in recursive functions.
  • +
  • I don't think it's possible via x64dbg but you could record a trace of the entire execution and then replay the bits you're interested in and check the callers. For this you could use e.g. https://rr-project.org/
  • +
+",25796,,,,,2/4/2019 13:09,,,,3,,,,CC BY-SA 4.0 +20552,2,,20518,2/4/2019 19:51,,2,,"

Your best ""crack-mes"" for games are games themselves! If spending money on games is a barrier to entry you'd rather not venture, then consider the following:

+ +
    +
  1. Demo/trial/free-to-play games on Steam. These are all freely available for you to download and work with. There are filters you can toggle to search for these types of games on Steam, so it's easy to find them. Examples: Free to play and free demos.
  2. +
  3. Open-source video games. Once again, these are free games, and they probably more fit the mold of your idea of a game crack-me since they're often somewhat crude/amateur in their artwork. These games have the added benefit of available source code, so you can imagine all the things that are possible if you'd like to dig deeper into specific things!
  4. +
  5. Cheat Engine has two of its own crack-mes built in! One of them is text-based, and the other is graphics-based.
  6. +
  7. As mentioned by Norwald, there are games made to be hacked, such as the PwnAdventure games--all of which (as well as other recommendations) can be found on a game-hacking GitHub repo I personally run.
  8. +
  9. Itch.io is a treasure trove of free-to-play games created by amateur game developers! You'll find games created within all sorts of engines, which will give you some solid exposure to learning many of the differences between, say, Unity, GameMaker, Flash, etc.
  10. +
+ +

There are others, but between those recommendations, you'll have exponentially more options than you could take on even if you wanted to! =)

+ +

Finally, if you REALLY get into things, I've been running a game-hacking channel on YouTube for ~5 years now, so there's a lot of fantastic educational material there if you're interested--as well as lots of videos showing you the true power of Cheat Engine and many of its buried features. Check it out sometime if you're so inclined!

+",20928,,,,,2/4/2019 19:51,,,,8,,,,CC BY-SA 4.0 +20553,1,20556,,2/4/2019 20:19,,0,3047,"

This question has already been asked here but for some reason it was deleted, as ""dead"".

+ +

I will try to explain again. I have a specific data type. It is used in a large number of disassembled functions. This type has a field whose purpose is unknown. I need to find all references to this field in the entire application.

+ +

I can belive to @Biswapriyo, that this behavior is by design and I cannot find xrefs to the field of data type. Ok, got it. Now I need to find a way to do that! :)

+ +

Perhaps there are any plugin? I don't understand why this can be difficult, since to perform this action, it is enough to generate a .c file, open it in notepad and press Ctrl+F. I want this functionality to be in IDA Hex-Rays.

+",26081,,,,,2/19/2021 7:20,IDA Hex-Rays: How to find all references to the certain field of all instances of the data type?,,2,0,,,,CC BY-SA 4.0 +20556,2,,20553,2/5/2019 5:41,,3,,"

IDA does support structure member cross-references: it will show you everywhere in the disassembly listing that an instruction operand has had that particular structure reference applied to it. See this picture:

+ +

However, this only works if the structure has been applied on the assembly-language level. Generally speaking, changing the type of a variable in Hex-Rays does not result in structure cross-references being created. Personally, I think this should be standard behavior.

+ +

Nevertheless, there's a Hex-Rays plugin called Referee that automatically adds assembly-level structure references based on the Hex-Rays types. There's also an IDAPython port of Referee. At the time of writing, neither the C++ nor the IDAPython version has been ported to the latest IDA 7.x SDK.

+",182,,,,,2/5/2019 5:41,,,,0,,,,CC BY-SA 4.0 +20557,1,,,2/5/2019 9:51,,0,1626,"

Look at this C code:

+ +
#include <stdio.h>
+#include <string.h>
+
+int my_function(char *s);
+
+int my_function(char *s)
+{
+    for (int i=0;i<strlen(s);i++)
+    {
+       s[i]++;
+    }
+    if (strncmp(s,""b{fsuz"",6)==0)
+    {
+       return 1; 
+    }
+    return 0;
+}
+
+
+int main(int argc , char *argv[])
+{
+    // Lot of stuff, including UI
+    if (my_function(argv[1])==1)
+    {
+        printf(""Good\n"");
+    }
+    else
+    {
+        printf(""Wrong !\n"");
+    }
+    return 0;
+}
+
+ +

What i want to do is to make a symbolic analysis on my_function (and only this function) with angr.

+ +

Here is the function disassembly:

+ +
|           ; var int local_28h @ rbp-0x28
+|           ; var int local_14h @ rbp-0x14
+|           ; CALL XREF from 0x000011e7 (main)
+|           0x00001155      55             push rbp
+|           0x00001156      4889e5         mov rbp, rsp
+|           0x00001159      53             push rbx
+|           0x0000115a      4883ec28       sub rsp, 0x28               ; '('
+|           0x0000115e      48897dd8       mov qword [local_28h], rdi
+|           0x00001162      c745ec000000.  mov dword [local_14h], 0
+|       ,=< 0x00001169      eb19           jmp 0x1184
+|      .--> 0x0000116b      8b45ec         mov eax, dword [local_14h]
+|      :|   0x0000116e      4863d0         movsxd rdx, eax
+|      :|   0x00001171      488b45d8       mov rax, qword [local_28h]
+|      :|   0x00001175      4801d0         add rax, rdx                ; '('
+|      :|   0x00001178      0fb610         movzx edx, byte [rax]
+|      :|   0x0000117b      83c201         add edx, 1
+|      :|   0x0000117e      8810           mov byte [rax], dl
+|      :|   0x00001180      8345ec01       add dword [local_14h], 1
+|      :|   ; JMP XREF from 0x00001169 (sym.my_function)
+|      :`-> 0x00001184      8b45ec         mov eax, dword [local_14h]
+|      :    0x00001187      4863d8         movsxd rbx, eax
+|      :    0x0000118a      488b45d8       mov rax, qword [local_28h]
+|      :    0x0000118e      4889c7         mov rdi, rax
+|      :    0x00001191      e8bafeffff     call sym.imp.strlen         ; size_t strlen(const char *s)
+|      :    0x00001196      4839c3         cmp rbx, rax
+|      `==< 0x00001199      72d0           jb 0x116b
+|           0x0000119b      488b45d8       mov rax, qword [local_28h]
+|           0x0000119f      ba06000000     mov edx, 6
+|           0x000011a4      488d35590e00.  lea rsi, str.b_fsuz         ; 0x2004 ; ""b{fsuz""
+|           0x000011ab      4889c7         mov rdi, rax
+|           0x000011ae      e87dfeffff     call sym.imp.strncmp        ; int strncmp(const char *s1, const char *s2, size_t n)
+|           0x000011b3      85c0           test eax, eax
+|       ,=< 0x000011b5      7507           jne 0x11be
+|       |   0x000011b7      b801000000     mov eax, 1
+|      ,==< 0x000011bc      eb05           jmp 0x11c3
+|      |`-> 0x000011be      b800000000     mov eax, 0
+|      |    ; JMP XREF from 0x000011bc (sym.my_function)
+|      `--> 0x000011c3      4883c428       add rsp, 0x28               ; '('
+|           0x000011c7      5b             pop rbx
+|           0x000011c8      5d             pop rbp
+\           0x000011c9      c3             ret
+
+ +

What i want is to ask angr: Which string should i pass in parameter to my_function in order to get a return of 1.

+ +

Here is what i've done:

+ +
import angr
+
+base = 0x400000
+function_start = base + 0x00001155 # 0x0000115e
+function_target = base + 0x000011b7
+function_end = base + 0x000011be
+
+p = angr.Project(""./a.out"")
+state = p.factory.blank_state(addr=function_start)
+a = state.solver.BVS('a', 8*7)
+# state.memory.store(state.regs.rbp-0x28,a)
+state.memory.store(state.regs.rdi,a)
+
+sm = p.factory.simulation_manager(state)
+sm.explore(find=function_target, avoid=function_end)
+
+found_path = sm.found[0]
+print(found_path.state.se.any_str(a))
+
+ +

It displays ""a{fsuz"" but the good answer is ""azerty"".

+ +

What is wrong ?

+ +

Second question: why does angr not found anything if i put 0x00001156 address as function start ?

+ +

Thanks

+",18590,,18590,,2/5/2019 18:24,2/7/2019 6:34,Solve an angr function with string parameters,,2,0,,,,CC BY-SA 4.0 +20558,2,,20557,2/5/2019 11:04,,1,,"

I think you might have a couple of errors there.

+ +

First, and this one shouldn't be too critical, is that your start address is not the function's entry (at 0x00001155). That may have been your intention when you were writing the BVS to the stack, but it is unnecessary now.

+ +

The second and more critical issue is that the BVS a is 6 bytes long, while it should be 7 bytes long to include the null terminator value that is required for strings of 6 non-null characters for angr's strlen implementation to function properly.

+",2147,,,,,2/5/2019 11:04,,,,2,,,,CC BY-SA 4.0 +20559,1,20560,,2/5/2019 12:14,,0,2671,"

I was reverse engineering a game using cheat engine and trying to trace where my health gets reduced.

+ +

Basically the health gets stored in the stack and then pops out for displaying on the screen. After it pops out I tried to modify the memory address but that didn't work. Which means we need to modify it before it gets placed into the stack. After lots of diligent scrolling back, I came across the following code.

+ +
fld qword ptr[ebp-38]
+
+ +

This code basically pushes my health onto the stack. However, there are a whole bunch of really odd things in this code:

+ +
    +
  1. This code pushes a value into the float register. It pushes my health float value (71.70) onto the Float registers. However, it is not clear from where its getting this value from. From [EBP-38]? It can't be that because that stores the value ""-2.0"".
  2. +
  3. Once the value is pushed onto the Float registers, I notice that a value has been pushed onto the first register and all other values seem to be shifted. Both of these changes happen from just 1 instruction. Please take a look at the screenshot to see what I'm talking about.
  4. +
+ +

(If screenshot doesn't show big then right-click and ""open in new tab"" for a bigger size). +

+ +
    +
  1. Here's the really odd part. If I select this code in cheat engine then it shows the details of the operation on the right pane. There it shows that the value being moved is ""double"". However, this is supposed to be a floating point instruction. So shouldn't a float value get moved?
  2. +
  3. Another odd thing is that after the value is moved, the float register shows that all 0s have been moved. The existing value is shifted down.
  4. +
+ +

+ +

So my question is:

+ +

1) What does this instruction do exactly?

+ +

2) To change this value to a custom value, can I change the source address? (wherever that is?). Assuming that that is [EBP-38] If yes, then can I use a simple move instruction for this?

+ +

Something like mov [ebp-38], (hex value for 99 float)?

+",27291,,,,,12/16/2019 11:27,"What is this assembly code, fld qword ptr code here doing? Also, how do I store my own value?",,2,0,,,,CC BY-SA 4.0 +20560,2,,20559,2/5/2019 12:28,,1,,"

Qword is 8 bytes not 4 bytes so what you show in your first screen shot as 32 bit value is not correct representation

+ +

ebp-38 is an address +it can point to x y z where x,y,z can be char , int , float , double , ""your fancy new secret type""

+ +

Qword qualifies the address with the type here it says it is a 64 bit numeric

+ +

float operations opearate on float (32) / double (64) / and ? long double ?? 80

+ +
cdb -c "".formats 4051eccc`c0000000;q"" cdb | grep -iE ""Double|Float""
+  Float:   low -2 high 3.28008
+  Double:  71.7
+
+ +

you can see how float operations work on botb 32 bit as well as 64 bit based on bit size type qualifiers assembling some instructions in-place

+ +
0:000> a .
+771f05a6 push 4051eccc
+771f05ab push 0xc0000000
+771f05b0 fld qword ptr [esp]
+771f05b3 fld dword ptr [esp]
+
+ +

disassembling to confirm

+ +
771f05b6
+0:000> u . l4
+ntdll!LdrpDoDebuggerBreak+0x2c:
+771f05a6 68ccec5140      push    4051ECCCh
+771f05ab 68000000c0      push    0C0000000h
+771f05b0 dd0424          fld     qword ptr [esp]
+771f05b3 d90424          fld     dword ptr [esp]
+
+ +

stepping through to see the results

+ +
0:000> 
+771f05a6 68ccec5140      push    4051ECCCh
+0:000> t
+771f05ab 68000000c0      push    0C0000000h
+0:000> t
+771f05b0 dd0424          fld     qword ptr [esp] ss:0023:000af874=4051ecccc0000000
+0:000> t
+771f05b3 d90424          fld     dword ptr [esp]      ss:0023:000af874=c0000000
+
+ +

querying registers

+ +
0:000> r st0
+st0=-2.0000000000000e+0000 (1:4000:8000000000000000)
+0:000> r st1
+st1= 7.16999969482421875000000000000e+0001 (0:4005:8f66660000000000)
+0:000> dd esp l2
+000af874  c0000000 4051eccc
+
+0:000> ?? *(float *) @@masm(@esp)
+float -2
+
+0:000> ?? *(double *) @@masm(@esp)
+double 71.6999969482421875
+
+ +

you should better read this to learn how fpu works why the top slot is copied etc At Simply FPU by Raymond Filiatreault read chapter 1 internals where he explains how st registers are loaded and copied and trashed an unloaded

+",3473,,3473,,2/5/2019 13:20,2/5/2019 13:20,,,,4,,,,CC BY-SA 4.0 +20562,2,,20557,2/6/2019 8:39,,1,,"

There is a problem in how you declare that string to angr. I started with your example code and checked if it works when I assign some address for the argument witch is checked. My best guess is that

+ +
state.memory.store(state.regs.rdi,a)
+
+ +

Does not do what you expect it to do. +Here is the full solution (addresses may differ):

+ +
# coding: utf8
+import angr
+
+function_start = 0x400590
+function_target = 0x400603
+function_end = 0x400616
+dummy_addr = 0x300000
+
+p = angr.Project(""./a.out"")
+state = p.factory.blank_state(addr=function_start)
+a = state.solver.BVS('a', 8 * 7)
+state.memory.store(dummy_addr, a)
+state.regs.rdi = dummy_addr
+
+sm = p.factory.simulation_manager(state)
+sm.explore(find=function_target, avoid=function_end)
+
+found_path = sm.found[0]
+print found_path.state.se.eval(a, cast_to=bytes)
+
+ +

edit

+ +

stack solution as requested

+ +

Please note my variables are located at a different offset (clang/gcc)

+ +
# coding: utf8
+import angr
+
+function_start = 0x40059c
+function_target = 0x400603
+function_end = 0x400616
+dummy_addr = 0x300000
+
+p = angr.Project(""./a.out"")
+state = p.factory.blank_state(addr=function_start)
+a = state.solver.BVS('a', 8 * 7)
+state.memory.store(dummy_addr, a)
+state.mem[state.regs.rbp-0x10].uint64_t = dummy_addr
+
+sm = p.factory.simulation_manager(state)
+sm.explore(find=function_target, avoid=function_end)
+
+found_path = sm.found[0]
+print found_path.state.se.eval(a, cast_to=bytes)
+
+",3162,,3162,,2/7/2019 6:34,2/7/2019 6:34,,,,11,,,,CC BY-SA 4.0 +20563,1,,,2/6/2019 9:59,,1,720,"

this question is a follow-up from this previous post: Flash dump binwalk blank, low entropy

+ +

I need to reverse engineer a firmware from a very secure device. I was able to reverse engineer the PCB and create a JTAG connector, which I used to read the EPROM memory. I tried to binwalk and all other software techniques but they all failed to provide any lead to what is in the firmware.

+ +

I then tried to open the file in IDA, and I could translate all memory blocks into Assembly instructions. Is it possible that the firmware does not reside in any operating system, but instead is only a set of Assembly instructions?

+ +

If indeed is just a set of instructions, would binwalk point anything confirming that?

+ +

File has 256Kb.

+ +

This is the processor: STM32L 152CCT6

+",27071,,245,,2/6/2019 23:29,5/26/2020 1:02,Firmware reverse engineering,,3,1,,,,CC BY-SA 4.0 +20564,2,,20563,2/6/2019 10:35,,1,,"

Yep it could be just ""bare metal"" code without any OS or standard data structures which binwalk can carve.

+",22324,,,,,2/6/2019 10:35,,,,0,,,,CC BY-SA 4.0 +20565,2,,20513,2/7/2019 4:49,,10,,"

First it should be noted that there are so many architectures out there, each with its own instruction set. Here I assume you mean x86 (and you should indeed tag the proper architecture as 0xC0000022L said above). Most parts of the below answer would apply to other architectures as well, but they may use different mnemonics or lack some mentioned instructions

+

SAL and SHL are the same. They're simply aliases to the same opcode because shifting left always fill the vacant bits with 0s. In C << will do a shift left, and whether the shift instruction is printed as SAL or SHL depends on the compiler/disassembler

+

OTOH there are 2 versions of right shift because you can fill the bits that were shifted out with zero (logical shift) or the high bit of the old value (arithmetic shift). SAR does an arithmetic shift and SHR does a logical shift. In C the operator for right shifting is >>, but the rule depends on the signness of the type:

+
    +
  • A right shift on an unsigned type is always a logical shift, therefore SHR will be used
  • +
  • A right shift on a signed type is implementation defined, i.e. the compiler can choose to do an arithmetic or a logical shift. However almost all modern compilers will do an arithmetic shift (SAR) on signed types (otherwise doing arithmetic shift would be too tricky/clumsy). Some compilers may have an option to select the right shift variant though
  • +
+

Per the C99 standard, section 6.5.7:

+
+

The integer promotions are performed on each of the operands. The type of the result is that of the promoted left operand. If the value of the right operand is negative or is greater than or equal to the width of the promoted left operand, the behavior is undefined.

+

The result of E1 << E2 is E1 left-shifted E2 bit positions; vacated bits are filled with zeros. If E1 has an unsigned type, the value of the result is E1 × 2E2, reduced modulo one more than the maximum value representable in the result type. If E1 has a signed type and nonnegative value, and E1 × 2E2 is representable in the result type, then that is the resulting value; otherwise, the behavior is undefined.

+

The result of E1 >> E2 is E1 right-shifted E2 bit positions. If E1 has an unsigned type or if E1 has a signed type and a nonnegative value, the value of the result is the integral part of the quotient of E1 / 2E2. If E1 has a signed type and a negative value, the resulting value is implementation-defined.

+
+
+

However there are a lot of other operations that can produce a shift instruction, and various cases that shift operators don't produce a shift instruction

+

It's less common to see <</>> that are not compiled to a shift instruction, but compilers may optimize x << 1 to x += x and you'll see things like ADD eax, eax or LEA ecx, [eax + eax]. On x86 x << i with i ⩽ 3 can also be compiled to LEA eax, [eax*2ⁱ] instead of shift. Of course an output like MUL x, 2 is also possible on a hypothetical architecture without shift, or where shift is slower than multiplication

+

Compilers are also able to transform complex statements like (x << 1) + (x << 4) + (x << 13) into simpler ones such as a single multiplication by 8210, no more shifts.
+Or GCC recognizes (a ^ b) + (a & b) + (a & b) as well as its the inverse condition (a + b) - (a & b) - (a & b) and optimize them to a + b and a ^ b respectively, so it's possible (in the future) that they'll be able to convert the equivalents (a ^ b) + ((a & b) << 1) and (a + b) - ((a & b) << 1) into ADD and XOR without any shifts at all.
+See them in action

+

For the other case there are various examples:

+
    +
  • Multiplication by a power of 2 is done by a left shift. On x86 there exists the more versatile LEA instruction, so for exponent ⩽ 8 the choice between LEA and SHL depends on the compiler. Array arithmetic also need a lot of multiplication, so a shift is also usually used
  • +
  • Multiplication by many other constants can also be optimized to a series of ADD/SUB and shifts if that's faster than the MUL instruction itself. Again in x86 occasionally LEA is used instead of shifts
  • +
  • Division by a power of 2 is done by a right shift. For unsigned types it's a simple logical shift. For signed types it's an arithmetic shift followed by some other shifts and ADDs to correct the result (since division rounds towards zero, and arithmetic right shift rounds towards -inf)
  • +
  • Division by constants will be optimized into a multiplication by the corresponding multiplicative inverse, which may involve some shifts to round the result
  • +
  • Clang even emits an SHR for checking the high bits while doing a division by a non-constant if tuning for microarchitectures from Sandy Bridge onward
  • +
  • Bitfield accesses of course need to use a lot of shifts in architectures without efficient bitfield manipulation like x86. See demo
  • +
  • ...
  • +
+

Here are some illustrations for the mul/div examples. You can easily see that x*15 is replaced by x*16 - x and x*33 is done by x*32 + x, i.e. (x << 4) - x and (x << 5) + x. Besides, x*8 is optimized to lea eax, [0+rdi*8] or shl edi, 3 depending on the compiler. The mnemonics SAL and SHL are also freely chosen by the compiler

+

I've also put some non-x86 compilers for comparison, because they don't have LEA but may have other shift-related instructions or different shift capabilities beside the normal shift instructions. You can change between various x86 as well as non-x86 compilers to see the differences between their outputs. Another example that combines multiple things I've said above:

+ +
struct bitfield {
+    int x: 10;
+    int y: 12;
+    int z: 10;
+};
+
+int f(bitfield b)
+{
+    int i = b.x*65;
+    int j = b.y/25;
+    int k = b.z/8;
+    return (i << j) + (k >> j);
+}
+
+

That compiles to

+
f(bitfield):
+        mov     eax, edi
+        mov     edx, edi
+        sar     edi, 22
+        sal     eax, 10
+        sal     edx, 6
+        sar     eax, 20
+        sar     dx, 6
+        imul    ecx, eax, 5243
+        sar     ax, 15
+        sar     ecx, 17
+        sub     ecx, eax
+        movsx   eax, dx
+        mov     edx, eax
+        movsx   ecx, cx
+        sal     edx, 6
+        add     edx, eax
+        lea     eax, [rdi+7]
+        sal     edx, cl
+        test    di, di
+        cmovns  eax, edi
+        sar     ax, 3
+        cwde
+        sar     eax, cl
+        add     eax, edx
+        ret
+
+

You can open the Godbolt link to see which instruction corresponds to which line of code in color

+

In summary: Compilers nowadays are really smart and can output "surprising" results to a normal people. They can emit a shift instruction for pretty much any operators in C. With an optimizing compiler, all bets are off

+

See also

+ +",2563,,-1,,6/17/2020 9:54,10/12/2019 4:55,,,,0,,,,CC BY-SA 4.0 +20567,2,,17666,2/7/2019 8:41,,3,,"

ldr without = does PC relative loads

+ +

This is true for both labels and numbers.

+ +

But you will of course rarely use numbers directly in your assembly. Maybe you have provided some disassembly without labels?

+ +

Both of the following work in GNU GAS ARMv8. With a label:

+ +
    ldr x0, pc_relative_ldr
+    b 1f
+pc_relative_ldr:
+    .quad 0x123456789ABCDEF0
+1:
+    /* x0 == 0x123456789ABCDEF0 */
+
+ +

with an offset:

+ +
    ldr x0, 0x8
+    b 1f
+    .quad 0x123456789ABCDEF0
+1:
+    /* x0 == 0x123456789ABCDEF0 */
+
+ +

Both are equivalent. The assembler just happens to convert the label into the correct offset for you.

+ +

GitHub upstream with assertions.

+ +

STR does not have PC-relative addressing like LDR in ARMv8, you just have to calculate the address into registers first: https://stackoverflow.com/questions/28638981/howto-write-pc-relative-adressing-on-arm-asm/54480999#54480999

+",27375,,27375,,2/8/2019 9:42,2/8/2019 9:42,,,,0,,,,CC BY-SA 4.0 +20568,1,20622,,2/7/2019 10:29,,3,555,"


+I'm working on an embedded system Coldfire ROM. Currently, I'm trying to reverse engineering it to gain some more in-depth knowledge about its structure.
+ROM code quality seems pretty low, and I see a lot of redundancy and dead code lay around, as if the code was compiled with a very low level of optimization.
+I'm telling you that because I do not understand if this fact is somehow related to the question I'm about to pose.
+Checking the code, not infrequently, I'm stepping into jumps inside a single multi byte instruction. I'm new to this technique, so I wonder if someone can put me in the right track to understand this, that I consider a strangeness.
+Here an example of what I'm referring to: +I have a function which starts at ROM:00005474

+ +
[...]
+.ROM:00005490 30 07             movew %d7,%d0
+.ROM:00005492 4a 80             tstl %d0
+.ROM:00005494 66 0c             bnes 0x0000000c :12 
+.ROM:00005496 70 00             moveq #0,%d0
+.ROM:00005498 60 00 00 a8       braw 0x000000b2
+.ROM:0000549c 4e b9 00 00 36 f8 jsr 0x000036f8  : the jump points inside here
+.ROM:000054a2 32 06             movew %d6,%d1
+.ROM:000054a4 48 c1             extl %d1
+.ROM:000054a6 20 01             movel %d1,%d0
+[...]
+
+ +

In another area of the ROM, I have another function which starts at ROM:00012016

+ +
[...]
+.ROM:000120c0 72 00             moveq #0,%d1
+.ROM:000120c2 12 00             moveb %d0,%d1
+.ROM:000120c4 20 3c 00 00 00 ff movel #255,%d0
+.ROM:000120ca b2 80             cmpl %d0,%d1
+.ROM:000120cc 66 00 01 92       bnew 0x00012260
+.ROM:000120d0 4e b9 00 00 54 9e jsr 0x0000549e :here the jump I do not understand
+.ROM:000120d6 72 00             moveq #0,%d1
+.ROM:000120d8 12 00             moveb %d0,%d1
+.ROM:000120da 20 3c 00 00 00 ff movel #255,%d0
+[...]
+
+ +

If I try to follow the jump and begin to disassemble the function starting from the address ROM:0000549e I get a translation which leads to the following interpretation. I understand it is executable, but I do not get the big picture in this action.

+ +
[...]
+.ROM:0000549e 00 00 36 f8                      orib #-8,%d0
+.ROM:000054a2 32 06                            movew %d6,%d1
+.ROM:000054a4 48 c1                            extl %d1
+.ROM:000054a6 20 01                            movel %d1,%d0
+[...]
+
+ +

Is there, behind this technique, some old practice I should know. Why this ROM developer should have used such a strange technique? To reduce the code size? If so, it is not fit with the rest of the code which is very redundant and has dead code in it which won't be ever executed!
+


EDIT.20190214
+At byte 0xc000 it begins a block of code extends to 0x40000 whose first function appears to be incomplete in its beginning part.
+The weirdness seems to begin from this point forward and extends to the byte 0x40000 where the second part of the firmware begins.
+In this code blocks, there are roughly 200 functions of various dimensions and the JSRs with a weird absolute address are not present in all the functions in this block.
+The functions in this block seem to interact with each other seamlessly, but they occasionally occur to present inconsistent addresses.

+",17411,,17411,,2/14/2019 16:50,2/14/2019 16:50,Jump in the middle of an instruction Coldfire firmware,,3,15,,,,CC BY-SA 4.0 +20570,1,20577,,2/7/2019 11:45,,4,1638,"

I'm trying to create an angr script to solve this test program:

+ +
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int main(int argc, char *argv[])
+{
+    int value = atoi(argv[1]);
+    char* foo = ""foobar"";
+    int sum = 0;
+    for (int i = 0; i < strlen(foo); ++i)
+    {
+        sum += foo[i];
+    }
+    return (sum == value);
+}
+
+ +

I'm trying to find out what value needs to be passed to the program in order for it to return True. This is turning out to be less trivial than anticipated.

+ +

The return value is set in the basic block:

+ +

+ +

As you can see, al is set if the values used in the cmp are equal.

+ +

Most angr solutions I have seen are based on a path that is taken if a certain condition is met. Given the address of that path, it is possible to solve the constraints required to get to the address of that path. This will not work in my case.

+ +

I have been scouring the angr examples for a way to solve a symbolic variable for a function return value, but this doesn't seem to be possible.

+ +

I'm currently trying to use run or execute with the find or until args to say: execute until rip == <end of function> and eax == 1.

+ +

Currently I have this:

+ +
import angr
+import claripy
+
+def bv_to_int(bv):
+    return claripy.backends.concrete.convert(bv).value
+
+def main():
+    p = angr.Project('angr_test')
+    arg = claripy.BVS('arg', 4*8)
+
+    st = p.factory.entry_state(args=[p.filename, arg])
+    sm = p.factory.simulation_manager(st)
+
+    sm.explore(find=lambda _s: bv_to_int(_s.regs.rip) >= 0x400708 and bv_to_int(_s.regs.al) == 1)
+
+    print(sm.found[0].solver.eval(arg, cast_to=bytes))
+
+if __name__ == ""__main__"":
+    main()
+
+ +

Which is currently throwing:

+ +
Traceback (most recent call last):
+  File ""angr_test.py"", line 19, in <module>
+    main()
+  File ""angr_test.py"", line 14, in main
+    sm.explore(find=lambda _s: bv_to_int(_s.regs.rip) >= 0x400708 and bv_to_int(_s.regs.al) == 1)
+  File ""/home/ben/.local/lib/python3.6/site-packages/angr/sim_manager.py"", line 237, in explore
+    self.run(stash=stash, n=n, **kwargs)
+  File ""/home/ben/.local/lib/python3.6/site-packages/angr/sim_manager.py"", line 259, in run
+    self.step(stash=stash, **kwargs)
+  File ""/home/ben/.local/lib/python3.6/site-packages/angr/misc/hookset.py"", line 75, in __call__
+    result = current_hook(self.func.__self__, *args, **kwargs)
+  File ""/home/ben/.local/lib/python3.6/site-packages/angr/exploration_techniques/explorer.py"", line 96, in step
+    return simgr.step(stash=stash, extra_stop_points=base_extra_stop_points | self._extra_stop_points, **kwargs)
+  File ""/home/ben/.local/lib/python3.6/site-packages/angr/misc/hookset.py"", line 80, in __call__
+    return self.func(*args, **kwargs)
+  File ""/home/ben/.local/lib/python3.6/site-packages/angr/sim_manager.py"", line 330, in step
+    goto = self.filter(state, filter_func=filter_func)
+  File ""/home/ben/.local/lib/python3.6/site-packages/angr/misc/hookset.py"", line 75, in __call__
+    result = current_hook(self.func.__self__, *args, **kwargs)
+  File ""/home/ben/.local/lib/python3.6/site-packages/angr/exploration_techniques/explorer.py"", line 113, in filter
+    stash = self._filter_inner(state)
+  File ""/home/ben/.local/lib/python3.6/site-packages/angr/exploration_techniques/explorer.py"", line 124, in _filter_inner
+    findable = self.find(state)
+  File ""angr_test.py"", line 14, in <lambda>
+    sm.explore(find=lambda _s: bv_to_int(_s.regs.rip) >= 0x400708 and bv_to_int(_s.regs.al) == 1)
+  File ""angr_test.py"", line 5, in bv_to_int
+    return claripy.backends.concrete.convert(bv).value
+  File ""/home/ben/.local/lib/python3.6/site-packages/claripy/backends/__init__.py"", line 160, in convert
+    ""conversion on a child node"" % (self, ast.op, ast.__class__.__name__))
+claripy.errors.BackendError: <claripy.backends.backend_concrete.BackendConcrete object at 0x7f47a92c05f8> can't handle operation Extract (BV) due to a failed conversion on a child node
+
+ +

Any help would be greatly appreciated.

+",3298,,3298,,2/7/2019 14:04,2/8/2019 12:59,Angr - Solve for function return value,,2,0,,,,CC BY-SA 4.0 +20571,2,,20570,2/7/2019 11:56,,2,,"

Right from the documentation:

+ +
> explore(stash='active', n=None, find=None, avoid=None,
+> find_stash='found', avoid_stash='avoid', cfg=None, num_find=1, **kwargs)
+
+ +
+

The “find” and “avoid” parameters may be any of:

+ +

An address to find A set or list of addresses to find A function that + takes a state and returns whether or not it matches.

+
+ +

Basically, you will have to implement a function accepting a state to decide whether you are in the desired state. You can also just implement a function for the failed state if you'd like.

+ +

Maybe something easy can help you, such as

+ +

find=lambda x: x.regs.eax == 1 && x.regs.rip >= 0x708

+",3162,,,,,2/7/2019 11:56,,,,1,,,,CC BY-SA 4.0 +20572,1,,,2/7/2019 12:07,,6,10055,"

I have a reverse engineering set up on a Mac machine. This set up does some reverse engineering on iOS applications(.ipa files). I'm migrating the setup from Mac to a linux machine.

+ +

Currently on Mac, I'm using OTOOL on ipa binary files and using the following commands:

+ +
    +
  1. otool -L /iOS/binary/path
  2. +
  3. otool -lv /iOS/binary/path
  4. +
  5. otool -hv /iOS/binary/path
  6. +
+ +

Now, I've to do the same operation, i.e reverse engineer the iOS applications, but now on the linux machine. AFAIK, OTOOL is not available for linux machine.

+ +
    +
  1. I've come across JTOOL which I think is most relevant till now. I can use it on linux, and it does something similar to OTOOL, but not exactly same. E.g. while using the -L command on JTOOL, I also need to specify architecture. However, OTOOL gives the shared libraries for all the available architectures.
  2. +
  3. I tried ldd, but I'm getting the error - ""not a dynamic executable"".
  4. +
  5. I tried objdump, but it asks for the object file.
  6. +
+ +

I'm not sure which tool can I use. I to figure out the alternate tool which can do same as OTOOL. Or, if not same, then what changes do i need to make to use the alternate tool.

+",20651,,20651,,2/12/2019 7:01,9/28/2021 21:10,OTOOL alternative for linux,,2,3,,,,CC BY-SA 4.0 +20573,1,,,2/7/2019 14:49,,1,4870,"

I have been trying to decode GPS coordinates (latitude and longitude) which is in HEX format, and the documentation doesn't have a clear explanation, please help me out. I'm adding some examples below.

+ +

latitude 0x414F51 = +28.758963 dd(decimal degree)

+ +

longitude 0x45429B = +077.627784dd(decimal degree)

+ +

screenshot of the documentation

+ +

official documentation

+",27377,,,,,2/8/2019 7:47,How to convert hex data to decimal degree latitude and longitude?,,1,0,,2/11/2019 4:24,,CC BY-SA 4.0 +20575,2,,20573,2/7/2019 18:59,,1,,"

your screenshot probably contains example data and not real values

+ +

first of all both longitude and latitude are 4 bytes as per your documentation

+ +

and there is an example of normal packet in your documentation

+ +

based on that packets data lat and long are as follows

+ +
4E    41 4F 51 53  N   AOQS   
+
+45    42 9B 7D 5C  E   B›}\  
+
+ +

these are normal IEEE float

+ +
:\>xxd -s 94  -l 1 foo.bin
+000005e: 4e                                       N
+
+:\>xxd -s 95  -l 4 foo.bin
+000005f: 414f 5153                                AOQS
+
+:\>xxd -s 99  -l 1 foo.bin
+0000063: 45                                       E
+
+:\>xxd -s 100  -l 4 foo.bin
+0000064: 429b 7d5c                                B.}\
+
+:\>cdb -c "".formats 414f5153;q"" cdb | grep -i float
+  Float:   low 12.9574 high 0
+
+:\>cdb -c "".formats 429b7d5c;q"" cdb | grep -i float
+  Float:   low 77.7448 high 0
+
+:\>
+
+ +

reverse geocoding this location is as shown in screen shot

+ +

+",3473,,3473,,2/8/2019 7:47,2/8/2019 7:47,,,,2,,,,CC BY-SA 4.0 +20576,1,,,2/7/2019 22:17,,4,237,"

I have a Schwinn 420 Elliptical Trainer (2012 model), and I want to reverse engineer it. Right now it has a big honking console that lets you increase/decrease the resistance and start a small handful of preprogrammed workout routines. The trouble is that the workout routines are very limited, and the console is bulky and annoying. I'd like to replace it with a flat board that I can rest my laptop on (not possible with it present) so I can do work while I run. I'd also like to replace the console's onboard computer with something like a Raspberry Pi to control the resistance levels. That way the sky's the limit in terms of programming custom workout routines.

+ +

I took a look at the wiring to the console, and there is a twelve-pin cable, pictured below.

+ +

+

+ +

I checked the Schwinn website for service manuals; unfortunately they don't have a service manual for my particular model, plus the service manuals they do offer say nothing about the wiring (the only thing they do say is ""All wires in cable should be intact. If any are visibly crimped or cut, replace cable."").

+ +

I can't imagine that this is a terribly complex circuit. I believe there's only three things this cable can truly be doing:

+ +
    +
  1. Supplying power to the console
  2. +
  3. Increasing/decreasing resistance on command
  4. +
  5. Receiving a signal as to whether the user is running, or not
  6. +
+ +

All the other functions, like showing a countdown clock, going through different workout routines, etc. would all be happening on the console and are therefore irrelevant (i.e. they can be replaced with a Pi). Because regardless of how complex a given workout routine is, at the end of the day, all it's doing is telling the machine to increase or decrease resistance. I noticed that it does automatically pause the workout when you stop moving, so it also must be getting some kind of signal to indicate whether the pedals are moving. I'm quite confident I can program a Pi to send the right signals on GPIO pins, if I know which ones to send.

+ +

But while I have a pretty extensive knowledge of software engineering, I have next to zero knowledge of electrical engineering. So I'm not really sure where to start. I imagine I'll need to essentially ""tap"" the wires (while they're still in use by the console) with something like a multimeter or oscilloscope. But I don't really know how to do that. For example, a multimeter has both a black and red cable. So if I want to test just one of the 12 wires, do I hold the black to it? Then where would the red go?

+ +

Can anyone here recommend any tips on how I can close my own knowledge gap here and start to figure out how to reverse engineer these 12 wires in my elliptical machine? Or better yet, has anyone here already done something like this, with exercise equipment?

+",27381,,,,,2/7/2019 22:17,How to reverse engineer an elliptical trainer?,,0,0,,2/11/2019 4:25,,CC BY-SA 4.0 +20577,2,,20570,2/8/2019 12:59,,4,,"

Ok, I've figured it out.

+ +

First of all, the run command should be used. This will run for all paths.

+ +

After the run the value of eax will actually contain two possible values (one for eax == 0, and another for eax == 1. The solver needs to be told to solve arg where eax == 1.

+ +

This script will give the correct output:

+ +
import angr
+import claripy
+
+def main():
+    p = angr.Project('angr_test')
+    arg = claripy.BVS('arg', 3*8)
+
+    st = p.factory.entry_state(args=[p.filename, arg])
+    sm = p.factory.simulation_manager(st)
+
+    sm.run()
+
+    sm.deadended[0].solver.add(sm.deadended[0].regs.eax == 1)
+
+    print(sm.deadended[0].solver.eval(arg, cast_to=bytes))
+
+if __name__ == ""__main__"":
+    main()
+
+",3298,,,,,2/8/2019 12:59,,,,0,,,,CC BY-SA 4.0 +20580,2,,20568,2/9/2019 13:26,,4,,"

It does look like a size optimization employed in some microcontrollers, although I haven't seen it used around subroutine calls. In particular, CodeWarrior compiler for HC08 and HC12 used it to optimize short branches.

+

From Freescale/NXP's S12(X) Build Tools Reference Manual (section HC(S)12 Backend Optimizations):

+
+

Short BRA Optimization (-OnB=a to disable it)

+

A branch over one byte is replaced with the opcode of BRN. A branch over two bytes is +replaced with the opcode of CPS +Listing 10.19 Short BRA optimization example

+
int q(void) {
+if (f()) {
+    return 1;
+  } else {
+    return 0;
+  }
+}
+
+

The code produced with this optimization:

+
0000 160000 JSR f
+0003 044403 TBEQ D,3 ;abs = 0009
+0006 C601 LDAB #1
+0008 21C7 BRN -57 ;abs = FFD1
+000A 87 CLRA
+000B 3D RTS
+
+

With the -OnB=a (disable short BRA optimization) option the Compiler produces one +more byte:

+
0000 160000 JSR f
+0003 044404 TBEQ D,4 ;abs = 000A
+0006 C601 LDAB #1
+0008 2001 BRA 1 ;abs = 000B
+000A C7 CLRB
+000B 87 CLRA
+000C 3D RTS
+
+

The branch optimizer replaces the BRA 1 in the second example with the opcode of +“BRN”, 0x21. Then the Decoder joins the BRN with the CLRB to one BRN. Actually the +Decoder writes something like the following:

+
0008 21 “BRA 1”
+000A C7 CLRB
+
+

The CLRB out of the second code disappears in the first listing into the offset of the +BRN instruction. The same type of optimization is also done with a BRA 2. Then the opcode of a CPS # is taken. +NOTE BRN and CPS in a Decoder listing are often the result of this optimization. If +so, one or two additional machine instructions are hidden after the opcode. The +compiler writes this as SKIP1 or SKIP2 pseudo opcode to the listing file.

+
+

I haven't found mentions of such optimization used for ColdFire and since you mention that the code does not look optimized it's probably not what is happening here. One theory I have is that the overlapping instructions sequence comes from the compiler's standard library and not developer's code so it has been optimized for size or even written manually in assembly.

+

Yet another option is that you're looking at data being disassembled which may produce all kinds of weird effects. For example, it could be jump tables embedded in code.

+

EDIT yeah, the stuff at 000120c0 does look like some kind of table. For example, when converted to an array of words, it becomes:

+
CODE:000120C0  dc.w $7200, $1200, $203C, 0, $FF, $B280, $6600, $192, $4EB9
+CODE:000120C0  dc.w 0, $549E, $7200, $1200, $203C, 0, $FF
+
+

So it's probably not code at all. I suspect it could be the table of initial tasks or similar.

+",60,,-1,,6/17/2020 9:54,2/10/2019 15:17,,,,9,,,,CC BY-SA 4.0 +20581,2,,12599,2/9/2019 14:51,,1,,"

I am probably late for this, but for future visitors: +the parameters to sub_457048 are passed in eax and edx. The call to _grSstScreenHeight is returned in eax and then saved in ebx, and finally moved in edx. +The call to _grSstScreenWidth is returned in eax.

+ +

so sub_457048 will be eax (width) and edx (height) which is correct.

+ +

The intermediate step to store the value in ebx, is because it's not known to the caller if _grSstScreenWidth will overwrite edx (as it is allowed to, according to the STDCALL calling convention https://en.wikipedia.org/wiki/X86_calling_conventions#stdcall). On the other hand, _grSstScreenWidth has to preserve ebx.

+ +

You're right however, IDA did not seem to see that the value returned by _grSstScreenWidth was to be stored in v4

+",27401,,,,,2/9/2019 14:51,,,,0,,,,CC BY-SA 4.0 +20583,1,,,2/9/2019 23:23,,4,2929,"

Context

+ +

As an exercise I am researching all methods of hiding a secret in an android mobile app binary... Yes I know that with more or less effort they can always be extracted with static analyses, run time introspection or with a MITM attack.

+ +

In my research to hide the secret, the best way I found for Android is by using JNI/NDK and until now I was not able to find a way of reverse engineer it.

+ +
+

NOTE: I understand the high level concept of reverse engineer but I don't have any experience of doing it.

+
+ +

My Attempts

+ + + +
$ strings -aw lib/x86/libnative-lib.so | grep -C 1 -irn 'the-secret-api-key-goes-here' -
+932-[^_]
+933:the-secret-api-key-goes-here
+934-cannot allocate __cxa_eh_globals
+
+ +

So I find the API key in the binary because I know it, but I would like to be able to find it by searching by the variable it is associated with:

+ + + +
$ strings -aw lib/x86/libnative-lib.so | grep -C 1 -irn 'JNI_API_KEY' -
+$
+
+ +

or

+ + + +
$ strings -aw lib/x86/libnative-lib.so | grep -C 1 -irn 'SECRETS_API_KEY' -
+$
+
+ +

Both doesn't return any result... I tried to use also hexdump and objdump without any success!!!

+ +

I tried also radare2 and retdec but my lack of knowledge may have not helped me in finding the API keys to.

+ +

As a last attempt I have de-compiled the binary with MobSF and searched the smali code for the JNI_API_KEY, SECRETS_API_KEY and the-secret-api-key-goes-here without any success.

+ +

At this point I don't want to resort to Frida or xPosed for a run-time reverse engineer technique or a MITM attack approach...

+ +

So for now I just want to know if I can employ other binary or de-compile techniques to find the API key?

+ +
+

NOTE: Looking for open source tools, not commercial ones.

+
+ +

The Code

+ +

The code that I have used to hide the API key with JNI and NDK in the Android app is the following...

+ +

file: native-lib.cpp

+ + + +
#include <jni.h>
+#include <string>
+#include ""api_key.h""
+
+extern ""C"" JNIEXPORT jstring JNICALL
+Java_com_example_secrets_MainActivity_stringFromJNI(
+        JNIEnv *env,
+        jobject /* this */) {
+
+    // To add the API_KEY to the mobile app when is compiled you need to:
+    //   * copy `api_key.h.example` to `api_key.h`
+    //   * edit the file and replace this text `place-the-api-key-here` with your desired API_KEY
+    std::string JNI_API_KEY = SECRETS_API_KEY;
+
+    return env->NewStringUTF(JNI_API_KEY.c_str());
+}
+
+ +

file: api_key.h

+ + + +
#ifndef SECRETS_API_KEY
+#define SECRETS_API_KEY ""the-secret-api-key-goes-here""
+
+#endif / SECRETS_API_KEY
+
+ +

file: CMakeLists.txt

+ +
# For more information about using CMake with Android Studio, read the
+# documentation: https://d.android.com/studio/projects/add-native-code.html
+
+# Sets the minimum version of CMake required to build the native library.
+
+cmake_minimum_required(VERSION 3.4.1)
+
+# Creates and names a library, sets it as either STATIC
+# orJNI_API_KEY SHARED, and provides the relative paths to its source code.
+# You can define multiple libraries, and CMake builds them for you.
+# Gradle automatically packages shared libraries with your APK.
+
+add_library( # Sets the name of the library.
+        native-lib
+
+        # Sets the library as a shared library.
+        SHARED
+
+        # Provides a relative path to your source file(s).
+        native-lib.cpp)
+
+# Searches for a specified prebuilt library and stores the path as a
+# variable. Because CMake includes system libraries in the search path by
+# default, you only need to specify the name of the public NDK library
+# you want to add. CMake verifies that the library exists before
+# completing its build.
+
+find_library( # Sets the name of the path variable.
+        log-lib
+
+        # Specifies the name of the NDK library that
+        # you want CMake to locate.
+        log)
+
+# Specifies libraries CMake should link to your target library. You
+# can link multiple libraries, such as libraries you define in this
+# build script, prebuilt third-party libraries, or system libraries.
+
+target_link_libraries( # Specifies the target library.
+        native-lib
+
+        # Links the target library to the log library
+        # included in the NDK.
+        ${log-lib})
+
+",27405,,,,,2/10/2019 8:21,Extract a secret from an Android apk or .so file,,1,0,,,,CC BY-SA 4.0 +20585,2,,20583,2/10/2019 8:21,,3,,"

If the API key is a string then just running strings would reveal it w/o grep as you do in your example. There might be some other strings but longer ones seems to stand out so it should be clearly visible that this is something meaningful. Having that API key I would probably go and use regular disassembler tools to see where and how it is used.

+ +

You can't search by variable names as those are not preserved in the binary (.so), with APK it might be a bit different.

+",18014,,,,,2/10/2019 8:21,,,,1,,,,CC BY-SA 4.0 +20586,2,,18493,2/10/2019 17:39,,0,,"

Try this:

+ +
    #!usr/bin/python
+    for i in Functions():
+        print ""function start = "" + hex(GetFunctionAttr(i, FUNCATTR_START))
+        print ""function end = "" + hex(GetFunctionAttr(i, FUNCATTR_END)) 
+        GetManyBytes(GetFunctionAttr(i, FUNCATTR_START), GetFunctionAttr(i, FUNCATTR_END) - GetFunctionAttr(i, FUNCATTR_START), 0)
+
+ +

I have found this python script some time ago somewhere on the net. I will find all functions for you. Verify it!

+",27414,,,,,2/10/2019 17:39,,,,2,,,,CC BY-SA 4.0 +20587,1,,,2/10/2019 18:27,,3,1228,"

I'm reversing a program that ""hides"" some instructions using the jump in the middle trick. This trick is a jump to a middle of an instruction, whereas the real address actually contains another opcode.

+ +

Example:

+ +
 CS:0100 E421           IN     AL,21
+ CS:0102 B0FF           MOV    AL,FF
+ CS:0104 EB02           JMP    0108
+ CS:0106 C606E62100     MOV    Byte Ptr [21E6],00
+ CS:010B CD20           INT    20
+
+ +

So I have some questions related to this: Can this trick hide imports? hide x references to functions or strings? Are there any way to fix it? (other than stepping through the code) +Edit: I'm using x32dbg

+",27415,,27415,,2/10/2019 19:13,2/11/2019 13:38,Jump in the middle trick,,2,0,,,,CC BY-SA 4.0 +20589,2,,20587,2/10/2019 19:56,,2,,"

Bytes are just bytes so it's only how you interpret them makes what they are - so yes, you could potentially hide function call or a string is such way.

+ +

How you would deal with that in x32dbg. Click on the opcode that you want to fix, and right click and select Binary -> Edit (or press CTRL+E). You would see a dialog where the bytes of the opcode will be shown. You simple replay the bogus bytes with nop (0x90).

+",18014,,,,,2/10/2019 19:56,,,,0,,,,CC BY-SA 4.0 +20590,1,20597,,2/10/2019 20:18,,1,908,"

Is it possible to generate a software breakpoint other than int3 to be catched by the debugger, like a division by zero for example?

+ +

If so, I was wondering why debuggers don't support generating different exceptions for software breakpoints? For programs that have anti-debugging mechanisms like scanning for unknown 0xCC.

+ +

Are there any reasons for this? because all debuggers I've seen so far implement only int3 software breakpoints.

+",19826,,2147,,2/11/2019 11:32,2/11/2019 11:32,Generate software breakpoint other than int3,,2,0,,,,CC BY-SA 4.0 +20591,1,20596,,2/10/2019 21:48,,1,2205,"

Update:

+ +

The problem turned out to be more complex and complex because Hex-Rays incorrectly restores the stack after calls of stdcall functions from cdecl functions:

+ +
.text:00403F2F 074                 mov     edx, gameScreenHeight
+.text:00403F35 074                 mov     ecx, [eax]
+.text:00403F37 **074**             push    10h
+.text:00403F39 078                 push    edx
+.text:00403F3A 07C                 mov     edx, gameScreenWidth
+.text:00403F40 07C                 push    edx
+.text:00403F41 080                 push    eax
+.text:00403F42 084                 mov     eax, [ecx+54h]
+.text:00403F45 084                 call    eax
+.text:00403F47 **070**             test    eax, eax
+.text:00403F49 070                 jz      short loc_4
+
+ +

As a result, a function that takes 4 arguments gets only three:

+ +

Bad: lpDD->lpVtbl->SetDisplayMode(lpDD, gameScreenWidth, gameScreenHeight, 16, **a1**)

+ +

Good: lpDD->lpVtbl->SetDisplayMode(lpDD, gameScreenWidth, gameScreenHeight, 16)

+ +

As a result, the function may not use the register value, but only save and restore it, but due to the shifted pointer to the stack after the call, it is considered to be used in some problem call. This causes the entire call chain to be marked as using this register as an argument.

+ +

Worst of all, such a problem arises in branched functions, which have several exit points and in each of them the stack is balanced (000). I can't just change the stack pointer after an erroneous call. I must also find another call and balance the changes made. x.x

+ +
+ +

The original question: +I need to detect and safely fix incorrectly recognized function signatures. How I can do that?

+ +

For example, this function saves game settings:

+ +
BOOL __thiscall sub_410640(HKEY this)
+{
+  HKEY v1; // ecx
+  HKEY v2; // ecx
+
+  sub_431C00(this, ""volumeMaster"", *(_DWORD *)&phkResult);
+  sub_431C00(*(HKEY *)&g_volumeMusic, ""volumeMusic"", *(_DWORD *)&g_volumeMusic);
+  sub_431C00(v1, ""volumeFX"", *(_DWORD *)&g_volumeFX);
+  sub_431C00(v2, ""volumeSpeech"", *(_DWORD *)&g_volumeSpeech);
+  return sub_431C00(*(HKEY *)&dword_4A262C, ""volumeMinimum"", *(_DWORD *)&dword_4A262C);
+}
+
+.text:00410640     sub_410640      proc near               ; CODE XREF: PlayVideo+50↑p
+.text:00410640                                             ; sub_416910+1A6↓p
+.text:00410640 000                 mov     eax, phkResult
+.text:00410645 000                 push    eax             ; Data
+.text:00410646 004                 push    offset ValueName ; ""volumeMaster""
+.text:0041064B 008                 call    sub_431C00
+
+.text:00410650 008                 mov     ecx, g_volumeMusic
+.text:00410656 008                 push    ecx             ; Data
+.text:00410657 00C                 push    offset aVolumemusic ; ""volumeMusic""
+.text:0041065C 010                 call    sub_431C00
+
+.text:00410661 010                 mov     edx, g_volumeFX
+.text:00410667 010                 push    edx             ; Data
+.text:00410668 014                 push    offset aVolumefx ; ""volumeFX""
+.text:0041066D 018                 call    sub_431C00
+
+.text:00410672 018                 mov     eax, g_volumeSpeech
+.text:00410677 018                 push    eax             ; Data
+.text:00410678 01C                 push    offset aVolumespeech ; ""volumeSpeech""
+.text:0041067D 020                 call    sub_431C00
+
+.text:00410682 020                 mov     ecx, dword_4A262C
+.text:00410688 020                 push    ecx             ; Data
+.text:00410689 024                 push    offset aVolumeminimum ; ""volumeMinimum""
+.text:0041068E 028                 call    sub_431C00
+
+.text:00410693 028                 add     esp, 28h
+.text:00410696 000                 retn
+.text:00410696     sub_410640      endp
+
+ +

If we look at the function inside, we can see that the arguments passed through the registers are not used in any way.

+ +

In addition, it is obvious that calls to the same function should be uniform and the transfer of such arguments does not make any sense.

+ +
BOOL __usercall sub_431C00@<eax>(HKEY a1@<ecx>, LPCSTR lpValueName, ...)
+{
+  LONG v3; // esi
+  HKEY phkResult; // [esp+0h] [ebp-4h]
+  va_list Data; // [esp+Ch] [ebp+8h]
+
+  va_start(Data, lpValueName);
+  phkResult = a1;
+  if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, SubKey, 0, 1u, &phkResult) )
+    return 0;
+  v3 = RegSetValueExA(phkResult, lpValueName, 0, 4u, (const BYTE *)Data, 4u);
+  RegCloseKey(phkResult);
+  return v3 == 0;
+}
+
+.text:00410600     sub_410600      proc near               ; CODE XREF: sub_4073F0+2B0↑p
+.text:00410600                                             ; WinMain(x,x,x,x)+5F4↓p ...
+.text:00410600
+.text:00410600     arg_0           = dword ptr  4
+.text:00410600
+.text:00410600 000                 mov     eax, [esp+arg_0]
+.text:00410604 000                 test    eax, eax
+.text:00410606 000                 mov     ecx, 1
+.text:0041060B 000                 mov     dword_4AE978, ecx
+.text:00410611 000                 mov     dword_4AF074, eax
+.text:00410616 000                 jz      short locret_410632
+.text:00410618 000                 mov     dword_4A267C, 69h
+.text:00410622 000                 mov     dword_4AE920, 0
+.text:0041062C 000                 mov     dword_4AF03C, ecx
+.text:00410632
+.text:00410632     locret_410632:                          ; CODE XREF: sub_410600+16↑j
+.text:00410632 000                 retn
+.text:00410632     sub_410600      endp
+
+ +

And now I need to adjust the declaration of these functions so that it corresponds to reality.

+ +

But two questions arise:

+ +
    +
  1. How to understand what the problem is?
  2. +
  3. How to make corrections safely so that one error in one function does not lead to unbalance of the stack and decompilation errors throughout the entire application database?
  4. +
+ +

Expected result:

+ +
BOOL __usercall sub_431C00(LPCSTR lpValueName, _DWORD value);
+
+sub_431C00(""volumeMaster"", *(_DWORD *)&phkResult);
+sub_431C00(""volumeMusic"", *(_DWORD *)&g_volumeMusic);
+sub_431C00(""volumeFX"", *(_DWORD *)&g_volumeFX);
+sub_431C00(""volumeSpeech"", *(_DWORD *)&g_volumeSpeech);
+
+ +

Link to this PE File

+ +

Oh yeah, the funny thing is that in this case IDA correctly defines the function signature, but for some reason Hex-Rays blows the roof off:

+ +

IDA: int __cdecl sub_431C00(LPCSTR lpValueName, BYTE Data)

+ +

Hex-Rays: BOOL __usercall sub_431C00@<eax>(HKEY a1@<ecx>, LPCSTR lpValueName, ...)

+",26081,,26081,,2/12/2019 22:23,2/13/2019 9:16,IDA Hex-Rays: How to SAFELY fix incorrect function declarations?,,2,8,,,,CC BY-SA 4.0 +20592,2,,20590,2/10/2019 21:56,,3,,"

if you were on windows then you can try ollydbg v2

+ +

+",3473,,,,,2/10/2019 21:56,,,,0,,,,CC BY-SA 4.0 +20593,1,20598,,2/10/2019 22:06,,1,191,"

I am new to reverse engineering and try to solve a crackme with radare2.

+ +

My problem is understanding of the following lines:

+ +
|           0x000007a9      c745b8000000.  mov dword [var_48h], 0
+|           0x000007b0      c745bc000000.  mov dword [var_44h], 0
+|           0x000007cd      8b45b8         mov eax, dword [var_48h]
+|           0x000007d0      4898           cdqe
+|           0x000007d2      0fb64405c0     movzx eax, byte [rbp + rax - 0x40]
+
+ +

From the bottom part of this code surrounding them:

+ +
|           0x0000076a      55             push rbp
+|           0x0000076b      4889e5         mov rbp, rsp
+|           0x0000076e      4883ec50       sub rsp, 0x50               
+|           0x00000772      64488b042528.  mov rax, qword fs:[0x28]    ; [0x28:8]=0x19c0 ; '('
+|           0x0000077b      488945f8       mov qword [canary], rax
+|           0x0000077f      31c0           xor eax, eax
+|           0x00000781      c645b700       mov byte [var_49h], 0
+|           0x00000785      488d3d580100.  lea rdi, qword str.Enter_password: ; 0x8e4 ; ""Enter password:"" ; const char *s
+|           0x0000078c      e87ffeffff     call sym.imp.puts           ; int puts(const char *s)
+|           0x00000791      488d45c0       lea rax, qword [var_40h]
+|           0x00000795      4889c6         mov rsi, rax
+|           0x00000798      488d3d550100.  lea rdi, qword [0x000008f4] ; ""%s"" ; const char *format
+|           0x0000079f      b800000000     mov eax, 0
+|           0x000007a4      e897feffff     call sym.imp.__isoc99_scanf ; String! ; int scanf(const char *format)
+|           0x000007a9      c745b8000000.  mov dword [var_48h], 0
+|           0x000007b0      c745bc000000.  mov dword [var_44h], 0
+|           0x000007cd      8b45b8         mov eax, dword [var_48h]
+|           0x000007d0      4898           cdqe
+|           0x000007d2      0fb64405c0     movzx eax, byte [rbp + rax - 0x40]
+|           0x000007d7      84c0           test al, al
+
+ +

I understand the output and that there is the input wanted (scanf). After that var_48h, var_44h and eax are set to 0. The next lines i don't understand at all. Beside the cdqe instruction there is some calculation(?) with the variables rbp and rax (=var_49h?).

+ +

Maybe you can help me to understand that?

+ +

Thank you in advance!

+",27418,,2147,,2/11/2019 13:12,2/11/2019 13:12,Calculation with not defined variables?,,2,0,,,,CC BY-SA 4.0 +20594,2,,20593,2/10/2019 22:22,,0,,"

CDQE Convert DoubleWord To QuadWord

+ +

it takes whatever is in eax sign extends it and puts it in Rax

+ +

so as long as eax holds anything less than 7fffffff and greater than 0
+Rax will be 00000000whateverwashereineax
+when eax holds anything from 0x80000000 to 0xffffffff
+rax will become ffffffff
whateverwashereineax

+ +

in your case eax is 0 (see var_48) so Rax will be 0 after execution of cdqe

+ +

and then it accesses a single byte (first letter of your password) and checks if it is 0 (test al,al)

+",3473,,,,,2/10/2019 22:22,,,,0,,,,CC BY-SA 4.0 +20595,2,,20297,2/11/2019 9:59,,1,,"

If commandline is required you can subscribe to WMI Win32_ProcessStartTrace events, here's an example in PowerShell:

+ +
Register-WMIEvent -query ""SELECT * FROM Win32_ProcessStartTrace"" -SourceIdentifier ""testevent"" -action { $e = $Event.SourceEventArgs.NewEvent
+Write-Host $e.ProcessName, ""started"" }
+
+ +

To stop notification call Unregister-Event Process-Started

+ +

But it might be a better solution to use Process Monitor and use the Process Tree functionality:

+ +

As an example I started a command prompt from PowerShell and then launched Notepad from that command prompt: +

+",99,,,,,2/11/2019 9:59,,,,0,,,,CC BY-SA 4.0 +20596,2,,20591,2/11/2019 10:39,,2,,"

Welcome to RE.SE!

+ +
+

How to understand what the problem is?

+
+ +

When the function is decompiled, IDA checks for its dependencies via dataflow analysis. Basically, it asks which values have to be defined in order to make this function work.

+ +

When it encounters the first line of the function (push ecx) IDA noticed that the value of ecx is used before it was defined in this function, hence it establishes it as a dependency, even though IDA is well aware that it is not a parameter to the RegOpenkeyExA call through its signature. At either and of the function, the ecx value is restored.

+ +

This is what makes IDA think, ecx is part of the function signature: it actually is

+ +

Fun IDA fact: When you decompile function sub_410640 first without looking at sub_431C00, the signatures are like you want them to be (due to the lack of information)

+ +
int sub_410640()
+{
+  sub_431C00(""volumeMaster"", phkResult);
+  sub_431C00(""volumeMusic"", dword_4D55C8);
+  sub_431C00(""volumeFX"", dword_4D55CC);
+  sub_431C00(""volumeSpeech"", dword_4D55D0);
+  return sub_431C00(""volumeMinimum"", dword_4A262C);
+}
+
+ +

The core problem is the weird useage of the ecx register in this function. Even from an optimization point of view, it does not make any sense.

+ +
+

How to make corrections safely so that one error in one function does + not lead to unbalance of the stack and decompilation errors throughout + the entire application database?

+
+ +

For example, you could NOP-out the code pushing and poping ecx in the function, since it seems the calling function doesn't rely on this value remaining constant. I tested it real quick and it seems to work.

+ +

You could also solve the pointer aliasing problem. If you could find a way to proof that the ecx value on the stack is not written or read, one could omit this parameter. Sadly, that's pretty hard.

+ +

You could also try and come up with a better decompiler utilizing different heuristics, I guess. You could also try RetDec or Snowman for better results, but they will perform dataflow analysis similar to Hex-Rays and may end up with similar results.

+ +

The decompiler works kind of like a one-way function. When you invoke it, the current function and meta data like variable names and function signatures are passed to it. Although it allows for some corrections, its only the meta data and should not change the assembly code at all.

+",3162,,3162,,2/12/2019 6:16,2/12/2019 6:16,,,,1,,,,CC BY-SA 4.0 +20597,2,,20590,2/11/2019 11:30,,3,,"

A more flexible solution using x64dbg

+

In addition to ollydbg2's built-in experimental support, it's relatively easy to achieve something similar in x64dbg, although some manual scripting is required. Using x64dbg's SetExceptionBPX function, you can define any exception to be treated as a breakpoint by x64dbg instead of being treated by regular exception handling logic. You will then need to create your own "breakpoint" handling logic (create & delete breakpoint) by modifying code at desired addresses to trigger that exception and restore it afterwards.

+

Answering the broader question

+

Additionally, you've asked

+
+

why debuggers don't support generating different exceptions for software breakpoints? For programs that have anti-debugging mechanisms like scanning for unknown 0xCC.

+
+

so I'll go ahead and answer the broader question.

+

Although you accurately noted debuggers default to use the int3 instruction for breakpoints, that is definitely not the only one. Several debuggers (especially those geared towards malware analysis and combating anti-debugging) have started implementing additional software breakpoint methods precisely for that reason. debuggers such as ollydbg and x64dbg implement multiple breakpoint types both for different debugging functionality (i.e. memory/data breakpoints) and for stealth (such as less common tricks to trigger an interrupt that the debugger may catch).

+

For most of the more common debugging tasks, these are just unnecessary for the majority of debugger use cases, therefore many debuggers are never required to use any alternative exception triggering instructions. The user base for say, gdb, is mostly software developers that never encounter the need for such features.

+

Why division by zero is a suboptimal choice regardless

+

Lastly, you've asked specifically about a division by zero exception being used as a software breakpoint alternative, so I'll include a few drawbacks for using division by zero specifically.

+
+

Is it possible to generate a software breakpoint other than int3 to be catched by the debugger, like a division by zero for example?

+
+

That one, specifically, is more known but is a suboptimal choice compared to alternatives. It's avoided even by debuggers providing many software breakpoint alternatives because it is a more difficult exception to generate and cleanup compared to single byte instructions such as int3, int1, outsb, etc.

+

As the div instruction requires either a register or a memory address and cannot accept an immediate value for the divisor, you're required to prepare a register or memory address with the value zero, as well as generate a longer instruction which may be a little riskier if overwriting multiple instructions of the original code. For those reasons, division by zero is far less convinenet to use as a software breakpoint alternative.

+",2147,,-1,,6/17/2020 9:54,2/11/2019 11:30,,,,4,,,,CC BY-SA 4.0 +20598,2,,20593,2/11/2019 13:06,,2,,"

Lets take a look at the specific piece of code you can't understand:

+ +
mov dword [var_48h], 0
+mov dword [var_44h], 0
+mov eax, dword [var_48h]
+cdqe
+movzx eax, byte [rbp + rax - 0x40]
+
+ +

And go over it a few lines at a time.

+ +

The first couple of lines are either initializing a local variable of size qword (8 bytes) to 0 by assigning one dword at a time, or two dword-sized variables, each of which to zero:

+ +
mov dword [var_48h], 0
+mov dword [var_44h], 0
+
+ +

Converting this to C, this may look similar to:

+ +
long var_ab = 0;
+
+ +

or

+ +
int var_a, var_b = 0;
+
+ +

The third line is a little puzzling assuming the above assignment is to a single qword variable:

+ +
mov eax, dword [var_48h]
+
+ +

Regardless, this does not translate to an actual C statement, but suggests the variable (either as var_ab or var_b will be used in following statements.

+ +

Taking a look at the following two lines makes it all clearer:

+ +
cdqe
+movzx eax, byte [rbp + rax - 0x40]
+
+ +

The first of the two, cdqe simply sign-extends eax into rax, effectively setting the higher half of rdx to zero too. the second line of the last snippet makes doing so clear, after we consider the limitations of the x86 assembly language.

+ +

Since eax is used as an index for a stack variable, it is required to be sign-extended to rax because of assembly limitations. executing byte [rbp +eax - 0x40] is impossible in x86 64bit assembly, as all registers in offset calculations are required to be of the same length.

+ +

This makes it clear that the variables are indeed two dword variables, and eax is sign extended solely to be used in the following mov instruction.

+ +

The assembly code above, then, is probably the result of the following C code:

+ +
char buf[...];
+dword idx = 0;
+if (buf[idx] == 0) {
+    ...
+}
+
+",2147,,,,,2/11/2019 13:06,,,,1,,,,CC BY-SA 4.0 +20599,1,20601,,2/11/2019 13:32,,2,1799,"

I've recently started writing a few IDAPython plugins or scripts instead of using the native SDK, but I think I did not really figure out which module(s) are recommended to be imported. Typically, my script imports look somehow like this:

+ +
import ida_funcs
+import ida_kernwin
+import ida_lines
+import ida_nalt
+import ida_name
+import ida_segment
+import ida_struct
+import idaapi
+import idautils
+import idc
+from ida_bytes import *
+from PyQt5 import QtCore, QtGui, QtWidgets
+
+ +

I've only just now realized that the idaapi module imports all the single modules. For example, I can define an action handler as

+ +
class MyHandler(ida_kernwin.action_handler_t):
+
+ +

but also as

+ +
class MyHandler(idaapi.action_handler_t):
+
+ +

So far, I was always trying to find the module the members originate from, and replace idaapi with the original module name where possible. But then I found BADADDR to originate from an ida_idaapi module, and the name feels so ridiculous, I wondered if I've been doing the right thing all along. The source and documentation on it is quite empty.

+ +
    +
  • Is it recommended to use idaapi instead of the single modules? Why does idaapi exist?
  • +
+ +

Then, on the other hand, there is idc, which seems to provide IDC like functions, even with C style name casing. If I recall correctly, I read that the usage of this module is deprecated and only meant for quickly porting IDC scripts; the documentation prominently states

+ +
This file is subject to change without any notice.
+Future versions of IDA may use other definitions.
+
+ +
    +
  • Should I use ida_* / idaapi methods instead and, if possible, ignore idc completely?
  • +
+",6957,,2147,,2/11/2019 17:39,2/11/2019 17:39,"IDAPython modules: Prefer using idaapi or ida_*, and ignore idc completely?",,1,0,,,,CC BY-SA 4.0 +20600,2,,20587,2/11/2019 13:38,,5,,"

Yes, this is indeed possible to employ consistently throughout the entire assembly listing, making manual analysis or adjustments a pain.

+ +

Disassemblers are often divided into two categories:

+ +
    +
  1. linear sweep disassembly - Linear sweep disassembly is more prone to this type of anti-disassembly, as instructions are analyzed linearly throughout the assembly code, top to bottom, which makes jumping over a single byte screw up the remaining disassembly process.
  2. +
  3. recursive disassembly - Recursive disassembly if often better (although, not immune) at managing such intentional tricks as well as unintentional complex assembly combinations. Generally speaking Recursive disassemblers are considered to yield better results but be more difficult to implement..
  4. +
+ +

If this is something you're encountering often with a given sample, you may want to consider a different disassembly engine, perhaps one with emphasis on disassembly, such as IDA, as opposed to debugging oriented tool like x64dbg.

+",2147,,,,,2/11/2019 13:38,,,,0,,,,CC BY-SA 4.0 +20601,2,,20599,2/11/2019 13:55,,4,,"

Short answer is that both idaapi and idc modules should be avoided if possible.

+ +

The idaapi module is there for backwards compatibility and should be avoided if possible. It will be dropped in a future version of IDA (probably with little to no warning ahead of time). You should strongly prefer the ida_ prefixed modules.

+ +

In older versions of IDA, a single module exposed all IDA functionality (that was idaapi), with a few modules implementing utility functions (in idautils) and IDC-translations to ease migration from IDC to IDAPython (in idc).

+ +

With IDA 6.95, IDA's python SDK was divided into multiple modules and idaapi was left to avoid breaking all existing code that relies on the idaapi module.

+ +

Since the idc module has been part of IDA for a long while (since IDAPython started), I think it'll remain part of IDA for longer than idaapi, so if you have to pick whether to use idc or idaapi (and cannot use the specific ida_* modules, for some obscure reason), I suggest you prefer idc over idaapi.

+ +

It's also important to note that idaapi has nearly no content on itself, and you'll see that nowadays idaapi.py is mostly composed of importing the other modules into it's namespace. This is also wrong for several reasons (accidental namespace overshadowing, longer load times by loading unnecessary code) and was part of the reason the namespace was split.

+ +

The ida_idaapi module, however, is part of the new interface and should be used whenever needed. This is where general definitions that have no other reasonable module are made.

+ +

Protip: When I want to convert an idaapi usage to an ida_* usage, I simply import the object at hand and print it's help, which will list where is this object actually defined.

+ +

P.S. +Although not really a duplicate, this is somewhat related to How is IDAPython API structured?

+",2147,,2147,,2/11/2019 14:49,2/11/2019 14:49,,,,1,,,,CC BY-SA 4.0 +20603,1,,,2/12/2019 10:05,,1,150,"

I'm trying to add a dynamic import segment in the IDA database which contains functions names, and I'm applying type information to it, so that I can obtain argument locations by using apply_callee_tinfo when I found a call to this dynamic imported function.

+ +

While I'm testing I found that for some of the declarations, the argument or return type is not able to identify. The IDA is giving a numeric type.

+ +

+ +

The code used is

+ +
def add_from_declaration(declarations):
+    dyn_imp_seg_loc = 0x10000
+    dyn_imp_seg_loc_end = 0x10000 + len(declarations.keys()) * 4
+    idaapi.add_segm(0, dyn_imp_seg_loc, dyn_imp_seg_loc_end, ""DYN_IMP"", ""XTRN"")
+    t_loc = dyn_imp_seg_loc
+    not_applied = []
+    for proc_name in declarations:
+        decl = str(declarations[proc_name])
+        print(decl)
+        try:
+            name, types, fields = idc.ParseType(decl, 0)
+            success = idc.MakeName(t_loc, str(proc_name))
+            t = idaapi.tinfo_t()
+            til = idaapi.til_t()
+            t.deserialize(til, types, fields)
+            if success:
+                idc.MakeDword(t_loc)
+                success = idaapi.apply_tinfo(t_loc, t, 1)
+                if not success:
+                    not_applied.append(proc_name)
+        except Exception:
+            continue
+        finally:
+            t_loc = t_loc + 4
+    return not_applied
+
+ +

declarations is a dict with key as the function name and value as the declaration. +What am I doing wrong in this?

+ +

Edit: My approach is based on the answers provided in this thread, In IDA, is there a way to add a reference to a dynamically imported function into the Imports tab?. My problem is not with adding import segment or creating cross references. But I'm unable to add type information to a name.

+ +

As you can see from the image, I'm trying to apply declaration BOOL __stdcall ReleaseMutex(HANDLE a0); at location 0x10000 which is named ReleaseMutex, but IDA is not able to identify BOOL and HANDLE structures even after parsing the declaration successfully.

+",26611,,26611,,2/13/2019 5:23,2/13/2019 9:26,Argument types not identified when parsing declarations,,0,0,,,,CC BY-SA 4.0 +20604,2,,17110,2/12/2019 10:19,,0,,"

DWORD is typedefined as unsigned long which is 32bits but the address is 64bits long hence the access violation error. So, use size_t datatype which is typedefined as unsigned long long (64bits long).

+ +

As it is a 64 bit program, replace all DWORD's with size_t.

+",27426,,,,,2/12/2019 10:19,,,,0,,,,CC BY-SA 4.0 +20605,1,,,2/12/2019 10:34,,1,247,"

i am trying to find the password of a binary with radare2 - a crackme again :-)

+ +

I already thought I've found the password ('pass'), but this seems to be not the right one. Or there is a trick I didn't found out yet...

+ +

Here is the code and my thoughts about it:

+ +
/ (fcn) sym.main 134
+|   int sym.main (int argc, char **argv, char **envp);
+|           ; var int var_dh @ rbp-0xd
+|           ; var int var_9h @ rbp-0x9
+|           ; var int var_8h @ rbp-0x8
+|           ; DATA XREF from entry0 (0x6dd)
+|           0x000008bc      55             push rbp
+|           0x000008bd      4889e5         mov rbp, rsp
+|           0x000008c0      4883ec10       sub rsp, 0x10
+
+ +
+

Memory Set-Up

+
+ +
|           0x000008c4      64488b042528.  mov rax, qword fs:[0x28]    ; [0x28:8]=0x1a30 ; '('
+|           0x000008cd      488945f8       mov qword [var_8h], rax
+|           0x000008d1      31c0           xor eax, eax
+|           0x000008d3      c745f3000000.  mov dword [var_dh], 0
+|           0x000008da      c645f700       mov byte [var_9h], 0
+|           0x000008de      488d3d140100.  lea rdi, qword str.Enter__pass__: ; 0x9f9 ; ""Enter \""pass\"":  ""
+|           0x000008e5      e896fdffff     call sym.imp.puts           ; int puts(const char *s)
+
+ +
+

Set up var_dh, var_9 and var_8h = 0, Display message 'Enter ""pass"":'

+
+ +
|           0x000008ea      488b151f0720.  mov rdx, qword [obj.stdin]  ; obj.__TMC_END ; [0x201010:8]=0
+|           0x000008f1      488d45f3       lea rax, qword [var_dh]
+|           0x000008f5      be05000000     mov esi, 5
+|           0x000008fa      4889c7         mov rdi, rax
+|           0x000008fd      e89efdffff     call sym.imp.fgets          ; char *fgets(char *s, int size, FILE *stream)
+
+ +
+

Get user input

+
+ +
|           0x00000902      488d45f3       lea rax, qword [var_dh]
+|           0x00000906      ba04000000     mov edx, 4
+|           0x0000090b      488d35030100.  lea rsi, qword str.pass     ; 0xa15 ; ""pass""
+|           0x00000912      4889c7         mov rdi, rax
+|           0x00000915      e856fdffff     call sym.imp.strncmp        ; int strncmp(const char *s1, const char *s2, size_t n)
+|           0x0000091a      85c0           test eax, eax
+
+ +
+

Compare user input with ""pass""

+
+ +
|           0x0000091c      90             nop
+|           0x0000091d      b800000000     mov eax, 0
+|           0x00000922      90             nop
+|           0x00000923      90             nop
+|           0x00000924      90             nop
+|           0x00000925      90             nop
+|           0x00000926      90             nop
+|           0x00000927      b800000000     mov eax, 0
+|           0x0000092c      488b4df8       mov rcx, qword [var_8h]
+|           0x00000930      6448330c2528.  xor rcx, qword fs:[0x28]
+|       ,=< 0x00000939      7405           je 0x940
+|       |   0x0000093b      e850fdffff     call sym.imp.__stack_chk_fail ; void __stack_chk_fail(void)
+|       |   ; CODE XREF from sym.main (0x939)
+|       `-> 0x00000940      c9             leave
+\           0x00000941      c3             ret
+
+ +
+

Leave program, when password is wrong?!

+
+ +

Maybe I just can't see the wood for the trees...

+",27418,,,,,2/12/2019 10:34,"Password is right, but still wrong?",,0,4,,,,CC BY-SA 4.0 +20606,1,,,2/12/2019 17:18,,2,707,"

I have seen the JEB decompiler by PNF Software morph from a specialised decompiler to a full fledged reverse engineering platform like Capstone or IDA Pro.

+ +

While examining the earlier versions of JEB, specifically the 1.x ones (some have been cracked and shared online, I noticed that it was created in pure Java, without any native code (JNI) and at most with the Jython library for access via Python API.

+ +

In fact, this Wikipedia article states that JEB's base language is Java.

+ +

However, if you look at the current features of JEB (currently at ver 3.X), +is it possible that the entire software is written in pure Java? From what I know about Java's Write Once Read Anywhere, there seems to be no separate downloads for Windows, Mac or Linux.

+ +

So is it technically possible to implement an IDA-Pro version in pure Java without any native code?

+ +

Even Capstone have new language (Python, Ruby and Java) bindings, but the decompiler engine is written in C/C++. Is this the case for JEB?

+ +

I note there have been attempts here, and here plus a research article to write a machine code dissembler/interpreter in pure Java, but doubt it can be stable enough to run a RE platform. Those repos I mentioned are experimental and outdated.

+ +

As I do not currently have enough money to get myself a JEB licence, can anyone using or have dug in care to comment, so that we can maintain factual information online and on Wikipedia?

+ +

EDIT: Ok. So when I finally do have the money to get myself a licence, I would like to know if its possible to hook LoadLibraryA or LoadLibraryW on Windows to determine. JEB uses an Eclipse RCP executable. So do I hook that executable or the JVM executable? Because the JVM on Windows uses many Windows API calls which will probably utilise the LoadLibraryX calls.

+",9782,,2147,,3/13/2019 19:25,3/14/2019 18:40,Is PNF's JEB Reverse Engineering platform written in pure Java?,,2,0,,,,CC BY-SA 4.0 +20607,2,,4430,2/12/2019 17:45,,0,,"

Have you tried JEB's library signatures?

+ +

https://www.pnfsoftware.com/blog/jeb-1-3-how-to-sign-and-match-third-party-library-code/

+ +

This was implemented in the earliest versions of that decompiler platform and I think will only get better over time

+",9782,,,,,2/12/2019 17:45,,,,0,,,,CC BY-SA 4.0 +20608,2,,20606,2/12/2019 18:56,,4,,"

There's no technical limitation preventing software development in Java verses C. The only major advantage is execution speed. Moreover, as JEB is directed towards Java programs (android APKs) writing it in Java makes sense.

+ +

However, this question is not really about reverse engineering.

+",2147,,,,,2/12/2019 18:56,,,,2,,,,CC BY-SA 4.0 +20609,1,20620,,2/12/2019 19:40,,1,291,"

If I have a program A, which uses execve to run program B. How can I set a breakpoint in program B's main routine if I'm debugging program A?

+ +

After a certain point in the execve routine, program B will be loaded into memory. After that I can see the symbols in the binary and the regions of memory they have been loaded into. However, to get to that point at the moment I just step through some of the execve instructions which is very fiddly and prone to mistakes.

+ +

Is there a simpler approach to this?

+",25955,,25955,,2/17/2019 16:50,2/17/2019 16:50,How to set a breakpoint in an execve'd program in radare2?,,1,0,,,,CC BY-SA 4.0 +20610,1,,,2/12/2019 23:05,,1,443,"

I've been trying to translate Fullmetal Alchemist 3, i extracted the CFC.DIG file (Main data file) using a QuickBMS script. but now I'm stuck with these .Raw files from RACJIN games, [same case as Bleach Soul Carnival]. It generate two folders ""0"": Characters in game voice ""1"": Texture, Models, Animations.. the files seems to be compressed with a unknown algorhythm..

+ +

here's hex dump of the first few bytes in the file: https://imgur.com/a/3DM6imQdo it not reveal any obvious header structure.

+ +

i wonder if is possible to do it.. anyone could help me with that?

+ +

.RAW Folder ""1"" sample: https://www.dropbox.com/s/w41oxpwq8ph7m56/1%20Folder%20Sample.7z?dl=0

+",27435,,,,,11/10/2019 2:01,Compressed PS2 .RAW File,,1,0,,,,CC BY-SA 4.0 +20611,2,,20568,2/13/2019 0:13,,3,,"

Now that you have shown us bit more of the code, a pattern is starting to emerge.

+ +
jsr     unk_A75E       ; This function does not exist.
+...
+jsr     (loc_576A+2).l  ; ...points in the middle of an instruction
+...
+jsr     (loc_88C+4).l   ; ...points in the middle of an instruction
+
+ +

Jumping into the middle of an instruction is sometimes used to produce slightly faster and more compact code (eg. to eliminate a branch when loading a register with one of two possible values).

+ +

However in this routine every jsr instruction appears to be pointing to invalid code, for no apparent reason. The addresses are absolute immediate values, and your CPU doesn't have an MMU, so these addresses must be valid. However the code at those locations may not be what you think it is.

+ +

You probably assumed that the ROM starts at address 0. If this is not the case then pc-relative code (branch instructions etc.) will still point to the 'correct' addresses, but absolute jumps won't. Another possibility is that the ROM does start at address 0 at power on, but is later swapped for RAM and/or moved to a higher address by special hardware. Code may also be copied from ROM to RAM (possibly at a different address) for execution. There are several possible reasons for doing this:-

+ +
    +
  1. RAM may have a shorter cycle time than ROM, so code which is copied to RAM will execute faster, requiring fewer (or no) wait states.

  2. +
  3. The ROM needs to be at location 0 at startup because code execution starts at location 0. However interrupt vectors also appear in the low memory area, and if they are in ROM then they cannot be changed at run time.

  4. +
  5. Absolute short addressing (which can only access the first and last 32k of memory) is a little quicker than long addressing, so it may be desirable to have RAM in this area for storing frequently accessed variables.

  6. +
+ +

You should analyze the code starting from location 0, verifying that it does essential stuff such as loading the stack pointer, clearing RAM and initializing I/O hardware. Then look for anything that copies executable code from ROM to RAM, and I/O operations that might change the memory map. From this you should be able to figure what is really at the locations those jsr instructions are pointing to.

+ +

You don't say exactly which CPU this code is for, and frankly I can't be bothered trawling through all the Coldfire V2 datasheets to find out what they can do. But you should, because it might have a feature which is relevant to your problem. For a full understanding you should also trace the circuit to determine the locations and functions of I/O pins etc. When reverse-engineering, every bit of information helps!

+",27393,,,,,2/13/2019 0:13,,,,12,,,,CC BY-SA 4.0 +20612,2,,20610,2/13/2019 0:36,,1,,"

This is not a real answer so I think this belongs in the comments section, but I don't have enough reputation, so.

+ +

I opened the sample files with the HxD hex editor and ran a byte-value count analysis. All the files show a similar pattern:

+ +

+ +

From this I can tell the files are not encrypted or compressed (or, at most, use a very basic compression - maybe RLE or such). Compressed files tend to have very random values so you would expect a more or less plain graph.

+ +

Those spikes you see, the higher ones (except zero, in red) correspond to bytes with power-of-two values. Then, halfway between one spike and another you have slightly lower spikes. And so on and so on. This makes me guess. Maybe the files are precalculated tables? Binary trees? Some kind of lookup data? I don't know. Anyway, I hope this helps you a little.

+",27436,,,,,2/13/2019 0:36,,,,1,,,,CC BY-SA 4.0 +20613,2,,12732,2/13/2019 0:57,,0,,"

VirtualProtect or WriteProcessMemory are affected by this

+ +

because windows checks up the Vad Table with +with a internal function called ""MiCheckForConflictingNode"" +windows reacts to 0x00200000 what is 2 = VVadImageMap = 2 +to value 0x00400000 what is in VadTypeVadWriteWatch = 4 +to value 0x0008000 this flag is ""NoChange"" yes (1) or no (0) either contains 0 or 1

+ +

KeAttachProcess also calls a trigger im uncertain if its a flag or a function that got set

+ +

the trigger from the target is made to delay executed +it then read out that information that got left from KeAttachProcess

+ +

after this the target prints a error but its only a trigger

+ +

to avoid this do not use that functions or either emulate them so they dont call triggers or flags +there other ways too

+ +

microsoft gives a .txt file what includes text that is pure scam and talks like 10 pages about that microsoft is protecting those companys

+ +

and saying something like ""stack error"" what is not the case its just scamming and trolling

+ +

also i figured out that this part got added to windows with over a so called ""security update"" what is rather about the take the users away the rights from his own computer

+ +

thats why i never liked windbg it has a tons of dependencies

+ +

as you can see this problem here

+",27439,,,,,2/13/2019 0:57,,,,0,,,,CC BY-SA 4.0 +20614,1,20630,,2/13/2019 6:15,,0,873,"

I am hoping someone can help me with a question or two.

+ +

Essentially I used to be a computer programmer who always wanted to get into a bit of game hacking, having not done any serious programming for a few years I had an itch for a technical endeavour. I decided on football (soccer) manager and wanted to do two things.

+ +
    +
  1. Decipher their file format for tactics. Essentially this has changed +from tac to fmf in the last version or so
  2. +
  3. When a game is being played hook into the DirectX calls to essentially record a match, or figure out the format of their saved matches which can be shown to others
  4. +
+ +

Now as I have no experience of DirectX I went to do number 1 first and have made good progress, but I am at the point where I need a bit of help and pointing in the right direction. Here's what I have deciphered so far with screenshots.

+ +

The start of the fmf file is written (always 02 01 61 66 65 afe) to start, so essentially the file header

+ +

+ +

Then actually the old TAC format is written to disk though the user never sees it unless you breakpoint it, as it puts the tactic on the file, reads it back in and then deletes it again

+ +

+ +

+ +

The TAC file is read back in and a new section of the fmf is written

+ +

+ +

Now this looks similar in size to the previous tac file and is written after the tac file is read back in by the application, it also seems to have section separators in the FMF file so it is its own section.

+ +

+ +

If you look carefully you can see that this section is what was written after it read the tac file back in, now this section appears to be compressed/encrypted but I would guess that this is the tac, and you can clearly see distinct sections in the file separated by

+ +

10 00 00 00 10 00 00 00

+ +

So it is easy to break the file up. Now my question is, this section is the area of interest.

+ +

+ +

The actual data always seems to be around rcx+8 which points to an address with a QWORD pointer which points to the data. I tried decompiling this function and got the following:

+ +
struct s0 {
+    uint32_t f0;
+    int8_t[4] pad8;
+    uint32_t f8;
+    int8_t[4] pad16;
+    uint32_t f16;
+    uint32_t f20;
+};
+
+int32_t fun_146da5dd0();
+
+/* function-which-calls-write */
+uint32_t function_which_calls_write(int64_t rcx, uint32_t rdx, int64_t r8);
+
+/* unknown 1 */
+int64_t unknown_1(struct s0* rcx) {
+    uint32_t eax2;
+    uint32_t eax3;
+    uint32_t edi4;
+    uint32_t rsi5;
+    int64_t rax6;
+    int32_t eax7;
+    int64_t rcx8;
+    int64_t r8_9;
+    uint32_t eax10;
+    uint32_t eax11;
+
+    eax2 = rcx->f20;    
+    if ((*(uint8_t*)&eax2 & 3) != 2 || ((eax3 = rcx->f20, (*(uint8_t*)&eax3 & 0xc0) == 0) || (edi4 = rcx->f0 - rcx->f8, rcx->f16 = 0, rsi5 = rcx->f8, rcx->f0 =     rsi5, (uint1_t)((int32_t)edi4 < (int32_t)0) | (uint1_t)(edi4 == 0)))) {
+        addr_0x146d9e917_2:
+        *(uint32_t*)&rax6 = 0;
+        *(int32_t*)((int64_t)&rax6 + 4) = 0;
+    } else {
+        eax7 = fun_146da5dd0();
+        *(int32_t*)&rcx8 = eax7;
+        *(int32_t*)((int64_t)&rcx8 + 4) = 0;
+        *(uint32_t*)&r8_9 = edi4;
+        *(int32_t*)((int64_t)&r8_9 + 4) = 0;
+        eax10 = function_which_calls_write(rcx8, rsi5, r8_9);
+        if (edi4 == eax10) {
+            eax11 = rcx->f20 >> 2;
+            if (*(uint8_t*)&eax11 & 1) {
+                rcx->f20 = rcx->f20 & 0xfffffffd;
+                goto addr_0x146d9e917_2;
+            }
+        } else {
+            rcx->f20 = rcx->f20 | 16;
+            *(uint32_t*)&rax6 = 0xffffffff;
+            *(int32_t*)((int64_t)&rax6 + 4) = 0;
+        }
+    }
+    return rax6;
+}
+
+ +

So obvious it seems like a struct, especially with the +number on the registers.

+ +

Another useful thing to note is that these sections in the fmf file are always different, ALWAYS, so if I make a tactic, save it, load in the tactic again (exact same one) and resave it is totally different content in between the constant separators 10 00 00 00 and the signature at the start of the file. So that leads me to believe it is some form of compression/encryption but with additional seed, such as the time added.

+ +

My question is I have located this data in the function I showed above, but obviously, there is data loaded in before this place in the function or in a previous function in the call stack. Is there any quick way of following where this data comes from? Once I find the exact point it originates I should obviously be able to conclude that is the encryption/compression function which produces it.

+ +

Thanks a lot.

+",27441,,27441,,2/14/2019 13:18,2/16/2019 10:48,x64dbg - Locating where data is initially written,,1,0,,,,CC BY-SA 4.0 +20615,2,,20591,2/13/2019 9:16,,2,,"

The decompiler decided that ecx is used by sub_431C00 because of push ecx at the beginning of the function which fills the stack slot later used by the variable phkResult, so it may look as if the initial value of phkResult is taken from ecx:

+ +
.text:00431C00                 push    ecx
+.text:00431C01                 lea     eax, [esp+4+phkResult]
+.text:00431C04                 push    eax             ; phkResult
+.text:00431C05                 push    1               ; samDesired
+.text:00431C07                 push    0               ; ulOptions
+.text:00431C09                 push    offset SubKey   ; ""SOFTWARE\\Valkyrie Studios\\Septerra Co""...
+.text:00431C0E                 push    80000002h       ; hKey
+.text:00431C13                 call    ds:RegOpenKeyExA
+.text:00431C19                 test    eax, eax
+.text:00431C1B                 jz      short loc_431C21
+.text:00431C1D                 xor     eax, eax
+.text:00431C1F                 pop     ecx
+.text:00431C20                 retn
+
+ +

In fact, this push ecx is just a shorter versions of sub esp, -4 - the value of ecx does not need to be preserved across function calls so this push is used to reserve 4 bytes of the stack for the phkResult variable. Unfortunately, it is pretty difficult for an automatic algorithm to differentiate between genuine pushes to save registers or pass arguments to function calls and dummy ones to manipulate the stack. If you decided that the ecx usage is false positive, just fix the function prototype (Y key) and remove the unnecessary argument:

+ +
int __cdecl sub_431C00(LPCSTR lpValueName, DWORD Data)
+{
+  LSTATUS v3; // esi
+  HKEY phkResult; // [esp+0h] [ebp-4h]
+
+  if ( RegOpenKeyExA(HKEY_LOCAL_MACHINE, ""SOFTWARE\\Valkyrie Studios\\Septerra Core"", 0, 1u, &phkResult) )
+    return 0;
+  v3 = RegSetValueExA(phkResult, lpValueName, 0, REG_DWORD, (const BYTE *)&Data, 4u);
+  RegCloseKey(phkResult);
+  return v3 == 0;
+}
+
+ +

And now the parent sub has nice decompilation too:

+ +
int sub_410640()
+{
+  sub_431C00(""volumeMaster"", g_volumeMaster);
+  sub_431C00(""volumeMusic"", g_volumeMusic);
+  sub_431C00(""volumeFX"", g_volumeFX);
+  sub_431C00(""volumeSpeech"", g_gvolumeSpeech);
+  return sub_431C00(""volumeMinimum"", g_volumeMinimum);
+}
+
+ +

So, to summarize:

+ +
    +
  1. The problem is caused by compiler optimization confusing the decompiler into deciding that the register value is used while it's just a dummy filler.
  2. +
  3. There is no one true solution that always works, you'll need to experiment and be prepared to roll back and try again. With experience it will become easier.
  4. +
+ +

P.S. IDA did not add ecx to the function prototype because it only analyzes stack arguments. The decompiler does dataflow analysis so it can recover register arguments too, but sometimes it can result in false positives, like here.

+",60,,,,,2/13/2019 9:16,,,,2,,,,CC BY-SA 4.0 +20617,1,,,2/13/2019 17:57,,-1,155,"

I'm trying to reverse engineering an android app API so this is what I tried:

+ +

First the app was using Okhttp certificate pinning and I couldn't track the URLs with Charles then I tried this method and now the tracking part is working but the request body is encrypted and I really can't understand the method of encryption because all of the requests have different length and its not like Base64 here like this example :

+ +
+

2W3UVr4mLWNceSUQ+g4c4ojHCQhlbPC1sjHHNd0l6Ro3FbmefatLFedfI1bvjOHpcApSOjmH1M7xNkLsAO8Vfj90hly8HlfI5paMTNYf/GALQMkevwznI4z1NfbijycqPQNfTZ5C2bjWhS6VHM5VwyPeFVs5R9or/L4EPIAECeGejaQiPfYnGibrGIoeKB34H9YPr7Po6/VoYv317xKNyIXcs290rWibIpMZZ1bwuvfxJGd+YAjUDHj9l32mtKezABBHRnAZDpO8rZ63TsEV8xciaUZhDiDCn1tvV9/QgRrPxNDENDrkwGdQQY3jWt1fuf0g9N7zWR7vi4lwUN8Nb8hCy5rjgPZipX45j0BSRRsHl0t1hQUg4n4ChKZxQy15Pi4sXJsMkFDtqJ5vTjh3iS+X5Dydp4u1QhdLTuEJe50=

+
+ +

now I'm trying to decompile the APK and try to understand the encryption method. so I decompile the APK then start to find endpoints (this app using okhttp and retrofit), I found the endpoint I wanted

+ +
@POST(""e/xam/ple"")
+Call<Object> m3550a(@Header(""Content-Type"") String str, @Body String str2);
+
+ +

then I tried to rebuild the process of sending this endpoint to simulate the request and encryption but not only its so hard (Java decompiler and Jadx cant decompile all the methods and some of them have exception) but some the methods have bad parameters like this method :

+ +
public static String j(Context context) {
+    try {
+        return aa.a(context);
+    } catch (Exception e2) {
+        e2.printStackTrace();
+        return a;
+    }
+}
+
+ +

and the aa.a() method :

+ +
public static String a(byte[] bArr) {
+    char[] cArr = new char[(bArr.length * 2)];
+    for (int i = 0; i < bArr.length; i++) {
+        int i2 = bArr[i] & 255;
+        int i3 = i * 2;
+        cArr[i3] = c[i2 >>> 4];
+        cArr[i3 + 1] = c[i2 & 15];
+    }
+    return new String(cArr);
+}
+
+ +

is there any way to do this easier i searched the decompiled folder for encrption methods and i find this codes :

+ +

Cipher :

+ +
public class C1355f {
+/* renamed from: a */
+public static String f3576a = ""MIGfMA0GCSqGSIb3DQEBAQUAA4GSADCBiQKBgQCVSNDQlVBMy2Wh4J3usfQydpwIzY6FwqDwV0Dd+Bk6PA5sc3usQ8mmjLiI2YD1RDv4jjvmAdkXK+HXuxm2fI6XeIQvgnPRaaj9yNcJnFNViogidcFO7Kg2YYj8yj6DgnCkAtgJeUx2DVvyPnv+Vk1q37Tg4qW0dEFNkWL9hKXGSwIDAQAB"";
+
+/* renamed from: a */
+public static byte[] m3787a(String str, String str2) throws Exception {
+    try {
+        str = C1355f.m3786a(str);
+        str2 = str2.getBytes(""UTF8"");
+        byte[] bArr = new byte[16];
+        Arrays.fill(bArr, (byte) 0);
+        AlgorithmParameterSpec ivParameterSpec = new IvParameterSpec(bArr);
+        Cipher instance = Cipher.getInstance(""AES/CBC/PKCS5Padding"");
+        instance.init(1, str, ivParameterSpec);
+        return instance.doFinal(str2);
+    } catch (String str3) {
+        throw new Exception(str3);
+    }
+}
+
+/* renamed from: a */
+public static SecretKeySpec m3786a(String str) throws UnsupportedEncodingException {
+    Object obj = new byte[16];
+    Arrays.fill(obj, (byte) 0);
+    str = str.getBytes(""UTF-8"");
+    System.arraycopy(str, 0, obj, 0, str.length < obj.length ? str.length : obj.length);
+    return new SecretKeySpec(obj, ""AES"");
+}
+
+/* renamed from: a */
+public static byte[] m3788a(byte[] bArr, String str) throws Exception {
+    bArr = KeyFactory.getInstance(""RSA"").generatePublic(new X509EncodedKeySpec(bArr));
+    Cipher instance = Cipher.getInstance(""RSA/ECB/PKCS1Padding"");
+    instance.init(1, bArr);
+    return instance.doFinal(str.getBytes());
+}
+}
+
+ +

Base64 :

+ +
private byte[] f8405h = new byte[0];
+Base64.encodeToString(this.f8405h, 2)
+
+ +

sorry if this question is a mess but i need help anything can be helpfull

+",27450,,,,,2/16/2019 10:28,decomplied apk with bad parameters,,1,0,,,,CC BY-SA 4.0 +20618,1,,,2/13/2019 18:31,,0,160,"

+ +

How do I find the flag in this QR image? After scanning the QR image, I obtain the following text which may be of help: N2QzNjYyMzQ2NDMzMzMzMzM3MzAzNDM0NjEzMzMyNjEzNjM2Mzk2NTY2MzQ2NDMwMzgzODMyMzQz +MzM4MzAzNTYyN2I2NzYxNmM2Ng==

+ +

What have you obtained as the flag and how? Thanking you all in advance.

+",27452,,,,,2/14/2019 15:50,How would I go about finding the 'flag' in this QR image(Capture the Flag)?,,1,3,,3/7/2019 2:11,,CC BY-SA 4.0 +20619,2,,15351,2/13/2019 19:10,,11,,"

Visual Studio for Mac can do the job. Just hit File / Open and then choose the executable or library you want. It'll open the Assembly Browser window.

+ +

If you need more detailed code change the Visibility to All members and the Language to C#.

+ +

+ +

+ +

+",27454,,27454,,2/14/2019 22:19,2/14/2019 22:19,,,,3,,,,CC BY-SA 4.0 +20620,2,,20609,2/13/2019 20:15,,1,,"

There's a debugging flag called dbg.execs that setting it to true should stop the execution when an execv is happening. So try this:

+ +
> e dbg.execs = true
+
+ +

It looks like it works on Linux, but I couldn't get the same behaviour on OSX.

+",18014,,,,,2/13/2019 20:15,,,,0,,,,CC BY-SA 4.0 +20621,2,,20618,2/14/2019 15:50,,2,,"

Its a base64 that once decoded will give you a HEX string, that if converted to chars will let you find your reversed flag string:

+ +

Redacted reversed flag: +}6b4d**********05b{galf

+ +

Redacted flag is: +flag{b508**********3d4b6}

+",13977,,,,,2/14/2019 15:50,,,,2,,,,CC BY-SA 4.0 +20622,2,,20568,2/14/2019 16:42,,3,,"

These phenomena may be explained by the technique used to write the code on the flash.
The fact that code is structured in two parts would allow the developers to write the code in the flash in two distinct moments.
From MCF5282 and MCF5216 ColdFire Microcontroller User’s Manual, Rev. 3 page 6-19 states:
Thus, a single erase page is effectively 2 Kbyte
(0xc00=24 pages).
It's probable that the code with weird JSR targets might derive from garbage remained there from previous versions, not erased by process of writing the current code in the lower memory.


This answer has been elaborated with the help of IgorSkochinsky and BruceAbbott.

+",17411,,,,,2/14/2019 16:42,,,,0,,,,CC BY-SA 4.0 +20623,2,,8992,2/15/2019 14:11,,0,,"

p $reg

+ +

In QEMU v3.0.0 built from source user mode + GDB 8.2 Ubuntu 16.04, if you do: info registers and info vector it does not show the floating point values but rather rounds them down to integers, I think there is a bug.

+ +

The following does work however. First I load:

+ +
1.5, 2.5, 3.5, 4.5
+
+ +

into v0 / q0.

+ +

ARMv8

+ +
(gdb) p $v0
+$2 = {
+  d = {
+    f = {[0] = 8.0000018998980522, [1] = 1024.0002455711365}, 
+    u = {[0] = 4620693218751676416, [1] = 4652218416153755648}, 
+    s = {[0] = 4620693218751676416, [1] = 4652218416153755648}
+  }, 
+  s = {
+    f = {[0] = 1.5, [1] = 2.5, [2] = 3.5, [3] = 4.5}, 
+    u = {[0] = 1069547520, [1] = 1075838976, [2] = 1080033280, [3] = 1083179008}, 
+    s = {[0] = 1069547520, [1] = 1075838976, [2] = 1080033280, [3] = 1083179008}
+  }, 
+  h = {
+    u = {[0] = 0, [1] = 16320, [2] = 0, [3] = 16416, [4] = 0, [5] = 16480, [6] = 0, [7] = 16528}, 
+    s = {[0] = 0, [1] = 16320, [2] = 0, [3] = 16416, [4] = 0, [5] = 16480, [6] = 0, [7] = 16528}
+  }, 
+  b = {
+    u = {[0] = 0, [1] = 0, [2] = 192, [3] = 63, [4] = 0, [5] = 0, [6] = 32, [7] = 64, [8] = 0, [9] = 0, [10] = 96, [11] = 64, [12] = 0, [13] = 0, [14] = 144, [15] = 64}, 
+    s = {[0] = 0, [1] = 0, [2] = -64, [3] = 63, [4] = 0, [5] = 0, [6] = 32, [7] = 64, [8] = 0, [9] = 0, [10] = 96, [11] = 64, [12] = 0, [13] = 0, [14] = -112, [15] = 64}
+  }, 
+  q = {
+    u = {[0] = 85818282497786728556221825347259203584}, 
+    s = {[0] = 85818282497786728556221825347259203584}
+  }
+}
+
+ +

and:

+ +
(gdb) p $v0.s
+$3 = {
+  f = {[0] = 1.5, [1] = 2.5, [2] = 3.5, [3] = 4.5}, 
+  u = {[0] = 1069547520, [1] = 1075838976, [2] = 1080033280, [3] = 1083179008}, 
+  s = {[0] = 1069547520, [1] = 1075838976, [2] = 1080033280, [3] = 1083179008}
+}
+
+ +

and:

+ +
(gdb) p $v0.s.f
+$3 = {[0] = 1.5, [1] = 2.5, [2] = 3.5, [3] = 4.5}
+
+ +

Test setup.

+ +

ARMv7

+ +
(gdb) p $q0
+$3 = {
+  u8 = {[0] = 0, [1] = 0, [2] = 192, [3] = 63, [4] = 0, [5] = 0, [6] = 32, [7] = 64, [8] = 0, [9] = 0, [10] = 96, [11] = 64, [12] = 0, [13] = 0, [14] = 144, [15] = 64}, 
+  u16 = {[0] = 0, [1] = 16320, [2] = 0, [3] = 16416, [4] = 0, [5] = 16480, [6] = 0, [7] = 16528}, 
+  u32 = {[0] = 1069547520, [1] = 1075838976, [2] = 1080033280, [3] = 1083179008}, 
+  u64 = {[0] = 4620693218751676416, [1] = 4652218416153755648}, 
+  f32 = {[0] = 1.5, [1] = 2.5, [2] = 3.5, [3] = 4.5}, 
+  f64 = {[0] = 8.0000018998980522, [1] = 1024.0002455711365}
+}
+
+ +

and:

+ +
(gdb) p $q0.f32
+$5 = {[0] = 1.5, [1] = 2.5, [2] = 3.5, [3] = 4.5}
+
+ +

Test setup.

+ +

Bug

+ +

The bug I mentioned earlier, leads in ARMv8 to:

+ +
(gdb) i r v0
+v0             {
+  d = {
+    f = {[0x0] = 0x8, [0x1] = 0x400}, 
+    u = {[0x0] = 0x402000003fc00000, [0x1] = 0x4090000040600000}, 
+    s = {[0x0] = 0x402000003fc00000, [0x1] = 0x4090000040600000}
+  }, 
+  s = {
+    f = {[0x0] = 0x1, [0x1] = 0x2, [0x2] = 0x3, [0x3] = 0x4}, 
+    u = {[0x0] = 0x3fc00000, [0x1] = 0x40200000, [0x2] = 0x40600000, [0x3] = 0x40900000}, 
+    s = {[0x0] = 0x3fc00000, [0x1] = 0x40200000, [0x2] = 0x40600000, [0x3] = 0x40900000}
+  }, 
+  h = {
+    u = {[0x0] = 0x0, [0x1] = 0x3fc0, [0x2] = 0x0, [0x3] = 0x4020, [0x4] = 0x0, [0x5] = 0x4060, [0x6] = 0x0, [0x7] = 0x4090}, 
+    s = {[0x0] = 0x0, [0x1] = 0x3fc0, [0x2] = 0x0, [0x3] = 0x4020, [0x4] = 0x0, [0x5] = 0x4060, [0x6] = 0x0, [0x7] = 0x4090}
+  }, 
+  b = {
+    u = {[0x0] = 0x0, [0x1] = 0x0, [0x2] = 0xc0, [0x3] = 0x3f, [0x4] = 0x0, [0x5] = 0x0, [0x6] = 0x20, [0x7] = 0x40, [0x8] = 0x0, [0x9] = 0x0, [0xa] = 0x60, [0xb] = 0x40, [0xc] = 0x0, [0xd] = 0x0, [0xe] = 0x90, [0xf] = 0x40}, 
+    s = {[0x0] = 0x0, [0x1] = 0x0, [0x2] = 0xc0, [0x3] = 0x3f, [0x4] = 0x0, [0x5] = 0x0, [0x6] = 0x20, [0x7] = 0x40, [0x8] = 0x0, [0x9] = 0x0, [0xa] = 0x60, [0xb] = 0x40, [0xc] = 0x0, [0xd] = 0x0, [0xe] = 0x90, [0xf] = 0x40}
+  }, 
+  q = {
+    u = {[0x0] = 0x4090000040600000402000003fc00000}, 
+    s = {[0x0] = 0x4090000040600000402000003fc00000}
+  }
+}
+
+ +

So note how the v0.s.f line has rounded down integers instead of floats:

+ +
  s = {
+    f = {[0x0] = 0x1, [0x1] = 0x2, [0x2] = 0x3, [0x3] = 0x4},
+
+ +

SVE

+ +

Not yet implemented on QEMU, see: https://stackoverflow.com/questions/52888916/how-to-assemble-arm-sve-instructions-with-gnu-gas-or-llvm-and-run-it-on-qemu/52888917#52888917

+",27375,,27375,,2/15/2019 14:18,2/15/2019 14:18,,,,0,,,,CC BY-SA 4.0 +20625,1,,,2/15/2019 22:20,,1,1080,"

First and foremost, this is really just a UI hack, nothing that would give you an unfair advantage over an opponent.

+ +

I play an online game that is predominately played by Spanish speaking players. I've got a really simple lookup type program that swaps out Spanish words for English so I work out what they are saying, so I can communicate with my teammates. I currently do this by typing whatever I understand from the game window into another window I have open (my program), it's cumbersome and messy and I'd like to just have this done automatically, ideally in the UI of the game.

+ +

Is there a solid plan I can use to go about finding out how to do this. I've tried to find memory addresses of the text, but this seems to change every execution and doesn't even maintain messages as more messages are received.

+ +

Any help or advice would be great; also any questions please feel free to ask, I'm not sure what information is appropriate to share.

+",11895,,,,,10/28/2022 21:06,How to 'hack' the chat box in an online game,,2,0,,,,CC BY-SA 4.0 +20626,1,,,2/15/2019 23:31,,1,646,"

I have a program that executes differently depending on what files are present on my computer. I'd like to run a trace in two scenarios (with the default file and with an edited version of the file) and then compare the traces to see where things differ.

+ +

Is there an in built method to do this in ollydbg? I'm by no means an expect with ollydbg, but I'm willing to put in any amount of time and effort to figure this out - I just need a little direction.

+ +

Thanks!

+",27465,,,,,2/16/2019 5:52,Compare two traces from ollydbg,,1,0,,,,CC BY-SA 4.0 +20627,2,,20625,2/15/2019 23:47,,0,,"

Yeah, there are multiple ways that this can be accomplished, depending on the type of game.

+ +

If the network packets of the game aren't encrypted you could probably sniff the traffic for the ""chat message"" network.

+ +

You could do a graphics library injection and replace the chat message routine with yours. I would imagine it would be similar to the process you would follow for developing a wall hack (chams)... First figure out what graphics library the game is using. Then determine which function routine is being used for writing the text. Hooking your own graphics calls is probably the approach that I would take considering graphics library API is pretty well documented.

+ +

Which game is it?

+ +

Another thing you could probably do is just use a text parser to read the chat box with python or whatever language.

+",27466,,,,,2/15/2019 23:47,,,,0,,,,CC BY-SA 4.0 +20628,2,,20626,2/16/2019 5:52,,1,,"

version used: ollydbg v2 but method is similar for v1 too

+ +

ollydbg allows you to log the trace i have done some crude diffs in the past as below +you can try improvise

+ +

here is the source code that's used for demo

+ +

keep in mind i had the source so i compiled it and linked with with /FIXED linker switch to vs 2017 linker so that ASLR doesn't get into play and make life harder +if you have a prebuilt binary and cant force load it in same address each time +text diffing will be tedious

+ +

for example push 402080 will be push f02080 which shouldn't matter +but text diff will show it a a difference and it is pure noise

+ +
#include <stdio.h>
+#include <stdlib.h>
+void main (int argc , char *argv[]) 
+{
+    if (argc !=2 ) 
+    {
+        printf(""usage %s password\n"" , argv[0]);
+        exit(-1);
+    }
+    int password = atoi(argv[1]);
+    if(password == 1337) 
+    {
+        printf(""good\n"");
+        exit(1);
+    }
+    else
+    {
+        printf(""Try again\n"");
+        exit(0);
+    }
+}
+
+ +

open a blank ollydbg and set trace options like this and close it

+ +

+ +

open a command prompt and run the executable wit a wrong pass

+ +
ollydbg.exe diffway.exe 4567  
+
+ +

when ollydbg stops on initial breakpoint open the trace window +1) view run trace or ... icon
+2) right click
+3) log to file -> file name (say wrongpass.txt)-> ok
+4) ctrl+f11 to trace in this will end in a termination
+5) trace window-> right click -> stop Logging -> close ollydbg

+ +

repeat the procedure with right pass and rightpass.txt as file name

+ +

you will now have two text files of two executions

+ +

sed grep awk diff are your friends now

+ +

rip the modified registers column we are not interested in registers

+ +
sed s/""...=.*""//g wrongpass..txt >> ripwrongpass.txt
+sed s/""...=.*""//g rightpass..txt >> riprightpass.txt
+diff -w riprightpass.txt ripwrongpass.txt
+
+ +

we got the first divergence between executions here

+ +
+
+    :\>diff -w riprightpass..txt ripwrongpass..txt
+    170028,170029c170028,170029
+     main  00401050  PUSH    0043E1B4
+     main  00401055  CALL    004010C0
+    ---
+     main  00401066  PUSH    0043E1BC
+     main  0040106B  CALL    004010C0
+    170477a170478,171087
+    > main  00410D40  MOVZX   EAX, BYTE PTR DS:[ECX*8+EAX+43EF78];
+    > main  00410D48  SHR     EAX, 4
+
+
+
+ +

+",3473,,,,,2/16/2019 5:52,,,,0,,,,CC BY-SA 4.0 +20629,2,,20617,2/16/2019 10:28,,0,,"

JADX often provides inaccurate de-compilation output. You'll have to look at the smali in methods that you find inconsistent.
+About the wrong parameter in the aa.a method, you'll have to check the smali to make sure you've got the right class and the right method because I never saw JADX get the types wrong.

+Now, about the request body, it seems like it's the base64 of some encrypted bytes. If I were you I'd look for xrefs for the endpoint retro fit method, and see how the arguments are generated.
+You could also try to hook the methods from the cipher class you found and compare that to what you see in the requests.

+",21707,,,,,2/16/2019 10:28,,,,0,,,,CC BY-SA 4.0 +20630,2,,20614,2/16/2019 10:48,,1,,"

If you know where the data is going to be before it's written, you can set a write hardware breakpoint and it should stop whenever that memory location is populated.
+Otherwise, you'll to reverse engineer where RCX comes by going up the stack frame judging by the decompiled output.

+",21707,,,,,2/16/2019 10:48,,,,2,,,,CC BY-SA 4.0 +20631,2,,20625,2/16/2019 14:53,,0,,"

One approach is to use DLL Injection. You would have to identify the functions that prints chat, then you can install a hook and make it process a different text.

+ +

Here's an example of this: https://github.com/ur0/DotATranslator

+",1635,,,,,2/16/2019 14:53,,,,0,,,,CC BY-SA 4.0 +20632,1,20688,,2/16/2019 17:18,,3,12563,"

I'm trying to unpack (extract) and analyse the firmware of an IP Camera (Xiaomi mjsxj02cm).

+ +

I have this tf_recovery.img that's supposedly a U-Boot image, but I can't unpack it either using dumpimage or other techniques because mkimage -l doesn't provide me with enough information.

+ +

dumpimage does nothing:

+ +
$ dumpimage -o out tf_recovery.img
+$ ls
+tf_recovery.img
+
+ +

mkimage -ldoesn't show any useful information:

+ +
$ mkimage -l tf_recovery.img
+GP Header: Size 27051956 LoadAddr 5799cfc3
+
+ +

file gives some information, nothing I can use:

+ +
$ file tf_recovery.img 
+tf_recovery.img: u-boot legacy uImage, MVX2##I3g60b5603KL_LX318####[BR:\3757zXZ, Linux/ARM, OS Kernel Image (lzma), 1724412 bytes, Wed Jun  6 08:02:07 2018, Load Address: 0x20008000, Entry Point: 0x20008000, Header CRC: 0x5799CFC3, Data CRC: 0x2FF27A1D
+
+ +

What I've already tried without success

+ +
    +
  1. Multiple versions of u-boot, including the latest (v2019.04-rc1) built from source.
  2. +
  3. Tried every image type explicitly, by using -T parameter of dumpimage
  4. +
  5. Simply extracting the image like if it was a compressed archive
  6. +
  7. Searched for, to the best of my abilities, any alternative methods online
  8. +
+ +

I'd really appreciate if anyone can provide additional ideias on how to unpack this. Thank you!

+",27471,,,,,2/22/2019 21:14,Help unpacking U-boot firmware,,3,0,,,,CC BY-SA 4.0 +20633,1,20636,,2/16/2019 20:49,,1,104,"

This is the beginning of one of the functions inside NTDLL of Windows XP:

+ +
MOV EDI,EDI
+PUSH EBP
+MOV EBP,ESP
+...
+
+ +

The book on reverse engineering I am reading(Eldad Eilam - Reversing: Secrets of Reverse Engineering) says this about the first line:

+ +
+

It is essentially dead code that was put in place by the compiler as a + placeholder, in case someone wanted to trap this function. Trapping + means that some external component adds a JMP instruction that is used + as a notification whenever the trapped function is called.

+
+ +

Can you show me how exactly can trapping be used in practice? I assume that trapping is just calling a function with trapping instruction inside the other function, but I don't realize how the outside function can get ""notified"" about the call... Is it possible the author meant by ""some external component"" the debugger? It can make sense because if I set a breakpoint for some strange assembly insruction like MOV EDI, EDI, I'll get to where trapped function is...

+",27474,,27474,,2/19/2019 19:50,2/19/2019 20:16,When can trapping be used?,,1,2,,,,CC BY-SA 4.0 +20634,1,,,2/16/2019 21:50,,1,666,"

So i am trying to ""hack"" a game however not for cheating purposes. I am looking to extend the games scripting functionality through a DLL that can look for processes and return them. The game I am looking to do this for is Train Simulator (i know, don't laugh) and the game uses lua to script all of the engine functionality within the game. All the 3rd party devs get to see is the lua script that they write.

+ +

Inside the games lua there is core functions. The main ones:

+ +
function Initialise()
+
+end
+
+function Update(time) -- time is the interval since the last update
+
+end
+
+ +

There is also C functions that are used as such:

+ +
Call(""SetControlValue"", name, index, value)
+or
+Call(""GetIsPlayer"")
+
+ +

These return different values.

+ +

What i have so far with my DLL is as follows:

+ +
#include <windows.h>
+
+
+BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
+{
+    switch (ul_reason_for_call)
+    {
+    case DLL_PROCESS_ATTACH:
+        /* The DLL is being loaded for the first time by a given process.
+        Perform per-process initialization here.  If the initialization
+        is successful, return TRUE; if unsuccessful, return FALSE. */
+        MessageBoxA(0, ""TSDll has been attached !"", ""Train Sim Dll"", MB_ICONEXCLAMATION | MB_OK);
+        break;
+    }
+    return TRUE;
+}
+
+ +

And this works. In my train sim engine script i am using the loadlib library to load the DLL.

+ +
libinit, err = loadlib(""plugins\\TSDll.dll"", ""libinit"")
+if _G[""libinit""] then 
+    Print(""TSDll Library Loaded!"")
+    libinit()
+else
+    Print(""loadlib on TSDll failed: "")
+    Print(err)
+end
+
+ +

And i get this result: +

+ +

So the dll initialises properly.

+ +

The problem i face is that the Lua library is directly built in to the game binary (as far as i know) which means i am unable to reference lua.dll for fundamental functions such as lua_pushstring. Does anyone here know how i can find the address of these functions. I know a dll like this has been made before but the person who did it has been very secretive about how it has been done.

+ +

Thanks, +Dan

+",27475,,,,,4/19/2022 19:11,Finding lua C functions compiled binary,,2,2,,,,CC BY-SA 4.0 +20636,2,,20633,2/17/2019 5:01,,1,,"

mov edi, edi is an instruction that is called hotpatch point

+ +

there are several articles about it on the internet, notable among them are:

+ +
    +
  1. Raymond Chens old new thing 1
  2. +
  3. Raymond Chens old new thing 2
  4. +
  5. Johannas passing's Hot patch walkthrough
  6. +
+ +

The main utility for this instruction is to enable a third party app or Windows update to patch an existing function to a newer function with minimal side effects when obscure race conditions become a reality (hard patching any function with a detour will work most of the time or as raymond puts will work 99% of the time

+ +

quoting from the article linked

+ +
+

The MOV EDI, EDI instruction is a two-byte NOP, which is just enough + space to patch in a jump instruction so that the function can be + updated on the fly. The intention is that the MOV EDI, EDI instruction + will be replaced with a two-byte JMP $-5 instruction to redirect + control to five bytes of patch space that comes immediately before the + start of the function. Five bytes is enough for a full jump + instruction, which can send control to the replacement function + installed somewhere else in the address space.

+
+ +

the mov edi, edi is used in conjunction with five space holders emitted by the compiler before the mov edi, edi like 0xcc or 0x90

+ +

so the patching software can patch in an atomically replaceable short jump and a long jump to a control area

+",3473,,2147,,2/19/2019 20:16,2/19/2019 20:16,,,,0,,,,CC BY-SA 4.0 +20640,2,,20632,2/17/2019 14:46,,3,,"

Try dumping the byte stream starting at the signature FD 37 7A 58 5A 00, then extract it using 7z or xz.

+ +

Note that it is only a Linux kernel image, it probably does not contain the full filesystem image (at most a minimal ramdisk).

+",60,,,,,2/17/2019 14:46,,,,1,,,,CC BY-SA 4.0 +20641,1,20668,,2/17/2019 19:17,,-1,1067,"

I have a PE executable which uses threads to handle most of its functionality. It uses CreateThread API to spawn local threads to handle functions.

+ +

+ +

The call to the CreateThread returns a valid handle value.

+ +

+ +

The problem is sometimes I don't see the thread getting created.

+ +

Or other times the thread gets created but none of the code that's specified at that thread's start address gets executed.(even though the thread is created with the dwCreationFlags parameter being set to 0)

+ +

What would the problem be?

+ +

P.S. I can't share the executable but I can provide more screenshots.

+",20848,,20848,,2/19/2019 16:15,2/20/2019 7:24,CreateThread returns true but thread doesn't run,,2,2,,3/28/2019 20:16,,CC BY-SA 4.0 +20642,1,,,2/17/2019 21:35,,1,4713,"

I work late nights and a dark theme like this would be nice with IDAPro.

+ +

I followed the installation steps and copied the contents of 'plugins' from the github page to the 'plugins' directory in my IDAPro folder in C:/

+ +

Then, I went to options > colors > import and imported the .clr file. But it only changes the color scheme for the disassembly window. Everything else is still the default theme (see image attached). I searched the web looking for if there's something I'm missing but no luck. Seems like I'm doing everything correctly.

+ +

Is there anything I'm missing? How can I get the theme to propagate all over IDAPro 7.0?

+ +

+",17040,,,,,4/4/2021 19:38,How to load a color theme correctly in IDAPro?,,3,0,,,,CC BY-SA 4.0 +20643,1,20645,,2/17/2019 23:44,,0,306,"

+ +

the c code:

+ +
void overflow (char* inbuf)
+{
+  char buf[64];
+
+  strcpy(buf, inbuf);
+}
+
+int main (int argc, char** argv)
+{
+    overflow(argv[1]);
+    return 0;
+}
+
+",27482,,18014,,2/18/2019 7:07,2/18/2019 7:07,why does the following non stack shellcode load /bin/sh string without pushing it onto the Stack?,,1,1,,,,CC BY-SA 4.0 +20644,2,,20642,2/18/2019 0:13,,3,,"

I think you're talking about changing the appearance of Qt widgets and not only IDA widgets. If so, take a look at zyantific/IDASkins python plugin. +There're also plugins in C++ if you prefer it.

+",26176,,,,,2/18/2019 0:13,,,,6,,,,CC BY-SA 4.0 +20645,2,,20643,2/18/2019 1:44,,0,,"

It actually does. The push operation is performed by the call instruction. +This instruction will push the address of the next instruction, here the address is 0x21. +From 0x21 to 0x28 you have your /bin/sh string which is, on your case, wrongly disassembled as x86 code. +Last but not least, the linux x86 32-bit syscall calling convention doesn't use the stack at all. The parameters are passed through ebx, ecx, edx, esi, edi, ebp and the syscall number is stored in eax.

+",26176,,,,,2/18/2019 1:44,,,,1,,,,CC BY-SA 4.0 +20646,1,20647,,2/18/2019 3:17,,-2,320,"

Disassembly:

+ +
0:  31 c9                    xor    ecx,ecx
+2:  f7 e1                    mul    ecx
+4:  51                       push   ecx
+5:  68 2f 2f 73 68           push   0x68732f2f
+a:  68 2f 62 69 6e           push   0x6e69622f
+f:  89 e3                    mov    ebx,esp
+11: b0 0b                    mov    al,0xb
+13: cd 80                   int    0x80
+15: 51                      push   ecx
+16: b0 01                   mov    al,0x1
+18: cd 80                   int    0x80
+
+",27482,,2318,,2/18/2019 6:33,2/18/2019 12:35,Can anyone please explain the following dissasembly codes?,,1,1,,,,CC BY-SA 4.0 +20647,2,,20646,2/18/2019 10:13,,1,,"
0:  31 c9                 xor    ecx,ecx     ;; ecx = 0
+2:  f7 e1                 mul    ecx         ;; eax = eax * ecx (set eax to 0)
+4:  51                    push   ecx         ;; push 0 on stack (string end)
+5:  68 2f 2f 73 68        push   0x68732f2f  ;; push ""//sh"" on stack
+a:  68 2f 62 69 6e        push   0x6e69622f  ;; push ""/bin"" on stack
+f:  89 e3                 mov    ebx,esp     ;; ebx = esp (esp = @""/bin//sh\0"")
+11: b0 0b                 mov    al,0xb      ;; eax = 0xb (sys_call_execve)
+13: cd 80                 int    0x80        ;; call execve(""/bin//sh"")
+15: 51                    push   ecx         ;; push 0 on stack
+16: b0 01                 mov    al,0x1      ;; eax = 1 (sys_call_exit)
+18: cd 80                 int    0x80        ;; call exit(ebx)
+
+ +

Basically, this is a shellcode that run /bin/sh and, then, exit().

+",53,,53,,2/18/2019 12:35,2/18/2019 12:35,,,,0,,,,CC BY-SA 4.0 +20648,1,,,2/18/2019 18:04,,4,444,"

I'm new with reversing and I did the following experiment just intent to help my understanding. I created a very simple 64-bit c++ program.

+ +
#include <iostream>
+#include <string>
+
+using namespace std;
+
+int main(int argc, char* argv[])
+{
+    string s1{ ""test"" };
+    cout << s1 << endl;
+    cout << &s1 << endl;
+
+    cout << ""============"" << endl;
+
+    int i{ 10 };
+    cout << i << endl;
+    cout << &i << endl;
+
+    getchar();
+}
+
+ +

I then compiled it and started it. The output is:

+ +

+ +

Now I know the addresses of these two variables and I want to check it in x64dbg. In x64dbg, I attached to the running process and it seems it's not the variables at the aforementioned addresses:

+ +

+",12047,,,,,7/4/2022 19:16,How can I find my variables in the running process?,,2,0,,,,CC BY-SA 4.0 +20650,1,,,2/18/2019 18:42,,1,438,"

I have a program linked against libcrypto.so. If i run the program in gdb i'll get the following error: +""Program received signal SIGILL, Illegal instruction."" +I researched a bit and found out that it is a problem of libcrypto and that i can ignore that signals using ""handle SIGILL nostop noprint"" before running. Works in gdb, but does not with a gdbserver.

+ +

Question: +How can i use ""handle SIGILL nostop noprint"" with a gdbserver? If i connect IDA to my gdbserver it always crash with the SIGILL, Illegal instruction error message.

+",27496,,27496,,2/18/2019 18:55,2/18/2019 18:55,"How to use ""handle SIGILL nostop noprint"" with a gdbserver?",,0,1,,,,CC BY-SA 4.0 +20652,1,,,2/18/2019 21:48,,2,53,"

I have an old piece of HP test gear from the 80's that HP no longer supports. I want to add in a feature and need to dump roms and figure things out to do that.

+ +

How can I share my process and findings on a personal blog without legal issues?

+ +

If a company no longer supports a product can I dump a rom and share it with the community? I physically own the hardware so I can be in possession of the rom I would imagine. If I don't share the entire rom can I copy sections of it to post to help clarify a post?

+ +

This also applies to the old schematics in the manuals. Can I post screenshots or not??

+",27498,,27498,,2/18/2019 22:53,2/18/2019 22:53,Legality on sharing rom dumps on abandoned hardware,,0,0,,,,CC BY-SA 4.0 +20653,1,,,2/19/2019 1:34,,1,181,"

I'm writing an Idapython loader script to help reverse-engineer the firmware on an embedded system with a 68000 processor.

+ +

Unfortunately I can't get a copy of the original C compiler used in order to build FLIRT signatures, but I would like to use Idapython to give IDA hints about some of the optimisations it's done.

+ +

As an example - the compiler often does things like this:

+ +
MOVEA.L   #sub_1234, a4
+...
+JSR       (a4)
+
+ +

The optimisation is, it's using an address register to hold the address of the function, which saves code space when one function is called several times.

+ +

I think I can figure out how to search for these patterns in the code -- but how can I tell IDA that ""(a4)"" is really a reference to sub_1234?

+",211,,,,,2/21/2019 17:29,Idapython: adding links where a function address is loaded into a register,,2,0,,,,CC BY-SA 4.0 +20654,2,,3689,2/19/2019 3:21,,1,,"

For me, just clicking

+ +
Options - General - Analysis - Reanalyze program
+
+ +

button solved problem.

+",27500,,,,,2/19/2019 3:21,,,,0,,,,CC BY-SA 4.0 +20655,2,,20648,2/19/2019 8:40,,4,,"
    +
  1. Your std::string is not a plain ascii string it is a structure (actually a class) so you cannot take the address and find the string.
  2. +
+

In your specific case since your string test's length is less than the threshold you are lucky you can see it in your screenshot look for 74 65 73 74 as ascii you will notice it is "test"

+
    +
  1. It appears your int i is visible +try looking at 0xa == 0n10
  2. +
+

Edit

+

Your source slightly modified to show the results of above statements

+
#include <iostream>
+#include <string>
+using namespace std;
+int main(void)
+{
+    //small string will be embedded inside std::string class 
+    // you can see 74657374 (hex for "test")
+    string s1{ "test" };
+    cout << s1 << endl;
+    cout << &s1 << endl;
+    printf("%llx\n", *(__int64 *)(&s1) );
+    printf("%p\n" , s1.c_str());
+    printf("%s\n" , s1.c_str());
+    
+    cout << "\n=========================================================================\n" ;
+    
+    // big string a pointer will be present to the c_str member
+    // you cannot see the string unless you dereference the pointer for c_str() member
+    
+    string s2 { "this is a very very very very very very biggy biggy biggy stringyyyyyy" };
+    cout << s2 << endl;
+    cout << &s2 << endl;
+    printf("%llx\n", *(__int64 *)&s2 );
+    printf("%p\n" , s2.c_str());
+    printf("%s\n" , s2.c_str());
+    
+    
+    return getchar();
+}
+
+

Results

+
>ogrish.exe
+test
+001AF7C8
+eafc0074736574  <<<< see the hex embedded
+001AF7C8   << both &std::string and std::strin.c_str() are same
+test  << c_str()  
+
+=========================================================================
+this is a very very very very very very biggy biggy biggy stringyyyyyy
+001AF7E0   &std::string 
+1af7f000265cf0   << address of std::string and c_str() are different
+00265CF0   & string->c_str()
+this is a very very very very very very biggy biggy biggy stringyyyyyy  << c_str()
+
+

and btw keep in mind if you attach to this console process all the code has already run and everything that is on stack can be out of scope and contain bogus values you need to step through for checking things on debugger +not execute and attach.

+",3473,,15246,,7/4/2022 19:16,7/4/2022 19:16,,,,3,,,,CC BY-SA 4.0 +20656,1,20658,,2/19/2019 8:48,,1,1175,"

I have generated an alphanumeric shellcode with this command:

+ +
msfvenom -a x86 --platform linux -p linux/x86/exec CMD=/bin/sh -e x86/alpha_mixed BufferRegister=ECX -f python
+
+ +

I am targeting a 32 bits x86 architecture on Linux.

+ +

Here is the shell code (i've converted it into a string):

+ +
IIIIIIIIIIIIIIIII7QZjAXP0A0AkAAQ2AB2BB0BBABXP8ABuJI0jTK68mIcbCVrHDmsSOyywSXfO2SsXgpe86OSRSY2NOyYs1Byxc8s0WpUPDo0b2I2NVOCCSXs0V7RsK9yq8Mk0AA
+
+ +

Here is a very basic c program which runs the shellcode:

+ +
#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+typedef void (*shellcode_t)();
+// unsigned char code[] = ""\x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80"";
+unsigned char code[] = ""IIIIIIIIIIIIIIIII7QZjAXP0A0AkAAQ2AB2BB0BBABXP8ABuJI0jTK68mIcbCVrHDmsSOyywSXfO2SsXgpe86OSRSY2NOyYs1Byxc8s0WpUPDo0b2I2NVOCCSXs0V7RsK9yq8Mk0AA"";
+
+
+int main (int argc, char * argv[])
+{
+  shellcode_t appel = (shellcode_t)code;
+  appel();
+
+  return 0;
+}
+
+ +

Here is how i compile it:

+ +
$ cc -Wall -m32 -z execstack -fno-stack-protector -O0 test.c -o test
+
+ +

When i run the program i get a segfault.

+ +

Please note the classical shellcode i've commented in the c program works perfectly. So it is not a c program compilation issue.

+ +

Thanks

+",18590,,,,,2/19/2019 13:55,alphanumeric shellcode,,1,5,,,,CC BY-SA 4.0 +20657,1,20682,,2/19/2019 12:38,,2,802,"

Over the IDA Gui it is possible to export a structure with dependencies to a header file. For example if I export a struct that has one member from type DWORD than the header file also contains "typedef unsigned int DWORD".

+

I want to do a similar task with the python api.

+
def get_member_type(struct, idx):
+   member = ida_struct.get_member(struct, idx)
+   tif = tinfo_t()
+   ida_struct.get_member_tinfo(member, tif)
+   return tif
+
+

This function return the type of the struct members for example "DWORD" but how can I get the information that this is a unsigned int?

+",27505,,33592,,2/7/2022 17:46,2/7/2022 17:46,IDA Python get struct type with dependencies,,2,2,0,,,CC BY-SA 4.0 +20658,2,,20656,2/19/2019 13:55,,5,,"

Alphanumeric shellcode expects the location of the shellcode to be stored in a register, since the usual technique of call/pop can't be performed with the limited character set.

+ +

In your example above this is set using BufferRegister=ECX, your C program doesn't take this into account though, which is why it crashes. Taking out the BufferRegister directive will give you a shellcode blob that determines the location manually, but isn't pure alphanumeric. This should run in your program though.

+ +

An alternative would be to use something that runs shellcode from a file, since these often have a jmp/call reg32, which you can then use with BufferRegister.

+",12794,,,,,2/19/2019 13:55,,,,2,,,,CC BY-SA 4.0 +20661,2,,20641,2/19/2019 17:10,,0,,"

I cannot tell specifically what your problem is (as is often the case with RE). Something I would recommend though is trying kernel debugging with Windbg. It's excellent because it has far more capability than ollydbg, albeit with a steeper learning curve.

+ +

Specifically you can have Windbg break on thread creation. No thread can begin without going through the operating system, and windbg catches that.

+ +

Note: you are going to need to set up kernel debugging with Windbg which means you will need a VM. You should probably be doing your dynamic analysis in a VM anyways...

+ +
SXE ct
+
+ +

https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/controlling-exceptions-and-events

+",14227,,,,,2/19/2019 17:10,,,,0,,,,CC BY-SA 4.0 +20665,1,,,2/19/2019 22:03,,1,46,"

CONTEXT: My first post in this stack. Absolute beginner at RE. Also generally a beginner at anything electronics. Please be kind and correct me instead of ridiculing me.

+ +

GOAL: Replace a damaged controller board within a light fixture with a DIY controller board that provides most of the functionality of the original controller. (ALL original functionality is not needed.)

+ +

NOTES ABOUT GROUNDING: This light fixture is positive-grounded, all grounds are tied to actual earth as well as to the positive output of the PSU. The small board on the right in the picture is an infrared board, and it's LT1791LTS has RE connected to ground (chip pin 3 on datasheet). The LT1791LTS on the LED Driver board does NOT have RE grounded.

+ +

WORK ALREADY DONE: I have searched extensively trying to gain more information about the device and it's component boards, but have not found any technical info on them. The manufacturer does not disclose this info (duh), and they don't repair any of it they just replace boards - which are not sold cheap. So I have bashed my noob head against google for a long time, found datasheets for the chips, tried to ID the eensy weensy components on the boards despite the inane lack of utility of their markings... (can tell things are resistors/capcitors/etc but cant figure out values from markings) I have used my Extech brand multimeter (model 22-816) to identify voltages on the wires, and to identify voltages where they go through the regulators - and to trace out the relevant bits' connections.(the only test equipment I own).

+ +

THOUGHTS: In looking at the datasheets for the chips, it SEEMS to this absolute noob that i'm looking at a RS485 setup wired in full duplex with the controller acting as a master and the LED driver and the IR board actng as slaves. BUT - I don't know anywhere near enough about this to make any claims that it is so, or even that I actually understand well what I just wrote. Also, I'm now aware that I'll need to ""sniff"" the communications, but do not yet know enough to proceed to a purchase of this kit. Will do so once I know enough to use it without screwing up the mismatch of positive ground vs negative ground (desktop vs. fixture grounding being opposite).

+ +

QUESTION: From the information in the posted picture, can anyone here narrow down the 'possibility list' for which means and methods are being used to communicate between the controller board (top left item) and the LED Driver board (lower left item)? Not just ""it is RS485"", but ""It's RS485 and it looks like it will probably use XXXXXX over that.""

+ +

Ideally, an explanation of what's happening here would be awesome but it is more important for me to just figure out how to talk to that LED Driver so ignore 'ideal' if need be. (Eg: why one chip on controller but a different chip on the two connected boards? Why would one connected board have RE grounded but the other doesn't? Etc)

+ +

More than happy to add images or info to this question as we go along - just tell me what's needed!

+ +

DATASHEETS IN SAME ORDER AS THEY APPEAR TOP TO BOTTOM ON PICTURE:

+ +

https://www.analog.com/media/en/technical-documentation/data-sheets/adm2582e_2587e.pdf

+ +

http://www.farnell.com/datasheets/681099.pdf?_ga=2.26682873.518865155.1550566744-570871691.1522878168

+ +

http://www.ti.com/lit/ds/symlink/sn65als180.pdf

+ +

https://www.analog.com/media/en/technical-documentation/data-sheets/178591fd.pdf

+ +

http://www.ti.com/lit/ds/symlink/iso7220a.pdf

+ +

http://www.ti.com/lit/ds/symlink/tms320f2808.pdf

+ +

+",27513,,27513,,2/24/2019 20:48,2/24/2019 20:48,Likely protocol determination by chip IDs and connections?,,0,2,,,,CC BY-SA 4.0 +20666,2,,20418,2/20/2019 0:15,,1,,"

If you want to find out statically, you have to inspect the call site to your function and see where the buffer argument comes from.

+ +

You may have to go back multiple layers until you either clearly see it's on the stack (if the address of a local memory area is passed in), or it comes from a call like VirtualAlloc, malloc, new, HeapAlloc (VirtualAlloc and HeapAlloc being Windows-specific APIs), in which case the memory is located on the heap.

+",23277,,,,,2/20/2019 0:15,,,,1,,,,CC BY-SA 4.0 +20667,2,,20653,2/20/2019 5:10,,0,,"

IDA doesn't accept ""hints"" along those lines, but you can create the cross-references manually via script. If you know the address of the destination, you can add an out-going cross-reference from the source address to the destination using add_cref. These will show up if you press ctrl-X at the destination, or X at the source. You can also add a comment at the call site with the target address, which will result in basically a ""hyperlink"" that you can double-click or press 'enter' with your cursor over.

+",182,,,,,2/20/2019 5:10,,,,0,,,,CC BY-SA 4.0 +20668,2,,20641,2/20/2019 7:24,,3,,"

you mean the thread doesn't run when you have single stepped out of the CreateThread() call ??

+ +

if yes then the Windows Scheduler hasn't yet found time to Schedule your Threads Code

+ +

you can confirm when the code is run by Setting breakpoint on the LP_THREAD_ROUTINE

+ +

Argument passed to CreateThread() probably be in R8D in your screenshot i think

+ +

the Threads Code Will run only when your existing thread (main ) has ceded control by Calling Any Of the Wait Functions

+ +

you can verify that with some code like this

+ +

here you create 5 threads but since you waste time in the loop and do not cede control to Windows Scheduler none of your Thread Routine is Executed until the WaitForMsg Function is called and your main thread goes idle waiting

+ +
#include <windows.h>
+#include <stdio.h>
+#define MAXT 5
+DWORD WINAPI ThFunc( LPVOID parm ) {
+    printf(""Thread No %p\n"" , parm);
+    return 0;
+}
+
+int main (void) {
+    DWORD   Tid[MAXT]   = {0};
+    HANDLE  Thand[MAXT] = {0};
+    int     Data[MAXT+1]  = {0};
+    for(int i =0; i < MAXT; i++) {
+        Data[i] = i;
+    }
+    for(int i=0;i<MAXT;i++) {
+        Thand[i] = CreateThread(NULL,0,ThFunc,(LPVOID)Data[i],0,&Tid[i]);        
+        if(Thand[i] == NULL) { ExitProcess(0); } else {
+            printf (""wasting time not ceding control to ThreadRoutine\n"");
+            for(int j =0; j < 10; j++) {
+                printf(""%p\n"" , Thand[i]);
+            }        
+        }
+    }
+    WaitForMultipleObjects(MAXT, Thand, TRUE, INFINITE);
+    for (int i = 0; i< MAXT;i++) {
+        CloseHandle(Thand[i]);
+    }   
+}
+
+ +

and the results are below +you can see the Thread Routines are executed only after coming out of loop and waiting by the main thread

+ +
cthread.exe
+wasting time not ceding control to ThreadRoutine
+0000001C,0000001C,0000001C,0000001C,0000001C,0000001C
+0000001C,0000001C,0000001C,0000001C
+wasting time not ceding control to ThreadRoutine
+00000020,00000020,00000020,00000020,00000020,00000020
+00000020,00000020.00000020,00000020
+wasting time not ceding control to ThreadRoutine
+00000024,00000024,00000024,00000024,00000024,00000024
+00000024,00000024,00000024,00000024
+wasting time not ceding control to ThreadRoutine
+00000028,00000028,00000028,00000028,00000028,00000028
+00000028,00000028,,00000028,00000028
+wasting time not ceding control to ThreadRoutine
+0000002C,0000002C,0000002C,0000002C,0000002C,0000002C
+0000002C,0000002C,0000002C,0000002C,Thread No 00000000
+Thread No 00000001
+Thread No 00000002
+Thread No 00000003
+Thread No 00000004
+
+",3473,,,,,2/20/2019 7:24,,,,1,,,,CC BY-SA 4.0 +20669,2,,20648,2/20/2019 8:09,,1,,"

Answer of blabb is correct, I will just add some more information.

+ +

You are looking at wrong window of x64 for searching values. As you can see in your picture content of this window (CPU) is automaticly trying to disassemble data in memory as code. If you want to see values it is better to look up adresses in dump window (bottom left) or in stack window (bottom right).

+",25138,,,,,2/20/2019 8:09,,,,0,,,,CC BY-SA 4.0 +20670,1,20690,,2/20/2019 12:39,,0,602,"

I am trying to add another button into windows form using dnSpy. Is it possible to add another?

+ +

I want the end result be like this one. +

+ +

Any help will be highly appreciated.Thanks

+",27517,,27517,,3/10/2019 16:30,3/10/2019 16:30,What methods exist for adding new windows form controls into compiled assembly using dnSpy?,,1,2,,,,CC BY-SA 4.0 +20671,1,20678,,2/20/2019 20:29,,0,451,"

I'm investigating the glitch attacks scenario and in particular, I read about the Nand Glitching with an example here. During my steps into reverse engineering a home router - you can read my steps here - I was wondering if this attack is applicable not only to NAND memory but also to the classic SPI Flash memory, like the one you can read in the aforementioned post.

+ +

In case it's possible, do you have any resource where I can study from? Also, what PINs need to be shortcircuited to try the attack?

+ +

Thanks!

+",22655,,22655,,2/21/2019 10:59,2/25/2019 8:31,Glitch attack on a SPI flash eeprom,,1,0,,,,CC BY-SA 4.0 +20672,1,,,2/20/2019 21:14,,1,93,"

I was experimenting with idea of decompiling a PowerShell cmdlet using reflection.

+ +

While I got some basics seem to work, how do I resolve the value in OperandField, for example ldfld cmd in this case if decompiled correctly may look like this:

+ +
ldfld      string[] Microsoft.PowerShell.Commands.GetAclCommand::path
+
+ +

Where as currently I am just displaying as ""ldfld""

+ +

This is parsed in this section of code:

+ +
{ $_ -eq ""InlineBrTarget"" -or
+                  $_ -eq ""InlineField"" -or
+                  $_ -eq ""InlineI"" -or
+                  $_ -eq ""InlineSig"" -or
+                  $_ -eq ""InlineString"" -or
+                  $_ -eq ""InlineTok"" -or
+                  $_ -eq ""InlineType"" -or 
+                  $_ -eq ""ShortInlineR"" }
+                {
+                    $count = [BitConverter]::ToInt32($Ilbytes,$offset+1)
+                    $offset += 4
+                }
+
+ +

The full script here:

+ +
# command to decompile
+$cmd = ""Get-Acl""
+
+$cmdInfo = Get-Command -CommandType Cmdlet -Name $cmd
+
+$methods = $cmdInfo.ImplementingType.UnderlyingSystemType.GetMethods()
+
+$opCodeDictionary = @{}
+ForEach ($field in [System.Reflection.Emit.OpCodes].GetFields())
+{
+    $fieldValue = $field.GetValue($null)
+    $opCodeDictionary.Add($fieldValue.Value,$fieldValue)
+}
+ForEach ($method in $Methods)
+{
+    Write-Host "".method "" -NoNewline
+    if ($method.IsPublic) 
+    { 
+        Write-Host ""public "" -NoNewline 
+    }
+
+    if ($method.IsPrivate) 
+    {
+        Write-Host ""private "" -NoNewline
+    }
+
+    if ($method.IsHideBySig) 
+    {
+        Write-Host ""hidebysig "" -NoNewline
+    }
+
+    if ($method.IsSpecialName) 
+    {
+        Write-Host ""specialname "" -NoNewline
+    }
+
+
+    if ($method.GetParameters() -ne $null)
+    {
+        Write-Host $method.GetParameters()[0]
+    }
+    else
+    {
+         ""$($method.ReturnType.Name) $($method.Name)""
+    }
+    Write-Host ""{""
+    $methodBody = $method.GetMethodBody()
+    if ($methodBody -ne $null)
+    {
+        $ilBytes = $methodBody.GetILAsByteArray()
+        $offset = 0
+
+        while ($offset -lt $ilBytes.Length)
+        {
+          Write-Host (""IL_{0:x4}: "" -f $offset) -NoNewline
+          [System.Int16]$code = $ilBytes[$offset++];
+          if ($code -eq 0xfe)
+          {
+             [System.Int16]$code = $ilBytes[$offset++] -bor 0xfe00
+          }
+
+          $opCode = $opCodeDictionary[[System.Int16]$code]
+
+          Write-Host $opCode.Name -NoNewline
+          switch ($opCode.Name)
+          {
+            { $_ -eq ""call"" -or
+              $_ -eq ""callvirt"" }
+              {
+                Write-Host "" "" -NoNewline
+              }
+            default { 
+                Write-Host 
+                }
+          } 
+          switch ($opCode.OperandType)
+          {
+                ""InlineMethod""
+                {
+                     $metaDataToken = [BitConverter]::ToInt32($ilBytes,$offset)
+                     $genericMethodArguments = $null
+                     if ($method.IsGenericMethod -eq $true)
+                     {
+                         $genericMethodArguments = $method.GetGenericArguments()
+                     }
+
+                    ($method.Module.ResolveMethod(
+                       $metaDataToken,
+                       $method.DeclaringType.GetGenericArguments(),
+                       $genericMethodArguments)).Name 
+
+                    $offset += 4
+                 }
+
+                ""InlineNone""
+                {
+                }
+
+                { $_ -eq ""ShortInlineBrTarget"" -or
+                  $_ -eq ""ShortInlineI"" -or
+                  $_ -eq ""ShortInlineVar"" }
+                {
+                    $offset++
+                }      
+
+                ""InlineVar""
+                {
+                    $offset += 2
+                }
+
+                { $_ -eq ""InlineBrTarget"" -or
+                  $_ -eq ""InlineField"" -or
+                  $_ -eq ""InlineI"" -or
+                  $_ -eq ""InlineSig"" -or
+                  $_ -eq ""InlineString"" -or
+                  $_ -eq ""InlineTok"" -or
+                  $_ -eq ""InlineType"" -or 
+                  $_ -eq ""ShortInlineR"" }
+                {
+                    $count = [BitConverter]::ToInt32($Ilbytes,$offset+1)
+                    $offset += 4
+                }
+
+                { $_ -eq ""InlineI8"" -or
+                  $_ -eq ""InlineR""
+                }
+                {
+                    $offset += 8
+                }
+
+                ""InlineSwitch""
+                {
+                    $count = [BitConverter]::ToInt32($Ilbytes,$offset+1)
+                    $offset += 4 * $count
+                }
+
+            default 
+               { throw ""$($opCode.OperandType) not implemented"" }
+
+            }
+        }
+    }
+
+    Write-Host ""} // end of method $($method.DeclaringType.ToString())::$($method.Name)""
+    Write-Host 
+}
+
+",2229,,,,,2/21/2019 1:11,Identify ldfld reference in .NET when parsing GetILAsByteArray,<.net>,1,0,,,,CC BY-SA 4.0 +20674,2,,20672,2/21/2019 0:38,,1,,"

This can be resolved using ResolveField method, fixed example. Note this example still has limitation in that it is failing to resolve fields where I need to specify genericTypeArguments and genericMethodArguments to resolvefield.

+ +
$fieldReference = [BitConverter]::ToInt32($Ilbytes,$offset)
+                    try
+                    {
+                        $field = $method.Module.ResolveField($fieldReference)
+                        Write-Host ""$($field.FieldType) $($field.ReflectedType.ToString())::$($field.Name)""
+                    }
+                    catch
+                    {
+                        Write-Host (""<Unresolved reference 0x{0:x}>"" -f $fieldReference)
+                    }
+                    $offset += 4
+
+ +

Updated within script:

+ +
# command to decompile
+$cmd = ""Get-Acl""
+
+$cmdInfo = Get-Command -CommandType Cmdlet -Name $cmd
+
+$methods = $cmdInfo.ImplementingType.UnderlyingSystemType.GetMethods()
+
+$opCodeDictionary = @{}
+ForEach ($field in [System.Reflection.Emit.OpCodes].GetFields())
+{
+    $fieldValue = $field.GetValue($null)
+    $opCodeDictionary.Add($fieldValue.Value,$fieldValue)
+}
+ForEach ($method in $Methods)
+{
+    Write-Host "".method "" -NoNewline
+    if ($method.IsPublic) 
+    { 
+        Write-Host ""public "" -NoNewline 
+    }
+
+    if ($method.IsPrivate) 
+    {
+        Write-Host ""private "" -NoNewline
+    }
+
+    if ($method.IsHideBySig) 
+    {
+        Write-Host ""hidebysig "" -NoNewline
+    }
+
+    if ($method.IsSpecialName) 
+    {
+        Write-Host ""specialname "" -NoNewline
+    }
+
+
+    if ($method.GetParameters() -ne $null)
+    {
+        Write-Host $method.GetParameters()[0]
+    }
+    else
+    {
+         ""$($method.ReturnType.Name) $($method.Name)""
+    }
+    Write-Host ""{""
+    $methodBody = $method.GetMethodBody()
+
+    if ($methodBody -ne $null)
+    {
+        Write-Host "".maxstack $($methodBody.MaxStackSize)""
+        if ($methodBody.LocalVariables -ne $null)
+        {
+            Write-Host "".locals "" -NoNewline
+            if ($methodBody.InitLocals -eq $True)
+            {
+                Write-Host ""init "" -NoNewline
+            }
+
+            Write-Host ""("" -NoNewLine
+            ForEach ($local in $methodBody.LocalVariables)
+            {
+                if ($local.LocalIndex -eq 0)
+                {
+                    Write-Host ""$($local.LocalType) V_$($local.LocalIndex)"" -NoNewline
+                }
+                else
+                {
+                    Write-Host "",`n`t$($local.LocalType) V_$($local.LocalIndex)""
+                }
+            }
+
+            Write-Host "")""
+        }
+        $ilBytes = $methodBody.GetILAsByteArray()
+        $offset = 0
+
+        while ($offset -lt $ilBytes.Length)
+        {
+          Write-Host (""IL_{0:x4}: "" -f $offset) -NoNewline
+          [System.Int16]$code = $ilBytes[$offset++];
+          if ($code -eq 0xfe)
+          {
+             [System.Int16]$code = $ilBytes[$offset++] -bor 0xfe00
+          }
+
+          $opCode = $opCodeDictionary[[System.Int16]$code]
+
+          Write-Host ""$($opCode.Name) "" -NoNewline
+
+          switch ($opCode.OperandType)
+          {
+                ""InlineMethod""
+                {
+                     $metaDataToken = [BitConverter]::ToInt32($ilBytes,$offset)
+                     $genericMethodArguments = $null
+                     if ($method.IsGenericMethod -eq $true)
+                     {
+                         $genericMethodArguments = $method.GetGenericArguments()
+                     }
+
+                    ($method.Module.ResolveMethod(
+                       $metaDataToken,
+                       $method.DeclaringType.GetGenericArguments(),
+                       $genericMethodArguments)).Name 
+
+                    $offset += 4
+                 }
+
+                ""InlineNone""
+                {
+                }
+
+                { $_ -eq ""ShortInlineBrTarget"" -or
+                  $_ -eq ""ShortInlineI"" -or
+                  $_ -eq ""ShortInlineVar"" }
+                {
+                    $offset++
+                }      
+
+                ""InlineVar""
+                {
+                    $offset += 2
+                }
+
+                ""InlineString""
+                {
+                    $stringReference = [BitConverter]::ToInt32($Ilbytes,$offset)
+                    try
+                    {
+                        $stringInfo = $method.Module.ResolveString($stringReference)
+                        Write-Host ""`""$stringInfo`""""
+                    }
+                    catch
+                    {
+                        Write-Host (""<Unresolved reference 0x{0:x}>"" -f $fieldReference)
+                    }
+                    $offset += 4
+                }
+
+                ""InlineType""
+                {
+                    $typeReference = [BitConverter]::ToInt32($Ilbytes,$offset)
+                    try
+                    {
+                        $typeInfo = $method.Module.ResolveType($typeReference)
+                        Write-Host ""$($typeInfo.BaseType.ToString())::$($typeInfo.Name)""
+                    }
+                    catch
+                    {
+                        Write-Host (""<Unresolved reference 0x{0:x}>"" -f $fieldReference)
+                    }
+                    $offset += 4
+                }
+
+                { $_ -eq ""InlineBrTarget"" -or
+                  $_ -eq ""InlineField"" -or
+                  $_ -eq ""InlineI"" -or
+                  $_ -eq ""InlineSig"" -or
+                  $_ -eq ""InlineTok"" -or
+                  $_ -eq ""ShortInlineR"" }
+                {
+                    $fieldReference = [BitConverter]::ToInt32($Ilbytes,$offset)
+                    try
+                    {
+                        $field = $method.Module.ResolveField($fieldReference)
+                        Write-Host ""$($field.FieldType) $($field.ReflectedType.ToString())::$($field.Name)""
+                    }
+                    catch
+                    {
+                        Write-Host (""<Unresolved reference 0x{0:x}>"" -f $fieldReference)
+                    }
+                    $offset += 4
+                }
+
+                { $_ -eq ""InlineI8"" -or
+                  $_ -eq ""InlineR""
+                }
+                {
+                    $offset += 8
+                }
+
+                ""InlineSwitch""
+                {
+                    $count = [BitConverter]::ToInt32($Ilbytes,$offset+1)
+                    $offset += 4 * $count
+                }
+
+            default 
+               { throw ""$($opCode.OperandType) not implemented"" }
+
+            }
+
+            Write-Host """" 
+        }
+    }
+
+    Write-Host ""} // end of method $($method.DeclaringType.ToString())::$($method.Name)""
+    Write-Host 
+}
+
+",2229,,2229,,2/21/2019 1:11,2/21/2019 1:11,,,,0,,,,CC BY-SA 4.0 +20676,2,,8219,2/21/2019 10:57,,3,,"

To find it using IDAPython:

+ +
ida_loader.get_fileregion_offset(ea)
+
+ +

where ""ea"" is your virtual offset like 0x400000.

+",25443,,18014,,2/21/2019 11:24,2/21/2019 11:24,,,,1,,,,CC BY-SA 4.0 +20677,1,,,2/21/2019 12:50,,0,235,"

actually i don't know where the problem but i will describe it +I am trying to analyse the firmware of a router and i could extract it and i got these files +libxmlapi.so +libhttpapi.so +libcfmapi.so +libmsgapi.so +But I can't read the file like this way in the IDA +and here is how it does like in my computer + +That's the link of the tutorial that i was following https://hg658c.wordpress.com/2017/12/04/decrypting-configuration-files-from-other-huawei-home-gateway-routers/ +But when i view the file in IDA mode it shows like 1 letter in every line and there is nothing like urk so i can determine the string that i have to copy to continue the tutorial +Here is the files so maybe someone want to take a look at them +https://drive.google.com/open?id=1cU9qgAsKecfLNuM7RLrBoin5DHl2GsB1 +I tried 3 other firmwares and i couldn't find any thing useful in them ( one of them is tested by other one and he could do it right )

+",27530,,27530,,2/21/2019 21:30,2/22/2019 5:57,Switching from seg to text in IDA-View,,1,4,,,,CC BY-SA 4.0 +20678,2,,20671,2/21/2019 16:09,,1,,"

As I know that specific glitch is specific to that device. I.e. it's firmware is written so that the device switches to the prompt in case it failed to access NAND. And if there was some other logic, like ""reboot the device if NAND is not accessible"", this NAND glitch won't be exploitable at all. Thus if it will work for EEPROM or not, depends on how the boot logic is organized in TG582N firmware.

+ +

Regarding the EEPROM pin, which you need to ground: https://www.exploitee.rs/index.php/Wink_Hub​​ they are grounding pin 29 of NAND chip, which is I/O1 pin. In case of EEPROM (which in your case is s25fl064l) I would try to ground SO/IO 1, SO/IO 0 pins, see the datasheet of s25fl064l.

+",22324,,22324,,2/25/2019 8:31,2/25/2019 8:31,,,,0,,,,CC BY-SA 4.0 +20679,2,,20653,2/21/2019 17:29,,1,,"

Come to think of it, apart from my other answer, there's a feature of IDA that I forgot: put your cursor on the call and do Edit->Plugins->Change the callee address (Alt-F11).

+",182,,,,,2/21/2019 17:29,,,,1,,,,CC BY-SA 4.0 +20680,1,,,2/22/2019 5:30,,0,227,"

I need to execute some instructions of library I'm using (ws2_32.dll) inside my C code, but I have a problem with a simple cmp instruction. +Followed by IDA, this instruction is:

+ +
cmp off_41AE7048, offset sub_41AC2E29
+
+ +

When I run my application in debugger, this above pice of code becomes:

+ +
CMP DWORD PTR DS:[77517048],WS2_32.774F2E29
+
+ +

What does this excatly mean? +Where this address(?) 77517048 came from?

+ +

I code comething like this

+ +
mov eax, DWORD ptr DS:[0x41AE7048]
+cmp eax, DWORD ptr DS:[0x41AC2E29]
+
+ +

but as I expected it doesn't work -> program crashes.

+ +###### EDIT + +

A little bit of explanation. I'm doing inline hook on listen function from ws2_32.dll library.

+ +

I have my own dll - hook.dll, which will be loaded into remote process. +Inside this dll I have funcion called listen_hook_wrapper;

+ +

After the dll is loaded into remote process, inside dllMain I'm overriding a few first instructions of 'listen' function, by loading my own code which is simple jump into 'listen_hook_wrapper'. To simplify, let's called this jump as trampoline.

+ +

Inside listen_hook_wrapper I'm taking listen's arguments, process them, and after all I would like to return executing to listen function, but before I will jump into listen function, I must execute listen's instructions which were overrided by my 'trampoline'.

+ +

The instructions of listen function, which were overriden by my trampoline are:

+ +
mov edi, edi
+push ebp
+mov ebp, esp
+push ecx
+cmp off_41AE7048, offset sub_41AC2E29 
+
+ +

After I execute this set of instruction I can jump back into listen function, and it should continue executing properly.

+ +

When I was writing this post I couldn't figure out what excatly is (what it is doing):

+ +
+

cmp off_41AE7048, offset sub_41AC2E29

+
+ +

and why executing this inside my trampoline causes errors, but now I think that it's because relocations.

+ +

As I mentioned above, when I take a look inside listen function during execution, the instrucion above becomes:

+ +
+

CMP DWORD PTR DS:[77517048],WS2_32.774F2E29

+
+ +

Let's compare this two addresses:

+ +
+

41AE7048 and 77517048.

+
+ +

They have common part which is ****7048. +As I know the 4**** is the default base address assigned during compile process, and the 7**** is address where usually dlls are loaded. So I think I need just update the instruction:

+ +
+

cmp off_41AE7048, offset sub_41AC2E29

+
+ +

by applying relocations, using the base address which was assigned in runtime by aslr mechanism.

+ +

I can't test it right now, but I think that it makes sense isn't it?

+",25385,,25385,,2/22/2019 7:28,2/22/2019 11:49,Executing CMP DS:[] by inline assembly inline hooks,,1,1,,,,CC BY-SA 4.0 +20681,2,,20677,2/22/2019 5:57,,1,,"

Welcome to RE.SE!

+ +

Could you elaborate which version of IDA you are using?

+ +

The files you shared were ELF shared objectes based on the ARM architecture. Although ELF is a well defined executable format, its seems IDA tries to disassemble the file as RAW. This means it doesn't parse the file format and can not tell apart code from data.

+ +

If you are utilizing IDAs free version, this is most likely due to the problem that is does not include arm support.

+ +

+ +

However, you could use other tools, such as objdump, radare2 or even online services like onlinedisassembler.com for free.

+",3162,,,,,2/22/2019 5:57,,,,0,,,,CC BY-SA 4.0 +20682,2,,20657,2/22/2019 9:26,,1,,"

print_decls(ordinals_sring, flags) return a string with the same content as the ""export to header file"" option in the GUI.

+ +

The ordinals string can contain multiple ordinals seperated with a comma and all PDF_ Flags can be used (for example PDF_INCL_DEPS).

+",27505,,,,,2/22/2019 9:26,,,,0,,,,CC BY-SA 4.0 +20683,1,,,2/22/2019 10:55,,0,484,"

I tried to find lua_pcall, lua_newthread, luaL_loadbuffer, lua_tolstring, lua_pushcclosure and lua_pushinteger functions with IDA decompiler but I didn't find them. Can someone please tell me what is best way to find this lua functions?

+",27538,,,,,2/22/2019 10:55,Finding lua addresses with ida,,0,2,,,,CC BY-SA 4.0 +20684,2,,20680,2/22/2019 11:22,,1,,"

Thanks for your ellaborations. All I had was the Win10 (64bit) version of winsock. The start of the listen function looks like this:

+ +

+ +

As you can see, the cmp instruction compares a fixed 32bit value (0x4f7902a0) to something in the .data-section of the library. As you can see, in the case they are not equal, there is another check of a data value and in the end its seems to decide whether to set a local variable to zero.

+ +

+ +

As you can see, the global variable which is checked contains the right value as per default. I can only speculate what is does... When you use the acutal pdb, you can see that it is a function pointer (PrologPointer).

+ +

+ +

But back to the core question. Without any meta information, when we decompile the instruction in question, we get the following output:

+ +
8b3500507c4f   mov    esi,DWORD PTR [rip+0x4f7c5000]
+
+ +

The library wants to be loaded at 0x4f780000. And the data is supposed to be read from rip+0x4f7c5000. Basically, this code is position independent and utilized a fixed offset between the dll base and its code section.

+ +

Normally, you should be able to install your hook in less than 9 bytes. Windows functions conveniently always utilize the standard function preamble, which is pretty easy to hook (e.g. with a far jump (5 bytes)). If that is not the case, you'll have to account for the relative address or skip the check altogether.

+",3162,,3162,,2/22/2019 11:49,2/22/2019 11:49,,,,0,,,,CC BY-SA 4.0 +20685,1,,,2/22/2019 14:05,,0,60,"

Look at this very basic javascript code:

+ +
if (s=='abcd')
+{
+    if (s2='cdef')
+    {
+       ...
+    }
+}
+
+ +

I want to hook all tests: I want to get this:

+ +
(s,'==','abcd')
+(s2,'==','cdef')
+
+ +

Is there a way to do this ?

+ +

I have tried to put hooks into v8 but it is not easy...

+",18590,,18590,,2/22/2019 14:45,2/22/2019 14:45,javascript hook comparisons,,0,2,,,,CC BY-SA 4.0 +20686,1,,,2/22/2019 14:49,,0,792,"

Attempting to reverse-engineer a checksum for a serial timing device that updates a display. Protocol is partly understood, however the checksum calculation specified does not produce the expected value.

+ +

I would like to understand what is happening in this protocol, as I would like to write to the display with my own software and not just sniff the data.

+ +

Known parameters:

+ +
    +
  • RS-485 half duplex
  • +
  • 8n1
  • +
  • DATA0...n transmitted unchanged, low nibbles are BCD (0-9)
  • +
  • (EDIT) this is likely not the case, as the spec I have does not seem to be the correct one. Disregard the following point. ADDR byte and CSUM byte split into two bytes each, hi and lo nibbles might be split between the two bytes, however I'm confused as to why it appears that the ADDR byte is a start flag byte.
  • +
  • sub_ADDR matches the protocol specification, used to identify the data in the packet to a specific part of the display, and possibly to different displays
  • +
  • One-way communication (EDIT) one-to-many master-slave likely
  • +
  • FEC appears to be ""repeat the message"" as all packets are immediately duplicated in the recorded stream, i.e. 1,1,2,2,3,3..etc.
  • +
  • Receiver likely ""pretends it never happened"" if packets are mangled as past data is irrelevant
  • +
  • (EDIT) All packets are of known length and the lengths do not change in the data set
  • +
  • (EDIT: CRITICAL INFO) Low nibbles of bytes labeled A3-A6 and B3-B6 represent digits 0-9 as BCD. A value of 0x0f would blank the digit on the display.[1] Therefore:

    + +
    0a 0c 02 00 60 00 80 0b -> ""20:00""
    +28 0c 02 00 60 00 80    -> ""20:00""
    +0a 0c 01 09 65 09 d8 0b -> ""19:59""
    +0a 0c 0f 09 65 09 80 0b -> "" 9:59""
    +
  • +
  • (EDIT) High nibbles of A3-A6 contain flag bits. Known flag bits include bit 6 in DATA2 (A5,B5) which indicates state == running, and bit 5 in DATA2 (A5,B5) which indicates colon == on.
  • +
+ +

First question: If the FEC is indeed ""repeat"", does it follow that the designer would incorporate a CSUM? Perhaps the packets that appear to be CSUM are something else not documented?

+ +
+ +

Packet format:

+ +

as described in protocol spec, possibly incorrect or outdated. (EDIT: the protocol spec does appear to be incorrect for my device. Corruption of the data is unlikely)

+ +

""X"" denotes a nibble that takes a value. +""?"" denotes a nibble that is used for flag bits.

+ +
| lo_ADDR | hi_ADDR | sub_ADDR | DATA_0 | DATA_1 | DATA_2 | DATA_3 | lo_CSUM | hi_CSUM |
+|   0x8X  |   0x9X  |   0x0c   |  0x?X  |  0x?X  |  0x?X  |  0x?X  |  0xAX   |   0xBX  |
+
+ +

Some of the fields seem to match; others don't. As seen below, lo and hi ADDR and lo and hi CSUM don't seem to match the description.

+ +

Most packets in the stream appear to start with 0x0a and end with 0x0b, although some packets observed don't follow that pattern. Are they flag bytes?

+ +

An example of two packets of interest, bytes that work as specified marked ok, ones that don't with !k

+ +
A1 A2 A3 A4 A5 A6 A7 A8     B1 B2 B3 B4 B5 B6 B7
+------------------------------------------------
+!k ok ok ok ok ok !k !k     !k ok ok ok ok ok !k
+0a 0c 02 00 60 00 80 0b     28 0c 02 00 60 00 80
+
+ +

Straight from Pyserial, appears as follows:

+ +
b'\n\x0c\x02\x00`\x00\x80\x0b(\x0c\x02\x00 \x00\x80'
+
+ +

Ten lines of packets, two neighboring packets shown, repeats removed: +(edit: added more lines, formatting for clarity)

+ +
A1 A2 A3 A4 A5 A6 A7 A8          B1 B2 B3 B4 B5 B6 B7
+--------------------- state == running --------------
+----------------------(A3, B3 <= 0x09)---------------
+
+0a 0c 01 09 65 09 d8 0b .repeat. 28 0c 01 09 65 09 e0 .repeat. ...
+0a 0c 01 09 65 08 c0 0b ........ 28 0c 01 09 65 08 80 ...
+0a 0c 01 09 65 07 a8 0b ........ 28 0c 01 09 65 07 a0 ...
+0a 0c 01 09 65 06 90 0b ........ 28 0c 01 09 65 06 c0 ...
+0a 0c 01 09 65 05 f8 0b ........ 28 0c 01 09 65 05 e0 ...
+0a 0c 01 09 65 04 e0 0b ........ 28 0c 01 09 65 04 80 ...
+0a 0c 01 09 65 03 c8 0b ........ 28 0c 01 09 65 03 a0 ...
+0a 0c 01 09 65 02 b0 0b ........ 28 0c 01 09 65 02 c0 ...
+0a 0c 01 09 65 01 98 0b ........ 28 0c 01 09 65 01 e0 ...
+0a 0c 01 09 65 00 80 0b ........ 28 0c 01 09 65 00 80 ...
+0a 0c 01 09 64 09 e0 0b ........ 28 0c 01 09 64 09 80 ...
+0a 0c 01 09 64 08 80 0b ........ 28 0c 01 09 64 08 80 ...
+0a 0c 01 09 64 07 a0 0b ........ 28 0c 01 09 64 07 80 ...
+0a 0c 01 09 64 06 c0 0b ........ 28 0c 01 09 64 06 80 ...
+0a 0c 01 09 64 05 e0 0b ........ 28 0c 01 09 64 05 80 ...
+0a 0c 01 09 64 04 80 0b ........ 28 0c 01 09 64 04 80 ...
+0a 0c 01 09 64 03 a0 0b ........ 28 0c 01 09 64 03 80 ...
+0a 0c 01 09 64 02 c0 0b ........ 28 0c 01 09 64 02 80 ...
+0a 0c 01 09 64 01 e0 0b ........ 28 0c 01 09 64 01 80 ...
+0a 0c 01 09 64 00 80 0b ........ 28 0c 01 09 64 00 80 ...
+         ...                             ...
+0a 0c 01 09 64 04 a0 0b ........ 28 0c 01 09 63 04 80 ...
+         ...                             ...
+-------------------- state == stopped -------------------
+------------(high nibble A5, B5 0b110 -> 0b10)-----------
+------------(bit 6 in byte A5, B5 == flag bit)-----------
+
+0a 0c 01 09 23 04 a0 0b ........ 28 0c 01 09 23 04 80 ...
+         ...                             ...
+---------------- state == running | stopped -------------
+------------(if A3, B3 == 0x0f, then A7, B7 -> 80)-------
+------------(A3, B3 == 0x0f == no digit displayed)-------
+         ...                             ...
+0a 0c 0f ** ** ** 80 0b ........ 28 0c 0f ** ** ** 80 ...
+         ...                             ...
+
+ +

0x0a << 2 == 0x28. Is that just coincidence? Or are some bits handled improperly?

+ +

It would appear that A7 and B7 are 8 bit CSUM values. However, when the following CSUM calculation is done as specified in the documentation:

+ +
CSUM = lo_ADDR ^ hi_ADDR ^ sub_ADDR ^ DATA_0 ^ DATA_1 ^ DATA_2 ^ DATA_3
+0x62 =   0xa   ^   0x0   ^   0x0c   ^  0x01  ^  0x09  ^  0x65  ^  0x09
+0x62 =   0x8   ^   0x2   ^   0x0c   ^  0x01  ^  0x09  ^  0x65  ^  0x09   
+
+ +

The calculated value doesn't match A7 or B7. However:

+ +

""The CSUM byte is then split into 2 bytes, 0xAX (low nibble) and 0xBX (high nibble)""

+ +

I've tried https://crccalc.com as well as others, thinking that the calculation in the specification is incorrect, however I can't get any matches on any 8-bit CSUMs that I've tried.

+ +

I think I'm missing something obvious, as I'm quite an amateur. I'm really trying to understand what's happening, where I've gone wrong, and not just get my problem solved. I'm now two days into trying to figure this out, and I just can't get it.

+ +

Quesion two: Are those fields actually checksums, if they are, how are they calculated?

+ +

Question three: If they're not, what are they?

+ +

Question four: Why would some packets appear to be missing (or have a different) start and stop flag bytes? (EDIT: Most likely because the specification I have is wrong)

+ +
+ +

(EDIT) The CSUM calc in the spec does not apply to my data.

+ +

Check sum calculation spec, verbatim from documentation:

+ +
CSUM = LOW ADDR
+CSUM = CSUM XOR'ed with HIGH ADDR
+CSUM = CSUM XOR'ed with SUB ADDR
+CSUM = CSUM XOR'ed with Data0
+..
+CSUM = CSUM XOR'ed with DataN (the last data-byte)
+The CSUM byte is then split into 2 byte, 0xAn (low nibble) and 0xBn (high nibble)
+
+ +
+ +

Some interesting patterns which seem to hold throughout my data set:

+ +
    +
  1. if A3,B3 == 0x0f then A7,B7 == 0x80
  2. +
  3. High nibble A5,B5 == 0x6 | 0x2: change does not seem to affect A7,B7
  4. +
  5. if A6,B6 == 0x00 then A7,B7 == 0x80
  6. +
+ +
+ +

(EDIT) UPDATE: +You know, the more I think about it and look around the internet, this system shares many similarities with DMX protocol. This system was made to work with many devices daisy-chained together.

+ +
    +
  1. One-to-many connection, with termination required at the end
  2. +
  3. 0x00 break on every line, similar to lo value inter-packet (line?) break, bursts of data about once a second
  4. +
  5. possibly no error correction at all
  6. +
  7. used to control a ""lighting"" device (7-segment display)
  8. +
  9. others ...?
  10. +
+ +
+ +

[1] ""The Texas Instruments seven-segment display decoder chips 7446/7447/7448/7449 and 74246/74247/74248/74249 and the Siemens FLH551-7448/555-8448 chips used truncated versions of ""2"", ""3"", ""4"", ""5"" and ""6"" for digits A–E. Digit F (1111 binary) was blank."" - wikipedia, 7-segment display

+",27541,,27541,,3/3/2019 13:58,3/3/2019 13:58,Reverse engineering checksum from RS-485 device,,1,5,,,,CC BY-SA 4.0 +20688,2,,20632,2/22/2019 16:29,,6,,"

What ultimately enabled me to understand the firmware structure was Binwalk. Then, it was a matter of using dd to split the parts and putting them back together.

+ +

For example, here's the output from Binwalk:

+ +
$ binwalk tf_recovery.img 
+
+DECIMAL       HEXADECIMAL     DESCRIPTION
+--------------------------------------------------------------------------------
+64            0x40            xz compressed data
+2162688       0x210000        Squashfs filesystem, little endian, version 4.0, compression:xz, size: 6502290 bytes, 2019 inodes, blocksize: 131072 bytes, created: 2018-06-06 07:02:05
+9830400       0x960000        JFFS2 filesystem, little endian
+
+ +

This means:

+ +
    +
  1. There is something from address 0 to 64 (something that binwalk doesn't show, this ended up being u-boot's header).
  2. +
  3. There's a XZ archive from 64 to 2162688.
  4. +
  5. There's also a SquashFS filesystem from 2162688 to 9830400.
  6. +
  7. And finally a JFFS2 filesystem from 9830400 to the end of the file.
  8. +
+ +

To unpack everything:

+ +
dd if=tf_recovery.img of=header.bin bs=1 count=64 skip=0
+dd if=tf_recovery.img of=xzdata.xz bs=1 count=2162624 skip=64
+dd if=tf_recovery.img of=squashfs.bin bs=1 count=7667712 skip=2162688
+dd if=tf_recovery.img of=jffs2.bin bs=1 skip=9830400
+
+ +

Putting it back together is a matter of doing the reverse:

+ +
dd if=header.bin of=somefile.img bs=1 count=64
+dd if=xzdata.xz of=somefile.img bs=1 count=2162624 seek=64
+dd if=squashfs.bin of=somefile.img bs=1 count=7667712 seek=2162688
+dd if=jffs2.bin of=somefile.img bs=1 count=6488144 seek=9830400
+
+ +

Important note: All these parts were padded to size with x'FF' this is something important to take into account when putting everything back together: How to pad a file with “FF” using dd?

+",27471,,,,,2/22/2019 16:29,,,,1,,,,CC BY-SA 4.0 +20689,1,20707,,2/22/2019 17:36,,1,228,"

For a CTF I have a fairly slow recursive function. I just need to cached the previous results in a dictionary and get them instead. I did it but had to reverse engineer the code. I was wondering if there is a better solution.

+ +

LD_PRELOAD won't work as it is a static binary. If I could copy the assembly and call the function in a C program with asm I could get it done but is there a better solution or a way to patch the binary and create a function that caches the slow one? We could path the binary or use somethings to hook the function call.

+",26228,,26228,,2/22/2019 18:06,2/25/2019 7:04,(CTF) Speed up assembly by hooking to an static function,,1,0,,,,CC BY-SA 4.0 +20690,2,,20670,2/22/2019 20:10,,2,,"

Yes, it is possible!

+ +

You'll have to do some trial and error for positioning though.

+ +

+ +

Adding in a new control is fairly easy. We essentially need to do what the designer usually automatically does for us and create the new control and set up its properties ourselves. Luckily, we can use the button that's already there as a template.

+ +

First order of business is declaring our new button. Right click inside the class and hit ""Edit Class"" to open the code editor. Scroll down to the bottom where the variables are declared and declare our new button like so:

+ +
public Button button2;
+
+ +

Once that's done, you should be able to find the designer auto-generated InitializeComponent() method for the form you want to modify. This is the function that does the initial setup for our form. it'll look something like this:

+ +
private void InitializeComponent()
+    {
+        this.button1 = new Button();
+        base.SuspendLayout();
+        this.button1.Location = new Point(189, 45);
+        this.button1.Name = ""button1"";
+        this.button1.Size = new Size(170, 53);
+        this.button1.TabIndex = 0;
+        this.button1.Text = ""ADD ANOTHER LIKE ME"";
+        this.button1.UseVisualStyleBackColor = true;
+        base.AutoScaleDimensions = new SizeF(6f, 13f);
+        base.AutoScaleMode = AutoScaleMode.Font;
+        base.ClientSize = new Size(563, 329);
+        base.Controls.Add(this.button1);
+        base.Name = ""Form1"";
+        this.Text = ""Form1"";
+        base.ResumeLayout(false);
+    }
+
+ +

We can copy and paste the creation code for the button that already exists in this case and replace ""button1"" with ""button2"". You'll probably want to change the tab index too.

+ +
private void InitializeComponent()
+    {
+        this.button1 = new Button();
+        this.button2 = new Button();
+        base.SuspendLayout();
+        this.button1.Location = new Point(189, 45);
+        this.button1.Name = ""button1"";
+        this.button1.Size = new Size(170, 53);
+        this.button1.TabIndex = 0;
+        this.button1.Text = ""ADD ANOTHER LIKE ME"";
+        this.button1.UseVisualStyleBackColor = true;
+
+        this.button2.Location = new Point(189, 145);
+        this.button2.Name = ""button2"";
+        this.button2.Size = new Size(170, 53);
+        this.button2.TabIndex = 1;
+        this.button2.Text = ""I am Added"";
+        this.button2.UseVisualStyleBackColor = true;
+
+        base.AutoScaleDimensions = new SizeF(6f, 13f);
+        base.AutoScaleMode = AutoScaleMode.Font;
+        base.ClientSize = new Size(563, 329);
+        base.Controls.Add(this.button1);
+        base.Name = ""Form1"";
+        this.Text = ""Form1"";
+        base.ResumeLayout(false);
+    }
+
+ +

Then, to get your button to actually appear, you'll need to add the line base.Controls.Add(this.button2); under base.Controls.Add(this.button1);.

+ +

We're not done yet, as our new button will have the exact same properties as the original if we leave it like this, and will appear in the same place with the same text. Replacing the text is easy, simply change the value of this.button2.Text to your desired value. The position will take a little trial and error.

+ +

You'll need to edit this line:

+ +
this.button2.Location = new Point(189, 45);
+
+ +

Here, the first argument of Point is the button's X position and the second is the button's Y position. To move the button downwards as seen in your question, you'll need to increase the Y position. How much you need to increase it depends on where you want the new button to be.

+ +

To save and test your changes, go to File -> Save Module. Your final code should look something like this:

+ +
// Token: 0x02000002 RID: 2
+public class Form1 : Form
+{
+    // Token: 0x06000001 RID: 1
+    public Form1()
+    {
+        this.InitializeComponent();
+    }
+
+    // Token: 0x06000002 RID: 2
+    protected override void Dispose(bool disposing)
+    {
+        if (disposing && this.components != null)
+        {
+            this.components.Dispose();
+        }
+        base.Dispose(disposing);
+    }
+
+    // Token: 0x06000003 RID: 3
+    private void InitializeComponent()
+    {
+        this.button1 = new Button();
+        this.button2 = new Button();
+        base.SuspendLayout();
+        this.button1.Location = new Point(189, 45);
+        this.button1.Name = ""button1"";
+        this.button1.Size = new Size(170, 53);
+        this.button1.TabIndex = 0;
+        this.button1.Text = ""ADD ANOTHER LIKE ME"";
+        this.button1.UseVisualStyleBackColor = true;
+        this.button2.Location = new Point(189, 145);
+        this.button2.Name = ""button2"";
+        this.button2.Size = new Size(170, 53);
+        this.button2.TabIndex = 1;
+        this.button2.Text = ""I am Added"";
+        this.button2.UseVisualStyleBackColor = true;
+        base.AutoScaleDimensions = new SizeF(6f, 13f);
+        base.AutoScaleMode = AutoScaleMode.Font;
+        base.ClientSize = new Size(563, 329);
+        base.Controls.Add(this.button1);
+        base.Controls.Add(this.button2);
+        base.Name = ""Form1"";
+        this.Text = ""Form1"";
+        base.ResumeLayout(false);
+    }
+
+    // Token: 0x04000001 RID: 1
+    private IContainer components;
+
+    // Token: 0x04000002 RID: 2
+    private Button button1;
+
+    public Button button2;
+}
+
+ +

and my final form looked like this: +

+ +

I hope this helped!

+",27512,,,,,2/22/2019 20:10,,,,1,,,,CC BY-SA 4.0 +20691,2,,20632,2/22/2019 21:14,,2,,"

curiosity led me to google for the firmware +found it at mi forums +it appears Uboot Image header and data that follows is documented fairly well
+i just cooked a python script to rip the compressed blob out of the firmware +and testing the blob with 7zip yields no errors

+ +

script

+ +
import struct
+import binascii
+import datetime
+fileext = { 0:'none',1:'gzip',2:'bzip2',3:'lzma',4:'lzo'}
+fin = open(""tf_recovery.img"" , ""rb"")
+uimghdr = fin.read(64)
+magic,        = struct.unpack(""!i""   , uimghdr[ 0:4 ] )
+headercrc32,  = struct.unpack(""!i""   , uimghdr[ 4:8 ] )
+timestamp,    = struct.unpack(""!i""   , uimghdr[ 8:12] )
+datasize,     = struct.unpack(""!i""   , uimghdr[12:16] )
+LoadAddress,  = struct.unpack(""!i""   , uimghdr[16:20] )
+EntryPtAddr,  = struct.unpack(""!i""   , uimghdr[20:24] )
+Datacrc32,    = struct.unpack(""!i""   , uimghdr[24:28] )
+OperatingSys, = struct.unpack(""!b""   , uimghdr[28:29] )
+Architecture, = struct.unpack(""!b""   , uimghdr[29:30] )
+ImageType,    = struct.unpack(""!b""   , uimghdr[30:31] )
+CompressType, = struct.unpack(""!b""   , uimghdr[31:32] )
+ImageName,    = struct.unpack(""!32s"" , uimghdr[32:64] )
+uimgdata = fin.read(datasize)
+fin.close()
+copy = list(uimghdr)
+copy[4:8] = '\x00\x00\x00\x00' 
+crcdata = ''.join(copy)
+realhdrcrc32 = binascii.crc32(crcdata)
+realdatacrc32 = binascii.crc32(uimgdata)
+assert ( realhdrcrc32  == headercrc32 )
+assert ( realdatacrc32 == Datacrc32 )
+print (""UBoot Header Magic %s"" ) % hex(magic)
+print (""UBoot Header crc32 %s"" ) % hex( realhdrcrc32)
+print (""UBoot Header Tstmp %s"" ) % datetime.datetime.fromtimestamp(timestamp)
+print (""UBoot Header DSize %s"" ) % hex(datasize)
+print (""Uboot Compression  %s"" ) % fileext[CompressType]
+fout = open('out.xz' , 'wb')
+fout.write(uimgdata)
+fout.close()
+
+ +

and results are

+ +
:\>ubootimgdump.py
+UBoot Header Magic 0x27051956
+UBoot Header crc32 0x5799cfc3
+UBoot Header Tstmp 2018-06-06 12:32:07
+UBoot Header DSize 0x1a4ffc
+Uboot Compression  lzma
+
+:\>e:\7Z\7z.exe t out.xz
+
+7-Zip [32] 15.14 : Copyright (c) 1999-2015 Igor Pavlov : 2015-12-31
+
+Scanning the drive for archives:
+1 file, 1724412 bytes (1684 KiB)
+
+Testing archive: out.xz
+--
+Path = out.xz
+Type = xz
+Physical Size = 1724412
+Method = LZMA2:23 CRC64
+Streams = 1
+Blocks = 1
+
+Everything is Ok
+
+Size:       3590624
+Compressed: 1724412
+
+:\>
+
+",3473,,,,,2/22/2019 21:14,,,,0,,,,CC BY-SA 4.0 +20692,1,,,2/22/2019 21:15,,1,218,"

So I have this sample problem that I need to buffer overflow. Its an elf file that require to be run on a separate terminal then using ""nc localhost 'port' "" on a separate terminal we can see the input.

+ +

On IDA I have

+ +

+ +

which from some reason I dont understand what Im looking for so I tried using a buffer overflow technique and I got

+ +

+ +

and in the other terminal I got

+ +

+ +

I tried for days looking around for techniques and understanding how to solve this problem but im always reaching dead ends.

+ +

Here is a link to the elf file: https://we.tl/t-vlqS6LwqlB

+",27552,,,,,2/22/2019 21:15,Need help understanding basic buffer overflow,,0,2,,,,CC BY-SA 4.0 +20693,1,,,2/23/2019 7:36,,1,351,"

I want to save flow/call graph of IDA into a pdf format so that I could view it in my android. How can I do that?

+ +

I know IDA can generate a flow chart (gdl file) and call chart (gdl file). But my question is, how do I convert those file format into pdf so that I could view the pdf on my android and iPad? I have no experience with those file formats before.

+ +

Thank you.

+",27557,,,,,2/23/2019 7:36,Saving IDA Graph to PDF format?,,0,0,,,,CC BY-SA 4.0 +20697,1,,,2/23/2019 22:52,,0,1438,"

I am new in the reverse engineering, I have a good experience in programming MCUs like c51 and ARM. +Now I would like to learn about Tricore reverse engineering... ECUs mainly. +I can obtain the ECU flash as bin files, my question is: what IDE and debugger hardware (jtag) is best for this job?

+",27564,,245,,3/3/2019 9:14,10/29/2020 2:14,Tricore debugging tools,,2,1,,,,CC BY-SA 4.0 +20698,1,,,2/24/2019 7:06,,1,792,"

I'm about to use IDA pro. +I have to access to 0018F42C(EAX) by using Hex view in IDA. +Maybe I guess there is EAX value.(String is ""happyy"", standard input) +but Hex view shows me 0018F410 as in screen1..

+ +

+ +

If it works well, I can find string ""happyy"" as in screen2 +

+ +

then.. how can I see 0018F42C, not 0018F410?

+",27568,,,,,2/24/2019 7:06,How can I see specific memory value by using Hex view in IDA?,,0,1,,,,CC BY-SA 4.0 +20702,2,,20697,2/24/2019 12:45,,2,,"
    +
  • IDE: High Tech RT but it is usually tied up to one TriCore processor with other limitations. However you can compile your C into TriCore executable +
  • JTAG Debugger: Mini Wiggler from Infineon or if your budget allows that, Lauterbach. However ECUs are safety critical devices, so they use a system of internal and external watchdogs. If you set a breakpoint in TriCore, after hitting the breakpoint ECU usually reset itself. So OCDS can be (on production ECUs) used only as RAM monitor at best.
    +Second problem which you will come across is, that most of TriCore ECUs has JTAG interface disabled because UCB0 is set. +
+ +

It should be obvious that you should first buy some development kit, like this application kit which has integrated debugger and understand how TriCore's internals are working. It is going to be less frustrating for you than develop anything on security hardened production ECUs.

+",27573,,,,,2/24/2019 12:45,,,,0,,,,CC BY-SA 4.0 +20703,1,20704,,2/24/2019 13:24,,1,720,"

I'm in a reverse engineering class. Our current assignment is to edit a notepad.exe application. Just to start out, I opened my notepad.exe in FlexHex, went to the end of the.rsrc section, changed a byte in one of the stock text strings from "70" to "31" and then saved the new file as an .exe. The size of the section and the overall file remains the same. Below is the line I changed.

+

+

When I try to run the file, I get an error that Windows cannot run the file, specifically "This app cannot run on your PC". I didn't think that I changed anything essential. I'm wondering if Windows is preventing me from running a modified version of a Window's program. Is there a way to specify that Windows should run this program?

+

Any help is appreciated, thank you.

+",27554,,-1,,6/17/2020 9:54,2/25/2019 5:14,Windows 10 will not run hex edited application,,1,2,,,,CC BY-SA 4.0 +20704,2,,20703,2/24/2019 16:12,,2,,"

I think “notepad.exe” has been digitally signed by Microsoft. You cannot change it because the signature will ( very very probably) be invalid. The OS doesn’t trust it anymore.

+",1517,,1517,,2/25/2019 5:14,2/25/2019 5:14,,,,1,,,,CC BY-SA 4.0 +20705,1,,,2/25/2019 2:57,,1,655,"

With great hopes I have tried to use fakenet-ng for testing spoofing or MITM type vulnerabilities. The android app I am testing uses HTTPS POST, and with fakenet it stops short of sending any data because the app rejects the SSL certificate presumably created by fakenet. I also tried simply with Edge and Chrome on Windows 10, and same deal - I can't get to first base. I can't find any information about fakenet and certificates. Fakenet lists decrypting SSL as a great feature - but it seems pretty useless without a solution to the certificate problem - I must be missing something - how do I get applications to send HTTPS data to fakenet?

+",27579,,,,,3/28/2019 13:47,fakenet for apps using SSL,,2,0,,,,CC BY-SA 4.0 +20706,1,,,2/25/2019 4:24,,1,1295,"

I am doing a reverse homework. see the following pictures:

+ +

+ +

as can be seen from this picture, before call push touch3, ""saved rip"" is at 0x5561dca8, which is equal to the current rsp(0x5561dca8).

+ +

once called push touch3, the ""saved rip"" is at 0x5561dca0, which is also equal to new rsp(0x5561dca0).

+ +

My question is, why push instruction changed the ""saved rip"" address.

+ +

+",27558,,245,,3/5/2019 21:06,3/5/2019 21:06,why saved rip changed by push?,,1,2,,,,CC BY-SA 4.0 +20707,2,,20689,2/25/2019 7:04,,2,,"

You can definitely edit the binary and implement a new function that handles caching and calls the original function as needed. Then just replace any call to your new cache-implementing function instead. You'll need to be careful when implementing the cache for a recursive function and decide if you wanna cache all intermediate results or only final results.

+ +

If you're looking for a fast solution, though, you may want to consider using an emulator as a way of running that function's code inside your program. Either using Unicorn, any other emulator or even IDAs app call for function execution.

+",2147,,,,,2/25/2019 7:04,,,,2,,,,CC BY-SA 4.0 +20708,2,,20706,2/25/2019 9:48,,2,,"

Mainly, this is because the program did enough pop previously to get rsp just in front the saved rip. Then, a simple push will overwrite the saved rip.

+ +

As you can notice on the first picture, your saved rip is at 0x5561dca8 and, your rsp as well. Therefore, a push operation will store the address of the touch3 function as return address of the stack-frame.

+ +

Nothing really difficult here.

+",53,,,,,2/25/2019 9:48,,,,2,,,,CC BY-SA 4.0 +20709,2,,20705,2/25/2019 10:04,,1,,"

It seems that most of the people are better using the mitmproxy tool (see docs) together with SSLsplit for this kind of usage.

+ +

Just for the sake of completeness, here are a few pages explaining how to do:

+ + +",53,,,,,2/25/2019 10:04,,,,1,,,,CC BY-SA 4.0 +20711,1,,,2/25/2019 13:51,,2,510,"

This might be a stupid question, but I am trying to learn by myself and I encountered a problem which I cannot solve for the life of me. I tried googling and I can't find anything relevant, so here goes:

+ +

When I use the aaa command while not in debug mode, it works fine, but as soon as I go into debug mode and I go into the main function and type aaa, the following shows up: +[ ] Analyze all flags starting with sym. and entry0 (aa)

+ +

If I press enter nothing happens and I can just type freely without any effect.

+ +

How am I supposed to proceed?

+",27584,,,,,12/10/2019 11:02,How to use aaa in radare2 while in -d (debug) mode?,,1,2,,,,CC BY-SA 4.0 +20712,1,20716,,2/25/2019 17:07,,7,1519,"

I have been trying to figure out the assembly for part of a DOS game and there is an operation that keeps getting called that uses all 4 registers. I can see what each line does but I can't for the life of me figure out what all the code together is meant be doing.

+ +

Can anyone give me some idea?

+ +

The code is:

+ +
seg000:3825 some_math_op_on_regs proc far; CODE XREF: sub_72C6+19FP
+seg000:3825                              ; sub_72C6+1DDP ...
+seg000:3825       cmp     cl, 10h
+seg000:3828       jnb     short loc_383A ; Jump if CF=0
+seg000:382A       mov     bx, dx         ; c register is < 16; move d to b
+seg000:382C       shr     ax, cl         ; Shift a right by value in c (logical)
+seg000:382E       sar     dx, cl         ; Shift d right by value in c (arithmetic)
+seg000:3830       neg     cl             ; Negate c (2's complement)
+seg000:3832       add     cl, 10h        ; Add 16 to c
+seg000:3835       shl     bx, cl         ; Shift b left by value in c (logical)
+seg000:3837       or      ax, bx         ; OR a and b, store result in a
+seg000:3839       retf
+seg000:383A ; --------------------------------------------------------------------
+seg000:383A
+seg000:383A loc_383A:                    ; CODE XREF: some_math_op_on_regs+3j
+seg000:383A       sub     cl, 10h        ; c register is >= 16; subtract 16 from c
+seg000:383D       xchg    ax, dx         ; Switch values in a and d
+seg000:383E       cwd                    ; Convert word to doubleword
+seg000:383F       sar     ax, cl         ; Shift a right by value in c (arithmetic)
+seg000:3841       retf
+seg000:3841 some_math_op_on_regs endp
+
+",22723,,53,,2/25/2019 19:27,2/25/2019 20:35,What's this assembly doing?,,2,0,,,,CC BY-SA 4.0 +20715,2,,20712,2/25/2019 20:33,,5,,"

It appears to be a 32 bit right shift with the 32 bit number provided in dx:ax, and cl being the number of bits to shift.

+ +

If you assume cl is over 16, a right shift by more than 16 bit only needs to care about the upper 16 bit, which are stored in dx, because the lower 16 bit are shifted out anyway.

+ +

So that's exactly what the 2nd block does. If cl larger than 16, move dx (upper 16 bit) into ax and convert it to a 32 bit number, subtract 16 from cl because this is implicitly done by ignoring the lower 16 bit, then shift the upper part (which is now dx:ax thanks to the cwd) by that number.

+ +

I didn't try to understand the top part, but my assumption is it does exactly the same for shift widths below 16 bits.

+ +

Basically, it's a 32 bit right shift done in 16 bit architecture.

+",23277,,,,,2/25/2019 20:33,,,,0,,,,CC BY-SA 4.0 +20716,2,,20712,2/25/2019 20:35,,9,,"

This looks like a 32-bit shift right compiler helper. In 16-bit era, 32-bit numbers were represented by a pair of registers, in this case ax:dx. The check for 16 is an optimization: if the shift is over 16, the low register value is lost completely, so it can be discarded and replaced by dx>>(shift-16), while the high register is filled with the sign bit as the result of the cwd instruction. Here's the (lightly) commented source code from the Borland C runtime library which seems to match yours:

+ +
;[]-----------------------------------------------------------------[]
+;|      H_LRSH.ASM -- long shift right                               |
+;[]-----------------------------------------------------------------[]
+
+;
+;       C/C++ Run Time Library - Version 5.0
+; 
+;       Copyright (c) 1987, 1992 by Borland International
+;       All Rights Reserved.
+; 
+
+        INCLUDE RULES.ASI
+
+_TEXT   segment public byte 'CODE'
+        assume  cs:_TEXT
+        public  LXRSH@
+        public  F_LXRSH@
+        public  N_LXRSH@
+
+N_LXRSH@:
+        pop     bx                      ;fix up for far return
+        push    cs
+        push    bx
+LXRSH@:
+F_LXRSH@:
+        cmp     cl,16
+        jae     lsh@small
+        mov     bx,dx                   ; save the high bits
+        shr     ax,cl                   ; now shift each half
+        sar     dx,cl
+;
+;                       We now have a hole in AX where the lower bits of
+;                       DX should have been shifted.  So we must take our
+;                       copy of DX and do a reverse shift to get the proper
+;                       bits to be or'ed into AX.
+;
+        neg     cl
+        add     cl,16
+        shl     bx,cl
+        or      ax,bx
+        retf
+lsh@small:
+        sub     cl,16                   ; for shifts more than 15, do this
+                                        ; short sequence.
+        xchg    ax,dx                   ;
+        cwd                             ; We have now done a shift by 16.
+        sar     ax,cl                   ; Now shift the remainder.
+        retf
+_TEXT   ends
+        end
+
+",60,,,,,2/25/2019 20:35,,,,0,,,,CC BY-SA 4.0 +20717,1,,,2/25/2019 22:04,,1,1290,"

I am trying to analyze lua functions of game but dll is packed and I can't see them. I tried to dump dll with scylla https://github.com/NtQuery/Scylla but I still didn't get lua functions. Can someone please help me to dump dll?

+ +

Dll is part of Watch Dogs game(It's called Disrupt_b64.dll) and it has VMProtector. +When I opened dll in IDA I first got error: +Can't find translation for relative virtual address 03ACF000, continue? +After that I got error: +The imports segment seems to be destroyed. This MAY mean that the file was packed or otherwise modified in order to make it more difficult to analyze.

+ +

When I opened dumped dll from Scylla I only got second error

+ +

Someone on I read on this site https://blog.lms-dev.com/category/watch-dogs/ successfully got that lua functions(collectgarbage, dofile, error, gcinfo). He said on site to unpack dll attach IDA to the process and dump the loader segments.

+ +

Disrupt_b64.dll looked like this + +Dumped Disrupt_b64.dll looked like this +

+",27538,,27538,,2/26/2019 8:24,2/26/2019 8:24,Dump packed dll,,0,1,,,,CC BY-SA 4.0 +20718,1,20727,,2/25/2019 22:19,,1,185,"

I've disassembled an old DOS program into assembly and I'm trying to figure out a function call. Here is the ASM:

+ +
seg000:373C ; ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦ S U B R O U T I N E ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦
+seg000:373C
+seg000:373C
+seg000:373C sub_373C        proc far                ; CODE XREF: sub_72C6+16BP
+seg000:373C                                         ; sub_72C6+18FP ...
+seg000:373C                 push    si              ; Temp. store si on stack so we can restore it later
+seg000:373D                 xchg    ax, si
+seg000:373E                 xchg    ax, dx
+seg000:373F                 test    ax, ax
+seg000:3741                 jz      short loc_3745
+seg000:3743                 mul     bx              ; Multiply b by a IIF a is non-zero
+seg000:3745
+seg000:3745 loc_3745:                               ; CODE XREF: sub_373C+5j
+seg000:3745                 jcxz    short loc_374C
+seg000:3747                 xchg    ax, cx
+seg000:3748                 mul     si
+seg000:374A                 add     ax, cx
+seg000:374C
+seg000:374C loc_374C:                               ; CODE XREF: sub_373C:loc_3745j
+seg000:374C                 xchg    ax, si
+seg000:374D                 mul     bx
+seg000:374F                 add     dx, si
+seg000:3751                 pop     si              ; Restore old si
+seg000:3752                 retf
+seg000:3752 sub_373C        endp
+
+ +

Frankly it just seems to be jumbling the registers around to me. My best guess is that it's some kind of primitive pseudo-random number generator. Can anyone confirm this or if not, tell me what it's actually meant to do?

+ +

EDIT:
+I've tried dry-running the code, and as far as I can tell, the following is the end result of the registers (can anyone confirm I've got this right and tell me what useful mathematical function it might be doing?):

+ +
ax: ( ax * bx )
+bx: bx
+cx: cx
+dx: ax + ( (bx * dx) + (ax * cx) )
+
+",22723,,22723,,2/26/2019 22:11,2/26/2019 22:42,Assembly that just seems to be a jumble,,2,3,,,,CC BY-SA 4.0 +20720,1,,,2/25/2019 22:26,,1,59,"

Hi I am a Service Engineer on some very old ASML stppers that run a system called PAS (Philips automated steppers), these steppers are obsoleted by the manufacturer and no longer supported by anyone. I have the install software but it requires a software key that I dont have. What I do have is 6 software keys from a previous version of software(I dont have) and would like to try and see how these keys are generated so I can generate new ones.

+ +

I am not very good at software issues but I can manage if I can get some ideas what way to go, I recently talked with the manufacturer and since they no longer support these are free to do with what we want.

+ +

This is a non standard system, neither windows or unix can view the file structure, I am able to use Acrius software to image the hard drives successfully, now I just need to be able to install software.

+ +

Anyone have any suggestions? Is there a way to use the old keys and info the tool asks for to decode the old keys?

+",27593,,,,,2/25/2019 22:26,1990s non windows software keys,,0,2,,3/7/2019 2:13,,CC BY-SA 4.0 +20722,2,,19852,2/26/2019 13:40,,1,,"

I dont know if you're still looking for an answer. But my best guess is that you have a firmware of a China TV/box board. In that case, download the ""MStar Android TV firmware tools"" and unpack the BIN file using it.

+ +

You will find the tools here: https://forum.xda-developers.com/android/software/tools-mstar-android-tv-firmware-tools-t3559227

+",27606,,,,,2/26/2019 13:40,,,,0,,,,CC BY-SA 4.0 +20724,2,,20718,2/26/2019 14:53,,2,,"

It looks like the code is specifically generating these outputs:

+ +
ax: (ax * bx)
+dx: (bx * dx + ax * cx)
+
+ +

This is under the assumption that the mul instructions never have operands large enough to set dx to a non-zero value. (If that is true, it seems kinda weird that seg000:374F is an add and not just an xchg.)

+ +

Maybe it's calculating the addition of two fractions?

+ +
dx   cx   (bx * dx + ax * cx)
+-- + -- = -------------------
+ax   bx        (ax * bx)
+
+",12017,,,,,2/26/2019 14:53,,,,1,,,,CC BY-SA 4.0 +20725,1,,,2/26/2019 16:12,,1,1261,"

I have two kinds of ELF files, built from C++.

+ +

.so files:

+ +
+

ELF 64-bit LSB shared object, x86-64, version 1 (GNU/Linux), dynamically linked, BuildID[sha1]=5e751e769912aef28bc63b888e5e4904b867a180, stripped

+
+ +

And executables:

+ +
+

ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, BuildID[sha1]=1c215d8895277612d3f4332836f48dd45967f69d, stripped

+
+ +

I am completely new to reverse engineering, and I have been experimenting with objdump, readelf and nm, but I still need some help.

+ +

I want to find function calls to a few functions from a library, without executing the binaries (i.e., static analysis).

+ +

With the above commands, I know the symbols are used, but I do not know which arguments are passed to the calls, or how many times the function was called.

+ +

Ideally, I would like to get something close to the original source code, e.g.

+ + + +
thelib::TheClass::theFunction(""a"", b, c);
+
+ +

but I understand this is hard to achieve. I would be content just by retrieving whether the first argument was a string literal (and its value) or something else.

+ +

Is this possible with existing tools, such as the above (possibly with specific options), or would I have to implement something of my own?

+",27609,,,,,2/26/2019 16:12,Finding function call (with arguments) in ELF file,,0,2,,,,CC BY-SA 4.0 +20726,2,,20686,2/26/2019 19:50,,2,,"

The protocol spec clearly does not apply to your device, so don't bother trying to use its checksum calculation. However it may be similar enough to provide some clues to the actual protocol.

+ +

The protocol should include some method of synchronizing the serial data stream. In the (incorrect) spec this could be done using the high nibbles (8,9,A,B) that all have bit 7 set. In your data only bytes A7 and B7 have bit 7 set, which suggests that this bit is used for synchronization.

+ +

Bytes A4-A6 and B4-B6 appear to be digit and flag data. Bytes A2 and B2 match the fixed value for sub_ADDR in the spec, which suggests they perform the same function.

+ +

A1,A3,A8,B1,B3 and bits 6-0 of A7 and B7 are unaccounted for. A1,A3,B1,B3 may be the high and low address nibbles, and A8 appears to be a constant value. Bits 2-0 of A7 and bits 3-0 of B7 are always 0 in your data, which leaves bits 6-3 of A7 and bits 6-4 of B7 as potential checksum bits.

+ +

As the digits are different on each line, so the checksum should also be different (though some lines may produce the same checksum). Combining A7 bits 6-3 and B7 bits 6-4 to produce a single 7 bit Hex number,

+ +
A7   A7    B7   B7   B7+A7
+   (6..3)     (6.4)  (Hex) (ID#)
+d8  1011   e0  110    6B     1
+c0  1000   80  000    08     2
+a8  0101   a0  010    25     3
+90  0010   c0  100    42     4
+f8  1111   e0  110    6F     5
+e0  1101   80  000    0B     6
+c8  1001   a0  010    29     7
+b0  1010   c0  100    4A     8
+98  0011   e0  110    63     9
+80  0000   80  000    00     10
+e0  1100   80  000    0C     11
+80  0000   80  000    00    (10)
+a0  0100   80  000    04     12
+c0  1000   80  000    08     (2)
+e0  1100   80  000    0C    (11)
+80  0000   80  000    00    (10)
+a0  0100   80  000    04    (12)
+c0  1000   80  000    08     (2)
+e0  1100   80  000    0C    (11)
+80  0000   80  000    00    (10)
+
+ +

The first 11 lines in your data dump all have unique 'checksums'. Looking good so far!

+ +

The next 9 lines are not so good, as they have many duplicate values. However I have not attempted to calculate checksums of address and data bytes. Depending on the algorithm used, some lines may be expected to produce the same checksum.

+ +

For a thorough analysis I would capture more data with as many different digit and flag combinations as possible, then write a program to create checksums with various algorithms until one matches the bits in A7 and B7.

+",27393,,27393,,2/26/2019 19:58,2/26/2019 19:58,,,,2,,,,CC BY-SA 4.0 +20727,2,,20718,2/26/2019 22:29,,5,,"

This appears to be a 32 bit multiplication implemented on a 16 bit architecture.

+ +

Input numbers are dx:ax and cx:bx, result in dx:ax.

+ +

The xchgs make the code confusing but if you play it through you notice it does a bunch of a seperate multiplications with the high and low 16 bit of the input numbers.

+ +

At this point I had a hunch it may be 32 bit multiplication so I tried to understand how that would look with the input numbers split and the result also split and approach the problem from the other way round.

+ +

Assuming the above inputs, one can deduce the following formulas:

+ +
dx:ax = (dx << 16) + ax
+cx:bx = (cx << 16) + bx
+
+ +

then just multiple them:

+ +
(dx:ax * cx:bx) = (dx << 16)*(cx << 16)  + (dx << 16)*bx + ax*(cx << 16) + ax*bx
+
+ +

If you take a look, we have 3 additions here instead of two. The reason is that multiplying the upper parts overflows 32 bit so the first multiplicant is dropped in the above code silently.

+ +

That leaves us

+ +
(dx:ax * cx:bx) = (dx << 16)*bx + ax*(cx << 16) + ax*bx
+
+ +

Now if you think about bitshifts and multiplications in this case every case, as a bitshift is nothing more than a multiplication by powers of 2, they commute meaning this is equivalent to:

+ +
(dx:ax * cx:bx) = (dx*bx << 16) + (ax*cx << 16) + ax*bx
+
+ +

and then we can split it back into 16 bit easily:

+ +
dx = dx*bx + ax*cx
+ax = ax*bx
+
+ +

and there you have it, the result of the multiplication of two 32 bit numbers given as 16 bit words.

+ +

And this seems to match what the code is doing (safe for bx cx swapped possibly, you may want to have a closer look on that), so it just seems to multiply numbers.

+ +

Edit: Armed with that knowledge and the response to your previous question by Igor I found this source code:

+ +

https://github.com/gandrewstone/GameMaker/blob/master/tools/BORLANDC/CRTL/CLIB/F_LXMUL.ASM

+ +

which confirms the finding.

+",23277,,23277,,2/26/2019 22:42,2/26/2019 22:42,,,,2,,,,CC BY-SA 4.0 +20730,2,,18361,2/27/2019 15:18,,0,,"

If the module does not have symbols loaded, set the symbol path to an empty folder .sympath c:\empty and issue bm moduleName!*. With no symbols available, windbg will set breakpoint only on the exported functions. Then set the symbol path to the previous value.

+",,user18424,,,,2/27/2019 15:18,,,,0,,,,CC BY-SA 4.0 +20731,1,,,2/27/2019 15:22,,1,655,"

Is it possible to find out all instances of static initialization in a elf dynamic library. +I can dump the array of function pointers in .init_array section via objdump command like this. +objdump -s -j .init_array <libname.so>

+ +

Is there a way to map these function pointers back to function names. I have unstripped library with debug symbols.

+",27618,,,,,11/9/2020 17:10,Find functions names in .init_array section in unstripped library,,1,4,,,,CC BY-SA 4.0 +20732,1,,,2/27/2019 16:05,,0,242,"

I have this function, named __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm.

+ +

And this is the relevant assembly:

+ +
mov     rdi, [rbp+var_A80]
+mov     rsi, [rbp+var_A88] 
+mov     rdx, [rbp+string_length]
+call    __ZNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEE6__initEPKcm 
+
+ +

From what I've noticed by looking at the registers before and after calling the function, the address of RSI is incremented by string_length, but I still have no idea what RDI is doing.

+ +

Another weird thing is that the string length reported by the register is 0x046, but the address is incremented by 0x040.

+ +

The RDI is 00007FFEEFBFF240 before the call, 0000000100400040 after it.

+ +

EDIT:

+ +

IDA is not letting me debug the function, as it throws SIGBUS.

+ +

I am slowly reversing the function, i'll update here with progress.

+ +

RDI is compared with 0FFFFFFFFFFFFFFF0h (Why?)

+",26890,,,,,2/27/2019 16:05,What is this function doing?,,0,3,,,,CC BY-SA 4.0 +20733,1,20740,,2/27/2019 17:14,,0,462,"

I have a function that seems to calculate the length of a string.

+ +

I have made this type declaration and it does kind of work as IDA now flags the string correctly.

+ +

__int64 __fastcall strlen(char strlen_string);

+ +

Now, RAX seems to hold the length of the string. But doing strlen@<rax> tells me that 'location rax is not allowed here'. Also, I'd like to flag exactly where the length is being used.

+ +

This is what I have now:

+ +
mov     rdi, rcx ; strlen_string
+call    strlen
+mov     [rbp+var001], rax  
+
+ +

and this is what I want to have with the new type declaration:

+ +
mov     rdi, rcx ; strlen_string
+call    strlen
+mov     [rbp+var001], rax ; string_length
+
+ +

How can I do that? Is it even possible?

+",26890,,26890,,2/27/2019 17:26,2/28/2019 10:07,How do I set the return type for this type declaration?,,1,1,,,,CC BY-SA 4.0 +20734,1,20736,,2/27/2019 18:56,,1,118,"

I have stumbled upon this:

+ +
public _oret
+__common:0000000100018000 _oret:                             
+
+__common:0000000100018000 sub     [rdi+4Fh], al
+__common:0000000100018003 db      4Fh
+__common:0000000100018003 and     [rdi+4Fh], r10b
+__common:0000000100018008 push    rdx
+__common:0000000100018009 and     [r8], rsp
+__common:000000010001800C db      40h, 46h, 43h
+__common:000000010001800C xor     r14d, [r14]
+__common:0000000100018012 xor     eax, 0A20h
+
+ +

What is this doing exactly? My RAX points here, but I don't understand anything about what the purpose of this is.

+",26890,,,,,3/2/2019 10:08,What is this assembly in the `__common` section doing?,,2,3,,,,CC BY-SA 4.0 +20736,2,,20734,2/27/2019 22:59,,3,,"

it is easily discoverable if you look at the bytes in a dump window or hex editor

+ +

or if you don't have the bytes but only the disassembly in text form +you can use some assembler like keystone to assemble it and dump
+the bytes as printable characters

+ +
C:\>cat ge0snow.py
+from keystone import *
+import binascii
+
+code = [
+    ""sub [rdi+4Fh], al"",
+    ""db 04Fh"",
+    ""and [rdi+4Fh], r10b"",
+    ""push rdx"",
+    ""and [r8], rsp"",
+    ""db 040h"",
+    ""db 046h"",
+    ""db 043h"",
+    ""xor r14d, [r14]"",
+    ""xor eax, 0A20h"",
+]
+ks = Ks(KS_ARCH_X86,KS_MODE_64)
+for i in range(0,len(code),1):
+    if( code[i][:2] == ""db""):
+        print (binascii.a2b_hex(code[i][4:6])),
+    else:
+        foo = ks.asm(code[i])
+        for j in foo[0]:
+            print chr(int(j)),
+
+
+C:\>python ge0snow.py
+( G O O D   W O R I !   @ F C E 3 6 5
+
+",3473,,,,,2/27/2019 22:59,,,,0,,,,CC BY-SA 4.0 +20737,2,,20734,2/27/2019 23:32,,1,,"

The __common section seems to be typical from Mach-O format. It contains uninitialized external globals, similar to static variables.

+ +

In your case, it holds a constant string as blabb showed it. But, you should better display it as a string (and not as code).

+ +

See: Overview of the Mach-O Executable Format, from the Apple ""Introduction to Code Size Performance Guidelines"".

+",53,,53,,3/2/2019 10:08,3/2/2019 10:08,,,,0,,,,CC BY-SA 4.0 +20740,2,,20733,2/28/2019 10:07,,0,,"

Specifying argument locations syntax is only available in the specific __usercall pseudo calling convention, which IDA supports precisely for that use case, where no other calling convention fit.

+ +

However, as mentioned in the comments, setting IDA's return value location has little impact, and it is impossible to have IDA automatically set a comment for the returned value (only arguments support that). You can, however, write a short IDAPython script for that.

+",2147,,,,,2/28/2019 10:07,,,,0,,,,CC BY-SA 4.0 +20742,2,,4294,2/28/2019 15:01,,0,,"

This is a kind of hackish method, but works.

+ +

Try to run Rohitab API Monitor. This will monitor process creations. If a process is started you will be notified and able to catch its parameter and more :)

+",27633,,,,,2/28/2019 15:01,,,,0,,,,CC BY-SA 4.0 +20743,1,20745,,2/28/2019 15:13,,2,1553,"

Mostly in the tutorials they are telling to use this tool and that tool to magically apply something and make XY work & run. I would love to know how these things are working, how is import reconstruction done generally?

+ +

For example in my case I would need dump a malware from memory, where it's manual mapped, but these import reconstruction tools usually does not support such a thing, this is why I want to learn what it is at all. (I know that there are workarounds how to make them work, but I want to know the logic behind imp reccing)

+ +

So, back to the question. Are they analyzing the code itself for calls which are residing in external modules? Or are they using some other/existing/runtime table which usually unveil the original modules/procs.

+ +

I couldn't find any good docs/description about it (except for whole the codebase of Scylla)

+",27633,,,,,2/28/2019 16:56,What does Scylla/ImpRec are doing? How to reconstruct imports?,,1,2,,,,CC BY-SA 4.0 +20745,2,,20743,2/28/2019 16:56,,3,,"

Different import reconstruction tools employ different heuristics in order to find the method used by the malware/packer because manually implemented import tables can be achieved in multiple different approaches (some without holding import tables at all).

+ +

Most import reconstruction tools usually have multiple heuristic choices, even. You can read about the different heuristics and their meaning in those tools' documentation and/or files. ImpRec's can be found with it as a text file while Scylla's can be interpreted from it's source code.

+ +

Normally, an import reconstruction tool needs to gather two pieces of information for every imported function:

+ +
    +
  1. Where is that imported function being called/referenced throughout the fixed binary. This may be either a pointer variable pointing to an imported function, or a piece of code that needs to be modified based on the imported function's address.

    + +

    If the binary creates a manual import table as part of it's execution, this involves iterating it until it's end is reached. Finding such manual import table is often left to the user, by either pointing to it directly by address or inferring it from the references done by the binary itself, as calls/jumps, after the binary is loaded and the OEP is reached.

    + +

    If the binary avoids an import table, all imports must be inferred by analyzing the code starting at OEP and recognizing indirect calls or calls made using a stored address. An import reconstruction tool may validate the target address is indeed an imported function.

  2. +
  3. Which imported function is actually being called. More often, this is the easier part of the two however it can be further complicated by packers. To resolve the imports the import reconstruction tool must obviously know to which function must every reference resolve.

    + +

    If those jumps/calls/ point to the relevant imported functions in the loaded library, resolving them is quite straightforward - enumerate all imports in the target module and match the addresses.

    + +

    If, however, the imported functions are being copied (entirely or partially) to an allocated memory region, figuring out what function is actually called may be a little more difficult.

  4. +
+",2147,,,,,2/28/2019 16:56,,,,1,,,,CC BY-SA 4.0 +20746,1,,,2/28/2019 23:07,,2,122,"

I am currently investigating GSL touch-screen controllers firmwares.

+ +

A firmware example can be found here : https://github.com/onitake/gsl-firmware/blob/master/firmware/4good/t803i/silead_ts.fw

+ +

In case the link goes down, here is a random relevant extract of said file:

+ +
04 60 03 9A 08 E0 C7 81 00 00 E8 81 73 26 08 C2 6C 25 00 DA 6F 00 80 00 01 60 00 82 7F 25 08 D8 01 40 5B 9A 01 20 03 98 00 00 80 81 00 00 00 01 00 00 00 01 00 00 00 01 0C 40 73 9A 6C 25 20 DA 00 20 10 96 02 E0 2A 83 6C 25 00 D8 B6 63 10 DA 0C 40 5B 9A 07 60 33 9B 01 E0 02 96 03 E0 A2 80 F9 FF BF 04 20 65 20 DA C0 23 00 C2 00 60 A0 80 07 00 80 02 01 30 10 82 00 22 00 C2 00 60 A0 80 05 00 80 22 40 25 00 C2 01 30 10 82 2C 25 20 C2 40 25 00 C2 00 60 A0 80 70 00 80 00 05 00 80 02 88 22 00 C2 01 60 30 9B 02 60 30 83 0D 40 00 82 1C 25 20 C2 07 00 00 03 44 62 C0 81 00 00 00 01 00 00 00 01 98 BF E3 9D 08 23 00 C2 01 60 00 82 FC 22 00 E0 01 00 A4 80 1E 00 80 0A 01 20 10 A4 F8 22 00 C2 01 80 A4 80 17 00 80 38 08 23 00 C2 02 20 2C 83 68 60 00 A2 EC 2F 00 C2 12 00 10 92 00 60 A0 80 01 A0 04 A4 04 00 80 02 10 00 10 90 00 40 C0 9F 00 00 00 01 1C 00 00 03 71 00 80 00 00 62 10 98 0C 40 04 DA 04 62 10 82 01 40 24 DA 0C 40 24 C0 F8 22 00 C2 01 80 A4 80 F0 FF BF 08 68 60 04 A2 08 23 00 C2 FF 3F 04 A0 E3 FF BF 10 01 60 00 82 00 23 00 C2 01 60 00 82 F8 22 00 E4 01 80 A4 80 20 00 80 0A 1A A0 5C A6 01 20 10 A0 08 23 00 C2 01 00 A4 80 15 00 80 18 02 E0 2C 83 04 60 00 A2 EC 2F 00 C2 10 00 10 90 00 60 A0 80 01 20 04 A0 04 00 80 02 12 00 10 92 00 40 C0 9F 72 00 80 00 00 00 00 01 1C 00 00 03 00 62 10 98 0C 40 04 DA 68 62 10 82 01 40 24 DA 0C 40 24 C0 08 23 00 C2 01 00 A4 80 F0 FF BF 08 04 60 04 A2 00 23 00 C2 FF BF 04 A4 01 60 00 82 01 80 A4 80 E4 FF BF 1A E6 FF 04 A6 08 E0 C7 81 00 00 E8 81 98 BF E3 9D 48 25 00 C2 00 61 88 80 00 20 10 AC
+
+ +

I have tried disassembling this file for quite a few architectures, but the result does not look like coherent machine code.

+ +

Which architecture should I use to disassemble this firmware?

+ +

Some info I found:

+ +
    +
  • Endianness should be flipped. This way, the strings at the end are readable.
  • +
  • There are a lot of null bytes, making me wonder if this is even executable code. If it is not, what else could it be? It is supposedly the firmware.
  • +
  • The beginning of the file looks like configuration data. Looking at offset e.g. 0x2000 seems more interesting
  • +
  • http://dl.linux-sunxi.org/touchscreen/GSL1680.pdf Page 9: we learn the MCU has a 32-bit CPU
  • +
  • There are a lot of recurring patterns, such as ""00 00 00 01"".
  • +
  • Plot of the bytes occurrences (log scale). ""Rounds values"" (e.g. 0x40,0x60,0x80) appear much more.
  • +
+ +

I am hopping someone more experiences would recognize the machine code signature of the specific CPU.

+",27637,,,,,2/28/2019 23:07,Which architecture is this firmware?,,0,0,,,,CC BY-SA 4.0 +20747,2,,18963,3/1/2019 2:43,,-1,,"

I think I had a similar issue and I got it solved by making sure that the target program has executable permissions set. Something like this in your case

+ +
chmod +x a.out
+
+ +

Hope that helps!

+",27601,,,,,3/1/2019 2:43,,,,0,,,,CC BY-SA 4.0 +20748,1,,,3/1/2019 4:31,,0,99,"

I am using an old piece of hardware which uses an RS485 serial interface. I'm trying to simulate slave node data but I don't have any documentation on the protocol and unfortunately the hardware is not supported any more.

+ +

I've got numerous examples of master and slave data for which I've tried to reverse engineer the check sequence but I've not found a match for the algorithm.

+ +

Master to Slave examples

+ +
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A5
+04 00 00 00 00 00 00 00 00 00 00 00 00 00 00 A9
+06 00 00 00 00 00 00 00 00 00 00 00 00 00 00 AB
+08 00 00 00 00 00 00 00 00 00 00 00 00 00 00 AD
+
+ +

Slave to Master examples

+ +
80 00 24 F4 67 1E A3 00 00 00 00 3F 00 FB E6 F9 81 BB 17 D1
+84 00 00 00 00 00 00 00 00 00 00 00 00 D8 3D 62 FC 6C 7C 84
+86 00 00 00 00 00 00 00 00 00 00 00 00 39 7A 9A 05 77 77 6B
+88 02 02 02 02 02 02 02 02 00 00 00 00 29 9E EA 45 76 78 21
+
+ +

It's clear the first 15 bytes for Master to Slave and first 19 bytes for Slave to Master is the data and the last byte is used as the check sequence. You can see the protocol uses the first byte as an address with the associated reply setting the most significant bit, though the addressing doesn't determine the error check byte algorithm it is included as part of the calculation.

+ +

My approach so far includes using the various online CRC and checksum calculators. I also tried to use reveng but have not managed to find a match. Any help would be much appreciated.

+",27628,,,,,3/1/2019 4:31,Reverse engineer 8 bit check sequence for old unkown protocol,,0,2,,,,CC BY-SA 4.0 +20749,1,,,3/1/2019 18:03,,1,723,"

If I have injected my own DLL into an executable (a game specifically) which imports a DLL to draw its graphics, camera, etc. How can I go about calling the DLLs functions?

+ +

I'm able to find the executables functions and hook them/call them at will, but I'm having trouble wrapping my head around how to do the same thing for the DLL which has the real goodies I want to call/manipulate.

+ +

I'm using IDA Pro to decompile the executable to get a good sense of what's happening. I'm still a beginner at this stuff but I think the dword_xxxx references is when the executable is calling DLL functions? Things like this for example:

+ +

+",27646,,2147,,3/3/2019 12:17,4/23/2021 16:16,Calling imported DLL functions from an injected DLL?,,1,0,,,,CC BY-SA 4.0 +20750,1,20758,,3/1/2019 18:25,,0,89,"

I am having some trouble understanding what this is doing.

+ +

This is the commented pseudocode.

+ +
mightGetUserInput(&std::__1::cin, &userInput) ; this fills the buffer with the user input, naming is a bit weird, but I'm not sure how to improve it?
+
+if ( userInput & 1 ) ; wtf is this doing? IDA flags userInput as _BYTE
+{
+  v54 = &userInput;  // 
+  v55 = &userInput;  // This is literally junk. Has no use. Would be nice to clean this up but how?
+  v56 = &userInput;  //
+  length_of_userInput = *((_QWORD *)&userInput + 1); I have been able to only trigger this
+}
+else
+{
+  v51 = &userInput;  //
+  v52 = &userInput;  // This is literally junk. Has no use. Would be nice to clean this up but how?
+  v53 = &userInput;  //
+  length_of_userInput = (signed int)userInput >> 1; No clue what this is doing
+} 
+
+ +

This is the actual assembly if you prefer it:

+ +
mov     [rbp+user_input], rcx
+mov     rcx, [rbp+user_input]
+movzx   edx, byte ptr [rcx]
+and     edx, 1
+cmp     edx, 0
+jz ....
+
+ +

EDIT: Someone in the comments asked for the disassembly of mightGetUserInput: here it is. DISCLAIMER: This is the pseudocode generated by IDA. It's pretty ugly and big.

+ +

I don't really know the size of userInput. It's either referred as void * or as __int64. If this is wrong (and can guide me through IDA, feel free to correct me).

+",26890,,26890,,3/1/2019 20:02,3/3/2019 12:41,Bitwise operation between byte and 1?,,2,2,,,,CC BY-SA 4.0 +20751,2,,20749,3/1/2019 18:30,,1,,"

I guess you need the base address of the loaded DLL to install your hooks. +You can simply call GetModuleHandleA/W if the DLL is already loaded or LoadLibraryA/W if the DLL is loaded later. +Once you get the base address, you have to add the RVA to this value, and you'll have the virtual address. +Or you can use GetProcAddress to retrieve the virtual address of the exported functions.

+ +

Regarding your screenshot, I didn't get it sorry. But I can't see any call instruction. I guess this is a pointer store in a global value. Probably not related to a DLL.

+",26176,,,,,3/1/2019 18:30,,,,5,,,,CC BY-SA 4.0 +20752,1,,,3/1/2019 18:39,,1,349,"

Cutter displays functions like this: +

+ +

I'm having trouble understanding the layout of the functions

+ +

For example: +

+ +

What does 184 mean? +What does the green | mean at the beginning of each line? +Why are there two jump instructions?

+",27647,,,,,3/2/2019 21:41,What does layout of Cutter/Radare2's function dissasembly mean?,,2,0,,,,CC BY-SA 4.0 +20753,2,,17110,3/2/2019 0:40,,1,,"

For anyone who sees this in the future. +The problem was indeed the 64 vs 32 bit issue that the asker thought. The mistake is in this line NtHeader = PIMAGE_NT_HEADERS(DWORD(Image) + DOSHeader->e_lfanew);.

+ +

Here, you attempt to add two pointers as a hack to get an address and cast it as a pointer to IMAGE_NT_HEADERS structure. 64-bit pointers, as @dee_two mentioned are 64bits long and DWORD-ing them truncates them; you should get a warning from the vs compiler about this.

+ +

The solution is here: don't ever typecast pointers to DWORD, especially on 64-bit architecture. Instead typecast it to a ULONG_PTR or UINT_PTR, like this: +NtHeader = PIMAGE_NT_HEADERS(ULONG_PTR(Image) + DOSHeader->e_lfanew);

+ +

I lost too much time to find this answer...

+",27649,,266,,3/8/2019 14:11,3/8/2019 14:11,,,,1,,,,CC BY-SA 4.0 +20754,2,,20750,3/2/2019 4:16,,0,,"

it may be a check for odd numbers

+ +

+",3473,,,,,3/2/2019 4:16,,,,0,,,,CC BY-SA 4.0 +20755,1,,,3/2/2019 15:37,,0,351,"

This is probably something very easy that I'm missing.

+ +

I have this operation

+ +

length_of_userInput = (signed int)(unsigned __int8)userInput >> 1;

+ +

And length_of_userInput is currently reading '4LL', type is __int64.

+ +

I'm wondering what is the correct type to give IDA to display '4LL' into a readable int?

+ +

I've tried inputting int, long (becomes __int64), and all __ints (int8,16,32) with no success.

+ +

This is the assembly:

+ +
mov     rax, [rbp+var_6E8]
+mov     [rbp+userInputBuffer], rax
+mov     rax, [rbp+userInputBuffer]
+mov     rcx, [rbp+auth_string_pointer]
+mov     [rbp+var_528], rcx
+mov     rcx, [rbp+var_528]
+mov     [rbp+var_520], rcx
+mov     rdx, [rbp+var_520]
+mov     [rbp+var_518], rdx
+mov     rdx, [rbp+var_518]
+mov     [rbp+var_510], rdx
+mov     rdx, [rbp+var_510]
+movzx   esi, byte ptr [rdx]
+and     esi, 1
+cmp     esi, 0
+mov     [rbp+length_of_userInput], rax
+mov     [rbp+var_6F8], rcx
+
+ +

(disclaimer: naming might be wrong. I hope not but I'm not sure :/ )

+",26890,,26890,,3/2/2019 18:24,3/2/2019 18:24,Handling __int64 in IDA?,,0,3,,,,CC BY-SA 4.0 +20756,2,,20752,3/2/2019 20:55,,0,,"

I don't know what the 184 means; perhaps you should scroll right the left pane to see if it appears there and what is the name of the column.

+ +

Regarding the pipes on the left, these are the arrows stretching from the functions that appear on top: these are just ""lines"" stretching down so you will be able to track the branches sources / destinations.

+",26722,,,,,3/2/2019 20:55,,,,1,,,,CC BY-SA 4.0 +20757,2,,20752,3/2/2019 21:41,,2,,"

this query has got noting to do with Reverse Engineering

+ +

184 is the size of Function +you can use afi to check what the function sizes are

+ +
[0x01012d6c]> afil
+address    size  nbbs edges    cc cost  min bound range max bound  calls locals args xref frame name
+========== ==== ===== ===== ===== ==== ========== ===== ========== ===== ====== ==== ==== ===== ====
+0x01012d6c  626    43    62    23  290 0x0101217f 110918 0x0102deb2    19    6      3    0   112 entry0
+[0x01012d6c]>
+
+ +

the green lines represent basic block boundaries / jumps to / jumps from etc

+ +

you can disable them with

+ +
e asm.lines = false
+
+ +

why two jumps who knows it is your binary may be it is handcrafted code +you have to determine that

+ +

you can have n number of unconditional jumps one below other

+ +

supposing you have code like this

+ +
#include <stdio.h>
+__declspec (naked) void foo(void) {
+    goto jumphere;
+    jumpthere:
+    goto dowork;    
+    jumphere:
+    goto jumpthere;
+    dowork:
+    printf (""i came here after jumping through hoops\n"");
+}
+void main(void){
+foo();
+}
+
+ +

if you disassemble foo() you can see jumps like you show on screenshot

+ +
[0x00401358]> af @0x401000
+[0x00401358]> pdf @0x401000
+            ;-- section..text:
+/ (fcn) fcn.00401000 20
+|   fcn.00401000 ();
+|       ,=< 0x00401000      eb06           jmp 0x401008                ; [00] -r-x section size 249856 named .text
+..
+|      ||   ; CODE XREF from fcn.00401000 (0x401008)
+|    ,.---> 0x00401004      eb04           jmp 0x40100a
+..
+|   |||||   ; CODE XREF from fcn.00401000 (0x401000)
+|   ||```-> 0x00401008      ebfa           jmp 0x401004
+|   ||      ; CODE XREF from fcn.00401000 (0x401004)
+|   ``----> 0x0040100a      68a0e14300     push str.i_came_here_after_jumping_through_hoops ; 0x43e1a0 ; ""i came here after jumping through hoops\n""
+|           0x0040100f      e85c000000     call fcn.00401070
+|           0x00401014      83c404         add esp, 4
+\           0x00401017      cc             int3
+
+ +

[0x00401358]> e asm.lines= false

+ +
[0x00401358]> pdf @0x401000
+;-- section..text:
+(fcn) fcn.00401000 20
+  fcn.00401000 ();
+0x00401000      eb06           jmp 0x401008                            ; [00] -r-x section size 249856 named .text
+..
+; CODE XREF from fcn.00401000 (0x401008)
+0x00401004      eb04           jmp 0x40100a
+..
+; CODE XREF from fcn.00401000 (0x401000)
+0x00401008      ebfa           jmp 0x401004
+; CODE XREF from fcn.00401000 (0x401004)
+0x0040100a      68a0e14300     push str.i_came_here_after_jumping_through_hoops ; 0x43e1a0 ; ""i came here after jumping through hoops\n""
+0x0040100f      e85c000000     call fcn.00401070
+0x00401014      83c404         add esp, 4
+0x00401017      cc             int3
+[0x00401358]>
+
+",3473,,,,,3/2/2019 21:41,,,,1,,,,CC BY-SA 4.0 +20758,2,,20750,3/3/2019 12:41,,0,,"

At it's most basic level, this code piece checks if the lowest bit of a given variable is set. As mentioned, one possibility is that this code checks if the variable is a even number.

+ +

Another option (which to me seems more reasonable given the limited context provided), is that the least significant bit is used as a flag/bit-field to signify the state of a value.

+ +

Several commonly seen options are:

+ +
    +
  1. specifying whether something is initialized.
  2. +
  3. what's the type of the value; either a string or an integer, for example. This can be seen in Javascript VMs, for example. To avoid storing an additional field.
  4. +
  5. An encoding of variable length values. ASN1, for example, encodes it's variable-length length fields dedicating a bit to whether this is the last byte of the length field.
  6. +
+",2147,,,,,3/3/2019 12:41,,,,0,,,,CC BY-SA 4.0 +20760,1,20766,,3/3/2019 18:37,,1,4632,"

What is the easiest way (or is there any) to modify an instruction +inside a binary opened inside IDA and save the changes to the original? +Is there a builtin assembler who's output I can place at a certain offset? How can I save back a binary after having edited the hex view?

+",16938,,,,,3/3/2019 22:21,Recommended way to modify assembler instructions in IDA,,1,0,,,,CC BY-SA 4.0 +20762,1,20764,,3/3/2019 20:01,,2,1280,"

I am solving a crack me challenge but I am stuck. The challenge executes several jne tests. The first test is the simpliest but I don't arrive to print the eax value to know the content of cmp instruction. According to this block of code :

+ +
|    ; DATA XREF from sym.main (0x804848e)
+|    0x08048497      b88a55ea8b     mov eax, 0x8bea558a
+|    0x0804849c      45             inc ebp
+|    0x0804849d      f4             hlt
+|    0x0804849e      83c004         add eax, 4
+|    0x080484a1      8a00           mov al, byte [eax]
+|    0x080484a3      38c2           cmp dl, al
+|,=< 0x080484a5      753d           jne 0x80484e4
+
+ +

How can I print the eax value to understand what are compared in the instruction ?

+ +

0x080484a1 8a00 mov al, byte [eax]

+ +

According to this question, I tried the 0x080484a1 but when I enter the command pxr 1 @ eax+0x4, nothing appears. If I enter the command pxr @ eax+0x4, this code appears :

+ +
0x080c288c  0x6f6c6165  ealo ascii
+0x080c2890  0x00796768  hgy. ascii
+
+ +

The ascii printed is linked with the string compared ksuiealohgy.

+",26974,,,,,3/3/2019 21:05,How to print eax value with Radare2?,,1,2,,,,CC BY-SA 4.0 +20764,2,,20762,3/3/2019 21:05,,3,,"

Not sure why you used pxr as you could get the output with px 1 @ eax+0x4. But another options would be that you could run this opcode and then read the register value of al to get that. But in order to do that you need to use debugger commands instead (of course you need to be in debugging mode):

+ +
[0x7f5953803e90]> dr?
+Usage: dr   Registers commands
+| dr                     Show 'gpr' registers
+<snip>
+
+ +

So to get the value of al execute during debugging session:

+ +
[0x7f5953803e90]> dr al
+0x00000090
+
+",18014,,,,,3/3/2019 21:05,,,,0,,,,CC BY-SA 4.0 +20765,1,,,3/3/2019 22:13,,0,177,"

I have a working device with a STM32F405ZGT6 in it. I want to dump the software it runs.

+ +

As far as I can tell, there's no external flash on the device, so it must be running off of the internal flash.

+ +

I've identified the SWD pins on the package and the designers helpfully left tiny attachment points to them.

+ +

As someone who's never done this on the hardware side, now what? What hardware do I need to attach to this core? What software? (I keep reading about openocd - is there something better?) How hard of a journey am I starting here?

+ +

Any help would be greatly appreciated.

+",27660,,,,,3/3/2019 22:13,Dumping flash from a running Cortex-M,,0,3,,,,CC BY-SA 4.0 +20766,2,,20760,3/3/2019 22:21,,3,,"

This is quite easy with IDA Pro:

+ +

With the cursor at the first instruction you want to modify go to Edit | Patch Program | Assemble

+ +

+ +

Change the instruction(s) as required until you are done, then press OK +

+ +

Finally choose Edit | Patch Program | Apply patches to input file (and optionally make a backup).

+ +

Here is an example: https://www.remkoweijnen.nl/blog/2013/05/23/application-compatibility-fixing-to-the-extreme/

+ +

From the Help:

+ +
+

Edit|Patch core submenu This submenu allows you to patch the image + of the input file. More precisely, IDA never modifies the input file. + The image of the input file which was loaded to the database will be + modified. You can modify the image of the input file:

+ +
    - change a byte
+    - change a word
+    - enter an assembler instruction (only for IBM PC)
+
+ +

IDA will display the original value, the current value and file + offset. If the file offset is equal to 0xFFFFFFFF then the current + byte comes from a compressed page (LX/LE/NE iterated pages, for + example) and/or it is not possible to tell the file position. You can + create a difference file and use an external tool to apply the patches + or you can apply the patches directly to the file using IDA.

+ +

The following commands are availabe:

+ +

Patch byte or word Assemble... Apply patches to input file...

+ +

See also: Produce EXE file Produce DIF file Edit submenu.

+
+",99,,,,,3/3/2019 22:21,,,,0,,,,CC BY-SA 4.0 +20768,1,20963,,3/4/2019 6:42,,6,418,"

I have written a kernel exploit (for the latest Win10 64bit) that executes (or returns to from the kernel) token stealing shellcode, which is placed in the VirtulAlloc'ed memory in the userland.

+ +

The problem is, when the exploit is executed by admin user, it works fine but if it is executed by the normal user (medium integrity), it crashes with ATTEMPTED_EXECUTE_OF_NOEXECUTE_MEMORY (fc).

+ +

When I check the permission of the usermode shellcode memory,

+ +

(standard user)

+ +
PXE at FFFF8542A150A010    PPE at FFFF8542A1402DF0    PDE at FFFF8542805BECA0    PTE at FFFF8500B7D94400
+contains 8A000000269B1867  contains 0A0000001C4F2867  contains 0A0000002673C867  contains 0000000032E84025
+pfn 269b1     ---DA--UW-V  pfn 1c4f2     ---DA--UWEV  pfn 2673c     ---DA--UWEV  pfn 32e84     ----A--UREV
+
+ +

while in admin

+ +
PXE at FFFF8944A2512028    PPE at FFFF8944A2405E48    PDE at FFFF894480BC9F28    PTE at FFFF8901793E5800
+contains 0A000000060BD867  contains 0A0000003593E867  contains 0A0000000FBAB867  contains 000000001DFF4825
+pfn 60bd      ---DA--UWEV  pfn 3593e     ---DA--UWEV  pfn fbab      ---DA--UWEV  pfn 1dff4     ----A--UREV
+
+ +

The difference is at the PXE level, there is no E bit set for standard user while admin user has execution permission on the usermode shellcode.

+ +

I tried implementing the shellcode as a function of the exploit(.exe) so it is placed in code segment (which it will probably have execution privilege), but it is same (No E set in PXE level) and crashes although !vad command outputs EXECUTE_WRITECOPY.

+ +

I have checked that ProcessMitigationPolicy's ProhibitDynamicCode is set to 0, so I don't think this is the problem.

+ +

How do you guys execute shellcode when writing kernel exploit these days? +(FYI I have disabled SMEP, SMAP via Kernel ROP).

+ +

Thanks in advance!

+",3461,,,,,3/26/2019 14:50,Returning to usermode shellcode from windows kernel (Win10),,1,2,,,,CC BY-SA 4.0 +20769,1,,,3/4/2019 11:23,,0,140,"

In IDA when disassembling a x86 EXE file there is a line

+ +
test byte ptr [ebp+XXX], cl
+
+ +

Before this line cl has a value of 0x11

+ +

The Hex-Rays decompiler plugin translates it as if (v10 &0x11).

+ +

Why is test decompiled like and?

+",27074,,245,,3/5/2019 21:08,3/5/2019 21:08,Why Ida pseudo-code translate test as AND?,,1,2,,,,CC BY-SA 4.0 +20770,2,,20769,3/4/2019 11:56,,6,,"

test is basically an and instruction except it doesn't update the left operand. +In the other hand, cmp is the equivalent of sub instruction except it doesn't update the left operand.

+ +

To sum up:

+ +
if (v & n)
+
+ +

Is compiled as test instruction.

+ +
if (v == n)
+
+ +

Is compiled as cmp instruction (or test reg, reg is n is 0x0)

+ +
v = a & n
+
+ +

Is compiled as and instruction.

+",26176,,26176,,3/4/2019 14:05,3/4/2019 14:05,,,,0,,,,CC BY-SA 4.0 +20771,1,,,3/4/2019 12:59,,4,765,"

I have some technical documentation which is supplied in the form of a generic Windows viewer and a database. The database contains different ""books"", which are represented by a bunch files:

+ +
    +
  • book.bbi - book index i.e. what pages are in the book
  • +
  • a bunch of .bli's - text entries on the page, that's a guess
  • +
  • a bunch of .ilg's - media on the page, that's a guess too
  • +
+ +

All these files have a plaintext header and what's remaining is the data which is compressed or encrypted in some way:

+ +

upd: the data_header is actually the uncompressed length of the data +

+ +

I tried running binwalk and XorSearch, but with no success. I guess now I have to debug it, but I am very, very unfamiliar with it. I am using x32dbg with the xAnalyzer plugin. I tried setting a breakpoint on ReadFile and tracing from there, but it produces an enormously large log. However I can see that it uses crush32.dll - ""old C/Win32 compression library"" and runs some ors/xors and byte shifts(shr) which kinda reinforces my thought about compression/encryption usage. +

+ +

So my question is how do I approach it from here? How do I at least dump all strings with the correspoding instructions i.e. get to the point where this byte-mess becomes readable strings? I am absolutely stuck. Thanks in advance!

+",27663,,27663,,3/6/2019 23:16,9/30/2020 18:34,Reverse engineering file format - ImageLink,,2,4,,,,CC BY-SA 4.0 +20772,1,20789,,3/4/2019 13:46,,1,2348,"

I'm working on an RFID reader that has partial implementation with ISO/IEC 14443-4 although not specifically compliant. I can decode a lot of the strings and understand the command base but I have not been able to crack the check sum.

+ +

Read commands are 4 bytes in the format

+ +
0x82 Read Chunk
+0xYY Chunk Number
+2 Byte checksum
+
+ +

the response is to echo the Read command, chunk Id, 32 Bytes of data then 2 byte checksum.

+ +

I've tried the hex strings with a bunch of standard checksum calculators as well as looking for things like logical ands but cannot find any rule for how they are generated. Is there some other techniques for this style of checksum?

+ +

Sample Data:

+ +
8208942d
+82081101004049424d2020202020363831303232393437310004000d1f0e000d220a273b
+82091d3c
+8209000d2591000e8521000e8521000e881d363955320000000000000000386c1940c1a4
+821b8e0f
+821b00000000000000000000000000000000000000000000000000000000000000008ca8
+821c317b
+821c0000000000000000000000000000000000000000000000000000000000000000b461
+821db86a
+821d0000000000000000000000000000000000000000000000000000000000000000d721
+
+",27664,,,,,3/6/2019 3:39,2byte checksum for serial traffic,,1,0,,,,CC BY-SA 4.0 +20774,1,20777,,3/4/2019 14:29,,1,713,"

I am using radare2 for disassemble an x86 binary:

+ +
$ r2 ./mynbinary
+[0x00001000]> aaa
+...
+[0x00001000]> pdf
+            ;-- section..text:
+            ;-- section.LOAD1:
+            ;-- rip:
+/ (fcn) entry0 53
+|   entry0 ();
+|           ; UNKNOWN XREF from 0x00001000 (entry0)
+|           0x00001000      e800000000     call loc.suite              ; [15] m-r-x section size 53 named LOAD1
+            ;-- suite:
+|           ; CALL XREF from 0x00001000 (entry0)
+|           0x00001005      48b968656c6c.  movabs rcx, 0x3332316f6c6c6568
+...
+
+ +

As you can see it works great.

+ +

Now, i am doing the same thing, on the same binary but with -d option in order to debug the binary

+ +
[0x7ff5a7183210]> aaa
+...
+[0x7ff5a7183210]> pdf
+p: Cannot find function at 0x7ff5a7183210
+
+ +

I don't know why it does not work in debuging...

+ +

Thanks

+",18590,,,,,3/4/2019 20:22,debugging with radare2,,1,0,,,,CC BY-SA 4.0 +20776,1,,,3/4/2019 15:19,,1,939,"

I'm learning reverse engineering and I'm trying to find where an error message is called. +I want to get in the part of the code, in the main module, where it decides to display the error message or the succeed message, but I'm having problems tracing back to the function call because I get in a point of nowhere. +This is what I do:

+ +
    +
  • Set breakpoint on MessageBoxW
  • +
  • Breakpoint on MessageBoxW
  • +
  • See the stack for the return address or run till return
  • +
+ +

But the address I get is something like: system.windows.forms.ni.123456. +If I keep tracing back I get in a point of nowhere (somewhere in user32.dll). +Hopefully someone has a better way to trace back this function or its familiar with ""system.windows.forms"" and can explain me how it works.

+",27415,,,,,2/25/2020 16:03,Trace back function call,,1,1,,,,CC BY-SA 4.0 +20777,2,,20774,3/4/2019 20:22,,2,,"

The issue is that address 0x7ff5a7183210 is not part of your binary but rather part of the kernel code that will run your code. So running aaa will not create any functions there. What you need to create a breakpoint in your code (i.e running db main) and only when your breakpoint is hit you could run pdf and it should should show you the disassembly.

+",18014,,,,,3/4/2019 20:22,,,,0,,,,CC BY-SA 4.0 +20780,1,,,3/5/2019 1:09,,8,2818,"

I need help identifying a chip and how to reset it from a new Brother's toner cartridge TN227 and TN223. This comes from the new Brother HL-L3230CDW laser printer.

+

There is currently no information on how to reverse engineer these chips to reset them, so I decided to investigate further, however I'm currently stuck.

+

Here are some pictures of the starter TN223 chip that my printer came with:

+

+

+

+

The pictures are shown as following:

+
    +
  • Pads of chip with numbers I added
  • +
  • Back of Chip
  • +
  • Light shining through chip
  • +
+

I then opened the printer to determine which pins go to what. I first used a multi-meter to determine that pads 2,3,4 are shorted to each other on each chip for each color C, Y, M, BK. I then found pad 2 was shorted to the printer frame, so I assumed that was ground. Then I looked at the wiring color. It's matched as the following:

+
    +
  • 1: purple, 2: white, 3: black, 4: red
  • +
+

When I attempted to measure any voltages from any of the pads during power-on, I was unable to measure anything.

+

I then connected a logic analyzer to the printer with the chip attached to see if I could figure out what protocol it was using. Assuming white is GND, Here's a sample of the Sigrok Pulseview received:

+

+

+

I ran the test twice and attached the Sigrok file results here and here.

+

These can be opened in Pulseview (free program) for a graphical representation of the data

+

It appears that the data is only sending when pad 4 goes high, I assume this is VCC. I then measured the voltage from pad 4 when communication occurs using an arduino and measured 3.3V. I now assume the chip is using 3.3V logic.

+

I still don't know if the pad 2 is GND since pad 3 is black which usually indicated ground, however as previously stated pad 2 is shorted to the frame of the printer. +I then attempted to connect pad 3 as GND to my logic analyzer and connect pad 2 as not ground, however something strange occurred, and the printer no longer accepted the cartridge I was messing around with. Going back to pad 2 as ground, and it started working again. I'm now assuming pad 2 is ground.

+

When investigating the data further, there seems to be a little difference between two runs. I simply turned the printer on and recorded data then immediately turned it off then back on to get my second run, however the data seemed to change slightly. To ensure it wasn't due to sampling error, I increased the sampling to 20 MHz, which includes about 20 samples per clock cycle which should be sufficient to measure the wave forms consistently. +When measuring the clock rate, I found it to be between 432-457Khz.

+

One idea I currently have is to analyze the data and find the ASCII text "brother" since each chip is required to have a manufacturing name and because the cartridges I have are from brother. More info can be found in Brothers white paper.

+

I'm not sure the best approach to analyze the binary data, since I can't identify the communication protocol, and I'm concerned that it might be encrypted. After searching patents to see if I could find more info on the chip, this was all I could find: +http://www.freepatentsonline.com/y2013/0070279.html +This suggests that the chip may be using crypto to hide info on the chip. If so, would it possible to crack it?

+

I tried analyzing the data as if it were I2C, but this doesn't seem right, Also I'm pretty sure it's not SPI. I do know there's a clock involved, so I know it has to be synchronous, but any help would be appreciated!

+",27667,,37138,,12/6/2021 19:14,12/6/2021 19:14,Identifying a toner chip and its communication protocol to re-program it,,1,7,,,,CC BY-SA 4.0 +20781,1,20785,,3/5/2019 10:21,,0,87,"

How can these pe attributes be used to identify malware.

+ +

I was going though a paper link at page 10 he mentioned.

+ +

""BYTES_REVERSED_HI and BYTES_REVERSED_LO both make ideal candidates as a primary indicator due to the significant detection rate with a low false positive rate""

+",27672,,27672,,3/5/2019 10:49,3/5/2019 15:58,what does BYTES_REVERSED_HI and BYTES_REVERSED_LO in an PE signify,,1,5,,,,CC BY-SA 4.0 +20782,1,20784,,3/5/2019 13:12,,0,370,"

I am not sure if IDA is working correctly or not.

+ +

I have the instructions

+ +
call $+5
+pop edi
+
+ +

If I understand this correctly, the program will jump forward, skipping some junk interpreted as instructions by IDA. To calculate where the execution continues, I have to get the location of pop edi (00002504), undefine everything after pop edi, and redefine as code at the location of pop edi + 5 (00002509) , or at least that's what I understood from searching here.

+ +

Now, the problem is that when I undefine everything after pop edi, IDA freaks out and does not undefine anything.

+ +

With the experience I have, when doing this I noticed that all the instructions after the undefine are well, undefined.

+ +

This does not happen. Here are some pictures to show this: +

+ +

After undefining: +

+ +

What is happening here?

+",26890,,,,,3/5/2019 15:50,IDA Pro not undefining assembly?,,2,2,,,,CC BY-SA 4.0 +20783,2,,20782,3/5/2019 15:01,,0,,"

The code is being undefined but it’s immediately converted back to instructions because of autoanalysis. It just happens very quickly so that you may not notice it.

+ +

However, your initial premise is incorrect. $ refers to the address of the current instruction so call $+5 jumps to the pop edi instruction itself and not somewhere after it. So there is no need to “fix” anything

+",60,,,,,3/5/2019 15:01,,,,2,,,,CC BY-SA 4.0 +20784,2,,20782,3/5/2019 15:50,,1,,"
call $+5
+pop edi
+
+ +

This code basically retrieves the address of the pop edi instruction into edi. The reason why this works is simple. call does two things:

+ +
    +
  • push the next instruction's address onto the stack
  • +
  • jump to the address given in its operand
  • +
+ +

But $+5 just means ""current position + 5"" and the length of this call instruction is 5 bytes, so it jumps to pop edi after pushing the address of pop edi on the stack. And then pop edi fetches that address from the stack into edi.

+ +

And why would you do that? Because sometimes you don't know where your code is located but need to supply an absolute address to someone. If you write code you can easily tell relative offsets, say that a string is 500 byte from the start of your code block. To get an absolute address you then use the call pop trick to get some anchor point and then can add whatever offset to it to turn it into an absolute address without having to know the code's location at runtime.

+",23277,,,,,3/5/2019 15:50,,,,0,,,,CC BY-SA 4.0 +20785,2,,20781,3/5/2019 15:58,,1,,"

I actually think this is a good and valid question.

+ +

And I think the answer here is - it is because it is. What I mean is that they analyzed a bunch of samples, separated them into malicious/benign, and then found out that when these flags are set it's almost always malware, so it makes a good indicator because they observed it to be a good one.

+ +

I can't think of a logical reason. It's probably a field nobody sets on purpose in legit software. Maybe some packers or whatever sets the field in order to alter the files' checksum? Google says those flags are obsolete so setting them should not have any effect at all, but it would change a file's checksum.

+",23277,,,,,3/5/2019 15:58,,,,0,,,,CC BY-SA 4.0 +20786,2,,20771,3/5/2019 16:10,,2,,"

I grabbed some crush32.dll from the Internet and it has some very interesting exports:

+ +
    +
  • cxBufDecrypt
  • +
  • cxCompressFile
  • +
  • cxExpandFile
  • +
  • cxBuf2BufCompress
  • +
  • cxBuf2BufExpand
  • +
+ +

I'd set a breakpoint on all of them, let your program run, wait for a bp to hit, inspect the stack arguments to find input/output buffers, let the function run and then look for readable data.

+",23277,,,,,3/5/2019 16:10,,,,2,,,,CC BY-SA 4.0 +20787,1,,,3/5/2019 16:36,,0,366,"

I'm trying to get the GPS lat/long data from a UDP message. It's captured on a radio dispatch console on a P25 radio system, if that helps.
+I captured this UDP message when I sent a simulated emergency from my device, which is supposed to send my user ID and lat/long coordinates. On the console it shows my user ID and my lat/long so I know it's getting to the console. +The picture is of the UDP message captured on Wireshark. My user ID is clearly there, so I know its my message, I'm pretty sure it contains the GPS coords, and I'm not sure how to decipher those. (I've redacted some identifying info fro security by the way). +The coordinates as rendered on the console are Lat: 34°2'56"" and Long: 118°10'15"" West, and my user ID is 00180011. In the picture you can see I identified what might be the most significant part of the lat/long degrees, 34 and 118, but I can't get the following bytes to match the minutes and seconds. I've tried a couple of conversion techniques from hex to lat/long, but none of my answers are making sense.
+I converted the lat/long to decimal 34.0489 and 118.1708, but can't get any further.
+Thanks for the help.

+ +

+",27676,,,,,3/5/2019 16:36,Decipher hexadecimal GPS coordinates from UDP message,,0,2,,,,CC BY-SA 4.0 +20788,1,20790,,3/5/2019 21:55,,1,1217,"

TL;DR:

+ +

Trying to mount extracted ubi file system onto /dev/mtd0 gives me the error:

+ +
libscan: scanning eraseblock 323 -- 100 % complete  
+ubiformat: 324 eraseblocks are supposedly empty
+ubiformat: error!: file ""340D04.ubi"" (size 42467348 bytes) is not multiple of eraseblock size (131072 bytes)
+           error 0 (Success)
+
+ +

How do I get that thing flashed?

+ +

Longer version:

+ +

I am looking to reverse the firmware for an Arris modem firmware, comparing older versions of the firmware to newer ones. I want to get access to the webroot of the little web server that runs the firmware because I think there is a bug in it.

+ +

In this older version, binwalk gives me this:

+ +
> binwalk spTurquoise210-700_1.6.9.bin
+
+DECIMAL       HEXADECIMAL     DESCRIPTION
+--------------------------------------------------------------------------------
+544           0x220           Certificate in DER format (x509 v3), header length: 4, sequence length: 985
+1533          0x5FD           Certificate in DER format (x509 v3), header length: 4, sequence length: 1246
+3332          0xD04           JFFS2 filesystem, little endian
+3411204       0x340D04        UBI erase count header, version: 1, EC: 0x0, VID header offset: 0x800, data offset: 0x1000
+
+ +

Extracting this binwalk -e spTurquoise210-700_1.6.9.bin yields:

+ +
total 166M
+drwxr-xr-x 3 root    root    4.0K Mar  5 16:10 .
+drwxr-xr-x 4 michael michael 4.0K Mar  5 16:10 ..
+-rw-r--r-- 1 root    root     43M Mar  5 16:10 220.crt
+-rw-r--r-- 1 root    root     39M Mar  5 16:10 340D04.ubi
+-rw-r--r-- 1 root    root     43M Mar  5 16:10 5FD.crt
+-rw-r--r-- 1 root    root     43M Mar  5 16:10 D04.jffs2
+drwxr-xr-x 3 root    root    4.0K Mar  5 16:10 jffs2-root
+
+ +

The contents of jffs2-root don't reveal the webroot. I have mounted the D04.jffs2 image, and it appears to be identical to the extracted jffs2-root directory contents. It appears to be the upgrader that flashes the firmware.

+ +

So, I figure I'll check the 340D04.ubi image. To mount that and check it, I:

+ +
> rmmod mtdram
+> du -sk 340D04.ubi
+39812   340D04.ubi
+> modprobe mtdram total_size=39812
+> flash_erase /dev/mtd0 0 0
+> ubiformat /dev/mtd0 -f 340D04.ubi
+
+ +

That's where I've hit a problem. The output of the ubiformat command is:

+ +
libscan: scanning eraseblock 323 -- 100 % complete  
+ubiformat: 324 eraseblocks are supposedly empty
+ubiformat: error!: file ""340D04.ubi"" (size 42467348 bytes) is not multiple of eraseblock size (131072 bytes)
+           error 0 (Success)
+
+ +

I cannot figure out how to flash the ubi file system onto the mtd0 device so I can (later) mount it.

+ +

Images:

+ + +",27677,,,,,3/6/2019 2:57,Reversing Arris BGW210 firmware,,1,0,,,,CC BY-SA 4.0 +20789,2,,20772,3/6/2019 2:24,,3,,"

It is a CRC-A checksum. 16bits. +Preface: From my research this is the crc for that standard.

+ +

Its calculated from start of packet up to checksum

+ +

https://crccalc.com +Put 8209 and check the result: 3C1D. This is byte swapped due to endian. Probably why you didn't find it.

+ +

Let me know if you need help, be happy to help code it. + Here is a c++ implementation of the calculation: +https://github.com/pkourany/MFRC522_RFID_Library/blob/master/src/MFRC522.cpp +This is the Arduino library for the NFC chip.

+ +

Cheers

+",18726,,18726,,3/6/2019 3:39,3/6/2019 3:39,,,,2,,,,CC BY-SA 4.0 +20790,2,,20788,3/6/2019 2:57,,2,,"

ubireader_extract_files from https://github.com/jrspruitt/ubi_reader can extract the UBI if it is padded with zeroes to the expected size.

+",12017,,,,,3/6/2019 2:57,,,,0,,,,CC BY-SA 4.0 +20791,1,20792,,3/6/2019 8:53,,5,3592,"

I am currently trying Ghidra and, I am looking at a specific function. I have the assembly code and the decompiled version of it. But, I am looking to see if I can have it as a CFG...

+ +

Does someone has a clue on how to do it?

+ +

+",53,,,,,3/6/2019 9:12,How to display the CFG of a function in Ghidra?,,1,0,,,,CC BY-SA 4.0 +20792,2,,20791,3/6/2019 9:01,,10,,"

Try Window -> Function Graph

+ +

Its even conveniently zoomable.

+ +

+",3162,,53,,3/6/2019 9:12,3/6/2019 9:12,,,,0,,,,CC BY-SA 4.0 +20796,1,,,3/6/2019 13:22,,0,456,"

When I open an executable (a.out), I can see header info: +

+ +

But when I load an object file, headers and segments aren't loaded:

+ +

+ +

The entire header section is skipped. It goes directly to main (starts at 55 48...)

+ +

Here's hexdump of the .o file:

+ +
00000000  cf fa ed fe 07 00 00 01  03 00 00 00 01 00 00 00
+00000010  04 00 00 00 50 02 00 00  00 20 00 00 00 00 00 00
+00000020  19 00 00 00 d8 01 00 00  00 00 00 00 00 00 00 00
+00000030  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
+00000040  c0 00 00 00 00 00 00 00  70 02 00 00 00 00 00 00
+00000050  c0 00 00 00 00 00 00 00  07 00 00 00 07 00 00 00
+00000060  05 00 00 00 00 00 00 00  5f 5f 74 65 78 74 00 00
+00000070  00 00 00 00 00 00 00 00  5f 5f 54 45 58 54 00 00
+00000080  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
+00000090  3b 00 00 00 00 00 00 00  70 02 00 00 04 00 00 00
+000000a0  30 03 00 00 04 00 00 00  00 04 00 80 00 00 00 00
+000000b0  00 00 00 00 00 00 00 00  5f 5f 64 61 74 61 00 00
+000000c0  00 00 00 00 00 00 00 00  5f 5f 44 41 54 41 00 00
+000000d0  00 00 00 00 00 00 00 00  3b 00 00 00 00 00 00 00
+000000e0  04 00 00 00 00 00 00 00  ab 02 00 00 00 00 00 00
+000000f0  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
+00000100  00 00 00 00 00 00 00 00  5f 5f 63 73 74 72 69 6e
+00000110  67 00 00 00 00 00 00 00  5f 5f 54 45 58 54 00 00
+00000120  00 00 00 00 00 00 00 00  3f 00 00 00 00 00 00 00
+00000130  1f 00 00 00 00 00 00 00  af 02 00 00 00 00 00 00
+00000140  00 00 00 00 00 00 00 00  02 00 00 00 00 00 00 00
+00000150  00 00 00 00 00 00 00 00  5f 5f 63 6f 6d 70 61 63
+00000160  74 5f 75 6e 77 69 6e 64  5f 5f 4c 44 00 00 00 00
+00000170  00 00 00 00 00 00 00 00  60 00 00 00 00 00 00 00
+00000180  20 00 00 00 00 00 00 00  d0 02 00 00 03 00 00 00
+00000190  50 03 00 00 01 00 00 00  00 00 00 02 00 00 00 00
+000001a0  00 00 00 00 00 00 00 00  5f 5f 65 68 5f 66 72 61
+000001b0  6d 65 00 00 00 00 00 00  5f 5f 54 45 58 54 00 00
+000001c0  00 00 00 00 00 00 00 00  80 00 00 00 00 00 00 00
+000001d0  40 00 00 00 00 00 00 00  f0 02 00 00 03 00 00 00
+000001e0  00 00 00 00 00 00 00 00  0b 00 00 68 00 00 00 00
+000001f0  00 00 00 00 00 00 00 00  24 00 00 00 10 00 00 00
+00000200  00 0d 0a 00 00 00 00 00  02 00 00 00 18 00 00 00
+00000210  58 03 00 00 03 00 00 00  88 03 00 00 14 00 00 00
+00000220  0b 00 00 00 50 00 00 00  00 00 00 00 00 00 00 00
+00000230  00 00 00 00 02 00 00 00  02 00 00 00 01 00 00 00
+00000240  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00
+*
+00000270  55 48 89 e5 48 83 ec 10  48 8d 3d 30 00 00 00 c7
+00000280  45 fc 00 00 00 00 b0 00  e8 00 00 00 00 48 8d 3d
+00000290  2a 00 00 00 89 45 f8 b0  00 e8 00 00 00 00 31 c9
+000002a0  89 45 f4 89 c8 48 83 c4  10 5d c3 4b 45 4b 00 68
+000002b0  65 6c 6c 6f 20 66 72 6f  6d 20 6d 61 63 00 68 65
+000002c0  6c 6c 6f 20 66 72 6f 6d  20 6d 61 63 32 00 00 00
+
+ +

Edit

+ +

The same thing happens when I open a Windows executable (a.exe), not a Mach-O. Why does IDA skip headers?

+",26540,,26540,,3/6/2019 13:31,3/6/2019 15:17,How to make IDA load headers of object files?,,1,0,,,,CC BY-SA 4.0 +20797,1,20799,,3/6/2019 13:48,,1,831,"

How do I set the data to floating point number in quickier way than clicking on:

+ +
Edit>Operand type>Number>Floating point
+
+ +

I have a lot of wrongly detected casual DWORD's instead of Float's and clicking on every single of them with above is a giant waste of time.

+ +

How can I automate this process, or setup a shortcut for floating point numbers? For example, how 'B' for binary or 'D' for byte/word/dword work by default.

+",15329,,266,,3/7/2019 14:37,3/7/2019 14:37,IDA - floating point operand type,,2,0,,,,CC BY-SA 4.0 +20798,2,,20797,3/6/2019 13:52,,2,,"

Type Alt+D to open up data type setup and check ""4 Float"".

+ +

Now every time you cycle through D on binary you will end up with one more datatype after dword which is float

+",15329,,,,,3/6/2019 13:52,,,,0,,,,CC BY-SA 4.0 +20799,2,,20797,3/6/2019 14:08,,1,,"
    +
  1. for data items: Alt-D, F
  2. +
  3. Menu: Options|Shortcuts..., add a custom shortcut for OpFloat action.
  4. +
+",60,,,,,3/6/2019 14:08,,,,0,,,,CC BY-SA 4.0 +20800,2,,20796,3/6/2019 15:17,,1,,"

By default IDA skips ""unimportant"" parts which are unlikely to contain code. Mach-O is actually a sort of an exception in that the header is loaded by default (although collapsed).

+ +

Sometimes you can decide which parts to load by checking [x] Manual Load in the initial load dialog.

+",60,,,,,3/6/2019 15:17,,,,1,,,,CC BY-SA 4.0 +20803,1,,,3/7/2019 3:13,,3,1143,"

I am using windbg for local kernel debugging. I want to view the disassembly of a kernel function (eg. AuxKlibQueryModuleInformation). I am not familiar with kernel debugging. Please help me do this.

+",27696,,266,,3/8/2019 14:10,3/8/2019 14:10,How to use windbg to view assembly code of kernel function?,,1,0,,,,CC BY-SA 4.0 +20805,2,,20803,3/7/2019 3:43,,3,,"

1) you should be aware local kernel debugging is not actual kernel debugging
+2) i hope you have enabled /debug on switch in bcdecdit prior to using local kernel debugging feature
+3) i hope you are aware a third party app is available which does not require setting /debug on switch

+ +

sysinternals livekd

+ +

i hope you have properly set the symbol path for downloading symbols using one of the recommended methods like setting an environment variable _NT_SYMBOL_PATH

+ +

usage is simple just run windbg ->file->kernel debugging-> local

+ +

or from a command line windbg -kl

+ +

issue .reload /f so that windbg downloads the required symbol files aka pdbs to the directory you have already set up in _NT_SYMBOL_PATH

+ +

now you can examine symbols which you need using x command

+ +
x *!*aux*     
+
+ +

here x is the command
+the * before ! (called bang in windbg ) is a wildcard for module name
+the * after ! (called bang in windbg ) is wildcard for partial symbol name matches

+ +

and windbg will show you all the matches for that partially looked up symbols as below

+ +
kd> x *!*auxklib*
+81f35962          hidusb!AuxKlibGetBugCheckData (<no parameter info>)
+81f38dfe          hidusb!AuxKlibQueryModuleInformation (<no parameter info>)
+81f38dac          hidusb!AuxKlibInitialize (<no parameter info>)
+81f45bc0          HIDCLASS!AuxKlibGetBugCheckData (<no parameter info>)
+81f4ace6          HIDCLASS!AuxKlibQueryModuleInformation (<no parameter info>)    <<<<<<<<<<<<<
+81f4ac94          HIDCLASS!AuxKlibInitialize (<no parameter info>)
+81f5a696          kbdhid!AuxKlibGetBugCheckData (<no parameter info>)
+81f5dfcc          kbdhid!AuxKlibQueryModuleInformation (<no parameter info>)  <<<<<<<<<<<<<
+81f5df7a          kbdhid!AuxKlibInitialize (<no parameter info>)
+81f66612          mouhid!AuxKlibGetBugCheckData (<no parameter info>)
+81f69e52          mouhid!AuxKlibQueryModuleInformation (<no parameter info>)  <<<<<<<<<<<<<<<<<
+81f69e00          mouhid!AuxKlibInitialize (<no parameter info>)
+88c66ff6          Wdf01000!AuxKlibGetBugCheckData (<no parameter info>)
+88c79686          Wdf01000!AuxKlibQueryModuleInformation (<no parameter info>)  <<<<<<<<<<<<<<<<<<
+88c79634          Wdf01000!AuxKlibInitialize (<no parameter info>)
+88c8b418          WDFLDR!AuxKlibQueryModuleInformation (<no parameter info>)  <<<<<<<<<<<<<
+88c8b3c6          WDFLDR!AuxKlibInitialize (<no parameter info>)
+8957e926          cdrom!AuxKlibGetBugCheckData (<no parameter info>)
+8958949c          cdrom!AuxKlibQueryModuleInformation (<no parameter info>)
+<<<<<
+8958944b          cdrom!AuxKlibInitialize (<no parameter info>)
+8f5af972          i8042prt!AuxKlibGetBugCheckData (<no parameter info>)
+8f5b51ae          i8042prt!AuxKlibQueryModuleInformation (<no parameter info>)
+8f5b515d          i8042prt!AuxKlibInitialize (<no parameter info>)
+8f5c291c          kbdclass!AuxKlibGetBugCheckData (<no parameter info>)
+8f5c701a          kbdclass!AuxKlibQueryModuleInformation (<no parameter info>)
+8f5c6fc8          kbdclass!AuxKlibInitialize (<no parameter info>)
+8f5d46b0          mouclass!AuxKlibGetBugCheckData (<no parameter info>)
+8f5d8da4          mouclass!AuxKlibQueryModuleInformation (<no parameter info>)
+8f5d8d52          mouclass!AuxKlibInitialize (<no parameter info>)
+903f4420          igdkmd32!AuxKlibGetImageExportDirectory (<no parameter info>)
+903f43ca          igdkmd32!AuxKlibGetBugCheckData (<no parameter info>)
+907169cc          igdkmd32!AuxKlibQueryModuleInformation (<no parameter info>)
+90716980          igdkmd32!AuxKlibInitialize (<no parameter info>)
+9aafd0df          srv2!AuxKlibQueryModuleInformation (<no parameter info>)           
+9aafd08e          srv2!AuxKlibInitialize (<no parameter info>)
+kd>
+
+ +

since AuxKlibQueryModuleInformation is implemented in many modules then it must be some sort of wrapper to some function which needs to be ascertained by disassembling each function possibly a system call

+ +

the uf /c command can disassemble a complete function and shows which child functions are called

+ +

if you are using a recent windbg then you can write a javascript to disassemble each function and grep for a common call in all the functions

+ +

here is a sample javascript that you can improvise

+ +
function exec ( cmdstr ) {
+    return host.namespace.Debugger.Utility.Control.ExecuteCommand( cmdstr );
+}
+function log( instr ){
+    host.diagnostics.debugLog( instr + ""\n"" );
+}
+function auximpl() {
+    var auxkqmi = exec( ""x /0 *!*auxklibquerymod*"" )
+    for ( var line of auxkqmi ) {
+        disfun = exec( ""uf /c "" + line )
+        curline = """"
+        for ( var a of disfun ) {
+            if( ! ( a.includes( ""Zw"" ) ) ) { 
+                curline = a 
+            }
+            else {
+                log( a + ""\t@\t"" + curline  ) 
+                var pstart = (curline.lastIndexOf(""("") + 1 )
+                var pend = pstart + 8
+                var prevstr = ""ub "" + curline.substring( pstart,pend  ) + "" l1""
+                var nextstr = ""u  "" + curline.substring( pstart,pend  ) + "" l1"" 
+                var previnst = exec ( prevstr )
+                var nextinst = exec ( nextstr )
+                for ( var [b,c] of [previnst , nextinst] ) {
+                    log ( b )
+                    log ( c )
+                }
+            }
+        }        
+    } 
+}
+
+ +

results will be as follows

+ +
kd> dx @$scriptContents.auximpl()
+    call to nt!ZwQuerySystemInformation (8286623c)  @     Wdf01000!AuxKlibQueryModuleInformation+0x8c (87218712):
+Wdf01000!AuxKlibQueryModuleInformation+0x8a:
+87218710 6a0b            push    0Bh
+Wdf01000!AuxKlibQueryModuleInformation+0x8c:
+87218712 ff15b8722087    call    dword ptr [Wdf01000!_imp__ZwQuerySystemInformation (872072b8)]
+    call to nt!ZwQuerySystemInformation (8286623c)  @     WDFLDR!AuxKlibQueryModuleInformation+0x8c (8722a4a4):
+WDFLDR!AuxKlibQueryModuleInformation+0x8a:
+8722a4a2 6a0b            push    0Bh
+WDFLDR!AuxKlibQueryModuleInformation+0x8c:
+8722a4a4 ff157c802287    call    dword ptr [WDFLDR!_imp__ZwQuerySystemInformation (8722807c)]
+    call to nt!ZwQuerySystemInformation (8286623c)  @     cdrom!AuxKlibQueryModuleInformation+0x8c (87ad1528):
+cdrom!AuxKlibQueryModuleInformation+0x8a:
+87ad1526 6a0b            push    0Bh
+cdrom!AuxKlibQueryModuleInformation+0x8c:
+87ad1528 ff150871ac87    call    dword ptr [cdrom!_imp__ZwQuerySystemInformation (87ac7108)]
+    call to nt!ZwQuerySystemInformation (8286623c)  @     i8042prt!AuxKlibQueryModuleInformation+0x8c (8d4d323a):
+i8042prt!AuxKlibQueryModuleInformation+0x8a:
+8d4d3238 6a0b            push    0Bh
+i8042prt!AuxKlibQueryModuleInformation+0x8c:
+8d4d323a ff1574e14c8d    call    dword ptr [i8042prt!_imp__ZwQuerySystemInformation (8d4ce174)]
+    call to nt!ZwQuerySystemInformation (8286623c)  @     kbdclass!AuxKlibQueryModuleInformation+0x8c (8d4e50a6):
+kbdclass!AuxKlibQueryModuleInformation+0x8a:
+8d4e50a4 6a0b            push    0Bh
+kbdclass!AuxKlibQueryModuleInformation+0x8c:
+8d4e50a6 ff152c114e8d    call    dword ptr [kbdclass!_imp__ZwQuerySystemInformation (8d4e112c)]
+    call to nt!ZwQuerySystemInformation (8286623c)  @     mouclass!AuxKlibQueryModuleInformation+0x8c (8d4f1e30):
+mouclass!AuxKlibQueryModuleInformation+0x8a:
+8d4f1e2e 6a0b            push    0Bh
+mouclass!AuxKlibQueryModuleInformation+0x8c:
+8d4f1e30 ff1524e14e8d    call    dword ptr [mouclass!_imp__ZwQuerySystemInformation (8d4ee124)]
+    call to nt!ZwQuerySystemInformation (8286623c)  @     srv2!AuxKlibQueryModuleInformation+0x8c (90d1c16b):
+srv2!AuxKlibQueryModuleInformation+0x8a:
+90d1c169 6a0b            push    0Bh
+srv2!AuxKlibQueryModuleInformation+0x8c:
+90d1c16b ff150c63d190    call    dword ptr [srv2!_imp__ZwQuerySystemInformation (90d1630c)]
+@$scriptContents.auximpl()
+
+",3473,,3473,,3/7/2019 17:24,3/7/2019 17:24,,,,4,,,,CC BY-SA 4.0 +20806,1,20807,,3/7/2019 9:58,,2,203,"

I would like to know if there are disassemblers based on a symbolic analysis, I'm beginner in RE, but I think that a disassembler based on symbolic techniques can be very interesting and could disassemble most of the obfuscated binaries..

+",27539,,27539,,3/7/2019 10:52,3/7/2019 10:52,Does a symbolic disassembler exist?,,1,0,,,,CC BY-SA 4.0 +20807,2,,20806,3/7/2019 10:26,,0,,"

Well, most of the disassembler based on 'symbolic execution' are kind of symbolic. The problem is that you need to modelize so much from the environment (system calls answers, interaction with other programs, ...) that most of them also use concrete execution when the program venture outside of their model.

+ +

But, you should look for symbolic execution tools such as angr, miasm and many others.

+",53,,,,,3/7/2019 10:26,,,,1,,,,CC BY-SA 4.0 +20808,1,20818,,3/7/2019 16:37,,1,659,"

I'm doing one of my first linux crackmes.

+ +

In the first blocks of code, it goes inside some anti-debug routine and inside one of those it forks and after it calls a waitpid routine. I can verify it and understand purely the code but I can't get why the creators put this code and how it can be an anti-debug technique. These are the interesting blocks.

+ +

+",22655,,,,,3/8/2019 0:10,Fork and Waitpid calls in a CTF linux binary,,1,2,,,,CC BY-SA 4.0 +20809,1,,,3/7/2019 17:41,,0,359,"

Hello I am trying to see if there is a way to see & keep track of the IP, and other registers as you would in OllyDbg or x64Dbg?

+",24346,,,,,4/6/2019 18:02,Is there a way to see & keep track of registers in dnSpy?,<.net>,1,0,,,,CC BY-SA 4.0 +20810,1,20837,,3/7/2019 17:50,,3,1547,"

I'm trying to disassemble some 6502 using Ghidra. The following (prerequisites: POSIX-style shell, Python 2.x) will generate a file called test.dat that demonstrates the issue:

+ +
python -c ""open('test.dat','wb').write(''.join([chr(x) for x in [0xa2,0xa3,0xa9,0x00,0x9d,0x40,0x00,0xca,0x10,0xfa,0x60]]))""
+
+ +

Then, from in Ghidra:

+ +
    +
  1. create new project (wherever you like)
  2. +
  3. import test.dat created above, with Language as 6502/default and Base Address as 0x400
  4. +
  5. double click test.dat in Active Project to get to the CodeBrowser window
  6. +
  7. say No when analysis is offered
  8. +
  9. go to location $400 and press D to disassemble
  10. +
+ +

The disassembly is pretty short.

+ +
                             //
+                             // RAM 
+                             // fileOffset=0, length=11
+                             // RAM: 0400-040a
+                             //
+            0400 a2 a3           LDX        #0xa3
+            0402 a9 00           LDA        #0x0
+                             LAB_0404                                        XREF[1]:     0408(j)  
+            0404 9d 40 00        STA        $0x40,X=>DAT_00e3                                = ??
+            0407 ca              DEX
+            0408 10 fa           BPL        LAB_0404
+            040a 60              RTS
+
+ +

The odd thing here is that rather than generating a label for $0040, which is the base address of the table, it's generated one for $00e3 - the first byte accessed - as if X is a TOC pointer, or similar, and $0040 is the offset. This isn't appropriate for 6502 code.

+ +

In this little example I can right click and fix up the references by hand, but I don't mind admitting that I don't want to have to do this for an entire program. 6502 code is full of this stuff.

+ +

Can I stop this from happening?

+ +

(I got very lost trying to follow through the Java source provided! - but I did figure out that this sort of reference is known as an extended reference, and appears to be common to all targets. I couldn't find anything in the documentation about these, though, or how to disable them.)

+",27694,,,,,3/10/2019 4:42,Can I stop Ghidra from creating extended references?,,2,2,,,,CC BY-SA 4.0 +20811,2,,20809,3/7/2019 17:53,,1,,"

Well, not really.

+ +

dnSpy is not a native debugger like OllyDbg/x64Dbg but rather a managed one. It is used for .NET assemblies which also are not native applications. The code is IL and it is stack-based so there are no registers on that level. Also there's not really a way to track instruction pointer.

+",18014,,,,,3/7/2019 17:53,,,,0,,,,CC BY-SA 4.0 +20813,2,,20810,3/7/2019 18:16,,1,,"

haven't used ghidra yet but checking your bytes on radare2 it appears the diassembly is right

+ +
C:\>radare2 -
+[0x00000000]> e io.cache = true
+[0x00000000]> w \xa2\xa3\xa9\x00\x9d\x40\x00\xca\x10\xfa\x60
+[0x00000000]> px 10
+- offset -   0 1  2 3  4 5  6 7  8 9  A B  C D  E F  0123456789ABCDEF
+0x00000000  a2a3 a900 9d40 00ca 10fa                 .....@....
+[0x00000000]> e asm.arch = 6502
+[0x00000000]> pd 6
+            0x00000000      a2a3           ldx #0xa3
+            0x00000002      a900           lda #0x00
+        .-> 0x00000004      9d4000         sta 0x0040,x  //(0xa3 + 0x40 == 0xe3)
+        :   0x00000007      ca             dex
+        `=< 0x00000008      10fa           bpl 0x000004
+            0x0000000a      60             rts
+[0x00000000]> af
+[0x00000000]> pdc
+function fcn.00000000 () {
+    //  3 basic blocks
+    loc_0x0:
+
+       x = #0xa3
+       a = #0x00
+   do
+   {
+        loc_0x4:
+
+           [0x0040+x ] = a
+           dex
+           bpl 0x000004             //unlikely
+       } while (?);
+  return;
+
+    loc_0xa:
+
+       rts
+(break)
+
+",3473,,,,,3/7/2019 18:16,,,,0,,,,CC BY-SA 4.0 +20814,2,,19550,3/7/2019 18:36,,1,,"

You can use Ghidra for this: https://ghidra-sre.org/

+ +

Creating new CPU descriptions is possible. There's nothing obvious in the way of documentation, but there are plenty of examples in the Ghidra/Processors folder. I managed to muddle through and create a new one for the 6502, even though I didn't quite understand everything (and still don't): https://github.com/tom-seddon/ghidra_6502

+ +

The decompiler appears to be driven entirely by these CPU descriptions, so I think all you need to do is make a new description, and you'll get C code, of a sort, out of it.

+ +

I'm not sure how feasible it is to turn a whole program into some code that you can recompile! - that's not something I need, so I haven't investigated that. But if you just need particular routines disentangling, it may suffice.

+",27694,,,,,3/7/2019 18:36,,,,0,,,,CC BY-SA 4.0 +20816,1,,,3/7/2019 21:18,,0,74,"

I'm trying to mess around with an old game and I want to reposition a UI element.

+ +

I found the address of where the x and y position get set (It's set to an X position of 90 and a Y position of 358) but it appears that because the 90 value is less than 128, the compiler optimized the assembly and changed the assembly from a push int (68 ? ? ? ?) to a push signed byte (6a ?).

+ +

This means that I'm unable to extend the X position beyond 128.

+ +

Is there any way for me to set the X position to something like 1000? I would need to somehow be able to change the assembly code to do a push int instead, correct? Will asm help me achieve that? Or what other methods could I use?

+ +

Here's what I'm talking: +

+",27646,,,,,3/7/2019 23:50,Is it possible to change a signed byte to an int in compiled assembly code?,,1,0,,,,CC BY-SA 4.0 +20817,2,,20816,3/7/2019 23:50,,2,,"

As you mentioned, 0x6a is the instruction push Ib, in this case, the operand is encoded in only one byte and it's signed (i.e. 0x6a 0xff → push -1). You need to promote to the instruction 0x68 push Iz which means expand the instruction. Your choice is rather limited. I suggest you try to find some code cave and jump on it to setup the stack as you want.

+ +

To do so:

+ +
    +
  • the first part is to find some free executable space. You might find that at the end of the .text section. Because of the alignment, you'll find some unused space padded with nop.
  • +
  • Once you find one, patch these pushes with a jmp to this location.
  • +
  • In this free space, you can freely encode your 0x68 pushes.
  • +
  • Finally, encode another jmp from this free space to jump back to the initial point.
  • +
+",26176,,,,,3/7/2019 23:50,,,,0,,,,CC BY-SA 4.0 +20818,2,,20808,3/8/2019 0:10,,1,,"

Basically, the process calls fork, on the child side it'll try to attach a debugger to the parent process:

+ +
ptrace(PTRACE_ATTACH, getppid(), 0, 0);
+
+ +

If this syscall failed, it probably means a debugger is already attached to the parent process, this is your anti-debugger. To notify the parent process, the developer relies on the exit code. It's 1 if a debugger is attached, 0 otherwise.

+ +

On the parent side, it retrieves the exit code with the macro WEXITSTATUS. In C this is defined as:

+ +
#define WEXITSTATUS(x)  (_W_INT(x) >> 8)
+
+ +

Which gives in assembly:

+ +
sar     eax, 8
+movzx   eax, al
+test    eax, eax
+jz      short no_debugger
+
+ +

This is another way to do a PTRACE_TRACEME. :)

+",26176,,,,,3/8/2019 0:10,,,,6,,,,CC BY-SA 4.0 +20819,1,,,3/8/2019 0:35,,9,4423,"

So I want to define a c++ string in ghidra struct. I noticed while reverse engineering a C++ binary, I found that, it defines a basic_string class in the symbol tree.

+ +

Now I want to define a std::string (not a pointer to it) within a struct. Is there a way to do it automatically right now, or will I still need to manually define a basic_string struct and go from there? Is there currently a way to associate classes and structs together like so (currently I think classes only act as namespaces?

+ +

I also tried just simply adding a field with the type basic_string in my struct, but it complains that basic_string is just a placeholder struct.

+ +

Haven't yet tested how ghidra would handle a std::string local variable.

+ +

EDIT: example code for what I described above:

+ +
#include <string>
+#include <iostream>
+
+struct Human {
+  int age;
+  bool is_male;
+  std::string name;
+
+public:
+  Human(int age, bool is_male, const std::string &name) : age(age), is_male(is_male), 
+    name(name) { }
+
+  void say_hello() {
+    std::cout << ""Hello, I am a "" << (is_male ? ""male "" : ""female "") << age << 
+      ""-year old named "" << name << ""!"" << std::endl;
+  }
+};
+
+int main() {
+  Human *human = new Human(17, true, ""Adam"");
+  human->say_hello();
+}
+
+ +

When you putting this into ghidra, and then do auto-fill struct fields, it will recognize the age and is_male fields, but not the name field, as this is an opaque std::string object.

+ +

Up to this point, when I was reversing another (much larger) binary, I simply manually created a new struct:

+ +
struct basic_string {
+  char *ptr;
+  size_t len;
+  char buff[0x10]
+};
+
+ +

Is there something that ghidra can do this automatically? Also I'm wondering would there be any portability issues if I just always assume the above struct?

+",23645,,23645,,3/8/2019 16:45,4/3/2019 20:34,Ghidra define c++ string,,1,3,,,,CC BY-SA 4.0 +20820,1,,,3/8/2019 10:52,,1,242,"

I want to see if anyone more experienced in reverse engineering and disassembly can take a look at this binary update file I have and maby ether help or just say if it is even possible to reverse it. +In the long run I want to add a missing functionality to it to allow for an AV input

+ +

The system in question is a bmw head unit (MMI) that has a main processor: renesas SH3 SH7709A . A secondary 16 bit processor ST10F269-T3. A xilinx FPGA. A most bus controller and dual 32mb flash memory for storage S29JL032H. +

+ +

The binary in question is a update file that has been converted from intelHEX to binary and then unpacked and can be found at this link: https://drive.google.com/file/d/1J6eLOfW17Sit-7-OnEUH_emWjf-3MIC7/view?usp=drivesdk +It does contain many debugging strings and so on at least. I have attempted some disassembly in IDA pro but would appreciate if someone else could take a look and maby see something obvious we have missed.

+ +

More documents, pictures, datacheets, dumps from a system with the same hardware that already has the functionality I want to add and so on can be found here: https://drive.google.com/folderview?id=1ue6Z0G95_-nF3svesaC4yThRse6rIdwk

+",27726,,,,,3/8/2019 10:52,Can anyone make much sense of this binary for an embedded system?,,0,4,,3/9/2019 8:25,,CC BY-SA 4.0 +20821,1,20832,,3/9/2019 3:14,,-2,194,"

A target library ""lib42.so"" has DT_DEBUG entry in the .dynamic section.

+ +

After dlopen(""lib42.so"", RTLD_LOCAL | RTLD_NOW) succeded, r_debug->d_un.d_ptr is equal to zero. Why?

+",27737,,,,,3/10/2019 0:02,DT_DEBUG not filled on dlopen,,1,0,,3/22/2019 14:36,,CC BY-SA 4.0 +20822,2,,20819,3/9/2019 5:12,,2,,"

EDIT: I misread the question. The solution I provided only shows how structures can be manually added. There does not appear to be a way in Ghidra to import a struct by text blob.

+ +
+ +

Yes.

+ +

To add a structure in Ghidra, you have to go to the Data Type Manager - for me it's the third frame on the left-most vertical pane.

+ +

+",11528,,11528,,3/9/2019 16:23,3/9/2019 16:23,,,,1,,,,CC BY-SA 4.0 +20823,1,20834,,3/9/2019 10:36,,0,39,"

I am trying to look under the hood of libnotify, and ran strace notify-send 'hello' and one of the system calls is:

+ +

sendto(5, ""AUTH\r\n"", 6, MSG_NOSIGNAL, NULL, 0) = 6

+ +

Surrounded by a:

+ +

sendmsg(5, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base=""\0"", iov_len=1}], msg_iovlen=1, msg_control=[{cmsg_len=28, cmsg_level=SOL_SOCKET, cmsg_type=SCM_CREDENTIALS, cmsg_data={pid=2555, uid=1000, gid=1000}}], msg_controllen=32, msg_flags=0}, MSG_NOSIGNAL) = 1

+ +

sendto(5, ""AUTH\r\n"", 6, MSG_NOSIGNAL, NULL, 0) = 6

+ +

recvfrom(5, ""REJECTED EXTERNAL\r\n"", 4096, 0, NULL, NULL) = 19

+ +

(Full paste https://pastebin.com/wi9Ecvmk, the above is on lines 322 - 324)

+ +

What is causing windows-like carriage returns here? I tried to look into Desktop notifications specs and to local installed libnotify's manual but found no explanation. No explanation in man pages of sendmsg or recvfrom either. And no component of this is ever going to run on any type of Windows.

+ +

So why is purely Linux program leveraging this type of newline?

+ +

(I'm running Arch Linux if that makes any difference)

+ +

Edit: I'm new in this so I'm sorry if it's really obvious and remove the question if needed.

+",27740,,27740,,3/9/2019 10:53,3/10/2019 2:27,What is causing \r\n in libnotify?,,1,0,,4/12/2019 19:42,,CC BY-SA 4.0 +20824,1,20825,,3/9/2019 14:19,,2,3432,"

Working a basic buffer overflow on a 64bit system and putting together some basic shellcode. The main program does a call to puts@plt. When I disassemble main in gdb, the opcodes show as:

+ +
e8 6b fe ff ff    0x555555554580 <puts@plt>
+
+ +

I looked at the call instruction set reference which says its a relative displacement from the next instruction. The next instruction is:

+ +
0x0000555555554715 b8 00 00 00 00 mov eax, 0x0
+
+ +

How is ""6b fe ff ff"" displaced from ""0x555555554715"" to get the puts@plt address?

+ +

I'm dropping my shellcode onto the stack, is it possible to call to puts@plt from there as a displacement from the next instruction? Or do I just need to setup the registers for a syscall?

+",27741,,,,,12/21/2020 20:09,x86-64 CALL opcode + disassembly,,1,0,,,,CC BY-SA 4.0 +20825,2,,20824,3/9/2019 14:54,,5,,"

relative address can be forward or backward from end of current instruction +or start of next instruction

+ +

that e8 00 00 00 00 will be call to the next immediate instruction
+forward can be e8 ( 00 00 00 00 .... 7f ff ff ff )
+backward can be e8 ( ff ff ff ff .... 80 00 00 00 )

+ +

so your immediate here is 0xfffffe6b that is == -0x195

+ +

negative numbers have their sign bit (31st bit ) set

+ +
0 & 0x80000000 == 0x80000000  will be False 
+and
+0xffffffff & 0x80000000 == 0x80000000  will be True
+
+C:\>python -c ""print((0xffffffff&0x80000000)==0x80000000);print((0x0&0x80000000)==0x80000000)""
+True
+False
+
+ +

so we can find out negative and positive numbers +negative jumps backward +positive jumps forward

+ +

positive 1 is 0 + 1
+positive 2 is 0 + 2 and so on ......

+ +

negative 1 is 0x10000000 - 1
+negative 2 is 0x10000000 - 2 and so on .......

+ +
>>> for i in range (1,20,1):
+...     print (  ""-%02d    ==    %x    +%02d    ==    %x"" %  (i,( 0x10000000-i) ,i,( 0 + i )) )
+...
+-01    ==    fffffff    +01    ==    1
+-02    ==    ffffffe    +02    ==    2
+-03    ==    ffffffd    +03    ==    3
+-04    ==    ffffffc    +04    ==    4
+-05    ==    ffffffb    +05    ==    5
+-06    ==    ffffffa    +06    ==    6
+-07    ==    ffffff9    +07    ==    7
+-08    ==    ffffff8    +08    ==    8
+-09    ==    ffffff7    +09    ==    9
+-10    ==    ffffff6    +10    ==    a
+-11    ==    ffffff5    +11    ==    b
+-12    ==    ffffff4    +12    ==    c
+-13    ==    ffffff3    +13    ==    d
+-14    ==    ffffff2    +14    ==    e
+-15    ==    ffffff1    +15    ==    f
+-16    ==    ffffff0    +16    ==    10
+-17    ==    fffffef    +17    ==    11
+-18    ==    fffffee    +18    ==    12
+-19    ==    fffffed    +19    ==    13
+
+ +

so i subtract 0xfffffe6b from 0x100000000

+ +
C:\>python -c ""print hex(0xfffffe6b - 0x100000000)""
+-0x195L
+
+C:\>python -c ""print hex(0x0000555555554715 + (-0x195))""
+0x555555554580L
+
+ +

demo in radare2

+ +
[0x00000000]> w \xe8\x00\x00\x00\x00 ; pd 1
+            0x00000000      e800000000     call 5
+[0x00000000]> w \xe8\x01\x00\x00\x00 ; pd 1
+            0x00000000      e801000000     call 6
+[0x00000000]> w \xe8\x02\x00\x00\x00 ; pd 1
+            0x00000000      e802000000     call 7
+[0x00000000]> w \xe8\x08\x00\x00\x00 ; pd 1
+            0x00000000      e808000000     call 0xd
+[0x00000000]> w \xe8\xff\xff\xff\xff ; pd 1
+            0x00000000      e8ffffffff     call 4
+[0x00000000]> w \xe8\xfe\xff\xff\xff ; pd 1
+            0x00000000      e8feffffff     call 3
+[0x00000000]> w \xe8\x6b\xff\xff\xff ; pd 1
+            0x00000000      e86bffffff     call 0xffffff70
+[0x00000000]> w \xe8\x6b\xfe\xff\xff ; pd 1
+            0x00000000      e86bfeffff     call 0xfffffe70
+[0x00000000]>
+
+ +

simulating an actual call opcodes

+ +
opening a random elf file 
+:\>radare2 elfie
+
+getting the address of sym.puts
+[0x08048150]> ?v sym.puts
+0x8048de0
+
+calculating relative address for force writing a call to sym.puts
+[0x08048150]> ?v sym.puts + 0x195 - 0x5
+0x8048f70
+
+seeking to target address
+[0x08048150]> s sym.puts + 0x195 - 0x5
+
+setting cache = true for writing to memory (radare2 opens in read only mode)
+[0x08048f70]> e io.cache = true
+
+checking the present disassembly
+[0x08048f70]> pd 1
+        `=< 0x08048f70      ebd7           jmp 0x8048f49
+patching a call to sym.puts in place 
+
+[0x08048f70]> w \xe8\x6b\xfe\xff\xff
+
+checking disassembly again 
+
+[0x08048f70]> pd 1
+            0x08048f70      e86bfeffff     call sym.puts
+
+",3473,,3473,,3/9/2019 21:27,3/9/2019 21:27,,,,2,,,,CC BY-SA 4.0 +20826,1,20830,,3/9/2019 18:33,,2,3903,"

I think the below instruction is used for position independent code. Could anyone please help me understand how it works?

+ +
call 135b<__x86.get_pc_thunk.ax>
+
+ +

What are the use of the below instructions after it returns?

+ + + +
add    eax,0x2d77
+mov    edx,DWORD PTR [eax-0xc]
+mov    edx,DWORD PTR [edx]
+
+ +

Is it possible to remove call 135b<__x86.get_pc_thunk.ax> from the assembly when compiling the code using GCC?

+ +

Thank you.

+ +

+",27714,,266,,3/12/2019 1:21,3/12/2019 1:21,"How does the x86 instruction, call 135b<__x86.get_pc_thunk.ax> work?",,1,0,,,,CC BY-SA 4.0 +20828,1,20836,,3/9/2019 20:07,,3,1537,"

I'm trying to decompile a function with ghidra 9.0. After a (short) while, I get :

+ +
Exception while decompiling 140062b00: process: timeout
+
+ +

I already ""succesfully"" decompiled this function using IDA hexrays and snowman. Both return a massive function with several thousand lines of code. I use quotes because I didn't validate the whole output, but the parts that I analysed made sense.

+ +

I'm thinking that this timeout error could be solved by increasing the time limit, but I haven't found any way of configuring this.

+ +

Is there any way to use ghidra to decompile this function anyway?

+",10182,,,,,3/10/2019 4:29,How to increase decompilation timeout in ghidra?,,1,0,,,,CC BY-SA 4.0 +20829,1,20833,,3/9/2019 21:42,,1,57,"

Processing a Mach-0 file with Rabin2 I'm obtaining the following result:

+ +
$ rabin2 -I mybinaryfile
+arw 00000000000000000000000000000000000000000000000000000000000000001f0000000000000000000000170000001f0000001f0000000000000000000000
+arch     x86
+baddr    0x0
+binsz    69256
+bintype  mach0
+bits     32
+canary   false
+sanitiz  false
+class    MACH0
+crypto   false
+endian   little
+havecode true
+laddr    0x0
+lang     c++
+linenum  false
+lsyms    false
+machine  386
+maxopsz  16
+minopsz  1
+nx       false
+os       darwin
+pcalign  0
+pic      false
+relocs   false
+static   true
+stripped false
+subsys   darwin
+va       true
+
+ +

Opening it with Radare2 the same ""arw"" line appears:

+ +
$ radare2 mybinaryfile
+arw 00000000000000000000000000000000000000000000000000000000000000001f0000000000000000000000170000001f0000001f0000000000000000000000
+ -- radare2-built farm beats the facebook one.
+[0x00000000]> 
+
+[0x00000000]> ih
+0x00000000  Magic       0xfeedface
+0x00000004  CpuType     0x7
+0x00000008  CpuSubType  0x3
+0x0000000c  FileType    0x1
+0x00000010  nCmds       3
+0x00000014  sizeOfCmds  840
+0x00000018  Flags       0x2000
+0x00000020  cmd       0 0x1 LC_SEGMENT
+0x00000024  cmdsize     736
+0x00000300  cmd       1 0x2 LC_SYMTAB
+0x00000304  cmdsize     24
+0x00000318  cmd       2 0x5 LC_UNIXTHREAD
+0x0000031c  cmdsize     80
+
+ +

I've searched but I didn't find any answer. What does this ""arw"" line mean?

+",27748,,27748,,3/10/2019 22:52,3/10/2019 22:52,"What this ""arw"" line means when processing Mach-0 file with Radare2 or Rabin2?",,1,1,,,,CC BY-SA 4.0 +20830,2,,20826,3/9/2019 21:58,,2,,"

the call is getting the next instructions address in eax
+notice the ax
+there are other variants of this call with bx,cx,dx at the end
+which respectively returns the next instruction address in ebx,ecx and edx

+ +

the call at 135b will look like

+ +
mov eax,[esp] 
+ret
+
+ +

so eax in your specific case will contain 0x1289
+after the addition eax will contain 0x4000
+ so edx will get what is stored at [3ff4]

+ +

this is called dereferencing pointers **foo

+ +

basically eax will contain the buffer where fscanf stores the return
+edx will contain the format string
+ecx will contain the FILE*

+",3473,,,,,3/9/2019 21:58,,,,0,,,,CC BY-SA 4.0 +20831,1,,,3/9/2019 22:08,,1,217,"

I am trying to reverse engineer firmware for an embedded device. The memory region 0xA0000000-0xA1FFFFFF is mapped to 0x80000000-0x81FFFFF. How do I setup ida to recognise this?

+",27749,,,,,3/9/2019 22:08,IDA map one memory address to another,
,0,1,,,,CC BY-SA 4.0 +20832,2,,20821,3/10/2019 0:02,,1,,"

You should probably check the dynamic linker source code to be sure but I suspect that DT_DEBUG is only filled for the main binary and not the additional modules.

+",60,,,,,3/10/2019 0:02,,,,0,,,,CC BY-SA 4.0 +20833,2,,20829,3/10/2019 1:46,,0,,"

It looks like it's a raw byte dump of an arch-specific thread_state structure (e.g. for 32bit x86). See here for where the dump happens.

+",12017,,,,,3/10/2019 1:46,,,,0,,,,CC BY-SA 4.0 +20834,2,,20823,3/10/2019 2:27,,1,,"

It's part of the authentication protocol in the D-Bus spec:

+ +
+

The protocol is a line-based protocol, where each line ends with \r\n. Each line begins with an all-caps ASCII command name containing only the character range [A-Z_], a space, then any arguments for the command, then the \r\n ending the line.

+
+ +

See here.

+",12017,,,,,3/10/2019 2:27,,,,0,,,,CC BY-SA 4.0 +20835,1,,,3/10/2019 3:54,,1,429,"

I'm trying to decompile the LUCs (customly extensioned LUAs) from both of the games but they won't decompile, they aren't encrypted and use LUA version 5.0.2 (32-bit) according to the game's code. They are headered LuaV with extra bytes of some sort. Anyone willing to help me decompile these files? If so thanks so much.

+ +

https://zenhax.com/download/file.php?id=6262 (Vol 1)

+ +

https://zenhax.com/download/file.php?id=6251 (Vol 2)

+",26767,,26767,,9/1/2019 2:36,9/1/2019 2:36,How to decompile these LUAs from the Bookworm Adventures games?,,0,5,,,,CC BY-SA 4.0 +20836,2,,20828,3/10/2019 4:29,,6,,"

You can configure the timeout in decompiler options. Go to Edit->Tool Options...->Decompiler and change ""Decompiler Timeout (seconds)"" to the desired value.

+",27751,,,,,3/10/2019 4:29,,,,0,,,,CC BY-SA 4.0 +20837,2,,20810,3/10/2019 4:42,,4,,"

To get rid of these references, you need to disable the ""Basic Constant Reference Analyzer"" located in the Analysis Options (Analysis -> Auto Analyze ...)

+ +

After this, select your code and clear it (C hotkey by default) and then disassemble again.

+",27751,,,,,3/10/2019 4:42,,,,2,,,,CC BY-SA 4.0 +20838,1,20897,,3/10/2019 8:09,,4,15098,"

I am trying to figure out the behavior of conditional jumps (JE/JNE, JZ/JNZ) in the x86 instruction set familly.

+ +

Which condition flags CMP instruction sets and how, if the result is equal and if it is not? For example:

+ +
    +
  • CMP eax, 0 (true)

  • +
  • CMP eax, 0 (false)

  • +
+",27301,,53,,3/10/2019 9:47,3/23/2019 18:42,How the CMP instruction uses condition flags?,,2,5,,,,CC BY-SA 4.0 +20839,2,,20838,3/10/2019 9:47,,4,,"

The CMP instruction does internally a SUB and sets the flags accordingly.

+ +

So all flags that are set by a SUB are also set by CMP.

+ +

Namely the flags SF, ZF, AF, PF, and CF are set.

+ +

This information is taken from the Intel manual for the processors (https://software.intel.com/en-us/articles/intel-sdm).

+",1490,,1490,,3/10/2019 9:57,3/10/2019 9:57,,,,0,,,,CC BY-SA 4.0 +20841,1,,,3/10/2019 11:03,,0,386,"

I would like to decompile a 32-bit Linux executable to C, modify some parts of it, and then compile it back. I do not care if the C code is not pretty and really hard to maintain. The only thing I care is to be able to compile it back to a 32-bit executable.

+

The program was written in C++ around 2006, but the source code was lost since then. It is not a small program, and it uses some dynamically linked libraries as well.

+

I tried Boomerang and Avast RetDec. None of them is able to provide a compilable result, but the one RetDec provides, is sometimes surprisingly readable. Unfortunately, I can not use this output to rewrite the project, because the code is really long. That is why I am looking for a way to produce compilable C code in the first place.

+",16846,,37138,,11/12/2021 19:33,11/12/2021 19:33,"Is there any decompiler, which can produce a compilable result?",,1,1,,,,CC BY-SA 4.0 +20842,1,,,3/10/2019 12:56,,1,167,"

What should I do if I have a batch of binaries to decompile with Hopper? +I know how to run a Hopper script in the UI interface, is there any way to run Hopper scripts from command line? Or any other way to decompile a lot of files easily?

+",27754,,27758,,3/11/2019 19:43,10/30/2019 10:24,Is there any way to execute Hopper scripts from command line?,