File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -99,7 +99,7 @@ Usage: ./ssc [-u] [-s] [-r] [-e|-E|-M file] [-0] [-n name] [-d date] [-m msg] [-
99
99
linux only, works like AppImage. if a directory is specified, create squashfs from it
100
100
-0, --fix-argv0 try to fix $0, may not work
101
101
if it doesn't work or causes problems, try -n flag or use $SSC_ARGV0 instead
102
- -n, --ps-name change script path in ps output
102
+ -n, --ps-name change script path in ps output, may contain 'XXXXXX' which will be replaced with a random string
103
103
upon execution, create a symlink to real path and pass it to the interperter
104
104
-d, --expire-date expire date, for example, 11/30/2023
105
105
-m, --expire-message expire message, default to 'script has expired!'
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ ssc本身并不是一个编译器,比如cc,它会生成包含脚本代码的
97
97
仅适用于Linux,类似AppImage。如果指定的是目录,从这个目录创建squashfs文件
98
98
-0, --fix-argv0 尝试修复$0,可能不起作用
99
99
如果不起作用或造成问题,请尝试使用-n选项或使用$SSC_ARGV0代替$0
100
- -n, --ps-name 更改ps输出中的脚本路径
100
+ -n, --ps-name 更改ps输出中的脚本路径,可包含XXXXXX,运行时替换为随机字符串
101
101
在执行时,创建一个指向真实路径的符号链接并将这个链接传递给解释器
102
102
-d, --expire-date 过期日期,例如 11/30/2023
103
103
-m, --expire-message 过期提示,默认为 script has expired!
Original file line number Diff line number Diff line change 13
13
#include < string>
14
14
#include < iterator>
15
15
#include < algorithm>
16
+ #include < random>
16
17
#include " obfuscate.h"
17
18
#include " utils.h"
18
19
#include " embed.h"
@@ -266,14 +267,24 @@ int main(int argc, char* argv[]) {
266
267
#endif
267
268
268
269
#ifdef PS_NAME
269
- if (is_symlink (OBF (STR (PS_NAME)))) {
270
- unlink (OBF (STR (PS_NAME)));
270
+ std::string link_name (OBF (STR (PS_NAME)));
271
+ pos = link_name.find (" XXXXXX" );
272
+ if (pos != std::string::npos) {
273
+ const char *chars = " ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789" ;
274
+ std::mt19937 gen (std::random_device{}());
275
+ std::uniform_int_distribution<> dist (0 , strlen (chars) - 1 );
276
+ for (; pos < link_name.size () && link_name[pos] == ' X' ; pos++) {
277
+ link_name[pos] = chars[dist (gen)];
278
+ }
279
+ }
280
+ if (is_symlink (link_name.c_str ())) {
281
+ unlink (link_name.c_str ());
271
282
}
272
- if (symlink (path.c_str (), OBF ( STR (PS_NAME) )) != 0 ) {
273
- LOGE (" failed to create symlink! path=" STR (PS_NAME) " err=`%s`" , strerror (errno));
283
+ if (symlink (path.c_str (), link_name. c_str ( )) != 0 ) {
284
+ LOGE (" failed to create symlink! path=%s err=`%s`" , link_name. c_str () , strerror (errno));
274
285
return 5 ;
275
286
}
276
- path = OBF ( STR (PS_NAME) );
287
+ path = std::move (link_name );
277
288
cleaner.add (path);
278
289
#endif
279
290
You can’t perform that action at this time.
0 commit comments