[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.programming

code and data

Bill Cunningham

10/20/2014 7:55:00 PM

Now is a flat binary only data or does it contain any code? I know the
sections are stripped away.

Bill


7 Answers

Melzzzzz

10/20/2014 8:25:00 PM

0

On Mon, 20 Oct 2014 15:55:15 -0400
"Bill Cunningham" <nospam@nspam.invalid> wrote:

> Now is a flat binary only data or does it contain any code? I
> know the sections are stripped away.
>
> Bill
>
>

What you mean by that? You can load binary into RAM and execute
it no problem on Linux and Windows.

--
Manjaro all the way!
http://ma...

Richard Heathfield

10/20/2014 8:29:00 PM

0

Bill Cunningham wrote:

> Now is a flat binary only data or does it contain any code? I know the
> sections are stripped away.

The distinction between code and data is arbitrary. A program that zips up
executables treats code as data. An interpreter treats data as code.

Here's a binary (nybbled into hexadecimal for ease of reading).

74 4A 24 89 05 32 8C 66 CA 1D EA 01 EA 39 1D 4F
57 2B B8 29 21 CD 27 2B B5 CA A3 08 64 68 99 F3
92 C2 53 7E 20 B3 3D E7 C6 38 B3 2A 55 42 32 86
66 07 81 61 A1 F5 A9 A4 AF F9 53 D4 5C 77 EA CD

Is that code or data?

The only meaningful answer is "yes".

--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

Bill Cunningham

10/20/2014 9:35:00 PM

0


"Melzzzzz" <mel@zzzzz.com> wrote in message
news:20141020222517.4d3ceaf8@maxa-pc...
> On Mon, 20 Oct 2014 15:55:15 -0400
> "Bill Cunningham" <nospam@nspam.invalid> wrote:
>
>> Now is a flat binary only data or does it contain any code? I
>> know the sections are stripped away.
>>
>> Bill
>>
>>
>
> What you mean by that? You can load binary into RAM and execute
> it no problem on Linux and Windows.

Only if there is relaocatable data mapped by the linker or loader for
execution. And the binary happens to have executable code. If you remove
section (or segment) headers which would be meaningful code, You'll have
something that linux's file command would call data because it's
unidentifiable. Not all binaries are executable on their own. JPEGs have a
header and are binaries but not executable.

What exactly is left when something has been reduced to a "flat binary"?
That is what I'm meaning. Linux certainly can't identify it I know that.

Bill


Bill Cunningham

10/20/2014 9:39:00 PM

0


"Richard Heathfield" <invalid@see.sig.invalid> wrote in message
news:zge1w.538878$NQ4.299324@fx26.am4...
> Bill Cunningham wrote:
>
>> Now is a flat binary only data or does it contain any code? I know
>> the
>> sections are stripped away.
>
> The distinction between code and data is arbitrary. A program that zips up
> executables treats code as data. An interpreter treats data as code.
>
> Here's a binary (nybbled into hexadecimal for ease of reading).
>
> 74 4A 24 89 05 32 8C 66 CA 1D EA 01 EA 39 1D 4F
> 57 2B B8 29 21 CD 27 2B B5 CA A3 08 64 68 99 F3
> 92 C2 53 7E 20 B3 3D E7 C6 38 B3 2A 55 42 32 86
> 66 07 81 61 A1 F5 A9 A4 AF F9 53 D4 5C 77 EA CD
>
> Is that code or data?
>
> The only meaningful answer is "yes".

What if your first two bytes, 74 4A was a format descriptor. Would that be
considered "code"?

Bill



Richard Heathfield

10/20/2014 10:10:00 PM

0

Bill Cunningham wrote:

>
> "Richard Heathfield" <invalid@see.sig.invalid> wrote in message
> news:zge1w.538878$NQ4.299324@fx26.am4...
>> Bill Cunningham wrote:
>>
>>> Now is a flat binary only data or does it contain any code? I know
>>> the
>>> sections are stripped away.
>>
>> The distinction between code and data is arbitrary. A program that zips
>> up executables treats code as data. An interpreter treats data as code.
>>
>> Here's a binary (nybbled into hexadecimal for ease of reading).
>>
>> 74 4A 24 89 05 32 8C 66 CA 1D EA 01 EA 39 1D 4F
>> 57 2B B8 29 21 CD 27 2B B5 CA A3 08 64 68 99 F3
>> 92 C2 53 7E 20 B3 3D E7 C6 38 B3 2A 55 42 32 86
>> 66 07 81 61 A1 F5 A9 A4 AF F9 53 D4 5C 77 EA CD
>>
>> Is that code or data?
>>
>> The only meaningful answer is "yes".
>
> What if your first two bytes, 74 4A was a format descriptor. Would that be
> considered "code"?

You seem to have missed my point. It's just bits. That's all. Bits have no
intrinsic meaning. They mean what a programmer wants them to mean. If they
are treated as code, they are code. They might be bad code or they might be
good code, but they're code. If they are treated as data, they are data.
They might be ill-formed data or well-formed data, but they're data.
Dataness or codinosity is in the eye of the program that reads the bits.

--
Richard Heathfield
Email: rjh at cpax dot org dot uk
"Usenet is a strange place" - dmr 29 July 1999
Sig line 4 vacant - apply within

Melzzzzz

10/20/2014 10:12:00 PM

0

On Mon, 20 Oct 2014 17:34:56 -0400
"Bill Cunningham" <nospam@nspam.invalid> wrote:

>
> "Melzzzzz" <mel@zzzzz.com> wrote in message
> news:20141020222517.4d3ceaf8@maxa-pc...
> > On Mon, 20 Oct 2014 15:55:15 -0400
> > "Bill Cunningham" <nospam@nspam.invalid> wrote:
> >
> >> Now is a flat binary only data or does it contain any code? I
> >> know the sections are stripped away.
> >>
> >> Bill
> >>
> >>
> >
> > What you mean by that? You can load binary into RAM and execute
> > it no problem on Linux and Windows.
>
> Only if there is relaocatable data mapped by the linker or loader
> for execution.

Well, you can write relocatable code in assembler or compile with PIC...
I did it. Loaded file in memory, mprotect it and just casted to
pointer to function and ...;)

