python小记--攻防世界Time_losing解题脚本编写

这篇博客介绍了如何使用Python处理文件时间戳,通过计算47个文件相对于给定源时间戳的差异,并将这些差异转换为ASCII码,最终组合成一个字符串。代码示例中展示了如何利用os库获取文件的修改时间,以及format函数的用法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

时间戳

对应攻防世界MISC题Time_losing

已知源时间戳为2000000000

定义一下 并且定义一个a来存储最终的flag

oldtime=2000000000
a=""

总共有47个文件 (0~46) 需要每个文件都和源时间戳进行相减

那么就要用到循环

先获取文件的路径(记得复制自己的文件路径 不要搬用我的)

给定参数时,路径前面有个字母“r”,为消除转义字符功能用
file= r"文件路径"
​
 file = r"C:\Users\12275\Desktop\stego\0.txt"

还需要用到一个format函数

format()函数介绍
它是通过引号中间包含花括号('{}')的形式通过点(.)format()形式进行函数调用
format()函数用来收集其后的位置参数和关键字段参数,并用他们的值填充字符串中的占位符。通常format()函数配合print()函数达到强格式化的输出能力,
​
format()函数固定的输出格式如下:
​
'{key : fill, align, sign,0,width, precision, type}'.format(para1...)
例子
​
通过关键字
​
print('{name}在{option}'.format(name="谢某人",option="写代码"))
​
结果:谢某人在写代码 
​
通过位置
1. 
​
print('name={} path={}'.format('zhangsan', '/')
​
结果:name=zhangsan path=/
​
2. 
​
print('{1}在{0}'.format('写代码','谢某人'))
​
3. 
​
print('{0}在{1}'.format('谢某人','写代码'))
​
结果:谢某人在写代码

简单来说format函数就是将format()中的参数填充到前面的{}中去

那么代码这么写

 file = r"C:\Users\12275\Desktop\stego\{0}.txt".format(i)  #每一次调用路径的时候 通过format改变调用的xt文件名 而不会只调用0.txt

然后需要获取每个文件的修改时间

 获取文件的时间属性
​
 用到的知识
​
 os.getcwd() 方法用于返回当前工作目录
​
 os.path.getatime(file) 输出文件访问时间
​
 os.path.getctime(file) 输出文件的创建时间
​
 os.path.getmtime(file) 输出文件最近修改时间
​

这里需要调用os库 要先用import导入

import os,time  #查找处理文件要调用os库 先用import 导入

获取最近修改的时间

newtime = int(os.path.getmtime(file)) #获取最近修改时间 并转为整数型(就是时间戳)

两时间戳相减

s = newtime-oldtime
a = a + chr(s) #将差值转换为ASCII码

循环就写好了:

for i in range(0,47): #有0~46个txt文件 就是循环47次
   file = r"C:\Users\12275\Desktop\stego\{0}.txt".format(i)  #调用文件路径 记得复制自己的文件路径 不要搬用我的
   newtime = int(os.path.getmtime(file))  #获取最近修改的时间
   s = newtime - oldtime
   a =a+chr(s)   #将差值转为ASCII码

完整代码如下

import os,time  #查找处理文件要调用os库 先用import 导入
​
oldtime=2000000000
a=""
​
for i in range(0,47): #有0~46个txt文件 就是循环47次
   file = r"C:\Users\12275\Desktop\stego\{0}.txt".format(i)  #调用文件路径 记得复制自己的文件路径 不要搬用我的
   newtime = int(os.path.getmtime(file))  #获取最近修改的时间
   s = newtime - oldtime
   a =a+chr(s)   #将差值转为ASCII码
print(a)

运行结果

 

flag出现

### GitHub Two-Factor Authentication Setup For securing access to repositories and accounts, setting up two-factor authentication (2FA) is crucial. As a fallback option, one can set up 2-Factor verification using Google Authenticator[^1]. This method enhances security by requiring not only a password but also an additional piece of information that the user must provide. To configure 2FA on GitHub: #### Enabling Two-Factor Authentication via SMS or TOTP Application 1. Navigate to the account settings page. 2. Select "Security". 3. Choose "Two-factor authentication" from the menu options. 4. Decide whether to receive codes through text messages sent to your phone or use an application like Google Authenticator for time-based one-time passwords (TOTP). After enabling this feature, every login attempt requires entering both the standard credentials plus either a code received over SMS or generated within the authenticator app. #### Troubleshooting Common Issues During Setup Occasionally users encounter problems when configuring their 2FA systems. Some common issues include incorrect entry of recovery codes during initial setup which prevents future logins without these backups; losing access to the registered mobile device used for receiving OTPs necessitating contacting support for assistance in regaining control over the compromised profile. In such cases where there might be difficulties accessing the primary means chosen for verifying identity, having alternative methods ready becomes essential—such as utilizing backup tokens previously saved securely offline or another trusted number linked specifically for emergency purposes. ```bash # Example command line usage related to generating SSH keys for added security layer post-t rsa -b 4096 -C "your_email@example.com" ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

tzyyyyyy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值