Data update
This commit is contained in:
parent
81fd053722
commit
52a6ef48dd
10248 changed files with 63654 additions and 6775 deletions
94
Task/Machine-code/AArch64-Assembly/machine-code.aarch64
Normal file
94
Task/Machine-code/AArch64-Assembly/machine-code.aarch64
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
/* ARM assembly AARCH64 Raspberry PI 3B */
|
||||
/* program Machine code */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes */
|
||||
/*******************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeConstantesARM64.inc"
|
||||
|
||||
/*******************************************/
|
||||
/* macros */
|
||||
/*******************************************/
|
||||
//.include "../../ficmacros64.inc" // for developper debugging
|
||||
|
||||
/*********************************/
|
||||
/* Initialized data */
|
||||
/*********************************/
|
||||
.data
|
||||
szMessDebutPgm: .asciz "Program 64 bits start. \n"
|
||||
szCarriageReturn: .asciz "\n"
|
||||
szMessFinOK: .asciz "Program normal end. \n"
|
||||
|
||||
/*********************************/
|
||||
/* UnInitialized data */
|
||||
/*********************************/
|
||||
.bss
|
||||
sAreaConv: .skip 24
|
||||
.align 4
|
||||
|
||||
/*********************************/
|
||||
/* code section */
|
||||
/*********************************/
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
ldr x0,qAdrszMessDebutPgm
|
||||
bl affichageMess // start message
|
||||
|
||||
mov x0,#5
|
||||
mov x1,#10
|
||||
bl addition // call function
|
||||
|
||||
ldr x1,qAdrsAreaConv // decimal conversion
|
||||
bl conversion10
|
||||
ldr x0,qAdrsAreaConv // display result
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
|
||||
adr x2,bCodeArmText // code machine arm address
|
||||
mov x0,#10
|
||||
mov x1,#20
|
||||
blr x2 // call code machine
|
||||
|
||||
ldr x1,qAdrsAreaConv // decimal conversion
|
||||
bl conversion10
|
||||
ldr x0,qAdrsAreaConv // display result
|
||||
bl affichageMess
|
||||
ldr x0,qAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
|
||||
ldr x0,qAdrszMessFinOK
|
||||
bl affichageMess
|
||||
|
||||
100:
|
||||
mov x8,EXIT
|
||||
svc #0 // system call
|
||||
qAdrszMessDebutPgm: .quad szMessDebutPgm
|
||||
qAdrszMessFinOK: .quad szMessFinOK
|
||||
qAdrszCarriageReturn: .quad szCarriageReturn
|
||||
qAdrsAreaConv: .quad sAreaConv
|
||||
|
||||
/******************************************************************/
|
||||
/* add two registers */
|
||||
/******************************************************************/
|
||||
/* x0 contains value 1 */
|
||||
/* x1 contains value 2 */
|
||||
|
||||
addition:
|
||||
stp x1,lr,[sp,-16]! // TODO: a completer
|
||||
add x0,x0,x1
|
||||
100:
|
||||
ldp x1,lr,[sp],16 // TODO: a completer
|
||||
ret
|
||||
// code machine ARM AARCH 64 bits
|
||||
bCodeArmText: .byte 0xE1,0x7B,0xBF,0xA9 // stp x1,lr,[sp,-16]!
|
||||
.byte 0x00,0x00,0x01,0x8B // add x0,x0,x1
|
||||
.byte 0xE1,0x7B,0xC1,0xA8 // ldp x1,lr,[sp],16
|
||||
.byte 0xC0,0x03,0x5F,0xD6 // ret
|
||||
/***************************************************/
|
||||
/* ROUTINES INCLUDE */
|
||||
/***************************************************/
|
||||
/* for this file see task include a file in language AArch64 assembly*/
|
||||
.include "../includeARM64.inc"
|
||||
98
Task/Machine-code/ARM-Assembly/machine-code.arm
Normal file
98
Task/Machine-code/ARM-Assembly/machine-code.arm
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
/* ARM assembly Raspberry PI */
|
||||
/* program Machine code */
|
||||
|
||||
/* REMARK 1 : this program use routines in a include file
|
||||
see task Include a file language arm assembly
|
||||
for the routine affichageMess conversion10
|
||||
see at end of this program the instruction include */
|
||||
|
||||
/*******************************************/
|
||||
/* Constantes */
|
||||
/*******************************************/
|
||||
.include "../constantes.inc"
|
||||
|
||||
/*******************************************/
|
||||
/* macros */
|
||||
/*******************************************/
|
||||
//.include "../../ficmacros32.inc" @ for developper debugging
|
||||
|
||||
/*********************************/
|
||||
/* Initialized data */
|
||||
/*********************************/
|
||||
.data
|
||||
szMessDebutPgm: .asciz "Program 32 bits start. \n"
|
||||
szCarriageReturn: .asciz "\n"
|
||||
szMessFinOK: .asciz "Program normal end. \n"
|
||||
|
||||
@ code machine ARM 32 bits
|
||||
.align 4
|
||||
bCodeArm: .byte 0x02,0x40,0x2D,0xE9 @ push {r1,lr}
|
||||
.byte 0x01,0x00,0x80,0xE0 @ add r0,r1
|
||||
.byte 0x02,0x80,0xBD,0xE8 @ pop {r1,pc}
|
||||
/*********************************/
|
||||
/* UnInitialized data */
|
||||
/*********************************/
|
||||
.bss
|
||||
sAreaConv: .skip 24
|
||||
.align 4
|
||||
|
||||
/*********************************/
|
||||
/* code section */
|
||||
/*********************************/
|
||||
.text
|
||||
.global main
|
||||
main:
|
||||
ldr r0,iAdrszMessDebutPgm
|
||||
bl affichageMess @ start message
|
||||
|
||||
mov r0,#5
|
||||
mov r1,#10
|
||||
bl addition @ call function
|
||||
|
||||
ldr r1,iAdrsAreaConv @ decimal conversion
|
||||
bl conversion10
|
||||
ldr r0,iAdrsAreaConv @ display result
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
|
||||
ldr r2,iAdrbCodeArm @ code machine arm address
|
||||
mov r0,#10
|
||||
mov r1,#20
|
||||
blx r2 @ call code machine
|
||||
|
||||
ldr r1,iAdrsAreaConv @ decimal conversion
|
||||
bl conversion10
|
||||
ldr r0,iAdrsAreaConv @ display result
|
||||
bl affichageMess
|
||||
ldr r0,iAdrszCarriageReturn
|
||||
bl affichageMess
|
||||
|
||||
ldr r0,iAdrszMessFinOK
|
||||
bl affichageMess
|
||||
|
||||
100:
|
||||
mov r7,#EXIT @ program end
|
||||
svc #0 @ system call
|
||||
iAdrszMessDebutPgm: .int szMessDebutPgm
|
||||
iAdrszMessFinOK: .int szMessFinOK
|
||||
iAdrszCarriageReturn: .int szCarriageReturn
|
||||
iAdrsAreaConv: .int sAreaConv
|
||||
iAdrbCodeArm: .int bCodeArm
|
||||
|
||||
/******************************************************************/
|
||||
/* add two registers */
|
||||
/******************************************************************/
|
||||
/* r0 contains value 1 */
|
||||
/* r1 contains value 2 */
|
||||
|
||||
addition:
|
||||
push {r1,lr} @ save registers
|
||||
add r0,r1
|
||||
100:
|
||||
pop {r1,pc}
|
||||
|
||||
/***************************************************/
|
||||
/* ROUTINES INCLUDE */
|
||||
/***************************************************/
|
||||
.include "../affichage.inc"
|
||||
|
|
@ -1,3 +1,49 @@
|
|||
;;Update 2024: the previous code is likely not going to work on modern OS, because there is a need to allocate memory with the correct permissions (readable, writable, and executable). We will update with another machine code, equivalent to the function 'ash' in common lisp
|
||||
|
||||
89 f8 mov %edi,%eax
|
||||
89 f1 mov %esi,%ecx
|
||||
d3 e8 shr %cl,%eax
|
||||
c3 ret
|
||||
|
||||
;;sbcl
|
||||
(require :sb-posix)
|
||||
|
||||
(defconstant +PROT-READ+ 1)
|
||||
(defconstant +PROT-WRITE+ 2)
|
||||
(defconstant +PROT-EXEC+ 4)
|
||||
(defconstant +MAP-PRIVATE+ 2)
|
||||
(defconstant +MAP-ANONYMOUS+ #x20)
|
||||
|
||||
(defun allocate-executable-memory (size)
|
||||
(sb-posix:mmap nil
|
||||
size
|
||||
(logior +PROT-READ+ +PROT-WRITE+ +PROT-EXEC+)
|
||||
(logior +MAP-PRIVATE+ +MAP-ANONYMOUS+)
|
||||
-1
|
||||
0))
|
||||
|
||||
;; Example usage:
|
||||
(defparameter *shellcode* #(#x89 #xf8 #x89 #xf1 #xd3 #xe8 #xc3))
|
||||
(defparameter *mem-ptr* (allocate-executable-memory (length *shellcode*)))
|
||||
|
||||
;; Copy shellcode to allocated memory
|
||||
(loop for byte across *shellcode*
|
||||
for i from 0
|
||||
do (setf (sb-sys:sap-ref-8 *mem-ptr* i) byte))
|
||||
|
||||
;; Create a callable function pointer
|
||||
(defparameter *func* (sb-alien:sap-alien *mem-ptr* (sb-alien:function sb-alien:unsigned-int sb-alien:unsigned-int sb-alien:unsigned-int)))
|
||||
|
||||
;; Call the function
|
||||
(sb-alien:alien-funcall *func* 18 1)
|
||||
;; 9
|
||||
;;(ash 18 -1) => 9
|
||||
|
||||
;; Don't forget to free the memory when done
|
||||
;;(sb-posix:munmap *mem-ptr* (length *shellcode*))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
;;old contribution starts here
|
||||
;;Note that by using the 'CFFI' library, one can apply this procedure portably in any lisp implementation;
|
||||
;; in this code however I chose to demonstrate only the implementation-dependent programs.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue