AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Perl Script to ahk

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
windboy



Joined: 13 Feb 2008
Posts: 31

PostPosted: Mon Sep 01, 2008 5:46 am    Post subject: Perl Script to ahk Reply with quote

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
View user's profile Send private message
windboy



Joined: 13 Feb 2008
Posts: 31

PostPosted: Mon Sep 01, 2008 5:47 am    Post subject: Reply with quote

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
View user's profile Send private message
windboy



Joined: 13 Feb 2008
Posts: 31

PostPosted: Tue Sep 02, 2008 4:09 am    Post subject: Reply with quote

Please help me. Thanks:)
Back to top
View user's profile Send private message
Guest






PostPosted: Tue Sep 02, 2008 6:14 am    Post subject: Reply with quote

post a torrent link to a sample file
Back to top
poo_noo



Joined: 08 Dec 2006
Posts: 137
Location: Sydney Australia

PostPosted: Tue Sep 02, 2008 11:30 am    Post subject: Reply with quote

http://thomaslauer.com/comp/Calling_Perl_from_AHK_or_AU3
http://www.autohotkey.com/forum/viewtopic.php?t=12333&highlight=perl

the above might help
_________________
Paul O
Back to top
View user's profile Send private message Visit poster's website
observer
Guest





PostPosted: Tue Sep 02, 2008 7:44 pm    Post subject: conversion Reply with quote

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





PostPosted: Wed Sep 03, 2008 1:18 am    Post subject: Re: conversion Reply with quote

observer wrote:

PERLEMBED.DLL and PERL.AHK being the critical files there, I think.


Er, and PERL58.DLL is needed too. Smile
Back to top
windboy



Joined: 13 Feb 2008
Posts: 31

PostPosted: Wed Sep 03, 2008 2:14 am    Post subject: Reply with quote

thank you very much:) ill go try:)
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group