Título: [BATCH/RUBY] [APORTE] REG2BAT (Convierte archivos REG a BAT)
Publicado por: Eleкtro en 30 Marzo 2012, 01:28 am
(http://img10.imageshack.us/img10/6448/prtscrcapturexf.jpg) Un simple programa por línea de comandos que convierte archivos de registro (.REG) a archivos por lotes (.BAT) Modo de empleo: Ejemplos: REG2BAT.exe Archivo.reg REG2BAT.exe *.reg REG2BAT.exe * Ahora con un sencillo instalador! Convierte archivos con un solo click del ratón! ::)(Hecho especialmente para aquellos Batcheros que no disponen del intérprete de Ruby :-[) (http://img254.imageshack.us/img254/8188/download1n.png) (http://exoshare.com/download.php?uid=17MLIUJZ) Nota: Esta version solamente es compatible con archivos de registro en codificación Unicode, debido a las mejoras para evitar los bugs corregidos. Test.reg(Un simple archivo de registro para que puedan testear el programa.) Windows Registry Editor Version 5.00
# Delete test: [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run] "my key"=- [-HKEY_CURRENT_USER\test]
# Add Test [HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run] "Binary Test"=hex:da,da,d2,dd,d0 "Dword Test"=dword:23523626 "Expand SZ Test"=hex(2):25,00,77,00,69,00,6e,00,64,00,69,00,72,00,25,00,00,00 "Multi SZ Test"=hex(7):22,00,63,00,3a,00,5c,00,70,00,72,00,6f,00,67,00,72,00,\ 61,00,6d,00,20,00,66,00,69,00,6c,00,65,00,73,00,5c,00,74,00,65,00,73,00,74,\ 00,2e,00,65,00,78,00,65,00,22,00,00,00,00,00 "Qword Test"=hex(b):2f,3b,00,00,00,00,00,00 "SZ Test"="Wscript.exe \"C:\\Program Files (x86)\\RUN.vbs\"" La conversión del test.reg: REG DELETE "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /V "my key" /F REG DELETE "HKCU\test" /F REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /V "Binary Test" /T "REG_BINARY" /D dadad2ddd0 /F REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /V "Dword Test" /T "REG_DWORD" /D 0x23523626 /F REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /V "Expand SZ Test" /T "REG_EXPAND_SZ" /D "%%windir%%" /F REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /V "Qword Test" /T "REG_QWORD" /D "0x0000000000003b2f" /F REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /V "Multi SZ Test" /T "REG_MULTI_SZ" /D "\"c:\program files\test.exe\"" /F REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Run" /V "SZ Test" /T "REG_SZ" /D "Wscript.exe \"C:\Program Files (x86)\RUN.vbs\"" /F
REG2BAT.rbVersión 0.3Soporte para convertir lineas de comentario a comentario de Batch Se ha mejorado la eficacia de conversión para evitar al 100% problemas con claves de varias lineas. Bugs corregidos: - Error al intentar convertir una clave binaria de varias lineas - Error al convertir claves predeterminadas Versión 0.2Ahora soporta el uso del comodín * # -*- coding: UTF-8 -*-
# # # # # # # # # # # # # # # # # # #
# REG2BAT v0.3 #
# By Elektro H@cker #
# Tested with REGEDIT 5.0 version #
# # # # # # # # # # # # # # # # # # #
require 'tmpdir' exit if Object.const_defined?(:Ocra)
def logo puts " _ .-') ('-. .-. .-') ('-. .-') _ ( \\( -O ) _( OO) \\ ( OO ) ( OO ).-.( OO) ) ,------. (,------. ,----. .-----. ;-----.\\ / . --. // '._ | /`. ' | .---'' .-./-') / ,-. \\ | .-. | | \\-. \\ |'--...__) | / | | | | | |_( O- ) '-' | | | '-' /_).-'-' | |'--. .--' | |_.' |(| '--. | | .--, \\ .' / | .-. `. \\| |_.' | | | | . '.' | .--'(| | '. (_/ .' /__ | | \\ | | .-. | | | | |\\ \\ | `---.| '--' | | | | '--' / | | | | | | `--' '--' `------' `------' `-------' `------' `--' `--' `--' "
puts "
Coded by Elektro H@cker
▄ ▄█████ ███▄▄ ▄▄▄▄▄▄▄▄█████████▀ ██████▀ ▄▄████████████████████ ▀████ ▄███████████████████████▄ ███ ▄███████████████████████████ ▀█ █████████████████▀▀ ██ ████ ▄▄█████████████████▀ ██ ████ ███▀▀████████████▀ ▄█ ████ ███▄ ▀▀█████▀ ▄▀▄ ▄█ ▄████ ███▄▄ ▄▀▄ ▀███▄▀▀ ▄▄▀█▀ █████ ▄▄█▄▀█▄▄ ▀▀████████▀███ ▄ ██████ ▀████▄▀▀▀██▀▀██▀▀██ ▀█ █▄█████ ▀▀███▄ ▀█ ▀█ ▀ █ ▄██████ ▄ ████▄▄▀██▄ █ ▄ █▄ ███ ████▀▀ ▄█ █▀▀▀▀▀▀ █████▄█▄▄████████▀ ▄▄ ▄██ ▄▄█▀▀ ▀█▀██████████▀ ▄███ █▀ ██▀ ▄▄▀ ▄ ▀▀▀████▀ ▄████ █ ▄██ ▄██ ▀█ ████ ▄███▄ ▄███ ▄███ ▀▀ ▄ ▀▀ " sleep 0.5 end
def help() print "\n How to use:\n\n" print " " + __FILE__.split('/').last + " [File]\n\n" print "\n Examples:\n\n" print " " + __FILE__.split('/').last + " File.reg\n\n" print " " + __FILE__.split('/').last + " *.reg\n\n" print " " + __FILE__.split('/').last + " *\n\n" Process.exit end
def expand(string)
# Comment line if string[0].eql? (';') $key = string print "[COMMENT] #{string}\n" write_comment() $key = '' end # Comment line
# Key to delete if string[0..1].eql? ('[-') $key = string[2..-2] $key = $key.gsub('HKEY_CLASSES_ROOT', 'HKCR').gsub('HKEY_CURRENT_USER', 'HKCU').gsub('HKEY_LOCAL_MACHINE', 'HKLM').gsub('HKEY_USERS', 'HKU') $subkey = '' print "IN: [-#{$key}]\n\n" write_delete() $key = ''
# Key to add elsif string[0..0].eql? ('[') and string[-1].eql? (']') $key = string[1..-2] $key = $key.gsub('HKEY_CLASSES_ROOT', 'HKCR').gsub('HKEY_CURRENT_USER', 'HKCU').gsub('HKEY_LOCAL_MACHINE', 'HKLM').gsub('HKEY_USERS', 'HKU') print "IN: #{string}\n\n"
#Subkey to delete elsif string[-1].eql? ('-') $subkey = string $subkey = $subkey[0..-3] print "[REG] #{string}\n" write_delete $key = ''
#Subkey to add elsif string.include? '"' if not $key.eql? ''
$subkey = string $subkey = $subkey.gsub('\\\\', '\\') $subkey = $subkey.gsub( '@=' , ' "" /D ' ) $subkey = $subkey.gsub( '=hex:' , ' /T "REG_BINARY" /D ' ) $subkey = $subkey.gsub('=hex(2):' , ' /T "REG_EXPAND_SZ" /D ') $subkey = $subkey.gsub('=hex(7):' , ' /T "REG_MULTI_SZ" /D ' ) $subkey = $subkey.gsub('=hex(b):' , ' /T "REG_QWORD" /D ' ) $subkey = $subkey.gsub( '=dword:' , ' /T "REG_DWORD" /D ' ) $subkey = $subkey.gsub( '"="' ,'" /T "REG_SZ" /D "' )
# BIANRY if $subkey.include? 'REG_BINARY' $subkey = $subkey.gsub(',' , '') end # BINARY
# DWORD if $subkey.include? 'REG_DWORD' $DWORD_data = $subkey.split('/D').last $New_DWORD_data = ' 0x' + $DWORD_data[1..-1] $subkey = $subkey.gsub($DWORD_data, $New_DWORD_data) end # DWORD
# QWORD if $subkey.include? 'REG_QWORD' $QWORD_data = $subkey.split('/D').last.gsub(',','').gsub(' ', '') hex_string_len = $QWORD_data.length $New_QWORD_data = '' min = -2 until min < -hex_string_len hex_string_block = $QWORD_data[min,2] $New_QWORD_data << hex_string_block min -= 2 end # until $subkey = $subkey.split('/D').first + '/D "0x' + $New_QWORD_data + '"' end # QWORD
# EXPAND # & # MULTI if $subkey.include? 'REG_EXPAND_SZ' or $subkey.include? 'REG_MULTI_SZ' hex_string = $subkey.split('/D').last.gsub(' ', '').gsub('\\', '').gsub(',00', '').gsub('00,', '').gsub(',', '') hex_string_len = hex_string.length $New_hex_data = '' min = 0 until min == hex_string_len $New_hex_data << hex_string[min,2].hex.chr min += 2 end # until $New_hex_data = $New_hex_data.gsub('"', '\"').gsub('%', '%%') $subkey = $subkey.split('/D').first + '/D "' + $New_hex_data + '"' end # EXPAND & MULTI
print "[REG] #{string}\n" write_add() $subkey = '' end # if not $key.eql? '' end # if & elsifs end
def write_delete() if not $subkey.eql? "" File.open(ARGV[$num][0..-4] + "bat", 'a+') do |file| file.print "REG DELETE \"#{$key}\" /V #{$subkey} /F \n" print "[BAT] REG DELETE \"#{$key}\" /V #{$subkey} /F \n\n" end # file (1) elsif File.open(ARGV[$num][0..-4] + "bat", 'a+') do |file| file.print "REG DELETE \"#{$key}\" /F \n" print "[BAT] REG DELETE \"#{$key}\" /F \n\n" end # file (2) end # if & elsifs end
def write_add() File.open(ARGV[$num][0..-4] + "bat", 'a+') do |file| file.print "REG ADD \"#{$key}\" /V #{$subkey} /F \n" print "[BAT] REG ADD \"#{$key}\" /V #{$subkey} /F \n\n" end # file end
def write_comment() File.open(ARGV[$num][0..-4] + "bat", 'a+') do |file| file.print "REM #{$key}\n" end # file end
def args() if ARGV.empty? or ARGV[$num] == "/?" help() elsif ARGV[$num] == nil print "Finished.\n" Process.exit elsif not File.exist? (ARGV[$num]) print "\n ERROR. File doesn't exist...\n\n" help() elsif not ARGV[$num].split('.').last.eql? "reg" and not ARGV[$num].split('.').last.eql? "REG" print "\n ERROR. File " + ARGV[$num] + " is not a valid registry...\n\n" $num += 1 if ARGV.length == 1 print "Finished.\n" Process.exit end # ARGV.length args() end # if & elsifs end
########################################################################################################
string = '' $string_hex = '' $num = 0 $regcode = ''
logo() args()
while not $num == ARGV.length or $num < ARGV.length args() File.open(ARGV[$num], "r:utf-16le:UTF-8").each_line { |line| if line[0..1].eql? " " then line = line[2..-1] end if line[-3..-2].eql? ",\\" then line = line[0..-3] end $regcode = $regcode + line } File.open("#{Dir.tmpdir}/#{ARGV[$num].split('\\').last}", 'a+') { |file| file.puts $regcode } File.open("#{Dir.tmpdir}/#{ARGV[$num].split('\\').last}", "r").each_line { |string| expand(string[0..-2]) and string = ''} File.open("#{Dir.tmpdir}/#{ARGV[$num].split('\\').last}", "w") { |delete| delete.print "" } $regcode = '' $num += 1 end # while
puts "Finished.\n" __END__
Saludos :D
Título: Re: [BATCH/RUBY] [APORTE] REG2BAT (Convierte archivos REG a BAT)
Publicado por: Eleкtro en 17 Septiembre 2012, 10:10 am
Nueva y espero que última versión :P
|