zardus / preeny

Some helpful preload libraries for pwning stuff.
BSD 2-Clause "Simplified" License
1.56k stars 171 forks source link

Can I compile preeny on an arm-based raspberrypi device? #54

Closed buptsseGJ closed 5 years ago

buptsseGJ commented 5 years ago

Hello, I want to compile it on my raspberrypi device, but it causes an error which doesn't occur on my X86_64 computer. The gcc is arm-linux-gnueabihf with 6.3.0 version. The error is as follows:

make -C src clean
make[1]: Entering directory '/home/pi/Downloads/protocal/preeny/src'
rm -f *.o
rm -f *.so
make[1]: Leaving directory '/home/pi/Downloads/protocal/preeny/src'
make -C src dist
make[1]: Entering directory '/home/pi/Downloads/protocal/preeny/src'
cc dealarm.c logging.c -o dealarm.so -shared -fPIC  -Wall -DLINUX -ldl
cc setcanary.c logging.c -o setcanary.so -shared -fPIC  -Wall -DLINUX -ldl
setcanary.c: In function ‘preeny_set_canary’:
setcanary.c:26:25: warning: implicit declaration of function ‘TONUMBER’ [-Wimplicit-function-declaration]
  uintptr_t new_canary = TONUMBER(new_canary_str, NULL, 0);
                         ^~~~~~~~
setcanary.c:30:3: error: expected ‘:’ or ‘)’ before ‘INSN_LOAD’
   INSN_LOAD
   ^~~~~~~~~
Makefile:69: recipe for target 'setcanary.so' failed
make[1]: *** [setcanary.so] Error 1
make[1]: Leaving directory '/home/pi/Downloads/protocal/preeny/src'
Makefile:6: recipe for target 'dist' failed
make: *** [dist] Error 2

Look forward for your reply. Thank you!

sudhackar commented 5 years ago

We only support x86 and x86-64 for now for some targets which require hacks written in assembly. You can build other targets.

https://github.com/zardus/preeny/blob/5d544d63e7ab363c7c465c6fd36f86b2bb41f85c/src/setcanary.c#L5

https://github.com/zardus/preeny/blob/5d544d63e7ab363c7c465c6fd36f86b2bb41f85c/src/setcanary.c#L11

You're welcome to PR.

zardus commented 5 years ago

Some of the preloads won't compile on some architectures or platforms, but you can use make -i to just skip them.

On Tue, Mar 19, 2019 at 6:19 PM Sudhakar Verma notifications@github.com wrote:

We only support x86 and x86-64 for now.

https://github.com/zardus/preeny/blob/5d544d63e7ab363c7c465c6fd36f86b2bb41f85c/src/setcanary.c#L5

https://github.com/zardus/preeny/blob/5d544d63e7ab363c7c465c6fd36f86b2bb41f85c/src/setcanary.c#L11

You're welcome to PR.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zardus/preeny/issues/54#issuecomment-474288158, or mute the thread https://github.com/notifications/unsubscribe-auth/ADSzl-7LMO95F2nbyG5r5oTkhg-4wY4Aks5vYLnCgaJpZM4bDG0l .

sudhackar commented 5 years ago

@zardus I have implemented canary read for arm. Are you planning on supporting arm?

zardus commented 5 years ago

Yeah! Like I said, we should support every arch in general, just some preloads are harder to support than others. Could you contribute your arm support?

On Fri, Mar 22, 2019 at 5:35 PM Sudhakar Verma notifications@github.com wrote:

@zardus https://github.com/zardus I have implemented canary read/write for arm. Are you planning on supporting arm?

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/zardus/preeny/issues/54#issuecomment-475552679, or mute the thread https://github.com/notifications/unsubscribe-auth/ADSzl7wPRO5_P8OIF5IVfQ5xEkUACfa7ks5vZKP5gaJpZM4bDG0l .

sudhackar commented 5 years ago

For setcanary its a little tricky as the page where __stack_chk_guard is mapped only r in the latest version I tested with on raspberry pi. Need to map it rw, write cookie and then map it to r back. If that's ok, I'll add a PR for that. Seems too intrusive to me.

zardus commented 5 years ago

I think intrusive is better than unsupported :-)

Thanks for sorting this out!