Chào mừng đến với Diễn đàn lập trình - Cộng đồng lập trình.
Kết quả 1 đến 3 của 3
  1. #1
    Ngày tham gia
    Sep 2015
    Bài viết
    0

    [Hỏi] code này là code gì ạ

    /*
    * Copyright (c) 2005-2011 Apple Computer, Inc. All rights reserved.
    *
    * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
    *
    * This file contains Original Code and/or Modifications of Original Code
    * as defined in and that are subject to the Apple Public Source License
    * Version 2.0 (the 'License'). You may not use this file except in
    * compliance with the License. The rights granted to you under the License
    * may not be used to create, or enable the creation or redistribution of,
    * unlawful or unlicensed copies of an Apple operating system, or to
    * circumvent, violate, or enable the circumvention or violation of, any
    * terms of an Apple operating system software license agreement.
    *
    * Please obtain a copy of the License at
    * http://www.opensource.apple.com/apsl/ and read it before using this file.
    *
    * The Original Code and all software distributed under the License are
    * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
    * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
    * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
    * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
    * Please see the License for the specific language governing rights and
    * limitations under the License.
    *
    * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
    */

    #include "asm_help.h"

    /**
    * boilerplate
    */

    .syntax unified
    .data

    .globl _kernel_code_start
    .globl _kernel_code_end
    .globl _kernelSlide

    .globl _task_for_pid0
    .globl _ioLogOffset
    .globl _PE_state
    .globl _sandboxBuiltin
    .globl _vmMapEnter
    .globl _vmMapProtect

    .globl _procEnforce
    .globl _amfiCSEnforcementDisable
    .globl _csEnforcementDisable
    .globl _PE_I_can_has_debugger

    /*
    * Helper Macros
    */
    #define LoadRegisterSlidden(_Data, _Reg, _Scratch) \
    LoadRegister(_Data, _Reg) ; \

    #define LoadRegister(_Data, _Reg) \
    adr _Reg, _Data ; \
    ldr _Reg, [_Reg]

    #define CallFunction(_Data) \
    LoadRegisterSlidden(_Data, r12, r9) ; \
    blx r12

    /**
    * kernel_code_start
    *
    * Patch the iOS kernel on runtime.
    */
    EnterThumb(kernel_code_start)
    push {lr}
    cpsid if /* Disable IRQ/FIQs */

    /* Enter */
    adr r0, _helloString
    CallFunction(_ioLogOffset)

    /* Patch boot-args */
    LoadRegisterSlidden(_PE_state, r1, r9)
    add r1, r1, #0x70
    ldr r1, [r1]
    add r1, r1, #0x38

    /* Copy string */
    adr r0, _bootArguments
    mov r2, #64
    copy_loop:
    ldrb r3, [r0]
    strb r3, [r1]
    add r0, r0, #1
    add r1, r1, #1
    subs r2, r2, #1
    cmp r2, #0
    bgt copy_loop

    /* vm_map_enter */
    LoadRegisterSlidden(_vmMapEnter, r0, r9)
    LoadRegister(_vmMapEnter_patch, r1)
    str r1, [r0]

    /* vm_map_protect */
    LoadRegisterSlidden(_vmMapProtect, r0, r9)
    LoadRegister(_vmMapProtect_patch, r1)
    str r1, [r0]

    /* amfi bypass */
    LoadRegisterSlidden(_amfiCSEnforcementDisable, r0, r9)
    mov r1, #1
    strb r1, [r0]

    /* pe_i_can_has_debugger */
    LoadRegisterSlidden(_PE_I_can_has_debugger, r0, r9)
    mov r1, #1
    str r1, [r0]

    /* proc_enforce */
    LoadRegisterSlidden(_procEnforce, r0, r9)
    mov r1, #0
    str r1, [r0]

    /* cs_enforcement */
    LoadRegisterSlidden(_csEnforcementDisable, r0, r9)
    mov r1, #1
    str r1, [r0]

    /* task-for-pid 0 */
    LoadRegisterSlidden(_task_for_pid0, r0, r9)
    LoadRegister(_task_for_pid0_patch, r1)
    str r1, [r0]

    __clean_cache:
    mov r0, #0

    mcr p15, 0, r0, c7, c5, 4 /* Prefetch Flush */
    mcr p15, 0, r0, c8, c7, 0 /* Invalidate TLB (d+i) */
    mcr p15, 0, r0, c7, c5, 0 /* Invalidate cache to PoU */
    mcr p15, 0, r0, c7, c5, 6 /* Invalidate branch predictor array */
    isb sy
    dsb sy /* Wait for operation to complete. */

    movs r0, #0
    cpsie if /* Re-enable IRQs/FIQs */

    pop {pc}

    .align 4
    _ioLogOffset:
    .long 0xaaaaaaaa
    _PE_state:
    .long 0xaaaaaaaa

    _task_for_pid0_patch:
    .long (0xa802e006)
    _task_for_pid0:
    .long 0xaaaaaaaa

    _vmMapProtect_patch:
    .long (0x2000e005)
    _vmMapProtect:
    .long 0xaaaaaaaa

    _vmMapEnter_patch:
    .long (0x46c02806)
    _vmMapEnter:
    .long 0xaaaaaaaa

    /* data patches */
    _procEnforce:
    .long 0xaaaaaaaa
    _amfiCSEnforcementDisable:
    .long 0xaaaaaaaa
    _PE_I_can_has_debugger:
    .long 0xaaaaaaaa
    _csEnforcementDisable:
    .long 0xaaaaaaaa
    _PE_initialize_console:
    .long 0xaaaaaaaa
    _kernelSlide:
    .long 0xaaaaaaaa

    _helloString:
    .asciz "your kernel is now supervised by @winocm.
    "
    .align 4
    _bootArguments:
    .asciz "debug=0x14e serial=3 -v cs_enforcement_disable=1 amfi=0xff "
    .align 4

    /*
    * Pad the shellcode out.
    */
    .org 512
    .align 2
    _kernel_code_end:
    nop

  2. #2
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    code này là code asm(hợp ngữ) [IMG]images/smilies/17.gif[/IMG]

  3. #3
    Ngày tham gia
    Sep 2015
    Bài viết
    0
    Thế à ^.^
    Mình không biết nhưng thấy cũng quen quen.
    Mấy bữa trước có xem qua mấy cuốn sách C thì thấy cái kernel quen quen hehe ^.^

 

 

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •