标签:
__attribute__ ((__constructor__))
void Main() {
LOGI(">>>>>>>>>>>>>I am in, I am a bad boy 1!!!!<<<<<<<<<<<<<<");
void* handle = dlopen("libinso.so", RTLD_NOW);
void (*setA_func)(int) = (void (*)(int))dlsym(handle, "setA");
if (setA_func) {
setA_func(999);
}
}void Main();
static void* _main(void*){
Main();
return NULL;
}
class EntryClass {
public:
EntryClass() {
pthread_t tid;
pthread_create(&tid, NULL, _main, NULL);
pthread_detach(tid);
}
} boy;/*
* inso.h
*
* Created on: 2014年6月24日
* Author: boyliang
*/
__attribute__ ((visibility ("default"))) void setA(int i);
__attribute__ ((visibility ("default"))) int getA();/*
* inso.c
*
* Created on: 2014年6月24日
* Author: boyliang
*/
#include <stdio.h>
#include "inso.h"
static int gA = 1;
void setA(int i){
gA = i;
}
int getA(){
return gA;
}/*
* demo1.c
*
* Created on: 2014年6月24日
* Author: boyliang
*/
#include <stdio.h>
#include <unistd.h>
#include "inso.h"
#include "log.h"
int main(){
LOGI("DEMO1 start.");
while(1){
LOGI("%d", getA());
setA(getA() + 1);
sleep(2);
}
return 0;
}
/*
* myso.c
*
* Created on: 2014年6月24日
* Author: boyliang
*/
#include <stdio.h>
#include <stddef.h>
#include <dlfcn.h>
#include <pthread.h>
#include <stddef.h>
#include "log.h"
__attribute__ ((__constructor__))
void Main() {
LOGI(">>>>>>>>>>>>>I am in, I am a bad boy 1!!!!<<<<<<<<<<<<<<");
void* handle = dlopen("libinso.so", RTLD_NOW);
void (*setA_func)(int) = (void (*)(int))dlsym(handle, "setA");
if (setA_func) {
setA_func(999);
}
}
I/TTT ( 594): DEMO1 start. I/TTT ( 594): 1 I/TTT ( 594): 2 I/TTT ( 594): 3 I/TTT ( 594): 4 I/TTT ( 594): 5 I/TTT ( 594): 6 I/TTT ( 594): 7 I/TTT ( 594): >>>>>>>>>>>>>I am in, I am a bad boy 1!!!!<<<<<<<<<<<<<< I/TTT ( 594): 999 I/TTT ( 594): 1000 I/TTT ( 594): 1001当运行./poison /data/local/tmp/libmyso.so 594后,输出中立即出现了特定字符串,而且打印的数据一下子变成了999,证明我们注入成功了。
标签:
原文地址:http://www.cnblogs.com/mengfanrong/p/4487344.html