Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建議添加 從環境變量中獲取命令行參數 的功能 #428

Open
LTP414 opened this issue Feb 8, 2025 · 0 comments
Open

建議添加 從環境變量中獲取命令行參數 的功能 #428

LTP414 opened this issue Feb 8, 2025 · 0 comments

Comments

@LTP414
Copy link

LTP414 commented Feb 8, 2025

爲什麽需要這個功能

在多人運動的時候,最常見的情景就是在linux上使用fscan掃描内網。但是在linux權限較低時,因爲fscan在運行時所需的參數較多,藍方很容易通過 ps -elf 命令,通過命令行參數直接發現fscan進程。

解決該問題最簡單的方法就是使用exec命令的 -a 參數僞裝進程,但是這個辦法僅能修改 argv[0] 依然無法隱藏命令行參數。

但如果添加了如題所示的功能,即可解決這個問題。

效果

asciicast

如何實現

這裏給一個參考實現,實際可能要考慮更多因素

修改 common/flag.goflag.Parse() 這一行為

envArgsString := os.Getenv("FS_ARGS")
if envArgsString != "" && runtime.GOOS != "windows" {
	envArgs := strings.Split(envArgsString, " ")
	flag.CommandLine.Parse(envArgs)
	os.Unsetenv("FS_ARGS")
} else {
	flag.Parse()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant