function-interposition

Function Interposing on OSX Mavericks

此生再无相见时 提交于 2020-07-10 04:57:24
问题 I followed the directions exactly as they are on this site here http://www.newosxbook.com/src.jl?tree=listings&file=4-5-interpose.c Here is the code from that page #include <stdio.h> #include <unistd.h> #include <fcntl.h> #include <stdlib.h> #include <malloc/malloc.h> // for malloc_printf() // Note: Compile with GCC, not cc (important) // // // This is the expected interpose structure typedef struct interpose_s { void *new_func; void *orig_func; } interpose_t; // Our prototypes - requires

How to hook system calls of my android app

╄→尐↘猪︶ㄣ 提交于 2019-12-13 06:52:06
问题 I want to intercept the connect() system call and use my own custom implementation. The custom implementation will do some action like printing a log for simplicity and then call the system implementation further. I looked at Audrey's blog where the approach is to patch the PLT. But unfortunately this code is crashing when trying to change the address in the relocation table. After goggling a while i came across This already answered question. But the approach described here gives me the

Polyfit and polyval to perform interpolation

怎甘沉沦 提交于 2019-12-12 05:49:52
问题 I have x = linspace(-5,5,256) y = 1./(1+x.^2) plot(x,y,'...') %plot of (x,y) I want to estimate this with a polynomial of order 10, such that the polynomial intersects the graph at 11 points. So, I did this: x2 = linspace(-5,5,11) y2 = 1./(1+x2.^2) p = polyfit(x2,y2,10) %finds coefficients of polynomial of degree 10 that fits x2,y2 y3 = polyval(p,x2) plot(x,y,x2,y3,'...') I thought the polyfit would give me the coefficients for a polynomial up to order 10, which intersects the points (x2,y2)

malloc function interposition in the standard C and C++ libraries

泪湿孤枕 提交于 2019-12-10 06:33:28
问题 I want to write a shared library in such a way that it is possible to isolate it’s memory usage from the application it is linked against. That is, if the shared library, let’s call it libmemory.so , calls malloc , I want to maintain that memory in a separate heap from the heap that is used to service calls to malloc made in the application. This question isn't about writing memory allocators, it more about linking and loading the library and application together. So far I’ve been

how to link with two shared libraries with many conflicting functions

自古美人都是妖i 提交于 2019-12-08 12:28:32
问题 I'm currently linking with two third party shared libraries (A.so and B.so) on linux. the problem is that both of the two so's linked statically with another library, as a result there are about 400 functions from A.so and B.so having the same names. When I compile and link with -lA -lB, or -lB -lA, depending on the order the functions are picked up from A or B separately as a result of function interposition which caused problem and the code cannot run. I'm wondering if there's a way to bind

Is it possible to make an arbitrary program ignore signals?

旧时模样 提交于 2019-12-06 13:33:55
问题 Specifically on Mac OS X, is it possible to make a program ignore SIGTERM via DYLD_INSERT_LIBRARIES, in a way which works for any or most programs? I tried compiling and inserting this: #include<stdio.h> #include<signal.h> #include<unistd.h> void sig_handler(int signo) { if (signo == SIGTERM) printf("received SIGTERM\n"); } int main(void) { signal(SIGTERM, sig_handler); return 0; } However, DYLD_INSERT_LIBRARIES=libignore.dylib sleep 60 was able to be kill -15'd without issue. 回答1: You can

malloc function interposition in the standard C and C++ libraries

眉间皱痕 提交于 2019-12-05 12:38:09
I want to write a shared library in such a way that it is possible to isolate it’s memory usage from the application it is linked against. That is, if the shared library, let’s call it libmemory.so , calls malloc , I want to maintain that memory in a separate heap from the heap that is used to service calls to malloc made in the application. This question isn't about writing memory allocators, it more about linking and loading the library and application together. So far I’ve been experimenting with combinations of function interposition, symbol visibility, and linking tricks. So far, I can’t

Is it possible to make an arbitrary program ignore signals?

孤人 提交于 2019-12-04 19:45:48
Specifically on Mac OS X, is it possible to make a program ignore SIGTERM via DYLD_INSERT_LIBRARIES, in a way which works for any or most programs? I tried compiling and inserting this: #include<stdio.h> #include<signal.h> #include<unistd.h> void sig_handler(int signo) { if (signo == SIGTERM) printf("received SIGTERM\n"); } int main(void) { signal(SIGTERM, sig_handler); return 0; } However, DYLD_INSERT_LIBRARIES=libignore.dylib sleep 60 was able to be kill -15'd without issue. You can create an executable that sets the action for SIGTERM to SIG_IGN and then execvp() the program you would like

How to hook system calls of my android app (non rooted device)

╄→гoц情女王★ 提交于 2019-12-04 10:41:41
问题 I am trying to intercept all system calls made by my Android app on a non rooted device. So every time my app writes/reads a file, I want to intercept the system call and encrypt/decrypt the stream for security purposes. The encryption part is no problem, but how do I intercept the system calls? Because parts of the app are modules developed by third party providers of which I can not change the source code, there is no other way to make sure that data is stored securely. Since I do not have

How to hook system calls of my android app (non rooted device)

百般思念 提交于 2019-12-03 06:35:07
I am trying to intercept all system calls made by my Android app on a non rooted device. So every time my app writes/reads a file, I want to intercept the system call and encrypt/decrypt the stream for security purposes. The encryption part is no problem, but how do I intercept the system calls? Because parts of the app are modules developed by third party providers of which I can not change the source code, there is no other way to make sure that data is stored securely. Since I do not have root access I cannot access the address of the system call table as described here and I can not do