![]() |
|
[.NET] >> CodeDom Tutorial | Detailed with Pictures | Very Easy | For Beginners << - 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] >> CodeDom Tutorial | Detailed with Pictures | Very Easy | For Beginners << (/showthread.php?tid=3757923) Pages: Pages
1
2
|
>> CodeDom Tutorial | Detailed with Pictures | Very Easy | For Beginners << - Madara-Uchiha - Sep 16, 2013 CodeDom Tutorial Hello guys, in this tutorial I show u a bit about CodeDom and how to make a sample application. Basiclly first, create a new VB.Net Windows Forms App. Than Add a Button, name it Compile and a two textboxes (set one of them Multiline = true) and also add a checkbox. That should basiclly look like this: [img]http://s14.directupload.net/images/130916/bn562x72.png[/img] Now Doubleklick the Compile Button. Here goes our main part. Inside the click procedure you add this: Code Dim newCode As String = My.Resources.SourceCodeSourceCode is the name of a text file we will add to the ressources later. There in the txt file goes the code we want to compile (for example the Rat Server or Keylogger or whatever) Now we write this: Code TryJust in case that something wents wrong we can display all the compiler errors. Now we go on inside the Try Statement: Code Dim compiler As System.CodeDom.Compiler.ICodeCompiler = New VBCodeProvider().CreateCompiler()Here we basiclly create a New CodeDom Compiler object. Now we create a new "parameter-variable" for all parameters we need to add to the compiler like this: Code Dim parameters As New System.CodeDom.Compiler.CompilerParameters()Now another important part: Code parameters.ReferencedAssemblies.Add("System.Windows.Forms.dll")There we added a dll as reference. When using "Imports System.Windows.Forms" we need to import that. For every import there exist different dlls. U can check msdn for more information. Code parameters.GenerateExecutable = TrueWe want to create an executable so set this to true! Now the Outputname of our compiled code: Code parameters.OutputAssembly = "App" U don't need to write .exe. CodeDom will add this automaticlly Now we add this: Code parameters.CompilerOptions = "/target:winexe"This tells the compiler we need to create a normale executable file. I am not exactly sure about different options but I think this is different when choosing a console app/Winform app/DLL etc Now for the main customization part: Code If Dim results As System.CodeDom.Compiler.CompilerResults = compiler.CompileAssemblyFromSource(parameters, My.Resources.SourceCode.Replace("--MESSAGE--", TextBox2.Text).Replace("--TITLE--", TextBox1.Text).Replace("--BOOLEAN--", CheckBox1.CheckState))What are we gonna do here? Thats simple! here the main compiling starts. We compile our code we have inside the txt file to an executable. There we replace the Strings: --MESSAGE-- ==> And fill in whatever is typed in TextBox2 --TITLE-- ==> And fill in whatever is typed in TextBox1 --BOOLEAN-- ==> And fill in whatever checkstate our checkbox has! As u can see it is an if statement so we need to end this: Code MsgBox("Error: Line>" & results.Errors(0).Line.ToString & ", " & results.Errors(0).ErrorText) 'Messagebox the error line number and the acctual errorThis logs compiler errors displays the line of the errors etc (similar to the IDE) If there is an error it stops compiling. Good news: WE ARE DONE WITH THE COMPILER!! :) Now we create a new txt file on our computer. We Name it SourceCode.txt (or whatever choosen as name above by newCode Variable) There we add this: Code Namespace MyAppI don't think I have to explain that... Its basiclly our program we are gonna go to compile. We show two MessageBoxes with the specific Strings we are replacing above with our TextBox Text. Also another messageBox for the boolean value :) Now add the txt file to your compiler-apps ressources (MyProject >> Ressources >> Add ressource >> Choose the txt file) [img]http://s14.directupload.net/images/130916/sq5t9ky3.png[/img] We are Done with our first CodeDom Application :) Lets try this out guys. Debug the compiler. And test it :) [img]http://s7.directupload.net/images/130916/85q8fjpk.gif[/img] I hope u liked the tutorial. I like like to get a feedback! Any mistakes I've made (I am also just a human), suggestions, questions? Also thanks to XilluX & Elektroalek, they helped me with CodeDom :) by Madara-Uchiha
* - Six Below - Sep 16, 2013 OP is a very talented developer. Everyone who needs help look no further! * - SIM-1456245 - Sep 16, 2013 Congrats man, I planned to do this, but you are faster than me. I like the tutorial, but yeah, it can be optimized a bit. * - Madara-Uchiha - Sep 16, 2013 Thanks, I know there are is optimazation possible, just post ur code here and Ill take a look. Since this is made for CodeDom newbies, I havent mentioned Icon changing and Assembly Information Manipulation etc:) * - LijpeMD - Sep 16, 2013 Hey can you help me trough PM or something? My application isn't working. * - Tostig - Sep 16, 2013 Very helpful. I would +3 if I could. * - SIM-1456245 - Sep 16, 2013 Here is my ub3r short version that is self adding all the imports needed in 90% of uses.Waning it's a 4 liner. You ask why I added all the imports there, first I made a simple application that you write code and it makes a simple EXE, but I didn't want to be bothered with imports. And all these imports are needed for my RAT, I will use this for my RAT. Here it is, and don't laugh, because it works. http://pastebin.com/0mFDCmgG My achievement was making it as short as possible. * - Dark_Noodles - Sep 16, 2013 (Sep 16, 2013 02:32 PM)Cup Noodles Wrote: Very helpful. I would +3 if I could. I'm sorry, but I'm the only noodles here. * - nathan72389 - Sep 16, 2013 i like how your app only shows 2 message box's and its 7KB... * - Swifthider - Sep 16, 2013 Very nice tutorial! Really detailed with good pictures. Good Job OP :) * - Fộrcəd - Sep 17, 2013 Nice tutorial OP! Detailed and well written * - Madara-Uchiha - Sep 18, 2013 Thanks, I am great you liked it :) Hope you find some use for this. * - Dr41DeY - Sep 18, 2013 Thanks, for posting this! :D Very nice tutorial! :p * - SIM-1980240 - Sep 18, 2013 I like the pictures in the tutorial. Makes it high quality. * - Vexane - Sep 18, 2013 It's not working as planned... Any advice? Can someone send me the source because he doesn't explain where to put it too well. |