Intercept linux2.4.20-8 and the system crashes when calling the function write.
Source: Internet
Author: User
During the interception of the write function of the linux2.4.20-8 system, the system crashes. For details, refer to Linux general technology-Linux programming and kernel information. If you replace write with mkdir, everything is normal, and mkdir becomes a null operation.
Source code:
# Ifndef MODULE
# Define MODULE
# Endif
# Ifndef _ KERNEL __
# Define _ KERNEL __
# Endif
# Include
# Include
# Include
# Include
# Include
# Include
# Include
# Include
MODULE_LICENSE ("GPL ");
Int ** sys_call_table = (int **) 0xc030a0f0;/* sys_call_table is exported, so we can access it */
Static unsigned long orig_write; // (int fd, char * buf, size_t count );
Int hacked_write (int fd, char * buf, size_t count)
{
Return 0;/* everything is OK, but he new systemcall does nothing */
}
Int init_module (void)/* module setup */
{
Orig_write = sys_call_table [SYS_write];
Sys_call_table [SYS_write] = hacked_write;
Return 0;
}
Void cleanup_module (void)/* module shutdown */
{
Sys_call_table [SYS_write] = orig_write;/* set mkdir syscall to the origal one */
}
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