当前位置:网站首页>渗透测试-后渗透-痕迹清理
渗透测试-后渗透-痕迹清理
2022-07-27 01:32:00 【amingMM】
https://mp.weixin.qq.com/s/bc2zKlsQSTMPVMPfQyrXSA 后渗透-痕迹清理
Windows
修改文件时间戳
登陆到服务器,对它的⽂件进行了修改,修改后的⽂件的时间戳会更新到最新的时间,那么这样就会引起管理员的注意。
那个⽂件的时间戳给修改成其他时间。
Powershell修改时间命令
$(DATE) 表示当前日期和时间;
$(Get-Date) 同$(DATE),表示当前日期和时间;
$(Get-Date "MM/DD/YYYY HH24:MI:SS") 表示指定的日期和时间;
$(Get-Item abc.txt) 表示获取文件的句柄;
$(Get-Item abc.txt).creationtime 获取文件创建时间
$(Get-Item abc.txt).lastaccesstime 获取文件最后访问时间
$(Get-Item abc.txt).lastwritetime 获取文件修改时间
# 设置文件test.txt的时间为当前时间
$(Get-Item abc.txt).creationtime=$(DATE)
$(Get-Item abc.txt).lastaccesstime=$(DATE)
$(Get-Item abc.txt).lastwritetime=$(DATE)
# 设置文件abc.txt的时间为指定的某个时间
$(Get-Item abc.txt).creationtime=$(Get-Date "11/04/2019 20:42:23")
$(Get-Item abc.txt).lastaccesstime=$(Get-Date "11/04/2019 20:42:23")
$(Get-Item abc.txt).lastwritetime=$(Get-Date "11/04/2019 20:42:23")
修改文件时间戳
$data="10/1/2008 12:30:30";$file="C:\test.txt";$(Get-Item $file).creationtime=$(Get-Date $data);$(Get-Item $file).lastaccesstime=$(Get-Date $data);$(Get-Item $file).lastwritetime=$(Get-Date $data)
Linux
修改文件时间戳
ls -l test.txt
# 修改文件的修改时间和访问时间
touch -d "2018-04-18 08:00:00" test.txt
清除history历史命令记录
bash执行命令时不是马上把命令名称写入history文件的,
而是存放在内部的buffer中,等bash退出时会一并写入。
不过,可以调用history -w命令要求bash立即更新history文件。
history # 查看历史操作命令
cat ~/.bash_history # history记录文件
第一种方式:
编辑history记录文件,删除部分不想被保存的历史命令。
vim ~/.bash_history
清除当前用户的history命令记录
history -c
第二种方式:
利用vim执行命令
使用vim打开一个文件
vi test.txt
设置vim不记录命令,Vim会将命令历史记录,保存在viminfo文件中。
:set history=0
:!command
第三种方式:
通过修改配置文件/etc/profile,使系统不再保存命令记录。默认情况下历史命令将保存1000条,可以将该值改为0,然后保存并退出,最后重启系统使得配置文件生效。
HISTSIZE=0
第四种方式:
登录后执行下面命令,不记录历史命令(.bash_history)
unset HISTORY HISTFILE HISTSAVE HISTZONE HISTORY HISTLOG; export HISTFILE=/dev/null; export HISTSIZE=0; export HISTFILESIZE=0
清除系统日志痕迹
Linux 系统存在多种日志文件,来记录系统运行过程中产生的日志。
/var/log/btmp 记录所有登录失败信息,使用lastb命令查看
/var/log/lastlog 记录系统中所有用户最后一次登录时间的日志,使用lastlog命令查看
/var/log/wtmp 记录所有用户的登录、注销信息,使用last命令查看
/var/log/utmp 记录当前已经登录的用户信息,使用w,who,users等命令查看
/var/log/secure 记录与安全相关的日志信息
/var/log/message 记录系统启动后的信息和错误日志
第一种方式:清空日志文件
l清除登录系统失败的记录:
echo > /var/log/btmp
lastb
清除登录系统成功的记录:
echo > /var/log/wtmp
last //查询不到登录成功的信息
清除相关日志信息:
清除用户最后一次登录时间:echo > /var/log/lastlog #lastlog命令
清除当前登录用户的信息:echo > /var/log/utmp #使用w,who,users等命令
清除安全日志记录:cat /dev/null > /var/log/secure
清除系统日志记录:cat /dev/null > /var/log/message
第二种方式:删除/替换部分日志
日志文件全部被清空,太容易被管理员察觉了,如果只是删除或替换部分关键日志信息,那么就可以完美隐藏攻击痕迹。
# 删除所有匹配到字符串的行,比如以当天日期或者自己的登录ip
sed -i '/自己的ip/'d test.txt
sed -i '/192.168.1.2/'d test.txt
# 全局替换登录IP地址:
sed 's/要被取代的字串/新的字串/g'
sed -i 's/192.168.1.1/192.168.1.2/g' test.txt
隐藏远程SSH登录记录
隐身登录系统,不会被w、who、last等指令检测到。
ssh -T [email protected]192.168.0.1 /bin/bash -i
不记录ssh公钥在本地.ssh目录中
ssh -o UserKnownHostsFile=/dev/null -T [email protected] /bin/bash –i
清除Web入侵痕迹
直接替换日志ip地址
sed -i 's/192.168.166.85/192.168.1.1/g' apache/logs/access.log
常见日志地址
# apache
apache/logs/access.log # 访问日志
apache/logs/error.log # 错误日志
# nginx
nginx/logs/access.log # 访问日志
nginx/logs/error.log # 错误日志
# tomcat
tomcat/logs/localhost_access_log.日期.txt # 请求日志
tomcat/logs/catalina.日期.log # 启动日志
tomcat/logs/localhost.日期.txt # 本地日志
tomcat/logs/host-manager.日期.log # manager管理日志
tomcat/logs/manager.日志.log # manager专有日志
Linux删除登录日志和操作信息
echo > /var/log/wtmp //清除用户登录记录
echo > /var/log/btmp //清除尝试登录记录 echo>/var/log/lastlog //清除最近登录信息
echo > /var/log/secure //登录信息
echo > /var/log/messages echo>/var/log/syslog //记录系统日志的服务
echo>/var/log/xferlog
echo>/var/log/auth.log
echo>/var/log/user.log
cat /dev/null > /var/adm/sylog
cat /dev/null > /var/log/maillog
cat /dev/null > /var/log/openwebmail.log
cat /dev/null > /var/log/mail.info echo>/var/run/utmp
边栏推荐
猜你喜欢

