Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^2: Interpreting Assembly

by misc (Friar)
on Dec 01, 2019 at 22:08 UTC ( [id://11109518]=note: print w/replies, xml ) Need Help??


in reply to Re: Interpreting Assembly
in thread Interpreting Assembly

The goal is to "port" an simple terminal text editor, written in C, to perl.

Besides, ideally the resulting code should be a pain in the ass to understand.

:)) the acme of wtf for the one, looking at the memory dump.

Addressing I'm least concerned with.
I believe, a simple perl string is enough for emulating the ram.

Each register is a variable, and that's it.

Strangely I wasn't able to find anything yet at all

Replies are listed 'Best First'.
Re^3: Interpreting Assembly
by LanX (Saint) on Dec 01, 2019 at 22:11 UTC
    > Strangely I wasn't able to find anything yet at all

    Because it is a WTF idea? ;)

    If your sole intention is obfuscation, try giving XS or Inline::C a chance.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      > Because it is a WTF idea? ;)

      :) yeah I know, sometimes I'm having strange ideas..

      However, as you write .. "You'd need to transform the ASM syntax a little to make it valid Perl code."

      There might exist something out there doing exactly this.

      Inline C, I don't like the idea of having external dependencies at run (compile) time.

      Much to many attack vectors.

      And there's also the point, there are really bad things possible within perl.

      e.g. The tie()s That Bind,
      meaning to store a var within x will not necessarily store the variable within x..

      so, the control flow can be fuzzed with, in really hard to predict ways.

      .. I'm thinking just now about parallelization..
Re^3: Interpreting Assembly
by LanX (Saint) on Dec 02, 2019 at 11:46 UTC
    > Addressing I'm least concerned with. I believe, a simple perl string is enough for emulating the ram.

    You might be confused what Addressing Modes are.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

      > ..what Addressing Modes are.

      I'd say, it's only about parsing the syntax.
      The registers ( ds, cs , .. ), depending on the architecture,
      have to be stored anyways.

      Furthermore, I didn't get so close yet,
      but the MIPS architecture/assembly seems to be a good target as intermediate language between c and perl.
      (according to schmorp, who chose the architecture cause it's simplicity for his emulator
      http://blog.schmorp.de/2015-07-01-emulating-linux-mips-in-perl-3.html)

      Oh, and I did find the movfuscator,
      which "compiles programs into "mov" instructions, and only "mov" instructions. Arithmetic, comparisons, jumps, function calls, and everything else a program needs are all performed through mov operations; there is no self-modifying code, no transport-triggered calculation, and no other form of non-mov cheating."
      :)) haven't got the thing to compile yet.
      And I can't imagine yet, how this should work at all.

      But this would not only solve the problem of addressing the pseudo ram,
      it might render the resulting code close to undebuggable.
      As long as there is no tool, which translates back into "normal" code.
      When this is possible at all.
        > it's only about parsing the syntax

        Not only, by far not...

        ... but this doesn't matter much because your approach(es) are far away from what I would ever consider. :)

        Cheers Rolf
        (addicted to the Perl Programming Language :)
        Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11109518]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-25 11:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found