ToB企服应用市场:ToB评测及商务社交产业平台

标题: Havoc插件编写 [打印本页]

作者: 火影    时间: 2024-3-23 03:57
标题: Havoc插件编写

配置文件的webhook支持discord,所以尝试使用钉钉和企业微信。
  1. WebHook {
  2.         Discord {
  3.                 Url = ""
  4.                 AvatarUrl = ""
  5.                 User = "announcer"
  6.         }
  7. }
复制代码
服务端中判断如果配置了webhook会在自身添加agent之前就转发给discord了。
  1. func (t *Teamserver) AgentAdd(Agent *agent.Agent) []*agent.Agent {
  2.         if Agent != nil {
  3.                 if t.WebHooks != nil {
  4.                         t.WebHooks.NewAgent(Agent.ToMap())
  5.                 }
  6.         }
  7. ...
  8. }
复制代码
可以看到在上线时,server的控制台上会有上线的信息。

借鉴一个老哥的做法:起个子程序来开服务端,同时监听并捕获这个信息:
  1.     process = subprocess.Popen(['./havoc', 'server', '--profile', './profiles/havoc.yaotl', '-v', '--debug'],
  2.                                stdout=subprocess.PIPE,
  3.                                stderr=subprocess.STDOUT,
  4.                                text=True)
  5.   
  6.     capture = False
  7. // 获取到前四行即可
  8.         if "[DBUG] [agent.ParseDemonRegisterRequest:382]" in line:
  9.             capture = True
  10.             captured_text = ""
  11.             line_count = 0
  12.             continue
  13.         if capture:
  14.             if line_count < 5:  
  15.                 captured_text += line + '\n'
  16.                 line_count += 1
  17.             else: #
  18.                 send_messages('New connection!\n'+captured_text.strip())
  19.                 capture = False
复制代码
然后根据官方文档 发送text类型的消息,markdown可以但是在微信中不能正常显示。

上面是markdown下面是text文本,代码也上传了:gayhub
​​​​
但这样并不是很好,而翻官方文档,里面有提供对客户端api的详细说明,主要涉及到havoc和havocui这两个。

对于ui可以直接在客户端的console中尝试他的效果:

像获取demons的数量可以用havoc.GetDemons()​
文档中介绍了一些比较常用的api,在\client\src\Havoc\PythonApi​有更多的调用方向,比如下面的:
  1. PyMemberDef PyDemonClass_members[] = {
  2.         { "Listener",       T_STRING, offsetof( PyDemonClass, Listener ),    0, "Listener name" },
  3.         { "DemonID",        T_STRING, offsetof( PyDemonClass, DemonID ),     0, "Listener name" },
  4.         { "ExternalIP",     T_STRING, offsetof( PyDemonClass, ExternalIP ),  0, "External IP" },
  5.         { "InternalIP",     T_STRING, offsetof( PyDemonClass, InternalIP ),  0, "Internal IP" },
  6.         { "User",           T_STRING, offsetof( PyDemonClass, User ),        0, "Username" },
  7.         { "Computer",       T_STRING, offsetof( PyDemonClass, Computer ),    0, "Computer" },
  8.         { "Domain",         T_STRING, offsetof( PyDemonClass, Domain ),      0, "Domain" },
  9.         { "OS",             T_STRING, offsetof( PyDemonClass, OS ),          0, "Windows Version" },
  10.         { "OSBuild",        T_STRING, offsetof( PyDemonClass, OSBuild ),     0, "Windows OS Build" },
  11.         { "OSArch",         T_STRING, offsetof( PyDemonClass, OSArch ),      0, "Windows Architecture" },
  12.         { "ProcessName",    T_STRING, offsetof( PyDemonClass, ProcessName ), 0, "Process Name" },
  13.         { "ProcessID",      T_STRING, offsetof( PyDemonClass, ProcessID ),   0, "Process ID" },
  14.         { "ProcessArch",    T_STRING, offsetof( PyDemonClass, ProcessArch ), 0, "Process Architecture" },
  15.         { "CONSOLE_INFO",   T_INT, offsetof( PyDemonClass, CONSOLE_INFO ),   0, "Console message type info" },
  16.         { "CONSOLE_ERROR",  T_INT, offsetof( PyDemonClass, CONSOLE_ERROR ),  0, "Console message type error" },
  17.         { "CONSOLE_TASK",   T_INT, offsetof( PyDemonClass, CONSOLE_TASK ),   0, "Console message type task" },
  18.         { NULL },
  19. };
  20. PyMethodDef PyDemonClass_methods[] = {
  21.         { "ConsoleWrite",           ( PyCFunction ) DemonClass_ConsoleWrite,           METH_VARARGS, "Prints messages to the demon sessions console" },
  22.         { "ProcessCreate",          ( PyCFunction ) DemonClass_ProcessCreate,          METH_VARARGS, "Creates a Process" },
  23.         { "InlineExecute",          ( PyCFunction ) DemonClass_InlineExecute,          METH_VARARGS, "Executes a coff file in the context of the demon sessions" },
  24.         { "InlineExecuteGetOutput", ( PyCFunction ) DemonClass_InlineExecuteGetOutput, METH_VARARGS, "Executes a coff file in the context of the demon sessions and get the output via a callback" },
  25.         { "DllSpawn",               ( PyCFunction ) DemonClass_DllSpawn,               METH_VARARGS, "Spawn and injects a reflective dll and get output from it" },
  26.         { "DllInject",              ( PyCFunction ) DemonClass_DllInject,              METH_VARARGS, "Injects a reflective dll into a specified process" },
  27.         { "DotnetInlineExecute",    ( PyCFunction ) DemonClass_DotnetInlineExecute,    METH_VARARGS, "Executes a dotnet assembly in the context of the demon sessions" },
  28.         { "Command",                ( PyCFunction ) DemonClass_Command,                METH_VARARGS, "Run a command" },
  29.         { "CommandGetOutput",       ( PyCFunction ) DemonClass_CommandGetOutput,                METH_VARARGS, "Run a command and retreive the output" },
  30.         { "ShellcodeSpawn",         ( PyCFunction ) DemonClass_ShellcodeSpawn,         METH_VARARGS, "Executes shellcode spawning a new process" },
  31.         { NULL },
  32. };
复制代码
代码的逻辑也很简单,就是通过havoc.Demon(demon_id)​获取到这个对象,抽出这里面的对象发送即可。代码可以去仓库看看。最终完成的效果如下:

最后也是正常能提示了,传送门:gayhub(一起交流)


免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!




欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/) Powered by Discuz! X3.4