Linux 你能伪造 *nix 正常运行时间吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4990861/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 02:51:24  来源:igfitidea点击:

can you fake *nix uptime?

linuxmacosunixuptime

提问by c2h2

Just curious, Can you fake an uptime, for instance increase it to 10 years?

只是好奇,你能伪造一个uptime,例如将它增加到 10 年吗?

I have tried changing system time, and it won't do this trick.

我试过改变系统时间,但它不会做这个把戏。

采纳答案by msx

Have a look at this utility: UptimeFaker.

看看这个实用程序:UptimeFaker

回答by Joachim Sauer

alias uptime='echo " 11:07:17 up 10 BILLION YEARS!,  4 users,  load average: 0.38, 0.52, 0.41"'

If you want to get extra-fancy, you could take the actual uptime output and modify that.

如果你想变得更花哨,你可以获取实际的正常运行时间输出并修改它。

回答by MarkR

Yeah, you should be able to attach a gdb to the running kernel, and hack the uptime value. You'd need to know where it was kept, and have a symbols file. I am assuming here, that uptime is held in something statically allocated.

是的,您应该能够将 gdb 附加到正在运行的内核,并破解正常运行时间值。您需要知道它的保存位置,并有一个符号文件。我在这里假设,正常运行时间是静态分配的。

Alternatively, write a small kernel module which hacks the uptime when you load it (and immediately unloads again).

或者,编写一个小的内核模块,它会在您加载(并立即再次卸载)时缩短正常运行时间。