Guest User

Untitled

a guest
Jan 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.12 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using System.CodeDom.Compiler;
  10. using Microsoft.CSharp;
  11. using System.IO;
  12. using System.Resources;
  13.  
  14. namespace Build
  15. {
  16. public partial class Form1 : Form
  17. {
  18. public Form1()
  19. {
  20. InitializeComponent();
  21. }
  22.  
  23. private void button1_Click(object sender, EventArgs e)
  24. {
  25. string linea = "-ip-" + ip.Text + "-ip-" + "-port-" + port.Text + "-port-"; // Establecemos la variable "linea" como los datos de la IP y el puerto
  26.  
  27. System.Resources.ResourceWriter escribiendo = new System.Resources.ResourceWriter("configuration.resources"); // Empezamos a escribir el
  28. // recurso "configuration"
  29.  
  30. escribiendo.AddResource("configuration", linea); // Agregamos el recurso "configuration" con los datos de la variable "linea"
  31. escribiendo.Close(); // Guarda los recursos y se cierra
  32.  
  33. System.CodeDom.Compiler.CompilerParameters compilador = new System.CodeDom.Compiler.CompilerParameters(); // Iniciamos la instancia CompilerParameters
  34.  
  35. compilador.GenerateExecutable = true; // Aclaramos que queremos que genere un ejecutable
  36. compilador.OutputAssembly = "stub.exe"; // Establecemos el nombre del ejecutable a generar
  37. compilador.ReferencedAssemblies.Add("System.dll"); // Agregamos el ensamblado System
  38. compilador.ReferencedAssemblies.Add("System.Windows.Forms.dll"); // Agregamos el ensamblado System.Windows.Forms
  39. compilador.EmbeddedResources.Add("configuration.resources"); // Agregamos los recursos que se van a incluir en el ejecutable resultante
  40. compilador.CompilerOptions += "/t:winexe"; // Establecemos los argumentos de la linea de comandos que usara el compilador
  41.  
  42. System.CodeDom.Compiler.CompilerResults final = new Microsoft.CSharp.CSharpCodeProvider().CompileAssemblyFromSource(compilador, Properties.Resources.stub);
  43.  
  44. // Compilamos el recurso
  45.  
  46. if (File.Exists("configuration.resources")) // Si existe el archivo "configuration.resources" ...
  47. {
  48. System.IO.File.Delete("configuration.resources"); // Lo borramos
  49. }
  50. MessageBox.Show("Done"); // Mostramos por pantalla un mensaje para decir que el stub esta listo
  51. }
  52. }
  53. }
  54.  
  55. using System;
  56. using System.Text;
  57. using System.Windows.Forms;
  58. using System.Resources;
  59. using System.Text.RegularExpressions;
  60.  
  61. namespace stub
  62. {
  63. class Program
  64. {
  65. static void Main()
  66. {
  67.  
  68. string ip = ""; // Declaramos la variable string "ip" que contendra la IP
  69. string port = ""; // Declaramos la variable string "port" que contendra el puerto
  70.  
  71. ResourceManager leyendo_recurso = new ResourceManager("configuration", System.Reflection.Assembly.GetExecutingAssembly()); // Cargamos los datos
  72. // del recurso "configuration"
  73.  
  74. string datos = leyendo_recurso.GetString("configuration"); // Leemos los datos del recurso "configuration"
  75.  
  76. Match regex = Regex.Match(datos, "-ip-(.*?)-ip--port-(.*?)-port-", RegexOptions.IgnoreCase); // Usamos una expresion regular para buscar la IP
  77. // y el puerto
  78. if (regex.Success) // Si se encontro algo ...
  79. {
  80. ip = regex.Groups[1].Value; // Guardamos la IP encontrada en la variable "ip"
  81. port = regex.Groups[2].Value; // Guardamos el puerto encontrado en la variable "port"
  82. }
  83.  
  84. MessageBox.Show("[+] IP : " + ip); // Mostramos la IP con un mensaje usando la variable "ip"
  85. MessageBox.Show("[+] Port : " + port); // Mostramos el puerto con un mensaje usando la variable "port"
  86.  
  87. }
  88. }
  89. }
  90.  
  91. using System;
  92. using System.Text;
  93. using System.Windows.Forms;
  94. using System.Resources;
  95. using System.Text.RegularExpressions;
  96. using System.IO;
  97. using System.Collections.Generic;
  98. using System.Xml.Linq;
  99.  
  100.  
  101. namespace stub
  102. {
  103. class Program
  104. {
  105. static void Main()
  106. {
  107.  
  108. string ip = ""; // Declaramos la variable string "ip" que contendra la IP
  109. string port = ""; // Declaramos la variable string "port" que contendra el puerto
  110.  
  111. ResourceManager leyendo_recurso = new ResourceManager("configuration", System.Reflection.Assembly.GetExecutingAssembly()); // Cargamos los datos
  112. // del recurso "configuration"
  113.  
  114. string datos = leyendo_recurso.GetString("configuration"); // Leemos los datos del recurso "configuration"
  115.  
  116. Match regex = Regex.Match(datos, "-ip-(.*?)-ip--port-(.*?)-port-", RegexOptions.IgnoreCase); // Usamos una expresion regular para buscar la IP
  117. // y el puerto
  118. if (regex.Success) // Si se encontro algo ...
  119. {
  120. ip = regex.Groups[1].Value; // Guardamos la IP encontrada en la variable "ip"
  121. port = regex.Groups[2].Value; // Guardamos el puerto encontrado en la variable "port"
  122. }
  123.  
  124. MessageBox.Show("[+] IP : " + ip); // Mostramos la IP con un mensaje usando la variable "ip"
  125. MessageBox.Show("[+] Port : " + port); // Mostramos el puerto con un mensaje usando la variable "port"
  126.  
  127. //codigo adicional
  128. byte[] file = File.ReadAllBytes(System.Reflection.Assembly.GetExecutingAssembly().Location);
  129.  
  130. var position = PatternAt(file, Encoding.ASCII.GetBytes("BLAUMOLAMUCHO"));
  131.  
  132. int longitudSeparador = Encoding.ASCII.GetBytes("BLAUMOLAMUCHO").Length;
  133.  
  134. byte[] encodedBytes = new byte[file.Length - position.First() - longitudSeparador];
  135. Array.Copy(file, position.First() + longitudSeparador, encodedBytes, 0, file.Length - position.First() - longitudSeparador);
  136.  
  137.  
  138. }
  139.  
  140. public static IEnumerable<int> PatternAt(byte[] source, byte[] pattern)
  141. {
  142. for (int i = 0; i < source.Length; i++)
  143. {
  144. if (source.Skip(i).Take(pattern.Length).SequenceEqual(pattern))
  145. {
  146. yield return i;
  147. }
  148. }
  149. }
  150. }
  151. }
Add Comment
Please, Sign In to add comment