• ¡Welcome to Square Theme!
  • This news are in header template.
  • Please ignore this message.
مهمان عزیز خوش‌آمدید. ورود عضــویت


امتیاز موضوع:
  • 34 رای - 2.82 میانگین
  • 1
  • 2
  • 3
  • 4
  • 5
Title: anti-debug.c
حالت موضوعی
#1
کد:
/*
* Thx Silvio Cesare Doc Anti-debug and special thx zert for other info :)
*/


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <termios.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ptrace.h>
#include <sys/wait.h>
#include <sys/syscall.h>
#include <asm/unistd.h>

#include "printf.h"


int
check_gdb_getenv(void) {

    extern char *__progname;

    if (!getenv("_")) {
        eprintf("Not Support for _ in this Shell\n");
        return 0;
    }
    
    if (strstr(getenv("_"), __progname) == 0) {
        eprintf("Detected Posible Debug with %s\n", getenv("_"));
        return 1;
    }

return 0;
}

int
check_gdb_fd(void) {

    if (close(3) == 0) {
        eprintf("GDB Detected!\n");
        return 1;
    }

return 0;
}

int
check_ptrace(pid_t pid) {

#if defined(__Linux__)  
    if (pid) {
        if (ptrace(PTRACE_ATTACH, pid, 0, 0) < 0) {
            eprintf("ptrace(): Detected! -> %s\n",strerror(errno));
            return 1;
        }
    }
    else
        if (ptrace(PTRACE_TRACEME, pid, 0, 0) < 0) {
            eprintf("ptrace(): Detected! -> %s\n",strerror(errno));
            return 1;
        }
#endif
    
return 0;
}

int
check_breakpoint(void *addr, int offset) {

    if ((*(volatile unsigned *)((unsigned)addr + offset) & 0xff) == 0xcc) {
        eprintf("Warning: breakpoint(%p + %d): Breakpoint Detected!\n", addr, offset);
        exit(2);
    }

return 0;
}

unsigned int
func_size(void *addr) {

    unsigned int byte = 1;
    unsigned int _break = 1;

    //     0x55 == push %ebp
    //     0xc3 == ret
    
    do {    
        /*    
        if ((*(volatile unsigned *)((unsigned)addr+byte) & 0xff) == 0xc3) {
            _break=1;
        }
        */
        if ((*(volatile unsigned *)((unsigned)addr+byte) & 0xff) == 0x55) {
            if (_break) {
            break;
            }
        }
    } while (byte++);

return byte;
}

pid_t getsid(pid_t );
pid_t getpgid(pid_t );

int
check_sid(void) {
/*
    printf("getsid: %d\n", getsid(0));
    printf("getppid: %d\n", getppid());
    printf("getpgid: %d\n", getpgid(0));

    if (getsid(0) != getppid()) {
        return 1;
    }
*/
return 0;

}
گروه دور همی پارسی کدرز
https://t.me/joinchat/GxVRww3ykLynHFsdCvb7eg
 
پاسخ
  


موضوعات مشابه ...
موضوع نویسنده پاسخ بازدید آخرین ارسال
  [C#][Snippets] Anti-WPE, Wireshark, Sandboxie, Emulation Amin_Mansouri 1 9,299 02-19-2015، 11:41 AM
آخرین ارسال: MBlackHat
  Anti-Debbuger Amin_Mansouri 0 4,420 01-12-2012، 11:43 PM
آخرین ارسال: Amin_Mansouri
  Anti Virtual PC vb.net Amin_Mansouri 0 4,448 10-18-2011، 09:03 PM
آخرین ارسال: Amin_Mansouri
  [VB.Net] Anti's Thread Amin_Mansouri 0 4,496 10-16-2011، 10:46 PM
آخرین ارسال: Amin_Mansouri
  C++ Anti-Debug Library: x64-compatible! Amin_Mansouri 0 5,651 09-28-2011، 06:18 PM
آخرین ارسال: Amin_Mansouri
  C++ Anti-Debug: Another trick Amin_Mansouri 0 3,548 09-22-2011، 12:34 AM
آخرین ارسال: Amin_Mansouri

پرش به انجمن:


Browsing: 1 مهمان