Jumping to machine code

Discussion in 'Perl Misc' started by Derek Fountain, Nov 3, 2004.

  1. I have a string in my Perl which contains the machine code for a short
    program I want to run. I want Perl to jump to it. It's the last thing my
    script will do, so I don't care about returning safely, etc. Ideally the
    Perl will just exit neatly, but I really don't mind. I just need that
    machine code to execute. I'm on Win32, but a cross platform method would be
    good.

    How can I do that?
     
    Derek Fountain, Nov 3, 2004
    #1
    1. Advertising

  2. "Derek Fountain" <> wrote in message
    news:41888be4$0$32221$...
    >I have a string in my Perl which contains the machine code for a short
    > program I want to run. I want Perl to jump to it. It's the last thing my
    > script will do, so I don't care about returning safely, etc. Ideally the
    > Perl will just exit neatly, but I really don't mind. I just need that
    > machine code to execute. I'm on Win32, but a cross platform method would
    > be
    > good.
    >
    > How can I do that?


    Have you considered putting the machine code into a .com file and just
    running it with system() ?

    Andrew
     
    Andrew Bryson, Nov 3, 2004
    #2
    1. Advertising

  3. Andrew Bryson wrote:
    > Have you considered putting the machine code into a .com file and just
    > running it with system() ?


    Yes, but the application doesn't easily allow disk access, plus I need
    speed. Is that all a .com file is - no headers or other confusing stuff I
    would need to generate?
     
    Derek Fountain, Nov 3, 2004
    #3
  4. Derek Fountain

    John Guest

    Derek Fountain wrote:
    > Andrew Bryson wrote:
    >
    >>Have you considered putting the machine code into a .com file and just
    >>running it with system() ?

    >
    >
    > Yes, but the application doesn't easily allow disk access, plus I need
    > speed. Is that all a .com file is - no headers or other confusing stuff I
    > would need to generate?


    First, there is no such thing as "cross platform machine code."

    Second, a Perl script must do an awful lot of disk access to get
    started, so what's the problem?

    Third, if you are so concerned about speed, WTF are you doing running it
    from within Perl?

    Fourth, this sounds like an attempt at injecting a virus in Perl code.

    Could you please tell us what this marvelous piece of machine code is
    going to do, and given that Perl is SOOO slow compared to machine code,
    what benefit you think you're going to get from this approach?
     
    John, Nov 3, 2004
    #4
  5. Derek Fountain

    Lukas Mai Guest

    Derek Fountain schrob:
    > I have a string in my Perl which contains the machine code for a short
    > program I want to run. I want Perl to jump to it. It's the last thing my
    > script will do, so I don't care about returning safely, etc. Ideally the
    > Perl will just exit neatly, but I really don't mind. I just need that
    > machine code to execute. I'm on Win32, but a cross platform method would be
    > good.


    > How can I do that?


    You could use Inline::ASM or Inline::C with something like:
    void execute(char *code) {
    ((void (*)(void))code)();
    }

    HTH, Lukas
    --
    print+74.117.115.116,,qq.\c!..not::.her,Perl=>q$hacker,$,!($,=$")
     
    Lukas Mai, Nov 3, 2004
    #5
  6. > First, there is no such thing as "cross platform machine code."

    I know that, but I can put the right flavour of machine code into the string
    dynamically.

    > Second, a Perl script must do an awful lot of disk access to get
    > started, so what's the problem?


    Perl scripts start with a lot of disk *reading*, I don't have easy write
    access.

    > Third, if you are so concerned about speed, WTF are you doing running it
    > from within Perl?


    The usual balance of convenience and speed; writing a file to disk might tip
    the balance the wrong way.

    > Fourth, this sounds like an attempt at injecting a virus in Perl code.


    It might sound like it, but no. Close though, I'm working with the
    metasploit framework and want to test some payloads.

    > Could you please tell us what this marvelous piece of machine code is
    > going to do, and given that Perl is SOOO slow compared to machine code,
    > what benefit you think you're going to get from this approach?


    Since your attitude is that of an idiot, and you clearly have no intention
    of helping me with my genuine, legitimate problem, no.
     
    Derek Fountain, Nov 4, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Bird via .NET 247

    DataGrid: jumping to the append row (asterisk)

    David Bird via .NET 247, Apr 16, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    482
    David Bird via .NET 247
    Apr 16, 2004
  2. Jerry

    Holy JUMPING frameset Batman!

    Jerry, Jan 27, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    309
    Jerry
    Jan 27, 2004
  3. Anonymous

    page editor: jumping in virtual space

    Anonymous, Sep 8, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    350
    Anonymous
    Sep 8, 2005
  4. Koos
    Replies:
    16
    Views:
    4,499
    Mitja
    May 8, 2004
  5. jalkadir
    Replies:
    3
    Views:
    446
    jalkadir
    Oct 5, 2005
Loading...

Share This Page