
XeroSecurity가 Sn1per v9.0 무료 버전에서 발견한 두 가지 보안 문제
KALI/UBUNTU/DEBIAN/PARROT LINUX INSTALL:
git clone https://github.com/1N3/Sn1per
cd Sn1per
bash install.sh
root@snipertest:~# git clone https://github.com/1N3/Sn1per
Cloning into 'Sn1per'...
remote: Enumerating objects: 2838, done.
remote: Counting objects: 100% (13/13), done.
remote: Compressing objects: 100% (9/9), done.
remote: Total 2838 (delta 5), reused 10 (delta 4), pack-reused 2825
Receiving objects: 100% (2838/2838), 43.18 MiB | 18.76 MiB/s, done.
Resolving deltas: 100% (1950/1950), done.
root@snipertest:~# cd Sn1per/
root@snipertest:~/Sn1per# bash install.sh
____
_________ / _/___ ___ _____
/ ___/ __ \ / // __ \/ _ \/ ___/
(__ ) / / // // /_/ / __/ /
/____/_/ /_/___/ .___/\___/_/
/_/
+ -- --=[ https://xerosecurity.com
+ -- --=[ Sn1per by @xer0dayz
[>] This script will install sn1per under /usr/share/sniper. Are you sure you want to continue? (Hit Ctrl+C to exit)
y
[snip]
'/usr/share/sniper/sniper.conf' -> '/root/.sniper.conf'
Please run msfdb as a non-root user
[*] Adding start menu and desktop shortcuts...
[>] Done!
[>] To run, type 'sniper'!
root@snipertest:~/Sn1per#
설치 직후 설치 디렉터리의 권한은 다음과 같이 설정됩니다:
root@snipertest:~/Sn1per# ls -ld /usr/share/sniper/
❗drwxrwxrwx❗ 10 root root 4096 Aug 16 19:19 /usr/share/sniper/
root@snipertest:~/Sn1per# ls -la /usr/share/sniper/
total 6668
drwxrwxrwx 10 root root 4096 Aug 16 19:19 .
drwxr-xr-x 222 root root 12288 Aug 16 19:41 ..
-rw-r--r-- 1 root root 36518 Aug 16 18:33 CHANGELOG.md
-rw-r--r-- 1 root root 1269 Aug 16 18:33 Dockerfile
-rw-r--r-- 1 root root 306 Aug 16 18:33 LICENSE.md
-rw-r--r-- 1 root root 11697 Aug 16 18:33 README.md
-rw-r--r-- 1 root root 6491364 Aug 16 18:33 Sn1per.gif
-rw-r--r-- 1 root root 159147 Aug 16 18:33 Sn1per.jpg
drwxr-xr-x 2 root root 4096 Aug 16 18:33 bin
drwxr-xr-x 2 root root 4096 Aug 16 19:41 conf
rwxr-xr-x 1 root root 11548 Aug 16 18:33 install.sh
drwxr-xr-x 9 root root 4096 Aug 16 19:42 loot
drwxr-xr-x 2 root root 4096 Aug 16 18:33 modes
drwxr-xr-x 43 root root 4096 Aug 16 19:27 plugins
drwxr-xr-x 2 root root 4096 Aug 16 18:33 pro
-rw-r--r-- 1 root root 276 Aug 16 18:33 sn1per.desktop
-rw-r--r-- 1 root root 4283 Aug 16 18:33 sn1per.png
-rwxr-xr-x 1 root root 28290 Aug 16 18:33 sniper
-rw-r--r-- 1 root root 9752 Aug 16 18:33 sniper.conf
drwxr-xr-x 4 root root 4096 Aug 16 18:33 templates
-rwxr-xr-x 1 root root 980 Aug 16 18:33 uninstall.sh
drwxr-xr-x 2 root root 4096 Aug 16 18:33 wordlists
모든 파일의 소유자가 root이지만, 포함하는 디렉터리의 권한으로 인해 파일을 조작할 수 있으므로 스크립트 중 하나에 백도어를 배치할 수 있습니다. 또 다른, 아마도 더 은밀한 수정 방법은 구성 파일(sniper.conf)에 백도어를 배치하는 것입니다. 이 파일은 bash source 명령으로 소싱되기 때문입니다.
애플리케이션은 root로 실행되어야 하며, 이는 스크립트의 EUID 검사를 통해 보장됩니다:
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
여기에 백도어를 배치하면 다음에 애플리케이션이 사용될 때 root 권한으로 실행됩니다.
설치 스크립트의 37-40행:
mkdir -p $INSTALL_DIR 2> /dev/null
chmod 777 -Rf $INSTALL_DIR 2> /dev/null
chown root $INSTALL_DIR/sniper 2> /dev/null
chmod 4777 $INSTALL_DIR/sniper 2> /dev/null
CVE-2021-39274와 다른 문제
애플리케이션을 처음 실행하면 스캐너 메인 스크립트 sniper가 init 함수를 실행하여 설치 디렉터리와 그 내용에 대한 권한을 재귀적으로 변경합니다.
_CVE-2021-39274_와 마찬가지로, 실행 파일과 구성을 포함한 모든 애플리케이션 파일을 수정할 수 있고, 그 안에 백도어를 배치하여 다음에 애플리케이션이 root에 의해 사용될 때 root 권한으로 실행되게 할 수 있습니다.
메인 스크립트의 464-466행:
chmod 777 -Rf $INSTALL_DIR 2> /dev/null
chown root $INSTALL_DIR/sniper 2> /dev/null
chmod 4777 $INSTALL_DIR/sniper 2> /dev/null