docker修改pod容器内时间,不改变宿主机时间

libfaketime 拦截程序用于检索的各种系统调用
当前日期和时间。然后它报告修改(伪造)的日期和时间(如
由您(用户)指定)到这些程序。这意味着您可以修改
程序看到的系统时间,而不必更改系统范围内的时间。

libfaketime 允许您指定绝对日期(例如,01/01/2004)和
相对日期(例如,10 天前)。
libfaketime 可能用于各种目的,例如

- 确定性的构建过程
- 调试与时间相关的问题,例如过期的 SSL 证书
- 2038 年合规性测试软件

libfaketime 附带一个名为“faketime”的命令行包装器
更易于使用,但并未公开 libfaketime 的所有功能。如果你的
faketime 命令未涵盖用例,请务必查看此
文档是否可以直接使用 libfaketime 来实现。

==================================

用法:

使用绝对日期
----------------------

_必须_用于_绝对_日期的格式是“YYYY-MM-DD hh:mm:ss”。
例如,必须将 2020 年 12 月 24 日晚上 8:30 指定为
FAKETIME="2020-12-24 20:30:00"。
使用“开始于”日期
--------------------------
_必须_用于_start_at_日期的格式是“@YYYY-MM-DD hh:mm:ss”。
例如,必须将 2020 年 12 月 24 日晚上 8:30 指定为
FAKETIME="@2020-12-24 20:30:00"。

下载libfaketime包,链接:https://download.csdn.net/download/yangbin1265712/86404423

# 解压
unzip libfaketime-master.zip

# 安装
cd libfaketime
make
make install

# 临时配置
# 安装完成后默认在/usr/local/lib下有个faketime目录,执行下面命令即可
export LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1 FAKETIME="YYYY-MM-DD hh:mm:ss"

# 永久配置
echo 'export LD_PRELOAD=/usr/local/lib/faketime/libfaketime.so.1 FAKETIME="YYYY-MM-DD hh:mm:ss"' >>/etc/profile
source /etc/profile

参考:https://github.com/wolfcw/libfaketime

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
国外网友基于faketime做的burp loader的unlimited版本. 需要一堆dll或者so. 详情见如下描述,没有分的可以去github上找. ======================== BurpUnlimited version 1.7.26 release 1.0 + Created by: mxcx@fosec.vn + Email: mxcxvn@gmail.com + Based on: BurpLoader by larry_lau + Github: https://github.com/mxcxvn/BurpUnlimited it's opensource ======================== This project is NOT intended to replace BurpLoader. It just EXTENDS BurpLoader's license! To run the project from the command line: java -javaagent:BurpUnlimited.jar -agentpath:lib/libfaketime -jar BurpUnlimited.jar or double click on BurpUnlimited.jar (set permision before) ## Notes: - There are some requirements files in lib at current folder: + burpsuite_pro_v1.7.26.jar is main object + libfaketime* Lib for hook time activation. Sourcecode is at https://github.com/faketime-java/faketime - For windows, vcredist is required: https://www.microsoft.com/en-gb/download/details.aspx?id=48145 - The folder for_windows_if_you_dont_wanna_install_vcredist is for anyone who don't wana install vcredist, please chose the file for x64 or x86, rename to vcruntime140.dll and copy to BurpUnlimited.jar's folder - To have no unexpected error, please leave all file in the folders which have not any space character (including java binary file in case not run with default java). - This version is tested run stable on MACOSX 64 bit, Ubuntu 64 bit, Windows 64 and 32 bit. If you have any error in starting, please try some ways: + Change manually your datetime to before 01/10/2017 + Build your own libfaketime, sourcecode is at https://github.com/faketime-java/faketime + Or contact me mxcxvn@gmail.com ## Hash MD5 version release 1 BurpUnlimited.jar 5cf68ad0cc2d4ee265d0da1469decf21 lib/ burpsuite_pro_v1.7.26.jar 5d1cbbebc7fb59a399ae7bcacbe05f74 libfaketime32.dll e3842711a065b672dec322c4140b950f libfaketime32.jnilib d2b62d06a972035149bfdefe1605c041 libfaketime32.so 5c2baa272037207533d74faa4291e91d libfaketime64.dll 6659efeee9698609a9ffd9ea8c9d07d1 libfaketime64.jnilib ff3dbde6a28f1c59d829cf5665c8e628 libfaketime64.so 5c2baa272037207533d74faa4291e91d for_windows_if_you_dont_wanna_install_vcredist/ vcruntime140_x32.dll b77eeaeaf5f8493189b89852f3a7a712 vcruntime140_x64.dll 6c2c88ff1b3da84b44d23a253a06c01b
要连接到运行在Pod所在的宿主机上,可以使用`kubectl`工具的`exec`命令结合`nsenter`命令。具体步骤如下: 1. 首先,使用以下命令获取Pod的名称和所在的Node节点名称: ``` kubectl get pod <pod-name> -o wide ``` 其中,`<pod-name>`是要连接的Pod的名称。 2. 然后,使用以下命令在Node节点上启动一个临时的容器,并通过`nsenter`命令进入到该容器中: ``` kubectl run -it --rm debug --image=busybox --restart=Never --overrides='{ "spec": { "nodeName": "<node-name>" } }' -- nsenter -t 1 -m -u -n -i sh ``` 其中,`<node-name>`是第1步中获取到的Node节点名称。 此命令将在Node节点上启动一个名为`debug`的容器,并在其中运行`nsenter`命令。`nsenter`命令将进入到宿主机的命名空间中,使你能够访问宿主机的文件系统和进程等。 3. 最后,使用以下命令进入到Pod所在的网络命名空间中: ``` chroot /host nsenter -t $(docker inspect --format '{{.State.Pid}}' <pod-name>) -n sh ``` 其中,`<pod-name>`是要连接的Pod的名称。 此命令将在宿主机的命名空间中启动一个新的`nsenter`命令,并进入到Pod所在的网络命名空间中。在该命名空间中,你可以访问Pod的网络接口和相关的进程等。 注意:执行该操作需要具备足够的权限,并且可能会对Pod宿主机的正常运行产生影响,因此在执行前请仔细考虑。如果没有足够的经验和知识,请勿轻易尝试。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值