Hack Forums
[.NET] Button that generates a Form as an .exe - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] Button that generates a Form as an .exe (/showthread.php?tid=3757428)



Button that generates a Form as an .exe - Nills - Sep 16, 2013

I'm working on a RAT.
I'm trying to create a generate stub button, but I'm not sure how to make it save the stub as an exe.
The stub is a regular form.


* - Dialog - Sep 16, 2013

You can compile binaries by using codedom.


* - LijpeMD - Sep 16, 2013

http://www.youtube.com/watch?v=qShN4TxMtU8


* - Nills - Sep 16, 2013

(Sep 16, 2013 08:48 AM)Version Wrote:  http://www.youtube.com/watch?v=qShN4TxMtU8

Like in the tutorial, should I put my form code in a .txt file?


* - LijpeMD - Sep 16, 2013

(Sep 16, 2013 09:14 AM)Nills Wrote:  Like in the tutorial, should I put my form code in a .txt file?

He isn't putting his code in a .txt file..
But you should convert the code to VB.


* - Nills - Sep 16, 2013

(Sep 16, 2013 09:15 AM)Version Wrote:  He isn't putting his code in a .txt file..
But you should convert the code to VB.

Ohhh sorry I watched another one.

Anyways, this is my code after converting it:

Code
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
  Dim provider As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic")
  Dim settings As New CompilerParameters
  Dim results = New CompilerResults(Nothing)
  settings.GenerateExecutable = True
  settings.OutputAssembly = "Stub"
  settings.CompilerOptions = "/target:winexe"
  settings.TreatWarningsAsErrors = False

  settings.ReferencedAssemblies.Add("system.dll")

    End Sub

It doesn't do anything though.


* - LijpeMD - Sep 16, 2013

Because it shouldn't do anything since you haven't added that to the code yet.
I think you should add a SaveFileDialog and then save the code which is generated.


* - Nills - Sep 16, 2013

(Sep 16, 2013 09:27 AM)Version Wrote:  Because it shouldn't do anything since you haven't added that to the code yet.
I think you should add a SaveFileDialog and then save the code which is generated.

I know about SaveFileDialog but what would I put?


* - LijpeMD - Sep 16, 2013

To be honest I have no experience with CodeDom so someone correct me if I'm wrong.

I think you should save: Dim results = New CompilerResults(Nothing)

For example: Save(results)


* - Nills - Sep 16, 2013

(Sep 16, 2013 09:31 AM)Version Wrote:  To be honest I have no experience with CodeDom so someone correct me if I'm wrong.

I think you should save: Dim results = New CompilerResults(Nothing)

For example: Save(results)

Thank you for your help, I'll try it soon.


* - Cornflower Blue இڿڰۣ-ڰۣ— - Sep 16, 2013

https://hackforums.net/showthread.php?tid=2512583


* - Nills - Sep 16, 2013

(Sep 16, 2013 09:35 AM)Nills Wrote:  Thank you for your help, I'll try it soon.

This is my code, I copied the SaveFileDialog from another thing I had.

Code
Dim provider As CodeDomProvider = CodeDomProvider.CreateProvider("VisualBasic")
  Dim settings As New CompilerParameters
  Dim results = New CompilerResults(Nothing)
  Dim save = New SaveFileDialog()
  settings.GenerateExecutable = True
  settings.OutputAssembly = "Stub"
  settings.CompilerOptions = "/target:winexe"
  settings.TreatWarningsAsErrors = False

  settings.ReferencedAssemblies.Add("system.dll")
  Dim OutputFile As String
  Dim sfd As New SaveFileDialog
  sfd.Filter = "*.exe | *.exe"
  If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
    OutputFile = sfd.FileName

  Else() : Exit Sub
  End If

I don't know what to put here so it saves the file

Code
If sfd.ShowDialog = Windows.Forms.DialogResult.OK Then
    OutputFile = sfd.FileName

  Else() : Exit Sub



* - LijpeMD - Sep 16, 2013

OutputFile = sfd.result

?

- version


* - Nills - Sep 16, 2013

(Sep 16, 2013 10:36 AM)Version Wrote:  OutputFile = sfd.result

?

- version

There is no result.
And all the tutorials that has been posted in this thread doesn't show how to save it as an .exe