VM 복제시 네트워크 안 되는 현상

주 원인은 MAC 주소 충돌 또는 불일치일 가능성이 크다.


터미널 명령어에

ifconfig eth0 down

ifconfig eth0 hw ether (VM상에 설정되어 있는 MAC주소)

ifconfig eth0 up


이래도 안되면

/etc/udev/rules.d/70-persistent-net.rules을 날려버리자


chmod 700 /usr/bin/w
chmod 700 /etc/alternatives/w
chmod 700 /usr/bin/w.procps
chmod 700 /bin/touch
chmod 700 /usr/bin/touch
chmod 700 /usr/bin/chsh
chmod 700 /bin/ps
chmod 700 /bin/mkdir
chmod 700 /bin/kill //(?)
chmod 700 /usr/bin/find
chmod 700 /bin/rmdir
chmod 700 /usr/bin/vi
chmod 700 /bin/ln
chmod 700 /usr/bin/env
chmod 700 /usr/bin/gcc
chmod 700 /usr/share/bash-completion/completions/export
chmod 700 /sbin/ifconfig
chmod 700 /bin/uname
chmod 700 /usr/sbin/useradd
chmod 700 /usr/sbin/adduser
chmod 700 /usr/sbin/userdel
chmod 700 /usr/share/X11/xkb/symbols/cd
chmod 700 /bin/cp
chmod 700 /bin/rm
chmod 700 /bin/mv
chmod 700 /usr/local/bin/python
chmod 700 /usr/bin/perl
chmod 700 /bin/su
chmod 700 /sbin/reboot
chmod 700 /usr/bin/apt-get
chmod 700 /usr/bin/wall
chmod 700 /usr/bin/vim
chmod 700 /usr/bin/gdb
chmod 700 /usr/bin/killall
chmod 700 /usr/bin/pstree
chmod 700 /usr/bin/top
chmod 700 /usr/bin/nice
chmod 700 /usr/bin/renice
chmod 700 /usr/bin/nohup
chmod 700 /sbin/init
chmod 700 /bin/netstat
chmod 700 /sbin/shutdown
chmod 700 /sbin/halt
chmod 700 /usr/bin/passwd

chmod 700 /usr/bin/wget


우리는 일부러 취약한 파일을 32비트로 컴파일을 할때 보통

gcc -m32 -o File File.c -fno-stack-protector


위와 같이 입력한다.


근데 아래와 같은 에러가뜨면

In file included from /usr/include/features.h:399:0,

                 from /usr/include/stdio.h:27,

                 from WeakFile.c:1:

/usr/include/gnu/stubs.h:7:27: fatal error: gnu/stubs-32.h: 그런 파일이나 디렉터리가 없습니다

 # include <gnu/stubs-32.h>

                           ^

compilation terminated.



이 명령어를 쳐서 라이브러리를 설치해주자..

yum install glibc-devel.i686 libstdc++-devel.i686


ASLR 이란

Adress Space Layout Randomization이란 뜻으로 메모리 보호기법중 하나이다

프로그램이 실행될때마다 실행되는 메모리 주소가 달라짐


하제방법

sysctl -w kernel.randomize_va_space=0

위와 같이하면

kernel.randomize_va_space = 0와 같이 뜨게된다.

다시활성화 시키려면 끝에 1을 적어주면됨

-----------------------------

또는

echo 0 >> /proc/sys/kernel/randomize_va_space

환경변수 주소 변경되는것 해제

------------------------------

스택가드 해제

gcc할때 옵션을 걸어준다.


스택가드 해제 및 더미값일정하게 만들기위해서 

gcc -o test test.c -fno-stack-protector -mpreferred-stack-boundary=2 -zexecstack

와같이 명령을 넣어주면 된다.



---------------------------

<추가적으로 잘 정리된 곳> 출처 : http://kaspyx.kr/3


* 공격환경 만들 때 컴파일 옵션들

-fno-stack-protector : 스택프로텍트

-fno-builtin : 표준 라이브러리와 링크되지 말고 단독으로 링크하라는 의미

-mpreferred-stack-boundary=2 : 더미 없애기

-z execstack : 스택에 실행 권한 주기


* 랜덤스택 (0 이면 해제)

sysctl -w kernel.randomize_va_space=1

(stack만 랜덤)

sysctl -w kernel.randomize_va_space=2

(heap/stack 둘다랜덤)

randomize_va_space=0 : ASLR 해제
randomize_va_space=1 : 랜덤 스택 & 랜덤 라이브러리 설정
randomize_va_space=2 : 랜덤 스택 & 랜덤 라이브러리 & 랜덤 힙 설정

* 스택 실행권한

sysctl -w kernel.exec-shield=0 (스택 실행권한 해제)

sysctl -w kernel.exec-shield=1 (위와 반대)


/etc/sysctl.conf에 저장되어있음


+ Recent posts