 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
windboy
Joined: 13 Feb 2008 Posts: 31
|
Posted: Mon Sep 01, 2008 5:46 am Post subject: Perl Script to ahk |
|
|
Hi guys, i am really bad in programming. Now i got a problem, i found a coding which uses Perl which i have no idea what it is(http://www.perl.org/get.html).
There are some of the video files which force the user to use this 3wPlayer to play the file, but this player is a rogue software. After searching the internet i found a piece of code which can help to bypass the need to use this 3wplayer and still watch the movie.
Please help me with the codings. I found the following codings from a forum posted by codemonkey this is the direct link to it(http://forum.mininova.org/lofiversion/index.php?t234994521.html)
Is it possible to convert the coding into an ahk formatt? Please help me, I'm sure this program produced is very helpful to many people. Thanks a lot.
The following is the coding:
| Code: | # Turn of output buffer
$|++;
# The key for XOR decryption
my $key = 'UIERYQWORTWEHLKDNKDBISGLZNCBZCVNBADFIEYLJ' . chr(0);
print "Reading from \"$ARGV[0]\":\n";
$insize = -s $ARGV[0];
# Open the bogus AVI file
open(IN, $ARGV[0]) or die $!;
binmode IN;
# Read Header to check
read(IN, $buffer, 4);
if ($buffer ne 'RIFF') {
print " ERROR: \"$ARGV[0]\" is not an AVI\n";
close IN;
exit(1);
}
# Get Length of the unencrypted movie
read(IN, $buffer, 4);
$offset = unpack 'L', $buffer;
print " End of the unencrypted movie is at byte offset $offset\n";
# Jump to the read offset
seek(IN, $offset, 0);
# The next 4 or 8 Bytes seem to be either an unsinged long
# or an unsigned quad. This is another offset to jump
# over some filler bytes. Right now I can't really tell if
# it's 4 or 8 bytes, because I only have 1 file to test with.
# I assume it's a quad.
# low word
read(IN, $buffer, 4);
$offlo = unpack 'L', $buffer;
# high word
read(IN, $buffer, 4);
$offhi = unpack 'L', $buffer;
# Calculate offset
$offset = $offhi * 4294967296 + $offlo;
print " Offset after the unencrypted movie is $offset\n";
seek(IN, $offset, 0);
# Then there seem to be another 100 filler bytes
# with value 0xff. Jump over those too, to get
# to the offset where the real movie starts.
printf " Adding extra filler bytes, final offset is %s\n", $offset+100;
seek(IN, 100, 1);
# Update the size
$insize -= $offset+100;
# Open a file for writing the decrypted data to
print "Decrypting to \"$ARGV[1]\":\n";
open(OUT, ">$ARGV[1]");
binmode OUT;
truncate OUT, 0;
$bytes = 0;
$klen = length($key);
# Read key length bytes, decrypt them and
# write them to the output file untill you reach
# the end of the file
while ( read(IN, $buffer, $klen) ) {
$buffer ^= $key;
print OUT $buffer;
$bytes += $klen;
# print the status
printf "\r %d written (% .1f %%)", $bytes, ($bytes / $insize * 100);
}
# Close both files
close OUT;
close IN;
print "\n\nDONE!\n"; |
|
|
| Back to top |
|
 |
windboy
Joined: 13 Feb 2008 Posts: 31
|
Posted: Mon Sep 01, 2008 5:47 am Post subject: |
|
|
According to a post made by code_wanker in the same forum he said that he made some changes to the code and it speed up the decoding process a lot. Here is his code
| Code: | # Turn of output buffer
$|++;
# The key for XOR decryption
my $key = 'UIERYQWORTWEHLKDNKDBISGLZNCBZCVNBADFIEYLJ' . chr(0);
my $times = 1;
print "Reading from \"$ARGV[0]\":\n";
$insize = -s $ARGV[0];
# Open the bogus AVI file
open(IN, $ARGV[0]) or die $!;
binmode IN;
# Read Header to check
read(IN, $buffer, 4);
if ($buffer ne 'RIFF') {
print " ERROR: \"$ARGV[0]\" is not an AVI\n";
close IN;
exit(1);
}
# Get Length of the unencrypted movie
read(IN, $buffer, 4);
$offset = unpack 'L', $buffer;
print " End of the unencrypted movie is at byte offset $offset\n";
# Jump to the read offset
seek(IN, $offset, 0);
# The next 4 or 8 Bytes seem to be either an unsinged long
# or an unsigned quad. This is another offset to jump
# over some filler bytes. Right now I can't really tell if
# it's 4 or 8 bytes, because I only have 1 file to test with.
# I assume it's a quad.
# low word
read(IN, $buffer, 4);
$offlo = unpack 'L', $buffer;
# high word
read(IN, $buffer, 4);
$offhi = unpack 'L', $buffer;
# Calculate offset
$offset = $offhi * 4294967296 + $offlo;
print " Offset after the unencrypted movie is $offset\n";
seek(IN, $offset, 0);
# Then there seem to be another 100 filler bytes
# with value 0xff. Jump over those too, to get
# to the offset where the real movie starts.
printf " Adding extra filler bytes, final offset is %s\n", $offset+100;
seek(IN, 100, 1);
# Update the size
$insize -= $offset+100;
# Open a file for writing the decrypted data to
print "Decrypting to \"$ARGV[1]\":\n";
open(OUT, ">$ARGV[1]");
binmode OUT;
truncate OUT, 0;
$bytes = 0;
$klen = length($key);
# Read key length bytes, decrypt them and
# write them to the output file untill you reach
# the end of the file
while ( read(IN, $buffer, $klen) ) {
$buffer ^= $key;
print OUT $buffer;
$bytes += $klen;
# print the status
if ($times == 500)
{
printf "\r %d written (% .1f %%)", $bytes, ($bytes / $insize * 100);
$times=0;
}
++$times;
}
# Close both files
close OUT;
close IN;
print "\n\nDONE!\n"; |
|
|
| Back to top |
|
 |
windboy
Joined: 13 Feb 2008 Posts: 31
|
Posted: Tue Sep 02, 2008 4:09 am Post subject: |
|
|
| Please help me. Thanks:) |
|
| Back to top |
|
 |
Guest
|
Posted: Tue Sep 02, 2008 6:14 am Post subject: |
|
|
| post a torrent link to a sample file |
|
| Back to top |
|
 |
poo_noo
Joined: 08 Dec 2006 Posts: 137 Location: Sydney Australia
|
|
| Back to top |
|
 |
observer Guest
|
Posted: Tue Sep 02, 2008 7:44 pm Post subject: conversion |
|
|
Something like this?
You'll want the perl , follow instructions here for ahk: http://thomaslauer.com/comp/Calling_Perl_from_AHK_or_AU3 namely, unzipping http://thomaslauer.com/download/Perlahk_perl58.zip into your c:\Program Files\AutoHotkey (or where the executable is installed). PERLEMBED.DLL and PERL.AHK being the critical files there, I think.
Here's a snippet. Loads, runs ... but not tested really, as I have no 3w movies to try it on. Basically I converted the perl code for ahk use by changing " to "", and swapping $in_filename for $ARGV[0] and $out_filename for $ARGV[1].
| Code: | #include c:\Program Files\AutoHotkey\perl.ahk
;; in_filename = existing 3w file to convert
;; out_filename = target avi file to create
in_filename=mymovie.3wp ;; have this one
out_filename=mymovie.avi ;; want this one
ProcessFile:
If (!PerlInit()) { ; first thing
MsgBox Perl not found, bye bye...
Exit
}
PerlSetStr("in_filename",in_filename)
PerlSetStr("out_filename",out_filename)
PerlEval(
(
"
# Turn of output buffer
$|++;
# The key for XOR decryption
my $key = 'UIERYQWORTWEHLKDNKDBISGLZNCBZCVNBADFIEYLJ' . chr(0);
my $times = 1;
print ""Reading from $in_filename :\n"";
$insize = -s $in_filename;
# Open the bogus AVI file
open(IN, $in_filename) or die $!;
binmode IN;
# Read Header to check
read(IN, $buffer, 4);
if ($buffer ne 'RIFF') {
print "" ERROR: $in_filename is not an AVI\n"";
close IN;
exit(1);
}
# Get Length of the unencrypted movie
read(IN, $buffer, 4);
$offset = unpack 'L', $buffer;
print "" End of the unencrypted movie is at byte offset $offset\n"";
# Jump to the read offset
seek(IN, $offset, 0);
# The next 4 or 8 Bytes seem to be either an unsinged long
# or an unsigned quad. This is another offset to jump
# over some filler bytes. Right now I can't really tell if
# it's 4 or 8 bytes, because I only have 1 file to test with.
# I assume it's a quad.
# low word
read(IN, $buffer, 4);
$offlo = unpack 'L', $buffer;
# high word
read(IN, $buffer, 4);
$offhi = unpack 'L', $buffer;
# Calculate offset
$offset = $offhi * 4294967296 + $offlo;
print "" Offset after the unencrypted movie is $offset\n"";
seek(IN, $offset, 0);
# Then there seem to be another 100 filler bytes
# with value 0xff. Jump over those too, to get
# to the offset where the real movie starts.
printf "" Adding extra filler bytes, final offset is %s\n"", $offset+100;
seek(IN, 100, 1);
# Update the size
$insize -= $offset+100;
# Open a file for writing the decrypted data to
print ""Decrypting to $out_filename :\n"";
open(OUT, "">$out_filename"");
binmode OUT;
truncate OUT, 0;
$bytes = 0;
$klen = length($key);
# Read key length bytes, decrypt them and
# write them to the output file untill you reach
# the end of the file
while ( read(IN, $buffer, $klen) ) {
$buffer ^= $key;
print OUT $buffer;
$bytes += $klen;
# print the status
if ($times == 500)
{
printf ""\r %d written (% .1f %%)"", $bytes, ($bytes / $insize * 100);
$times=0;
}
++$times;
}
# Close both files
close OUT;
close IN;
print ""\n\nDONE!\n"";
")
)
PerlExit() ; last thing
|
Good luck! |
|
| Back to top |
|
 |
observer Guest
|
Posted: Wed Sep 03, 2008 1:18 am Post subject: Re: conversion |
|
|
| observer wrote: |
PERLEMBED.DLL and PERL.AHK being the critical files there, I think.
|
Er, and PERL58.DLL is needed too.  |
|
| Back to top |
|
 |
windboy
Joined: 13 Feb 2008 Posts: 31
|
Posted: Wed Sep 03, 2008 2:14 am Post subject: |
|
|
| thank you very much:) ill go try:) |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|