# The blog of malweisse's corruptions

The blog of malweisse's corruptions

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## Sanitized Emulation with QASan

DevFeed: [Sanitized Emulation with QASan](<https://devfeed.tech/articles/sanitized-emulation-with-qasan-41516.md>)

Original publisher: [Read original article](<https://andreafioraldi.github.io/articles/2019/12/20/sanitized-emulation-with-qasan.html>)

Author: malweisse's corruptions

Published: 2019-12-20T00:00:00Z

Content type: article

Language: en

Sources: [The blog of malweisse's corruptions](<https://devfeed.tech/sources/the-blog-of-malweisse-s-corruptions.md>)

Topics: [Fuzzing/Fuzz testing](<https://devfeed.tech/topics/fuzzing.md>), [Instrumentation](<https://devfeed.tech/topics/instrumentation.md>), [qemu](<https://devfeed.tech/topics/qemu.md>), [Sanitization](<https://devfeed.tech/topics/sanitization.md>), [x86](<https://devfeed.tech/topics/x86.md>), [LLVM](<https://devfeed.tech/topics/llvm.md>), [gcc](<https://devfeed.tech/topics/gcc.md>), [Linux](<https://devfeed.tech/topics/linux.md>)

Tags: [fuzzing](<https://devfeed.tech/tags/fuzzing.md>), [gcc](<https://devfeed.tech/tags/gcc.md>), [instrumentation](<https://devfeed.tech/tags/instrumentation.md>), [linux](<https://devfeed.tech/tags/linux.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [qemu](<https://devfeed.tech/tags/qemu.md>), [techniques](<https://devfeed.tech/tags/techniques.md>), [x86](<https://devfeed.tech/tags/x86.md>)

### AI overview

The article introduces QASan, a fork of user-mode QEMU that adds AddressSanitizer-based heap instrumentation to binaries. It targets Linux and BSD binaries across x86, x86_64, ARM, and ARM64, and can instrument code generated at runtime, including JIT code. The article presents QASan as a way to improve bug detection for binary-level fuzzing.

### Source excerpt

Update: the new QASan architecture is described and evaluated in this paper: https://andreafioraldi.github.io/assets/qasan-secdev20.pdf Fuzzing techniques evolved and tools are nowadays able to reach a good coverage of target programs with techniques that allow fuzzers to bypass roadblocks [1] [2] [3] [4]. But without good bug detection capabilities, a fuzzer that reaches a high coverage is less effective. Fuzzing with additional instrumentation for bug detection is one of the most important fields of research in this matter. Source-level fuzzers such as AFL [5], AFLplusplus [6], libFuzzer [7] and honggfuzz [8] can make use of sanitization frameworks provided by compilers (GCC and LLVM) such as ASAN, MSAN, UBSAN [9] to detect bugs that don't necessary crash the programs such as uninitialized reads, heap negative OOBs, and many others. Binary-level fuzzers can make use of special hardened allocators such as AFL's libdislocator to detect common misuse of the heap. However, these tools are far from complete (e.g. libdislocator's memalign is not guaranteed to be at the end of a page and so OOBs are not always detected) and don't scale with programs that frequently allocate small chunks. Static rewriting of binaries is a possible way to address this problem [10] but at the moment only x86_64 PIC ELFs binaries can be rewritten with ASAN support. As always, there is a gap between source-level and binary-level fuzzing. And, as always, I'll try to share knowledge to fill a bit this gap using the binary instrumentation tool that I love: QEMU. I created QASan (QEMU-AddressSanitizer), a fork of user-mode QEMU that introduce AddressSanitizer for heap objects into QEMU. QASan not only enables AddressSanitizer on COTS x86/x86_64/ARM/ARM64 binaries on Linux/*BSD but allows also the instrumentation of code generated at runtime (e.g. JIT) that is, of course, not supported by source-level ASAN. Note also that at the time of writing AddressSanitizer doesn't support ARM/ARM64 on Linux a

## Compare coverage for AFL++ QEMU

DevFeed: [Compare coverage for AFL++ QEMU](<https://devfeed.tech/articles/compare-coverage-for-afl-qemu-41515.md>)

Original publisher: [Read original article](<https://andreafioraldi.github.io/articles/2019/07/20/aflpp-qemu-compcov.html>)

Author: malweisse's corruptions

Published: 2019-07-20T00:00:00Z

Content type: article

Language: en

Sources: [The blog of malweisse's corruptions](<https://devfeed.tech/sources/the-blog-of-malweisse-s-corruptions.md>)

Topics: [Fuzzing/Fuzz testing](<https://devfeed.tech/topics/fuzzing.md>), [qemu](<https://devfeed.tech/topics/qemu.md>), [Instrumentation](<https://devfeed.tech/topics/instrumentation.md>), [LLVM](<https://devfeed.tech/topics/llvm.md>)

Tags: [bug](<https://devfeed.tech/tags/bug.md>), [fuzzing](<https://devfeed.tech/tags/fuzzing.md>), [instrumentation](<https://devfeed.tech/tags/instrumentation.md>), [llvm](<https://devfeed.tech/tags/llvm.md>), [qemu](<https://devfeed.tech/tags/qemu.md>)

### AI overview

The article describes AFL++ QEMU instrumentation for binary-only fuzzing, focusing on CompareCoverage. It explains how instrumentation can help fuzzers overcome hard comparisons and discusses thread-safety issues involving QEMU TCG block chaining and per-thread variables.

### Source excerpt

Recently, my AFL QEMU instrumentation based on QEMU 3.1 and TCG chaining was merged in the AFLplusplus project and I accepted to become a contributor and maintainer together with van Hauser and hexcoder. AFLplusplus is the son of the American Fuzzy Lop fuzzer and was created initially to incorporate all the best features developed in the years for the fuzzers in the AFL family and not merged in AFL cause it is not updated since November 2017. All the best features are there, you can check the full list in the PATCHES file. Introduction AFL is a battle-tested fuzzer but it can get easily stuck with hard comparison, as described here. In a program like the following the probabilities to trigger the bug are less than the probability that our universe is ruled by Ralph Wiggum. if (input == 0xabad1dea) { /* terribly buggy code */ } else { /* secure code */ } The laf-intel LLVM pass was introduced to address this problem splitting the comparison into many branches, assuming that the fuzzer can easily bypass a comparison of one byte. if (input >> 24 == 0xab){ if ((input & 0xff0000) >> 16 == 0xad) { if ((input & 0xff00) >> 8 == 0x1d) { if ((input & 0xff) == 0xea) { /* terrible code */ goto end; } } } } /* good code */ end: A similar approach was developed by j00ru for Project Zero in his CompareCoverage LLVM pass not splitting the branches this time but instrumenting at a sub-instruction level as described here. This approach was later implemented in a real fuzzer always by Google, honggfuzz but always at the source level. AFLplusplus already support the laf-intel instrumentation in LLVM mode but when comes to fuzz binaries this issue is stronger than ever (almost for public fuzzers). So, why not develop an almost equivalent technique for binary-only fuzzing? It's time to use my QEMU TCG patching skillz. AFLplusplus QEMU instrumentation Before diving in QEMU CompareCoverage, let's understand how I implemented the AFL instrumentation in QEMU 3.1.0 with TCG block chaining in

## Introduction to American Fuzzy Lop fuzzing, internals, and bug-detection strategies

DevFeed: [Introduction to American Fuzzy Lop fuzzing, internals, and bug-detection strategies](<https://devfeed.tech/articles/fuzzing-like-the-legendary-super-saiyan-afl-talk-41514.md>)

Original publisher: [Read original article](<https://andreafioraldi.github.io/articles/2019/03/29/afl-talk.html>)

Author: malweisse's corruptions

Published: 2019-03-29T00:00:00Z

Content type: tutorial

Language: en

Sources: [The blog of malweisse's corruptions](<https://devfeed.tech/sources/the-blog-of-malweisse-s-corruptions.md>)

Topics: [Fuzzing/Fuzz testing](<https://devfeed.tech/topics/fuzzing.md>), [bug](<https://devfeed.tech/topics/bug.md>)

Tags: [automatic](<https://devfeed.tech/tags/automatic.md>), [bug](<https://devfeed.tech/tags/bug.md>), [fuzzing](<https://devfeed.tech/tags/fuzzing.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [introduction](<https://devfeed.tech/tags/introduction.md>), [performance](<https://devfeed.tech/tags/performance.md>), [strategies](<https://devfeed.tech/tags/strategies.md>), [useful](<https://devfeed.tech/tags/useful.md>)

### AI overview

An introduction to fuzzers that explains the strengths and weaknesses of automatic bug detection, with a focus on using and understanding American Fuzzy Lop. It also covers strategies for improving AFL performance on specified classes of programs.

### Source excerpt

You can read here an introduction to fuzzers showing strengths and weakness of this approach in automatic bug detection. In particular the talk focus into the usage and the internals of one of the most popular fuzzers of this time: American Fuzzy Lop. You will read not only how to use it but also some useful strategies that can be applied to specified classes of programs to improve the performance of AFL.

## Build an AngrDBG frontend for your debugger

DevFeed: [Build an AngrDBG frontend for your debugger](<https://devfeed.tech/articles/build-an-angrdbg-frontend-for-your-debugger-41512.md>)

Original publisher: [Read original article](<https://andreafioraldi.github.io/articles/2018/09/22/angrdbg-frontend.html>)

Author: malweisse's corruptions

Published: 2018-09-22T00:00:00Z

Content type: tutorial

Language: en

Sources: [The blog of malweisse's corruptions](<https://devfeed.tech/sources/the-blog-of-malweisse-s-corruptions.md>)

Topics: [synchronization](<https://devfeed.tech/topics/synchronization.md>), [gdb](<https://devfeed.tech/topics/gdb.md>), [debugging](<https://devfeed.tech/topics/debugging.md>), [Process](<https://devfeed.tech/topics/process.md>)

Tags: [debugger](<https://devfeed.tech/tags/debugger.md>), [gdb](<https://devfeed.tech/tags/gdb.md>), [process](<https://devfeed.tech/tags/process.md>), [python](<https://devfeed.tech/tags/python.md>), [subclass](<https://devfeed.tech/tags/subclass.md>), [synchronization](<https://devfeed.tech/tags/synchronization.md>)

### AI overview

This tutorial explains how to build a frontend for a debugger using AngrDBG. It describes the subclass and registration required to synchronize a concrete process state with an angr state, along with methods for process control, memory and register access, executable metadata, and symbol resolution.

### Source excerpt

AngrDBG is the library that I developed to synchronize a concrete process state with an angr state. The library is debugger agnostic. A frontend library that integrates AngrDBG with a specific debugger must implements a subclass of angrdbg.Debugger and register an istance of that class as source of data using angrdbg.register_debugger. The methods that must be implemented are the following: before_stateshot(self) An event handler triggered before the synchronization setup in StateShot, just after the empty state creation after_stateshot(self, state) An event handler triggered before the StateShot return is_active(self) Return True if the debugger is running the target process input_file(self) Return a python file-like object of the target executable image_base(self) Return the process base address get_<byte|word|dword|qword>(self, addr) Read an byte|word|dword|qword from the memory as a python int (4 distinct methods) get_bytes(self, addr, size) Read a string from the memory put_<byte|word|dword|qword>(self, addr, value) Write a python in as a byte|word|dword|qword to the memory (4 distinct methods) put_bytes(self, addr, value) Write a string to the memory get_reg(self, name) Get a register value set_reg(self, name, value) Set a register value step_into(self) Call the debugger step into command run(self) Run the process inside the debugger wait_ready(self) Wait until the debugged process is ready to be inspected refresh_memory(self) Refresh the memory API of the debugger seg_by_name(self, name) Get a Segment object by the name seg_by_addr(self, name) Get a Segment object by the address get_got(self) Get a tuple (start address, end address) related to the GOT section get_plt(self) Get a tuple (start address, end address) related to the PLT section resolve_name(self, name) Resolve a symbol to its address using the name You can find here the GDBDebugger class used in the GDB frontend.

## Taint with Frida

DevFeed: [Taint with Frida](<https://devfeed.tech/articles/taint-with-frida-41520.md>)

Original publisher: [Read original article](<https://andreafioraldi.github.io/projects/2018/09/02/taint-with-frida.html>)

Author: malweisse's corruptions

Published: 2018-09-02T00:00:00Z

Content type: tutorial

Language: en

Sources: [The blog of malweisse's corruptions](<https://devfeed.tech/sources/the-blog-of-malweisse-s-corruptions.md>)

Topics: [Tool](<https://devfeed.tech/topics/tool.md>), [Software Testing](<https://devfeed.tech/topics/software-testing.md>)

Tags: [analysis](<https://devfeed.tech/tags/analysis.md>), [frida](<https://devfeed.tech/tags/frida.md>), [function](<https://devfeed.tech/tags/function.md>), [memory](<https://devfeed.tech/tags/memory.md>), [report](<https://devfeed.tech/tags/report.md>), [testing](<https://devfeed.tech/tags/testing.md>), [tool](<https://devfeed.tech/tags/tool.md>), [writing](<https://devfeed.tech/tags/writing.md>)

### AI overview

A tutorial demonstrates using Frida to write a taint-analysis module. The example taints buffers read through the read syscall, traces syscall activity, and reports the taint state when the process exits.

### Source excerpt

Frida is slow, you can't do taint analysis cit. chqmatteo I never used Frida before, so I decided some days ago to start learning it. But how to start? Obviously testing the real capabilities of the tool writing a taint analysis module. https://github.com/andreafioraldi/taint-with-frida In the following example each buffer readed using the read syscall is tainted. var taint = require("./taint"); taint.syscallPreHook = function(ctx) { var sn = ctx.rax.toInt32(); taint.log("foo", "syscall index = " + sn); if(sn == 0) { //read taint.memory.taint(ctx.rsi, ctx.rdx); taint.report(); } else if(sn == 60 || sn == 231) { //exit || exit_group taint.log("foo", "exiting"); taint.stopTracing(); taint.report(); } } taint.syscallPostHook = function(ctx) { taint.log("foo", "syscall ret = " + ctx.rax); } Interceptor.attach(ptr("0x400643"), //main function() { taint.log("foo", "enter main()"); taint.startTracing(true); //true -> hook syscalls } );

## SFTP - Google CTF 2018

DevFeed: [SFTP - Google CTF 2018](<https://devfeed.tech/articles/sftp-google-ctf-2018-41518.md>)

Original publisher: [Read original article](<https://andreafioraldi.github.io/ctf/2018/06/29/google-ctf-2018-sftp.html>)

Author: malweisse's corruptions

Published: 2018-06-29T00:00:00Z

Content type: tutorial

Language: en

Sources: [The blog of malweisse's corruptions](<https://devfeed.tech/sources/the-blog-of-malweisse-s-corruptions.md>)

Topics: [ctf](<https://devfeed.tech/topics/ctf.md>), [Reverse Engineering](<https://devfeed.tech/topics/reverse-engineering.md>), [Vulnerabilities](<https://devfeed.tech/topics/vulnerabilities.md>), [x86](<https://devfeed.tech/topics/x86.md>), [passwords](<https://devfeed.tech/topics/passwords.md>)

Tags: [authentication](<https://devfeed.tech/tags/authentication.md>), [code](<https://devfeed.tech/tags/code.md>), [ctf](<https://devfeed.tech/tags/ctf.md>), [go](<https://devfeed.tech/tags/go.md>), [ida](<https://devfeed.tech/tags/ida.md>), [ida-pro](<https://devfeed.tech/tags/ida-pro.md>), [password](<https://devfeed.tech/tags/password.md>), [reverse-engineering](<https://devfeed.tech/tags/reverse-engineering.md>), [vulnerability](<https://devfeed.tech/tags/vulnerability.md>), [x86](<https://devfeed.tech/tags/x86.md>)

### AI overview

A walkthrough of the Google CTF 2018 SFTP challenge. It uses IDA Pro and symbolic execution to recover the password, then examines the shell-like file server, reconstructs missing allocator and filesystem details, and searches the binary and source code for a vulnerability.

### Source excerpt

Crosspost from the mhackeroni website This file server has a sophisticated malloc implementation designed to thwart traditional heap exploitation techniques... The challenge file is only a x86_64 ELF binary named sftp. The active protections are the following: Partial RELRO Stack canary NX PIE FORTIFY Executing the file results in a password prompt: Let's dissect it in IDA. In the main procedure we can see that the authentication is handled by a function that returns a boolean value. Here the decompiled code: The password is hashed using a custom algorithm as we can see and the hash must be 0x8dfa to gain the access. To reverse the hash I use the IDA Pro plugin IDAngr with the following steps: Set a breakpoint just after the password scanf (as in the picture) Run the debugger and insert "a"*15 as the password when the debugged process ask for it. When the breakpoint is hitted set the avoid address to the "return 0" address and the find address to the "return result" address. Mark the password as symbolic To get an usable result some constraints must be added to the symbolic password: it must be printable and without spaces (due to scanf). Ok it's time to run the exploration engine and get a result. ... after some time ... Here you go! p&a2] is a valid password for SFTP. After the successful login we are in a shell-like prompt with some commands available: With ls we can see that in the current directory there are two nodes: flag and src. The command "get flag" returned a very interesting output, check it here. In the src folder you can find the application source code sftp.c (You can find it in the attached zip file). The next step is to analyze the code in order to find a vulnerability. You can immediately see that the files secure_allocator.h and filesystem.h included in the code are missing and so we must combine the sftp.c file with the information that we can extract from the binary with a bit of reverse engineering. Firstly we try to reconstruct secure_allocator.h i

## CyberChallenge 2018 Lesson on ROP Exploit Development

DevFeed: [CyberChallenge 2018 Lesson on ROP Exploit Development](<https://devfeed.tech/articles/rop-lesson-cc-18-41519.md>)

Original publisher: [Read original article](<https://andreafioraldi.github.io/cyberchallenge/2018/04/04/rop-lesson.html>)

Published: 2018-04-04T00:00:00Z

Content type: tutorial

Language: en

Sources: [The blog of malweisse's corruptions](<https://devfeed.tech/sources/the-blog-of-malweisse-s-corruptions.md>)

Topics: [Exploit](<https://devfeed.tech/topics/exploit.md>), [software-development](<https://devfeed.tech/topics/software-development.md>)

Tags: [development](<https://devfeed.tech/tags/development.md>), [exploit](<https://devfeed.tech/tags/exploit.md>)

### AI overview

This page provides slides for a CyberChallenge 2018 lesson on return-oriented programming (ROP) exploit development.

### Source excerpt

The slides for the CyberChallenge 2018 lesson about ROP exploit development:

## SharifCTF 8 - t00p\_secrets

DevFeed: [SharifCTF 8 - t00p\_secrets](<https://devfeed.tech/articles/sharifctf-8-t00p-secrets-41517.md>)

Original publisher: [Read original article](<https://andreafioraldi.github.io/ctf/2018/02/04/t00p_secrets.html>)

Author: malweisse's corruptions

Published: 2018-02-04T00:00:00Z

Content type: tutorial

Language: en

Sources: [The blog of malweisse's corruptions](<https://devfeed.tech/sources/the-blog-of-malweisse-s-corruptions.md>)

Topics: [bug](<https://devfeed.tech/topics/bug.md>), [Exploit](<https://devfeed.tech/topics/exploit.md>)

Tags: [bug](<https://devfeed.tech/tags/bug.md>), [exploit](<https://devfeed.tech/tags/exploit.md>), [heap](<https://devfeed.tech/tags/heap.md>), [secrets](<https://devfeed.tech/tags/secrets.md>)

### AI overview

A SharifCTF 8 write-up analyzes an off-by-one overflow in a secret-management service and develops a House of Einherjar heap exploit to overwrite __free_hook. It also uses a hidden option involving the master key and heap information leaked from freed memory.

### Source excerpt

Crosspost from the TRX website Decompiling the binary we can discover the master key. Running the program the output is this: $ ./t00p_secrets Welcome to SUCTF secret management service Enter your master key: wjigaep;r[jg]ahrg[es9hrg 1. Create a secret 2. Delete a secret 3. Edit a secret 4. Print secret 5. Print a secret 6. Exit > There are six options: create, delete, edit... ok it's a heap pwn. Exploring the create and edit options we can see that the content of a secret can be a string or a binary data. The function that reads the content of a secret is the following: __int64 __fastcall read_content(void *dest, signed __int64 size, __int16 is_string) { __int16 v4; // [rsp+Ch] [rbp-24h] unsigned int v5; // [rsp+24h] [rbp-Ch] v4 = is_string; if ( size > 0 ) { v5 = read(0, dest, size); if ( v4 ) *((_BYTE *)dest + v5) = 0; //overflow if v5==size } return 0LL; } Note: dest is a buffer allocated with malloc(size). The bug is here. If the user choice is that a secret content is a string there is an off-by-one overflow due to the string terminator. House of Einherjar can be used to force malloc to return a pointer near an area where you can write. The idea is to force malloc to return a pointer near the global variable ptr + 0xA in .data (where the program stores the pointers to the secrets contents) so we can write the address of __free_hook (not a GOT entry beacause there is Full RELRO) in that area and then use edit to write in __free_hook. Firstly I used the overflow to crash the program and retrieve some offsets of libc symbols from the crash dump. create(0, 24) create(1, 24) edit(0, "a"*24) #overflow, write 0 to the last byte of the size field in the chunck 1 delete(1) #free search for a free chunck in [address of 1] + 0xaaaaaaaa, so it crashes with 'free(): invalid pointer' Using libc database I found that the service is using libc6_2.23-0ubuntu10_amd64.so. Let's write the exploit. In the main procedure we can see that there is an hidden option, the seventh, that ca