VsCode编译调试Suricata

2024-06-02 14:20
文章标签 编译 调试 vscode suricata

本文主要是介绍VsCode编译调试Suricata,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

原理:

Suricata 源码说到底也是一个makefile项目,Code 是绝对可以编译的,本质上还是模拟 make 命令,然后使用GDB调试c程序。

有一个视频: https://www.bilibili.com/video/BV1Aw4m1U7Mo/?vd_source=b6d10e8288ab2f9afe2227a94446a6c3

c_cpp_properties.json:

实际上这部分是关于 代码悬停提示,智能提示这一方面的,

关于includepath和browse ->path的介绍有一个视频:https://www.bilibili.com/video/BV1Hm411r7nq/?vd_source=b6d10e8288ab2f9afe2227a94446a6c3

{"configurations": [{"name": "daxian-2023-12-24","includePath": ["${workspaceFolder}/**","/usr/include/**","/usr/local/include/**","/usr/include/netinet/**"],"defines": [],"compilerPath": "/usr/bin/g++","cStandard": "c17","cppStandard": "c++17","intelliSenseMode": "gcc-x64","browse": {"path": ["${workspaceFolder}","/usr/include/netinet"],"limitSymbolsToIncludedHeaders": true,"databaseFilename": ""},"configurationProvider": "ms-vscode.makefile-tools"}],"version": 4
}

settings.json

这其实和编译无关,涉及到一些 vsocode 的配置

