Ai
1 Star 0 Fork 0

小义的爸爸/pentestpackage

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
LinEsc.sh 3.11 KB
一键复制 编辑 原始数据 按行查看 历史
Leon Teale 提交于 2017-01-25 19:13 +08:00 . updated entire repo from private
#!/bin/bash
#
# A script designed to help aid in the process of escalating a user privalage to root!
#
#
# Usage = ./LinEsc
#
# Leon Teale (@leonteale)
## Setting Coloured variables
red=`echo -e "\033[31m"`
lcyan=`echo -e "\033[36m"`
yellow=`echo -e "\033[33m"`
green=`echo -e "\033[32m"`
blue=`echo -e "\033[34m"`
purple=`echo -e "\033[35m"`
normal=`echo -e "\033[m"`
#Funcetions
header () {
clear
echo "$yellow _ _ ______ "
echo " | | (_) | ____| "
echo " | | _ _ __ | |__ ___ ___ "
echo " | | | | '_ \| __| / __|/ __|"
echo " | |____| | | | | |____\__ \ (__ "
echo " |______|_|_| |_|______|___/\___|$normal"
echo " "
echo "A script designed to aid the process of escilating user privalage to root"
echo ""
}
# Check that the user isnt already root or running script as root
sudo_check () {
if [ "$(id -u)" == "0" ]; then
echo "$green You already have root access! :D$normal" 1>&2
exit 1
echo ""
fi
}
info () {
echo "$yellow Current User$normal : `whoami`"
echo "$yellow uid/gid/group$normal: `id 2>/dev/null`"
echo "$yellow System Info$normal : `uname -a`"
echo "$yellow Distribution$normal : `cat /etc/issue`"
echo "$yellow Hostname $normal : `hostname`"
echo ""
}
# Check to see what sudo access the user has been granted
sudo_script_access () {
CAN_I_RUN_SUDO=$(sudo -n uptime 2>&1|grep "load"|wc -l)
if [ ${CAN_I_RUN_SUDO} -gt 0 ]; then
if sudo -l | grep "may run the following commands on this host" 2>/dev/null; then
echo "This user has access to $green"
sudo -l | grep root
echo "$normal"
fi
else
echo "$red Current user has no sudo access$normal"
echo ""
fi
}
# Check for suid files
suid () {
if find / -perm -4000 -type f 2>/dev/null | grep -w 'nmap\|perl\|'awk'\|'find'\|'bash'\|'sh'\|'man'\|'more'\|'less'\|'vi'\|'vim'\|'nc'\|'netcat'\|python\|ruby\|lua\|irb\|pl' ; then
echo "$yellow Possibly interesting suid files: $green"
find / -perm -4000 -type f 2>/dev/null | grep -w 'nmap\|perl\|'awk'\|'find'\|'bash'\|'sh'\|'man'\|'more'\|'less'\|'vi'\|'vim'\|'nc'\|'netcat'\|python\|ruby\|lua\|irb\|pl'
echo "$normal"
fi
echo "$yellow uid files found$normal"
find / -xdev \( -perm -4000 \) -type f -print0 2>/dev/null | xargs -0 ls -l
echo ""
}
# Check for world writable and executable files
wre () {
echo "$yellow world writable & executable files found$normal"
find / -perm -0002 -type f 2>/dev/null | grep -vE 'proc'
echo " "
}
# Check /etc/passwd for passwords
passwd () {
passwd_check=$(cat /etc/passwd | cut -d : -f 2 | grep -vE 'x' | wc -l)
if [ ${passwd_check} -gt 0 ]; then
echo "$yellow Possible password(s) found in /etc/passwd$green"
grep `cat /etc/passwd | cut -d : -f 2 | grep -w -vE 'x'` /etc/passwd
echo "$normal"
fi
}
file_access () {
echo ""
}
# Run the script
header
sudo_check
info
sudo_script_access
suid
wre
passwd
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Shell
1
https://gitee.com/csharphpython/pentestpackage.git
git@gitee.com:csharphpython/pentestpackage.git
csharphpython
pentestpackage
pentestpackage
master

搜索帮助