(filePath)
| 42 | } |
| 43 | } |
| 44 | function readFile(filePath) { |
| 45 | const ptr_open = Module.findExportByName("libc.so", "open"); |
| 46 | const open = new NativeFunction(ptr_open, 'int', ['pointer', 'int']); |
| 47 | const ptr_read = Module.findExportByName("libc.so", "read"); |
| 48 | const read = new NativeFunction(ptr_read, 'int', ['int', 'pointer', 'int']); |
| 49 | const ptr_close = Module.findExportByName("libc.so", "close"); |
| 50 | const close = new NativeFunction(ptr_close, 'int', ['int']); |
| 51 | const fd = open(Memory.allocUtf8String(filePath), 0); |
| 52 | const size = get_file_size(fd); |
| 53 | if (size > 0) { |
| 54 | const data = Memory.alloc(size + 5); |
| 55 | if (read(fd, data, size) < 0) { |
| 56 | console.log('[+] Unable to read DLL [!] ' + filePath); |
| 57 | close(fd); |
| 58 | return {data: null, size: 0}; |
| 59 | } |
| 60 | close(fd); |
| 61 | return {data: data, size: size}; |
| 62 | }else { |
| 63 | return {data: null, size: 0}; |
| 64 | } |
| 65 | } |
| 66 | |
| 67 | function get_file_size(fd) { |
| 68 | const statBuff = Memory.alloc(500); |
nothing calls this directly
no test coverage detected