linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* execve-type memory-based function, possible?
@ 2006-10-23  9:19 "Jørgen P. Tjernø"
  2006-10-23 10:20 ` "Jørgen P. Tjernø"
  0 siblings, 1 reply; 3+ messages in thread
From: "Jørgen P. Tjernø" @ 2006-10-23  9:19 UTC (permalink / raw)
  To: linux-c-programming

Hi!

I've recently been toying with methods for copy-protection and other 
esoteric subjects, for academic and hobby purposes, and I haven't found 
much info on this subject.

I want to see if it's possible (from userspace) to load and execute an 
ELF-binary based on a memory-buffer, i.e. load, relocate, etcetera (then 
execute) a program that's stored in memory.

I can't find any readily available options, I've toyed a bit with shmem 
(to get an fd) and fexecve, but haven't gotten far. I've briefly looked 
at the execve-code in the kernel.

So I'm curious; does anyone have any experience or suggestions on this 
subject? Is it at all possible to do the operations via usermode? I've 
toyed with creating copy-protection-schemes and binary packers and such 
under Win32, where it's possible, but I have no experience on the 
subject under Linux (or found any documentation on anyone else doing so).

Any papers, links, source-file-references etcetera would be appreciated. :-)

-- 
Kindest regards / Med vennlig hilsen,
  Jørgen P. Tjernø
  <jorgen@devsoft.no>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: execve-type memory-based function, possible?
  2006-10-23  9:19 execve-type memory-based function, possible? "Jørgen P. Tjernø"
@ 2006-10-23 10:20 ` "Jørgen P. Tjernø"
  2006-10-23 11:33   ` Steve Graegert
  0 siblings, 1 reply; 3+ messages in thread
From: "Jørgen P. Tjernø" @ 2006-10-23 10:20 UTC (permalink / raw)
  To: linux-c-programming

Jørgen P. Tjernø wrote:
 > [ .. a lot of stuff .. ]

It might've been a bit unclear, so here goes:

I'm thinking something like if you read the contents of the file 
"/bin/ls" into a buffer, and then want to execute that.
Wouldn't that require that you allocate the memory, do relocation, set 
the correct memory page protection (to execute for code, etc), etcetera?

-- 
Kindest regards / Med vennlig hilsen,
  Jørgen P. Tjernø
  <jorgen@devsoft.no>
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: execve-type memory-based function, possible?
  2006-10-23 10:20 ` "Jørgen P. Tjernø"
@ 2006-10-23 11:33   ` Steve Graegert
  0 siblings, 0 replies; 3+ messages in thread
From: Steve Graegert @ 2006-10-23 11:33 UTC (permalink / raw)
  To: Jørgen P. Tjernø; +Cc: linux-c-programming

On 10/23/06, "Jørgen P. Tjernø" <jorgen@devsoft.no> wrote:
> Jørgen P. Tjernø wrote:
>  > [ .. a lot of stuff .. ]
>
> It might've been a bit unclear, so here goes:
>
> I'm thinking something like if you read the contents of the file
> "/bin/ls" into a buffer, and then want to execute that.
> Wouldn't that require that you allocate the memory, do relocation, set
> the correct memory page protection (to execute for code, etc), etcetera?

Jørgen,

(now I got it)  Looks like you'd want to implement some kind of
userland exec.  In this case the following archive will be useful:
http://www.graegert.com/code/ul_exec-v1.1.tar.gz.  Although quite
dated it illustrates basic concepts.

If you have questions about the code or the general approach, feel
free to contact me privately.

	\Steve

--

Steve Grägert <steve@graegert.com>
Jabber    xmpp://graegerts@jabber.org
Internet  http://eth0.graegert.com, http://blog.graegert.com
-
To unsubscribe from this list: send the line "unsubscribe linux-c-programming" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2006-10-23 11:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-23  9:19 execve-type memory-based function, possible? "Jørgen P. Tjernø"
2006-10-23 10:20 ` "Jørgen P. Tjernø"
2006-10-23 11:33   ` Steve Graegert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).