Conventions used plus preliminary remarks
I am trimming the output of GDB for brevity since it usually shows the copyright and other information at the beginning of ever session. When I reproduce the output I'll start at the first (gdb) prompt line, or in case or auto-executed commands from the first genuine output line.
In order to distinguish commands ...
I will try to answer from the kernel perspective, covering various OS's.
Memory segmentation is the old way of accessing memory regions.
All major operating systems including OSX, Linux, (from version 0.1) and Windows (from NT) are now using paging which is a better way (IMHO) of accessing memory.
Intel, has always introduced backward ...
There are several broad ways in which you could do this.
Tools such as PIN, Valgrind, or DynamoRIO allow you to dynamically change the behavior of a program. For instance, you can add calls to new functions at particular addresses, intercept library calls and change them, and much more.
The downside is that dynamic instrumentation ...
Ida Pro runs on Windows, Linux and Mac OS, so i guess the Linux equivalent of Ida Pro is Ida Pro. The debugger that's used mostly seems to be gdb, possibly enhanced with a GUI.
Hopper and Radare2 run on Linux as well.
ptrace can be detected by the fact that a process can only call ptrace once.
if ptrace() was already called by the strace executable or a debugger, we can detect it in runtime.
if (ptrace(PTRACE_TRACEME, 0, 1, 0) == -1)
printf("don't trace me !!\n");
I initially thought you wouldn't be able to dump the program, but it turns out that you can — see the second section of this answer.
Running the program
Most of the usual methods won't work because the executable is setuid. If you start the program normally, it runs with elevated privileges (euid ≠ ruid), and most debugging facilities are reserved to root. ...
VMWare can capture USB traffic between the device and the VM. A VMWare engineer even made an open-source tool for analyzing and visualizing USB logs - Virtual USB analyzer.
Alternatively, a tool for converting VMWare logs to .pcap for analyzing in Wireshark is available from Sogeti.
It is actually very simple and works for me just fine as you can see in the following gif:
First you need to figure out the tty of the terminal you want to redirect the STDIO to (a.k.a Terminal 2, T2).
You can do this by simply execute:
This tty will soon be used on the rarun2 profile file.
Meantime, let's put T2 to sleep by using sleep ...
Even stripped libraries still must retain the symbols necessary for dynamic linking. These are usually placed in a section named .dynsym and are also pointed to by the entries in the dynamic section.
For example, here's the output of readelf on a stripped Android library:
[Nr] Name Type Addr Off Size ES ...
Here is the list of few decompilation tools / resources that you may find useful.
IDA Pro + Hex-Rays decompiler
Hopper disassembler (has a decompiler)
ODA (Online Disassembler)
Injecting payload and hexadecimal addresses through program inputs depends on the type of input you get. Here is a list of all the possible inputs and the way to do it with both a pure shell environment and from within gdb.
Getting inputs from char *argv
In this case, the arguments are read from the initial command line, so the most convenient thing is:
Very often, you can change the behavior of a program by carefully hooking into it. Whether you can add the functionality you want this way depends on how the program is constructed. It helps if the program comes in the form of one main executable plus several libraries.
You can hook into any call that the program makes to shared libraries by linking your ...
Matt Cutts wrote a series of blog posts outlining the general approach of reverse-engineering a USB device and getting it working with linux, and explaining how he did this for a USB controlled toy missile launcher. You may find them a useful starting point.
It is possible to determine what command line arguments or options can be passed to a Linux executable. Of course, how this can be done will depend on the type and design of the program and on factors such as obfuscation, encryption, compression, etc.
Linux executables designed to be easily usable by humans and whose behavior ...
Hypothesis: the file is encrypted
1. Absence of Compression Signatures
The relevant compression formats that Binwalk detects are as follows: bzip2, lzop, lzip, lrzip, LZO, 7z, gzip, rzip, LZMA, zlib, and LZ4. Since running Binwalk against H201LV2.0_Cur_config.bin returns no results even though Binwalk normally will recognize any of these compression ...
Apart from the ptrace trick, you can check /proc/PID/cmdline, raise a SIGTRAP, use getppid, ...
You may want to check pangu (disclamer: I'm the author).
Pangu a a little toolset to mess around with debugging-related tools
from the GNU project, and especially on GNU/Linux x86.
After decompressing and loading the kernel, you need to find a couple of tables that encode the compressed symbol table. These are (in the usual order they are placed in binary):
kallsyms_addresses - a table of addresses to all public symbols in the kernel
kallsyms_num_syms - not a table but just an integer with total number of symbols (should match ...
FS points to the exception handling chain, CS and DS are filled from the OS with code and data segment. SS is the battery/stack segment. From what I remember, GS and ES are free.
It shouldn't matter much if kernel or user mode (they are used by some instructions like XLAT, MOVS, and some others, so you have to use them in the same way), but just in case I'm ...
There are a plethora of things programmers do not know about how ELF binaries work internally. And, unfortunately, there's almost no solid references apart from two or three which broadly cover the subject. Many tools (linkers, loaders, assemblers, debuggers, ...) remain a mystery for most of you. When it comes to linkers and loaders, the main reference is ...
First of all, I have bad news for you ! Doug Lea's malloc is almost no more used in any C library implementation (even if understanding dlmalloc can help a lot to understand new ones).
The new implementation that is most widely used is ptmalloc2 and the best way to learn about it is... to read the code... So, if you are using a Debian(-like) distribution, ...
Okay, assuming vanilla UPX you should be fine by detecting the strings UPX! or UPX0. As far as I remember this would also work on Windows.
So it's a shell one-liner such as:
grep UPX\! <filename>
grep UPX0 <filename>
... assuming the GNU version of grep here.
Another method, but using the same principle:
$ hexdump -C <filename> |...
functionpointer is declared before char buffer; on the stack so How comes it overwrites it ???
The order of objects in the stack is implementation defined. C does not mention any stack and the direction of the stack growing is also implementation-defined (usually it grows downwards but in some systems it grows upwards).
In your case functionpointer is ...
For understanding how dynamic memory allocation (the malloc, free, calloc, realloc library functions) really works there is no substitute for reading the source code of malloc(). It is well commented:
comments on chunks:
1056 malloc_chunk details:
1058 (The following includes lightly edited explanations by Colin Plumb.)
arm64 syscall numbers are defined at: https://github.com/torvalds/linux/blob/v4.17/include/uapi/asm-generic/unistd.h
This is a bit confusing since it is quite different from x86 and x86_64 and arm 32-bit which define syscall numbers under arch/, e.g. arch/arm/tools/syscall.tbl for arm 32-bit, but the arm64 file has a comment saying:
New architectures should ...
I found a small tool which uses ptrace to single step instructions from a forked child which executed another program:
This worked perfectly. I got a dump of all the instructions used. I know that it didn't run with the setuid privileges, but it will probably help me anyway. Now I only need something to disassemble the ...
In fact, ldd is loading the libraries on-the-fly to list what libraries are needed. So, on this run, you can say that libc.so.6 has been loaded at 0xb7e5c000, but you have no warranty that it will always be the case. Even with no ASLR, it is mainly depending on the loading order of the libraries that might vary from one run to another.
If you look at offset 0xDF of your backup file you'll see the two bytes:
These commonly delimit the beginning of a zlib compressed file.
In fact, the original XML config file has been split up into multiple zlib compressed blocks:
$ binwalk default-config.bin
DECIMAL HEXADECIMAL DESCRIPTION
Current IDA versions (as of 6.5) are pretty much equivalent for all three platforms. You can disassemble all file formats on all three platforms. You can definitely analyze PE and Mach-O files on Linux. Most debuggers are also available on all platforms.
A couple of features are available only in the Windows version:
WinDbg and Symbian debuggers
On Linux, in protected mode, the segment registers aren't standard "segments" anymore, instead, they're called selectors, and include information if the segment is readable/writable/executable. The real address they're pointing to is "hidden" in a table in the kernel and the segment register is used as an index into that table, but the physical address ...
In gdb you can set a syscall breakpoint with catch syscall.
If this is in 32-bit x86 (IA-32), check the syscall number in your_linux_source_dir/usr/include/asm/unistd_32.h. There is no syscall called socket in 32-bit x86, do you mean socketcall? Its number is 102.
If this is in x86-64 (AMD64), check the syscall number in your_linux_kernel_source_dir/usr/...