Linux Dynamic Code Injection

Source: Internet
Author: User

Reference Online article: http://www.freebuf.com/articles/system/6388.html

According to the article, the dynamic injection of code, that is, a running process, without restarting the implementation of the code is not within the original program.

My lab Environment:

Ubuntu 14.10 System

1.Makefile Compilation:

All:
Gcc-g-wall Dynlib.c-fpic-shared-o libdynlib.so
GCC app.c-g-o app-ldynlib-l./
Gcc-wall injection.c-c-O INJECTION.O
Clean:
Rm-f libdynlib.so


2. My experiment records:

GDB) Call Open ("INJECTION.O", 2)
$ = 3
(GDB) Call Mmap (0, 1056, 1|2|4, 1, 3, 0)
$1216774144
(GDB) P &print
$4 = (void (*) ()) 0xb7782575 <print>
(GDB) p/x *0x0804a010
$ $ = 0xb7782575
(GDB) p/x *0x08
Cannot access memory at address 0x8
(GDB) p/x *0x0804a010
$6 = 0xb7782575
(GDB) p/x *0x0804a010
$7 = 0xb7782575
(GDB) Set *0x0804a010 = 0xb7798000 + 0x000034
(GDB) P &system
$8 = (<text variable, no debug info> *) 0xb7612770 <__libc_system>
(GDB) p * (0xb7798000 + 0x000034 + 0x00000014)
$9 =-4
(GDB) Set * (0xb7798000 + 0x000034 + 0x00000014) = 0xb7612770-(0xb7798000 + 0x000034 + 0x00000014)-4
(GDB) P &print
$ = (void (*) ()) 0xb7782575 <print>
(GDB) p * (0xb7798000 + 0x000034 + 00000007)
$11 =-4
(GDB) Set * (0xb7798000 + 0x000034 + 00000007) = 0xb7782575-(0xb7798000 + 0x000034 + 00000007)-4
(GDB) p * (0xb7798000 + 0x000034 + 0x0000000f)
$0
(GDB) Set * (0xb7798000 + 0x000034 + 0x0000000f) = 0xb7798000 + 0x000051
(GDB)

Linux Dynamic Code Injection

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.