And the binary happens to have executable code. If you
> remove section (or segment) headers which would be meaningful code,
> You'll have something that linux's file command would call data
> because it's unidentifiable. Not all binaries are executable on their
> own. JPEGs have a header and are binaries but not executable.

You can execute anything in memory. Question is if you would get
meaningful result ;)

>
> What exactly is left when something has been reduced to a "flat
> binary"? That is what I'm meaning. Linux certainly can't identify it
> I know that.

Flat binary can be loaded into memory and run no problem. It just need
to have position independent code.

>
> Bill
>
>



--
Manjaro all the way!
http://ma...

Bill Cunningham

10/21/2014 12:01:00 AM

0


"Melzzzzz" <mel@zzzzz.com> wrote in message
news:20141021001137.6b93d8c5@maxa-pc...
> On Mon, 20 Oct 2014 17:34:56 -0400
> "Bill Cunningham" <nospam@nspam.invalid> wrote:
>
>>
>> "Melzzzzz" <mel@zzzzz.com> wrote in message
>> news:20141020222517.4d3ceaf8@maxa-pc...
>> > On Mon, 20 Oct 2014 15:55:15 -0400
>> > "Bill Cunningham" <nospam@nspam.invalid> wrote:
>> >
>> >> Now is a flat binary only data or does it contain any code? I
>> >> know the sections are stripped away.
>> >>
>> >> Bill
>> >>
>> >>
>> >
>> > What you mean by that? You can load binary into RAM and execute
>> > it no problem on Linux and Windows.
>>
>> Only if there is relaocatable data mapped by the linker or loader
>> for execution.
>
> Well, you can write relocatable code in assembler or compile with PIC...
> I did it. Loaded file in memory, mprotect it and just casted to
> pointer to function and ...;)
>
> And the binary happens to have executable code. If you
>> remove section (or segment) headers which would be meaningful code,
>> You'll have something that linux's file command would call data
>> because it's unidentifiable. Not all binaries are executable on their
>> own. JPEGs have a header and are binaries but not executable.
>
> You can execute anything in memory. Question is if you would get
> meaningful result ;)
>
>>
>> What exactly is left when something has been reduced to a "flat
>> binary"? That is what I'm meaning. Linux certainly can't identify it
>> I know that.
>
> Flat binary can be loaded into memory and run no problem. It just need
> to have position independent code.

Sounds like gcc -fPIC libraries.

Hummm

Bill