Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1036529
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T14:43:12+00:00 2026-05-16T14:43:12+00:00

A friend’s server (yes, really. Not mine.) was broken into and we discovered a

  • 0

A friend’s server (yes, really. Not mine.) was broken into and we discovered a perl binary running some bot code. We could not find the script itself (probably eval’ed as received over the network), but we managed to create a core dump of the perl process.

Running strings on the core gave us some hints (hostnames, usernames / passwords), but not the source code of the script.

We’d like to know what the script was capable of doing, so we’d like to reverse-engineer the perl code that was running inside that perl interpreter.

Searching around, the closest thing to a perl de-compiler I found is the B::Deparse module which seems to be perfectly suitable for converting the bytecode of the parse-trees back into readable code.

Now, how do I get B::Deparse to operate on a core dump? Or, alternatively, how could I restart the program from the core, load B::Deparse and execute it?

Any ideas are welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T14:43:13+00:00Added an answer on May 16, 2026 at 2:43 pm

    ysth asked me on IRC to comment on your question. I’ve done a whole
    pile of stuff “disassembling” compiled perl and stuff (just see my
    CPAN page [http://search.cpan.org/~jjore%5D).

    Perl compiles your source to a tree of OP* structs which
    occasionally have C pointers to SV* which are perl values. Your core
    dump now has a bunch of those OP* and SV* stashed.

    The best possible world would be to have a perl module like
    B::Deparse do the information-understanding work for you. It
    works by using a light interface to perl memory in the B::OP and
    B::SV classes (documented in B, perlguts, and
    perlhack). This is unrealistic for you because a B::* object is
    just a pointer into memory with accessors to decode the struct for our
    use. Consider:

    require Data::Dumper;
    require Scalar::Util;
    require B;
    
    my $value = 'this is a string';
    
    my $sv      = B::svref_2object( \ $value );
    my $address = Scalar::Util::refaddr( \ $value );
    
    local $Data::Dumper::Sortkeys = 1;
    local $Data::Dumper::Purity   = 1;
    print Data::Dumper::Dumper(
      {
        address => $address,
        value   => \ $value,
        sv      => $sv,
        sv_attr => {
          CUR           => $sv->CUR,
          LEN           => $sv->LEN,
          PV            => $sv->PV,
          PVBM          => $sv->PVBM,
          PVX           => $sv->PVX,
          as_string     => $sv->as_string,
          FLAGS         => $sv->FLAGS,
          MAGICAL       => $sv->MAGICAL,
          POK           => $sv->POK,
          REFCNT        => $sv->REFCNT,
          ROK           => $sv->ROK,
          SvTYPE        => $sv->SvTYPE,
          object_2svref => $sv->object_2svref,
        },
      }
    );
    

    which when run showed that the B::PV object (it is ISA B::SV) is
    truely merely an interface to the memory representation of the
    compiled string this is a string.

    $VAR1 = {
              'address' => 438506984,
              'sv' => bless( do{\(my $o = 438506984)}, 'B::PV' ),
              'sv_attr' => {
                             'CUR' => 16,
                             'FLAGS' => 279557,
                             'LEN' => 24,
                             'MAGICAL' => 0,
                             'POK' => 1024,
                             'PV' => 'this is a string',
                             'PVBM' => 'this is a string',
                             'PVX' => 'this is a string',
                             'REFCNT' => 2,
                             'ROK' => 0,
                             'SvTYPE' => 5,
                             'as_string' => 'this is a string',
                             'object_2svref' => \'this is a string'
                           },
              'value' => do{my $o}
            };
    $VAR1->{'value'} = $VAR1->{'sv_attr'}{'object_2svref'};
    

    This however implies that any B::* using code must actually operate
    on live memory. Tye McQueen thought he remembered a C debugger which
    could fully revive a working process given a core dump. My gdb
    can’t. gdb can allow you to dump the contents of your OP* and
    SV* structs. You would most likely just read the dumped structs to
    interpret your program’s structure. You could, if you wished, use
    gdb to dump the structs, then synthetically create B::* objects
    which behaved in interface as if they were ordinary and use
    B::Deparse on that. At root, our deparser and other debug dumping
    tools are mostly object oriented so you could just “fool” them by
    creating a pile of fake B::* classes and objects.

    You may find reading the B::Deparse class’s coderef2text method
    instructive. It accepts a function reference, casts it to a B::CV
    object, and uses that for input to the deparse_sub method:

    require B;
    require B::Deparse;
    sub your_function { ... }
    
    my $cv = B::svref_2object( \ &your_function );
    my $deparser = B::Deparse->new;
    print $deparser->deparse_sub( $cv );
    

    For gentler introductions to OP* and related ideas, see the updated
    PerlGuts Illustrated and Optree guts.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A friend of mine told me that saving images in the database is not
Friend of mine has a problem :). There is an application written in Visual
A friend of mine is now building a web application with J2EE and Struts,
A friend of mine brought up this questiont he other day, he's recently bought
A friend of mine was explaining how they do ping-pong pairing with TDD at
A friend of mine and I were having a discussion regarding currying and partial
A friend of mine told me there was a way to connect two private
A friend of mine claims that in a typical database, using (for example) nvarchar[256]
A friend of mine was recently asked in a job interview to tell the
Friend of mine wanted introduce in his company emails PGP encryption for exchange mails

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.