Skip to main content

ubuntu的机器被黑了~

今早到学校,打开ubuntu机器,发现桌面是空的.我记得很清楚前一天走的时候还在写程序,打开了很多窗口,怎么窗口自动关闭了呢? 马上打开用户管理,发现多了一个nobody5的帐户.在application里也多了一个zenmap的扫描器.一部小心我成了别人肉鸡和跳板,汗~
然后我决定把nobody5找出来:
1 断网线
2 查看未知帐号"grep :x :0: /etc/passwd",发现多了一个管理员用户nobody5.
root:x:0:0:root:/root:/bin/bash
nobody5:x:0:1002:SunOS 5.x Nobody:/tmp:/bin/bash
3  "last -a"查找所有登录过的用户,看到了这厮~worldserver.net的ip显示是德国~
nobody5  pts/5        Tue Oct 13 19:14 – 21:15  (02:00)     vz275.worldserver.net
nobody5  pts/4        Tue Oct 13 17:09 – 19:42  (02:33)     vz275.worldserver.net
nobody5  pts/3        Tue Oct 13 16:17 – 19:40  (03:23)     vz275.worldserver.net
4 在用户管理器里修改nobody5的密码,然后用nobody5的帐号登陆,看看他干过什么."histroy"查看,动作很利落,没有什么多余的命令,注释如下:
    1  df -h  //查看磁盘使用情况
    2  cat /proc/version //查看系统版本信息
    3  cd ~
    6  ls -la //查看我的目录
    7  ifconfig -a //查看ip信息
    8  find / -name .bashrc //查看有几个bashrc,应该是看用户情况
    9  find / -name .bash_history
   10  vi /home/ppa/.bash_history //查看我输入过什么命令
   11  env //系统环境便量
   12  cat /etc/shadow //用户信息
   14  pwd //当前路径
   16  wget http://mirrors.kernel.org/debian-cd/5.0.3/i386/iso-cd/debian-503-i386-CD-31.iso //下了个镜像
   18  rm debian-503-i386-CD-31.iso //把刚下的东西删了,估计nobody5觉得这个没用
   19  apt-get install nmap //装nmap
   23  nmap -PN -T4 -p445 -n -v –script smb-check-vulns,smb-os-discovery *.*.0.0/16>>temp //开始扫描和我同网段的机器
   28  wget http://nmap.org/svn/scripts/smb-check-vulns.nse //装上一个加强版的脚本
   29  nmap -PN -T4 -p445 -n -v –script smb-check-vulns,smb-os-discovery *.*.0.0/16>>temp //再扫一遍
   36  rm temp //完事屁屁
   58  nmap -PN -T4 -p445 -n -v args=unsafe=1 –script smb-check-vulns,smb-os-discovery 129.59.0.0/16>>temp //胡汉山又回来了
   59  apt-get remove nmap //二擦屁屁
   60  rm -rf /usr/share/nmap //三擦屁屁
   71  cd mail //看我的邮件
   78  wget http://nmap.org/dist/nmap-5.00.tar.bz2 //下载一个最新版的nmap
   79  bzip2 -cd nmap-5.00.tar.bz2 | tar xvf – //解压缩
   80  cd nmap-5.00
   81  ./configure
   82  make
   83  make install
   85  find / -name nmap
   86  /usr/local/bin/nmap //装上了namp
   89  /usr/local/bin/nmap -PN -T4 -p445 -n -v –script smb-check-vulns,smb-os-discovery *.*.0.0/16>>temp //扫描同网机器
   90  /usr/local/bin/nmap -PN -T4 -p445 -n -v –script smb-check-vulns,smb-os-discovery 160.129.0.0/16>>temp2 //5555~我成了跳板
   91  cd /var/tmp/nmap-5.00
   94  tail -f temp | grep vul //看看谁的机器还有漏洞
  110  cat temp | grep -B 12 VULN
 
  460  wget http://iroffer.dinoex.net/iroffer-dinoex-3.15.tar.gz //装iroffer
