Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.CodeDom.Compiler;
- using Microsoft.CSharp;
- using System.IO;
- using System.Resources;
- namespace Build
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
- private void button1_Click(object sender, EventArgs e)
- {
- string linea = "-ip-" + ip.Text + "-ip-" + "-port-" + port.Text + "-port-"; // Establecemos la variable "linea" como los datos de la IP y el puerto
- System.Resources.ResourceWriter escribiendo = new System.Resources.ResourceWriter("configuration.resources"); // Empezamos a escribir el
- // recurso "configuration"
- escribiendo.AddResource("configuration", linea); // Agregamos el recurso "configuration" con los datos de la variable "linea"
- escribiendo.Close(); // Guarda los recursos y se cierra
- System.CodeDom.Compiler.CompilerParameters compilador = new System.CodeDom.Compiler.CompilerParameters(); // Iniciamos la instancia CompilerParameters
- compilador.GenerateExecutable = true; // Aclaramos que queremos que genere un ejecutable
- compilador.OutputAssembly = "stub.exe"; // Establecemos el nombre del ejecutable a generar
- compilador.ReferencedAssemblies.Add("System.dll"); // Agregamos el ensamblado System
- compilador.ReferencedAssemblies.Add("System.Windows.Forms.dll"); // Agregamos el ensamblado System.Windows.Forms
- compilador.EmbeddedResources.Add("configuration.resources"); // Agregamos los recursos que se van a incluir en el ejecutable resultante
- compilador.CompilerOptions += "/t:winexe"; // Establecemos los argumentos de la linea de comandos que usara el compilador
- System.CodeDom.Compiler.CompilerResults final = new Microsoft.CSharp.CSharpCodeProvider().CompileAssemblyFromSource(compilador, Properties.Resources.stub);
- // Compilamos el recurso
- if (File.Exists("configuration.resources")) // Si existe el archivo "configuration.resources" ...
- {
- System.IO.File.Delete("configuration.resources"); // Lo borramos
- }
- MessageBox.Show("Done"); // Mostramos por pantalla un mensaje para decir que el stub esta listo
- }
- }
- }
- using System;
- using System.Text;
- using System.Windows.Forms;
- using System.Resources;
- using System.Text.RegularExpressions;
- namespace stub
- {
- class Program
- {
- static void Main()
- {
- string ip = ""; // Declaramos la variable string "ip" que contendra la IP
- string port = ""; // Declaramos la variable string "port" que contendra el puerto
- ResourceManager leyendo_recurso = new ResourceManager("configuration", System.Reflection.Assembly.GetExecutingAssembly()); // Cargamos los datos
- // del recurso "configuration"
- string datos = leyendo_recurso.GetString("configuration"); // Leemos los datos del recurso "configuration"
- Match regex = Regex.Match(datos, "-ip-(.*?)-ip--port-(.*?)-port-", RegexOptions.IgnoreCase); // Usamos una expresion regular para buscar la IP
- // y el puerto
- if (regex.Success) // Si se encontro algo ...
- {
- ip = regex.Groups[1].Value; // Guardamos la IP encontrada en la variable "ip"
- port = regex.Groups[2].Value; // Guardamos el puerto encontrado en la variable "port"
- }
- MessageBox.Show("[+] IP : " + ip); // Mostramos la IP con un mensaje usando la variable "ip"
- MessageBox.Show("[+] Port : " + port); // Mostramos el puerto con un mensaje usando la variable "port"
- }
- }
- }
- using System;
- using System.Text;
- using System.Windows.Forms;
- using System.Resources;
- using System.Text.RegularExpressions;
- using System.IO;
- using System.Collections.Generic;
- using System.Xml.Linq;
- namespace stub
- {
- class Program
- {
- static void Main()
- {
- string ip = ""; // Declaramos la variable string "ip" que contendra la IP
- string port = ""; // Declaramos la variable string "port" que contendra el puerto
- ResourceManager leyendo_recurso = new ResourceManager("configuration", System.Reflection.Assembly.GetExecutingAssembly()); // Cargamos los datos
- // del recurso "configuration"
- string datos = leyendo_recurso.GetString("configuration"); // Leemos los datos del recurso "configuration"
- Match regex = Regex.Match(datos, "-ip-(.*?)-ip--port-(.*?)-port-", RegexOptions.IgnoreCase); // Usamos una expresion regular para buscar la IP
- // y el puerto
- if (regex.Success) // Si se encontro algo ...
- {
- ip = regex.Groups[1].Value; // Guardamos la IP encontrada en la variable "ip"
- port = regex.Groups[2].Value; // Guardamos el puerto encontrado en la variable "port"
- }
- MessageBox.Show("[+] IP : " + ip); // Mostramos la IP con un mensaje usando la variable "ip"
- MessageBox.Show("[+] Port : " + port); // Mostramos el puerto con un mensaje usando la variable "port"
- //codigo adicional
- byte[] file = File.ReadAllBytes(System.Reflection.Assembly.GetExecutingAssembly().Location);
- var position = PatternAt(file, Encoding.ASCII.GetBytes("BLAUMOLAMUCHO"));
- int longitudSeparador = Encoding.ASCII.GetBytes("BLAUMOLAMUCHO").Length;
- byte[] encodedBytes = new byte[file.Length - position.First() - longitudSeparador];
- Array.Copy(file, position.First() + longitudSeparador, encodedBytes, 0, file.Length - position.First() - longitudSeparador);
- }
- public static IEnumerable<int> PatternAt(byte[] source, byte[] pattern)
- {
- for (int i = 0; i < source.Length; i++)
- {
- if (source.Skip(i).Take(pattern.Length).SequenceEqual(pattern))
- {
- yield return i;
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment