Netcat 사용법

energy·2022년 7월 29일
0

system

목록 보기
3/4

Netcat

TCP / UDP 프로토콜을 사용하는 네트워크 연결에서 데이터를 읽고 쓰는 간단한 프로그램


Options

-d 콘솔에서 분리, 백그라운드 모드
-e prog 인바운드 프로그램 실행 [위험!!]
-g 게이트웨이 소스 라우팅 홉 포인트, 최대 8개
-G num 소스 라우팅 포인터: 4, 8, 12, ...
-h 이 크러스트
-i 초 전송된 라인 지연 간격, 포트 스캔
-l 수신 모드, 인바운드 연결용
-L 더 열심히 듣고 소켓을 닫을 때 다시 듣기
-n 숫자 전용 IP 주소, DNS 없음
-o 파일 16진수 트래픽 덤프
-p 포트 로컬 포트 번호
-r 로컬 및 원격 포트를 무작위로 지정
-s addr 로컬 소스 주소
-t TELNET 협상에 응답
-c LF 대신 CRLF를 보냄
-u UDP 모드
-v verbose [더 자세한 정보를 얻으려면 두 번 사용]
-w secs 연결 및 최종 순 읽기에 대한 시간 초과
-z 제로-I

-e Option

침투테스트 시 리버스 쉘을 사용하기 위해 -e 옵션을 자주 사용한다.
간혹 아래와 같이 -e 옵션이 설치되지 않은 버전이 있다.

root@energy:~# nc -lvp 7777 -e /bin/bash

nc: invalid option -- 'e'
usage: nc [-46CDdFhklNnrStUuvZz] [-I length] [-i interval] [-M ttl]
	  [-m minttl] [-O length] [-P proxy_username] [-p source_port]
	  [-q seconds] [-s source] [-T keyword] [-V rtable] [-W recvlimit] [-w timeout]
	  [-X proxy_protocol] [-x proxy_address[:port]] 	  [destination] [port]

이럴 땐, netcat-traditional을 설치하고, 해당 버전으로 설정해야 사용할 수 있다.
root@energy:~# sudo apt-get install netcat-traditional

Reading package lists... Done
. . .
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
root@energy:~# sudo update-alternatives --config nc

There are 2 choices for the alternative nc (providing /bin/nc).
  Selection    Path                 Priority   Status
------------------------------------------------------------
* 0            /bin/nc.openbsd       50        auto mode
  1            /bin/nc.openbsd       50        manual mode
  2            /bin/nc.traditional   10        manual mode

Press <enter> to keep the current choice[*], or type selection number: 2
update-alternatives: using /bin/nc.traditional to provide /bin/nc (nc) in manual mode

이제 -e 옵션을 통해 쉘을 Open 할 수 있다.

root@energy:~# nc -lvp 7777 -e /bin/bash
listening on [any] 7777 ...

0개의 댓글