AFL qemu模式安装报错解决

AFL qemu模式安装报错解决

AFL qemu模式安装出现如下报错:

error: static declaration of ‘gettid’ follows non-static declaration;
error: ‘SIOCGSTAMPNS’ undeclared here (not in a function);

解决方法
将文件qemu_mode/patches/syscall.c中内容替换为以下内容:

--- qemu-2.10.0-clean/linux-user/syscall.c	2020-03-12 18:47:47.898592169 +0100
+++ qemu-2.10.0/linux-user/syscall.c	2020-03-12 19:16:41.563074307 +0100
@@ -34,6 +34,7 @@
#include <sys/resource.h>
#include <sys/swap.h>
#include <linux/capability.h>
+#include <linux/sockios.h> // https://lkml.org/lkml/2019/6/3/988
#include <sched.h>
#include <sys/timex.h>
#ifdef __ia64__
@@ -116,6 +117,8 @@ int __clone2(int (*fn)(void *), void *ch
#include "qemu.h"

+extern unsigned int afl_forksrv_pid;
+
#ifndef CLONE_IO
#define CLONE_IO                0x80000000      /* Clone io context */
#endif

@@ -256,7 +259,9 @@ static type name (type1 arg1,type2 arg2,
#endif

#ifdef __NR_gettid
-_syscall0(int, gettid)
+// taken from https://patchwork.kernel.org/patch/10862231/
+#define __NR_sys_gettid __NR_gettid
+_syscall0(int, sys_gettid)
#else
/* This is a replacement for the host gettid() and must return a host
 errno. */
@@ -6219,7 +6224,8 @@ static void *clone_func(void *arg)
  cpu = ENV_GET_CPU(env);
  thread_cpu = cpu;
  ts = (TaskState *)cpu->opaque;
-    info->tid = gettid();
+    // taken from https://patchwork.kernel.org/patch/10862231/
+    info->tid = sys_gettid();
     task_settid(ts);
     if (info->child_tidptr)
         put_user_u32(info->tid, info->child_tidptr);
@@ -6363,9 +6369,11 @@ static int do_fork(CPUArchState *env, un
                mapping.  We can't repeat the spinlock hack used above because
                the child process gets its own copy of the lock.  */
             if (flags & CLONE_CHILD_SETTID)
-                put_user_u32(gettid(), child_tidptr);
+                // taken from https://patchwork.kernel.org/patch/10862231/
+                put_user_u32(sys_gettid(), child_tidptr);
             if (flags & CLONE_PARENT_SETTID)
-                put_user_u32(gettid(), parent_tidptr);
+                // taken from https://patchwork.kernel.org/patch/10862231/
+                put_user_u32(sys_gettid(), parent_tidptr);
             ts = (TaskState *)cpu->opaque;
             if (flags & CLONE_SETTLS)
                 cpu_set_tls (env, newtls);
@@ -11402,7 +11410,8 @@ abi_long do_syscall(void *cpu_env, int n
         break;
 #endif
     case TARGET_NR_gettid:
-        ret = get_errno(gettid());
+        // taken from https://patchwork.kernel.org/patch/10862231/
+        ret = get_errno(sys_gettid());
         break;
 #ifdef TARGET_NR_readahead
     case TARGET_NR_readahead:

参考
AFL QEMU模式安装报错(afl-2.52b & qemu-2.10.0)[已解决]
AFL(afl-qemu mode)的安装和使用(一)

  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
AFL(American Fuzzy Lop)是一款非常受欢迎的模糊测试工具,可以用于发现软件程序中的漏洞和错误。而QEMU是一款开源的虚拟机监控程序,可以模拟不同的系统架构,用于测试和调试。 在进行AFL QEMU测试二进制之前,我们首先需要安装AFLQEMU这两个工具。安装完成后,我们可以通过以下步骤进行测试: 1. 准备一个待测试的二进制文件,可以是目标软件程序的可执行文件; 2. 使用AFL对二进制文件进行处理,将其变成可模糊测试的目标; 3. 设置AFLQEMU的参数,如模糊测试的目标文件、输入样本和输出文件等; 4. 运行AFL QEMU,开始进行模糊测试。AFL会根据设置的参数,生成各种变异的输入样本,并将其输入到待测试的二进制文件中; 5. QEMU会模拟执行这些输入样本,并监控目标程序的执行过程。它会在发现异常情况时,如程序崩溃或产生错误输出,记录下这些情况; 6. 模糊测试结束后,AFL会生成一个测试报告,包含了发现的漏洞和错误。我们可以根据这些报告,进行漏洞修复或错误修正。 通过AFL QEMU测试二进制,我们可以有效地发现软件程序中的潜在问题,提高程序的安全性和稳定性。同时,由于AFLQEMU都是开源工具,可以根据需要进行自定义设置和扩展,以满足不同测试需求。总之,AFL QEMU测试二进制是一种非常有效的方法,可以帮助开发人员提升软件质量和性能。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值