vector 转 svg 方法

1.28亿美元!芬兰量子计算公司IQM获世界基金支持

OpenTelemetry 在服务网格架构下的最佳实践

Comprehensive care analysis lyriq Ruige battery safety design

window对象的常见事件

安全员及环保员岗位职责

HCIP第十四天笔记

图解用户登录验证流程,写得太好了!

注解@Autowired和@Resource的区别总结
Common questions and answers of software testing interview (divergent thinking, interface, performance, concept,)
随机推荐
On the prototype of constructor
【flask】服务端获取客户端的请求头信息
[paper]PointLaneNet论文浅析
抖音服务器带宽有多大,才能供上亿人同时刷?
The most complete basic knowledge of software testing in the whole network (a must for beginners)
Abbkine AbFluor 488 细胞凋亡检测试剂盒特点及实验建议
Pytoch loss function summary
自己梳理的LocalDateTime的工具类
Worthington木瓜蛋白酶解离系统解决方案
Data Lake (20): Flink is compatible with iceberg, which is currently insufficient, and iceberg is compared with Hudi
Activiti5.22.0扩展支持达国产数据库,以GBase据库为例
Worthington过氧化物酶活性的6种测定方法
将幕布文章OPML转换为Markdown的方法
impala 执行计划详解
Common events of window objects
[binary search simple question] leetcode 35. search insertion position, 69. Square root of X, 367. Effective complete square, 441. Arrange coins
177. 第N高的薪水(简单)
[动态规划中等题] LeetCode 198. 打家劫舍 740. 删除并获得点数
一个测试类了解BeanUtils.copyProperties
最大连续子序列(DAY 77)