{"window.zoomLevel": 0.5,"files.exclude": {"**/.exe": true  //排除尾缀为.exe的文件不在编辑器左边的目录菜单中显示},// "C_Cpp.intelliSenseEngine": "Tag Parser",/*或者是default模式(默认也是这个)*/"C_Cpp.exclusionPolicy": "checkFilesAndFolders","C_Cpp.default.intelliSenseMode": "gcc-x64","C_Cpp.default.compilerPath": "/usr/bin/g++","C_Cpp.default.cppStandard": "c++17","debug.onTaskErrors": "abort","files.associations": {"iostream": "cpp","suricata-common.h": "c","cstdlib": "c","array": "c","istream": "c","ostream": "c","tuple": "c","type_traits": "c","utility": "c","fstream": "c","streambuf": "c","queue.h": "c","deque": "c","string": "c","unordered_map": "c","vector": "c","string_view": "c","initializer_list": "c","functional": "c","threads.h": "c","threadvars.h": "c","util-lua.h": "c","util-lua-http.h": "c","detect-threshold.h": "c","*.tcc": "c","numeric": "c","sstream": "c","detect-engine-register.h": "c","detect-engine-build.h": "c"},"C_Cpp.errorSquiggles": "enabled","workbench.editor.wrapTabs": false,/*选项卡是否换行*/"editor.wordWrap": "off",/*编辑区域是自动换行*/// "editor.renderWhitespace": "all"/*让空格显示为点  selection*/}

tasks.json

执行编译任务, ctrl+b执行编译任务,会选择第一个make

{"version": "2.0.0","tasks": [{"label": "build_suricata","type": "shell","command": "make",  //suricata编译"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"presentation": {"echo": true,"reveal": "always","focus": false,"panel": "dedicated","showReuseMessage": false,"clear": true}},//下面是C++的不予理会{"type": "shell",  //或者是process 区别找文档"label": "C/C++: g++ build active file", //任务标签"command": "/usr/bin/g++","args": ["-g","-Wall","-std=c++17","${fileDirname}/*.cpp","-o","${fileDirname}/${fileBasenameNoExtension}"],"detail": "compiler: /usr/bin/g++","group": {"kind": "build","isDefault": true},"presentation": {"echo": true,"reveal": "always", //是否将集成终端面板置于前面"focus": true, //是否获得焦点"panel": "dedicated","showReuseMessage": false, //控制是否显示“终端将被任务重用,按任意键关闭它”消息"clear": true // 运行前清除终端},"problemMatcher": ["$gcc"]},],"options": {"shell": {"executable": "/bin/bash","args": ["-c"]},"env": {"PATH": "/usr/bin:${env:PATH}"}}
}//官方文档:https://code.visualstudio.com/docs/editor/tasks

launch.json

make 以后不用make install的

make编译之后会在src/.libs/下生成临时的可执行程序, gdb可以调试这个程序,args是执行调试时候加入的参数,--runmode  single是只有一个处理线程的模式,(参照suricata的运行模式,要注意不是任何情况下都有single模式的),这里读入的流量是从pcap文件中拿到的(这个文件是通过wireshark抓包工具得到的),关于这些参数在这里

{"version": "0.2.0","configurations": [{"type": "cppdbg","request": "launch","name": "DeBug_suricata","program": "${workspaceFolder}/src/.libs/suricata",// "program": "/usr/local/bin/suricata",  //make install 后可执行程序的安装位置"args": ["--runmode","single","-r", "/home/daxian/ping.pcap","-vvvv","-c","/home/daxian/Desktop/zs/suricata-6.0.8/suricata.yaml","-l","/home/daxian/Desktop/zs/suricata-log-dir","-S","/home/daxian/Desktop/zs/rules/test.rules","-k","none"// "-i",// "ens33",// "--list-keywords=csv",// "--list-app-layer-protos"],"stopAtEntry": false,"cwd": "${workspaceFolder}","environment": [],"externalConsole": false,"MIMode": "gdb","miDebuggerPath": "/usr/bin/gdb","preLaunchTask": "build_suricata"},//下面是c++的 不予理会{"name": "g++ - Build and debug active file","type": "cppdbg","request": "launch","program": "${fileDirname}/${fileBasenameNoExtension}","args": [],"stopAtEntry": false,"cwd": "${workspaceFolder}","environment": [],"externalConsole": false,"MIMode": "gdb","miDebuggerPath": "/usr/bin/gdb","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}],"preLaunchTask": "C/C++: g++ build active file"},]
}

这篇关于VsCode编译调试Suricata的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1024211

相关文章

ASIO网络调试助手之一:简介

多年前,写过几篇《Boost.Asio C++网络编程》的学习文章,一直没机会实践。最近项目中用到了Asio,于是抽空写了个网络调试助手。 开发环境: Win10 Qt5.12.6 + Asio(standalone) + spdlog 支持协议: UDP + TCP Client + TCP Server 独立的Asio(http://www.think-async.com)只包含了头文件,不依

如何在Visual Studio中调试.NET源码

今天偶然在看别人代码时,发现在他的代码里使用了Any判断List<T>是否为空。 我一般的做法是先判断是否为null,再判断Count。 看了一下Count的源码如下: 1 [__DynamicallyInvokable]2 public int Count3 {4 [__DynamicallyInvokable]5 get

计算机毕业设计 大学志愿填报系统 Java+SpringBoot+Vue 前后端分离 文档报告 代码讲解 安装调试

🍊作者:计算机编程-吉哥 🍊简介:专业从事JavaWeb程序开发,微信小程序开发,定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事,生活就是快乐的。 🍊心愿:点赞 👍 收藏 ⭐评论 📝 🍅 文末获取源码联系 👇🏻 精彩专栏推荐订阅 👇🏻 不然下次找不到哟~Java毕业设计项目~热门选题推荐《1000套》 目录 1.技术选型 2.开发工具 3.功能

maven 编译构建可以执行的jar包

💝💝💝欢迎莅临我的博客,很高兴能够在这里和您见面!希望您在这里可以感受到一份轻松愉快的氛围,不仅可以获得有趣的内容和知识,也可以畅所欲言、分享您的想法和见解。 推荐:「stormsha的主页」👈,「stormsha的知识库」👈持续学习,不断总结,共同进步,为了踏实,做好当下事儿~ 专栏导航 Python系列: Python面试题合集,剑指大厂Git系列: Git操作技巧GO

vscode中文乱码问题,注释,终端,调试乱码一劳永逸版

忘记咋回事突然出现了乱码问题,很多方法都试了,注释乱码解决了,终端又乱码,调试窗口也乱码,最后经过本人不懈努力,终于全部解决了,现在分享给大家我的方法。 乱码的原因是各个地方用的编码格式不统一,所以把他们设成统一的utf8. 1.电脑的编码格式 开始-设置-时间和语言-语言和区域 管理语言设置-更改系统区域设置-勾选Bata版:使用utf8-确定-然后按指示重启 2.vscode

Windows环境利用VS2022编译 libvpx 源码教程

libvpx libvpx 是一个开源的视频编码库,由 WebM 项目开发和维护,专门用于 VP8 和 VP9 视频编码格式的编解码处理。它支持高质量的视频压缩,广泛应用于视频会议、在线教育、视频直播服务等多种场景中。libvpx 的特点包括跨平台兼容性、硬件加速支持以及灵活的接口设计,使其可以轻松集成到各种应用程序中。 libvpx 的安装和配置过程相对简单,用户可以从官方网站下载源代码

起点中文网防止网页调试的代码展示

起点中文网对爬虫非常敏感。如图,想在页面启用调试后会显示“已在调试程序中暂停”。 选择停用断点并继续运行后会造成cpu占用率升高电脑卡顿。 经简单分析网站使用了js代码用于防止调试并在强制继续运行后造成电脑卡顿,代码如下: function A(A, B) {if (null != B && "undefined" != typeof Symbol && B[Symbol.hasInstan

Golang test编译使用

创建文件my_test.go package testsimport "testing"func TestMy(t *testing.T) {t.Log("TestMy")} 通常用法: $ go test -v -run TestMy my_test.go=== RUN TestMyTestMy: my_test.go:6: TestMy--- PASS: TestMy (0.

vscode中使用go环境配置细节

1、在docker容器中下载了go的sdk 2、在/etc/profile.d/go.sh里填入如下内容: #!/bin/bashexport GOROOT=/home/ud_dev/goexport PATH=$GOROOT/bin:$PATH  3、设置go env go env -w GOPROXY=https://goproxy.cn,directgo env -w GO