Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff -rupN make-static-0.01/Makefile make-static-0.02/Makefile
- --- make-static-0.01/Makefile 2004-11-18 16:48:02.000000000 +0100
- +++ make-static-0.02/Makefile 2013-06-30 15:51:56.243592997 +0200
- @@ -1,6 +1,6 @@
- OBJECTS = make-static
- -CFLAGS = -g -Wall -O3
- +CFLAGS = -g -W -Wall -Wextra -O3
- CHPAX = /sbin/chpax
- DEPAX = test ! -x $(CHPAX) || $(CHPAX) -xperms
- diff -rupN make-static-0.01/imagewriter.c make-static-0.02/imagewriter.c
- --- make-static-0.01/imagewriter.c 2004-11-14 11:22:17.000000000 +0100
- +++ make-static-0.02/imagewriter.c 2013-06-30 15:49:35.089390936 +0200
- @@ -13,7 +13,7 @@
- #include <dirent.h>
- #include <fcntl.h>
- #include <signal.h>
- -#include <linux/user.h>
- +#include <sys/user.h>
- #include <linux/kdev_t.h>
- #include <asm/ldt.h>
- #include <elf.h>
- @@ -93,7 +93,7 @@ int write_proc_image_to_elf(struct proc_
- eh.e_type = ET_EXEC;
- eh.e_machine = EM_386;
- eh.e_version = EV_CURRENT;
- - eh.e_entry = p->user_data.regs.eip;
- + eh.e_entry = p->user_data.regs.rip;
- eh.e_phoff = sizeof(eh);
- eh.e_shoff = 0;
- eh.e_flags = 0x112;
- diff -rupN make-static-0.01/make-static.c make-static-0.02/make-static.c
- --- make-static-0.01/make-static.c 2004-11-18 16:45:27.000000000 +0100
- +++ make-static-0.02/make-static.c 2013-06-30 15:49:37.361426379 +0200
- @@ -7,7 +7,7 @@
- #include <sys/types.h>
- -#include <linux/user.h>
- +#include <sys/user.h>
- #include <sys/ptrace.h>
- #include <fcntl.h>
- #include <elf.h>
- diff -rupN make-static-0.01/process.c make-static-0.02/process.c
- --- make-static-0.01/process.c 2004-11-14 10:00:43.000000000 +0100
- +++ make-static-0.02/process.c 2013-06-30 15:54:02.013554965 +0200
- @@ -23,7 +23,7 @@
- #include <dirent.h>
- #include <fcntl.h>
- #include <signal.h>
- -#include <linux/user.h>
- +#include <sys/user.h>
- #include <linux/kdev_t.h>
- #include <asm/ldt.h>
- #include <asm/unistd.h>
- @@ -36,7 +36,7 @@ long scribble_zone = 0; /* somewhere to
- char* backup_page(pid_t target, void* addr) {
- long* page = malloc(PAGE_SIZE);
- - int i;
- + size_t i;
- long ret;
- for(i = 0; i < PAGE_SIZE/sizeof(long); i++) {
- ret = ptrace(PTRACE_PEEKTEXT, target, (void*)((long)addr+(i*sizeof(long))), 0);
- @@ -58,7 +58,7 @@ char* backup_page(pid_t target, void* ad
- int restore_page(pid_t target, void* addr, char* page) {
- long *p = (long*)page;
- - int i;
- + size_t i;
- assert(page);
- for (i = 0; i < PAGE_SIZE/sizeof(long); i++) {
- if (ptrace(PTRACE_POKETEXT, target, (void*)((long)addr+(i*sizeof(long))), p[i]) == -1) {
- @@ -74,7 +74,7 @@ int restore_page(pid_t target, void* add
- int memcpy_into_target(pid_t pid, void* dest, const void* src, size_t n) {
- /* just like memcpy, but copies it into the space of the target pid */
- /* n must be a multiple of 4, or will otherwise be rounded down to be so */
- - int i;
- + size_t i;
- long *d, *s;
- d = (long*) dest;
- s = (long*) src;
- @@ -90,7 +90,7 @@ int memcpy_into_target(pid_t pid, void*
- int memcpy_from_target(pid_t pid, void* dest, const void* src, size_t n) {
- /* just like memcpy, but copies it from the space of the target pid */
- /* n must be a multiple of 4, or will otherwise be rounded down to be so */
- - int i;
- + size_t i;
- long *d, *s;
- d = (long*) dest;
- s = (long*) src;
- @@ -143,7 +143,7 @@ int do_syscall(pid_t pid, struct user_re
- }
- /* Set up registers for ptrace syscall */
- - regs->eip = loc;
- + regs->rip = loc;
- if (ptrace(PTRACE_SETREGS, pid, NULL, regs) < 0) {
- perror("ptrace setregs");
- return 0;
- @@ -396,7 +396,7 @@ int get_one_vma(pid_t target_pid, char*
- }
- int get_user_data(pid_t target_pid, struct user *user_data) {
- - long pos;
- + unsigned long pos;
- int* user_data_ptr = (int*)user_data;
- /* We have a memory segment. We should retrieve its data */
- @@ -411,7 +411,7 @@ int get_user_data(pid_t target_pid, stru
- return 1;
- }
- -int get_i387_data(pid_t target_pid, struct user_i387_struct* i387_data) {
- +int get_i387_data(pid_t target_pid, struct user_fpregs_struct* i387_data) {
- /* We have a memory segment. We should retrieve its data */
- fprintf(stderr, "[+] Retrieving FP registers... ");
- @@ -432,20 +432,20 @@ off_t get_file_offset(pid_t pid, int fd,
- return 0;
- }
- - r.eax = __NR_lseek;
- - r.ebx = fd;
- - r.ecx = offset;
- - r.edx = whence;
- + r.rax = __NR_lseek;
- + r.rbx = fd;
- + r.rcx = offset;
- + r.rdx = whence;
- if (!do_syscall(pid, &r)) return 0;
- /* Error checking! */
- - if (r.eax < 0) {
- - errno = -r.eax;
- + if ((signed)r.rax < 0) {
- + errno = -r.rax;
- return (off_t)(-1);
- }
- - return r.eax;
- + return r.rax;
- }
- int get_file_contents(char *filename, struct fd_entry_t *out_buf) {
- @@ -495,9 +495,9 @@ struct user_desc *get_tls_info(pid_t pid
- return u;
- }
- -int is_in_syscall(pid_t pid, void* eip) {
- +int is_in_syscall(pid_t pid, void* rip) {
- long inst;
- - inst = ptrace(PTRACE_PEEKDATA, pid, eip-2, 0);
- + inst = ptrace(PTRACE_PEEKDATA, pid, rip-2, 0);
- if (errno) {
- perror("ptrace(PEEKDATA)");
- return 0;
- @@ -513,17 +513,17 @@ int get_signal_handler(pid_t pid, int si
- return 0;
- }
- - r.eax = __NR_rt_sigaction;
- - r.ebx = sig;
- - r.ecx = 0;
- - r.edx = scribble_zone+0x100;
- - r.esi = sizeof(ksa->sa_mask);
- + r.rax = __NR_rt_sigaction;
- + r.rbx = sig;
- + r.rcx = 0;
- + r.rdx = scribble_zone+0x100;
- + r.rsi = sizeof(ksa->sa_mask);
- if (!do_syscall(pid, &r)) return 0;
- /* Error checking! */
- - if (r.eax < 0) {
- - errno = -r.eax;
- + if ((signed)r.rax < 0) {
- + errno = -r.rax;
- perror("target rt_sigaction");
- return 0;
- }
- @@ -543,16 +543,16 @@ int get_termios(pid_t pid, int fd, struc
- return 0;
- }
- - r.eax = __NR_ioctl;
- - r.ebx = fd;
- - r.ecx = TCGETS;
- - r.edx = scribble_zone+0x50;
- + r.rax = __NR_ioctl;
- + r.rbx = fd;
- + r.rcx = TCGETS;
- + r.rdx = scribble_zone+0x50;
- if (!do_syscall(pid, &r)) return 0;
- /* Error checking! */
- - if (r.eax < 0) {
- - errno = -r.eax;
- + if ((signed)r.rax < 0) {
- + errno = -r.rax;
- perror("target ioctl");
- return 0;
- }
- @@ -570,19 +570,19 @@ int get_fcntl_data(pid_t pid, int fd, st
- return 0;
- }
- - r.eax = __NR_fcntl;
- - r.ebx = fd;
- - r.ecx = F_GETFD;
- + r.rax = __NR_fcntl;
- + r.rbx = fd;
- + r.rcx = F_GETFD;
- if (!do_syscall(pid, &r)) return 0;
- /* Error checking! */
- - if (r.eax < 0) {
- - errno = -r.eax;
- + if ((signed)r.rax < 0) {
- + errno = -r.rax;
- perror("target fcntl");
- return 0;
- }
- - f->close_on_exec = r.eax;
- + f->close_on_exec = r.rax;
- return 1;
- }
- @@ -646,11 +646,11 @@ struct proc_image_t* get_proc_image(pid_
- proc_image = NULL;
- goto out_ptrace;
- }
- - fprintf(stderr, "EIP is 0x%lx\n", proc_image->user_data.regs.eip);
- - if (is_in_syscall(target_pid, (void*)proc_image->user_data.regs.eip)) {
- + fprintf(stderr, "rip is 0x%llx\n", proc_image->user_data.regs.rip);
- + if (is_in_syscall(target_pid, (void*)proc_image->user_data.regs.rip)) {
- fprintf(stderr, "[+] Process is probably in syscall. Noting this fact.\n");
- - proc_image->user_data.regs.eip-=2;
- - proc_image->user_data.regs.eax = proc_image->user_data.regs.orig_eax;
- + proc_image->user_data.regs.rip-=2;
- + proc_image->user_data.regs.rax = proc_image->user_data.regs.orig_rax;
- }
- /* Get FP regs */
- diff -rupN make-static-0.01/process.h make-static-0.02/process.h
- --- make-static-0.01/process.h 2004-11-14 10:29:15.000000000 +0100
- +++ make-static-0.02/process.h 2013-06-30 15:50:56.734665097 +0200
- @@ -13,7 +13,7 @@
- #include <sys/ptrace.h>
- #include <sys/mman.h>
- #include <signal.h>
- -#include <linux/user.h>
- +#include <sys/user.h>
- #include <linux/kdev_t.h>
- #include <linux/types.h>
- #include <asm/ldt.h>
- @@ -71,7 +71,7 @@ struct fd_entry_t {
- struct proc_image_t {
- pid_t pid;
- struct user user_data;
- - struct user_i387_struct i387_data;
- + struct user_fpregs_struct i387_data;
- int num_maps;
- struct map_entry_t *maps;
- int num_tls;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement