streamich / static-buffer

Execute machine code in your Buffer
2 stars 0 forks source link

libsys.malloc is not a function #2

Open lucascebertin opened 4 years ago

lucascebertin commented 4 years ago

Trying to run some samples of ass-js, came to this libsys.malloc is not a function at: https://github.com/streamich/static-buffer/blob/de12e160d0cb3ab3b551719e98d12ee08de118c6/arraybuffer.js#L38

Sample trying to be executed:

require('libsys/shim')
const {X64} = require('ass-js')
const {StaticBuffer} = require('static-buffer/buffer')

const asm = X64({main: 'hello_world_app'})
asm._('db', 'Hello World!\n')
asm._('mov', ['rax', 1])
asm._('mov', ['rdi', 1])
asm._('lea', ['rsi', asm._('rip').disp(-34)])
asm._('mov', ['rdx', 13])
asm._('syscall')
asm._('ret')

const bin = asm.compile()
StaticBuffer.from(bin, 'rwe').call([], 13)

At some point, I just find out about libsys shim, so I imported it at the first line of my code... Without that import, I face libsys undefined and Cannot read property 'syscall64' of undefined

OS Version:

DISTRIB_ID=ManjaroLinux
DISTRIB_RELEASE=19.0.2
DISTRIB_CODENAME=Kyria
DISTRIB_DESCRIPTION="Manjaro Linux"

Node Version:

v10.17.0

NPM Version:

6.11.3

May I did something wrong? Any tips?

f-y-l commented 1 year ago

libsys.malloc is not a function

f-y-l commented 1 year ago

var libjs = require('libjs'); console.dir(libsys ) { syscall: [Function: syscall], syscall64: [Function: syscall64], syscall_0: [Function: syscall_0], syscall_1: [Function: syscall_1], syscall_2: [Function: syscall_2], syscall_3: [Function: syscall_3], syscall_4: [Function: syscall_4], syscall_5: [Function: syscall_5], syscall_6: [Function: syscall_6], syscall64_0: [Function: syscall64_0], syscall64_1: [Function: syscall64_1], syscall64_2: [Function: syscall64_2], syscall64_3: [Function: syscall64_3], syscall64_4: [Function: syscall64_4], syscall64_5: [Function: syscall64_5], syscall64_6: [Function: syscall64_6], getAddressArrayBuffer: [Function: getAddressArrayBuffer], getAddressTypedArray: [Function: getAddressTypedArray], getAddressBuffer: [Function: getAddressBuffer], getAddress: [Function: getAddress], frame: [Function: frame], call: [Function: call], call64: [Function: call64], call_0: [Function: call_0], call_1: [Function: call_1], call64_0: [Function: call64_0], call64_1: [Function: call64_1], sigaction: [Function: sigaction], dlsym: [Function: dlsym], __testDlsymAddr: [Function: __testDlsymAddr], cmpxchg8: [Function: cmpxchg8], cmpxchg16: [Function: cmpxchg16], cmpxchg32: [Function: cmpxchg32], async: [Function: async] }