5 修补漏洞:
a 改一个强壮的本机密码
b “userdel -r newuser”删除帐户(用户管理里删除不了管理员帐户)
c 重启机器发现无法从图形界面里登录了,显示错误“/etc/gdm/Xsession: Beginning session setup… mkdtemp: private socket dir: Permission denied.”,估计是和删除管理员帐户有关.幸好还能通过ssh远程登录,修改"/tmp"的权限:“chmod a+w /tmp”,搞定~
4 卸载namp
5 关闭ftp服务。虽然我的ftp已经换了端口,保险起见,还是先关了~
将"etc/rc5.d/S20vsftpd"改名成"K20vsftpd"
6 限制访问本机的ip:
在/etc/hosts.allow中添加允许的ip或者网段 
ALL:192.168.1.2:allow 或者
ALL:192.168.1.0/24:allow 
在/etc/hosts.deny添加不允许ssh登陆的IP
ALL: ALL@ALL, PARANOID
7 关闭ipp
sudo /etc/init.d/cupsys stop
sudo update-rc.d -f cupsys remove
8 设置ping,icmp和其他
a in ubuntu ping can be disable by adding following line to /etc/init.d/networking (network init script)
echo 1 >/proc/sys/net/ipv4/icmp_echo_ignore_all
b in 8.04.1 /etc/sysctl.conf add:
# Ignore ICMP broadcasts
net/ipv4/icmp_echo_ignore_broadcasts = 1
#
# Ignore bogus ICMP errors
net/ipv4/icmp_ignore_bogus_error_responses = 1
#
# Do not accept ICMP redirects (prevent MITM attacks)
net/ipv4/conf/all/accept_redirects = 0
# _or_
# Accept ICMP redirects only for gateways listed in our default
# gateway list (enabled by default)
net/ipv4/conf/all/secure_redirects = 0
#
# Do not send ICMP redirects (we are not a router)
net/ipv4/conf/all/send_redirects = 0
#
# Do not accept IP source route packets (we are not a router)
net/ipv4/conf/all/accept_source_route = 0

also add to /etc/ufw/sysctl.conf:

#Ignorar Broadcast.
net/ipv4/icmp_echo_ignore_broadcasts=1

#Ignorar pings.
net/ipv4/icmp_echo_ignore_all=1

#No responder a paquetes icmp defectuosos.
net/ipv4/icmp_ignore_bogus_error_responses=1
ps:现在用"netstat -a -t"查看,只剩下ssh, vnc的端口还在使用,ping主机没反应,很完美~应该能清静一会了~
ps2:安装chkrootkit又查了一遍,确保没有留下后门,这次真的该清静了~

Comments

Popular posts from this blog

CKA Simulator Kubernetes 1.22

  https://killer.sh Pre Setup Once you've gained access to your terminal it might be wise to spend ~1 minute to setup your environment. You could set these: alias k = kubectl                         # will already be pre-configured export do = "--dry-run=client -o yaml"     # k get pod x $do export now = "--force --grace-period 0"   # k delete pod x $now Vim To make vim use 2 spaces for a tab edit ~/.vimrc to contain: set tabstop=2 set expandtab set shiftwidth=2 More setup suggestions are in the tips section .     Question 1 | Contexts Task weight: 1%   You have access to multiple clusters from your main terminal through kubectl contexts. Write all those context names into /opt/course/1/contexts . Next write a command to display the current context into /opt/course/1/context_default_kubectl.sh , the command should use kubectl . Finally write a second command doing the same thing into ...

OWASP Top 10 Threats and Mitigations Exam - Single Select

Last updated 4 Aug 11 Course Title: OWASP Top 10 Threats and Mitigation Exam Questions - Single Select 1) Which of the following consequences is most likely to occur due to an injection attack? Spoofing Cross-site request forgery Denial of service   Correct Insecure direct object references 2) Your application is created using a language that does not support a clear distinction between code and data. Which vulnerability is most likely to occur in your application? Injection   Correct Insecure direct object references Failure to restrict URL access Insufficient transport layer protection 3) Which of the following scenarios is most likely to cause an injection attack? Unvalidated input is embedded in an instruction stream.   Correct Unvalidated input can be distinguished from valid instructions. A Web application does not validate a client’s access to a resource. A Web action performs an operation on behalf of the user without checkin...