Skip to content

Commit 539268d

Browse files
committed
Starting to test darwin and freebsd support
1 parent 5846d65 commit 539268d

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed
Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// +build linux freebsd darwin
12
package shellcode
23

34
/*
@@ -6,24 +7,26 @@ package shellcode
67
#include <string.h>
78
#include <unistd.h>
89
9-
void call(char *shellcode) {
10+
void call(char *shellcode, size_t length) {
1011
if(fork()) {
1112
return;
1213
}
1314
unsigned char *ptr;
14-
ptr = (unsigned char *) mmap(0, 0x1000, \
15+
ptr = (unsigned char *) mmap(0, length, \
1516
PROT_READ|PROT_WRITE|PROT_EXEC, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0);
1617
if(ptr == MAP_FAILED) {
1718
perror("mmap");
1819
return;
1920
}
20-
memcpy(ptr, shellcode, strlen(shellcode));
21+
memcpy(ptr, shellcode, length);
2122
( *(void(*) ()) ptr)();
2223
}
2324
*/
2425
import "C"
25-
import "unsafe"
26+
import (
27+
"unsafe"
28+
)
2629

2730
func Run(sc []byte) {
28-
C.call((*C.char)(unsafe.Pointer(&sc[0])))
31+
C.call((*C.char)(unsafe.Pointer(&sc[0])), (C.size_t)(len(sc)))
2932
}

0 commit comments

Comments
 (0)