Is there is a way to call assembly instructions from perl on Linux?!!!

I wonder if there is a way to call assembly instructions from Perl on Linux
like calling assembly from c or c++.
I put this question on yahoo answers and I got two "NO" answers.
I know that the first question will jump to your mind is "Why the hell you want to do this?!!".
OK, here is the answer. Suppose you succeeded to get a non root Linux shell and unfortunately
there is no c or c++ compiler installed but luckily Perl is available. I think it would be very helpful if
you could write assembly in Perl !!!

I found this code which is very close of what we'r talking about.
This code work well on windows and of course doesn't work at all on Linux.
This is because it depends on win32 API.

Our problem will be solved if we could find an equivalent of the function
"DeclareFarProc"  that work on Linux.

Here is our magic function
sub DeclareFarProc
{
    my $PROCPTR = Ptr($_[0]);
    my @args;
    my $rtn;
    my $argstr = $_[1];
    if(defined($argstr))
   {
      foreach my $arg (split(//,$argstr)) 
         { push(@args, Win32::API::type_to_num($arg));}
   } ;
    $rtn = Win32::API::type_to_num($_[2]) if defined $_[2];
    my $hackedObject = new Win32::API("kernel32.dll", "GetCurrentProcessId", "", "N");
    $hackedObject->{proc} = $PROCPTR; # Substitute our assembly language routine
    @{$hackedObject->{in}} = @args if scalar(@args); # Substitute our parameters
    $hackedObject->{out} = $rtn if defined($rtn);
    return $hackedObject;
 }
By Alaa Jamal

No comments:

Post a Comment