栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

【阿尼亚不会CTF】Access Denied CTF 2022 writeup-Misc/Bobs Favourite Number

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

【阿尼亚不会CTF】Access Denied CTF 2022 writeup-Misc/Bobs Favourite Number

Misc/Bobs Favourite Number

题目描述:
Can you find identify bob's favourite numbers?
server: nc 35.193.60.121 1337

附件(bob.txt),内容如下:

Bobs favourite numbers

Bob likes two numbers 1856 (as his college was founded as the Civil Engineering College on 24 November 1856) and 2014 (as his college was renamed as Indian Institute of Engineering Science and Technology, Shibpur by the Govt. of India in March 2014).

A number N is Bob's favourite number if N is equal to the sum of a certain number of 1856 and sum of a certain number of 2014.

Task: Print whether a number is Bob's favourite number or not.

Input: 
First line contains a single integer number N.

Output:
Print “Yes” if Favourite if N is Bob’s favourite number, else print “No”.

Constraints: 1 <= N <= 10^9

Sample input:
5726

Sample output:
Yes

Sample explanation:
5726 can be represented as the sum of 1856 + 1856 + 2014.

解题脚本(Python):

#!/bin/python

import telnetlib

tn = telnetlib.Telnet("35.193.60.121",1337)

def bob(n):
    for i in range(int(n/1856)):
        if (n-(i*1856)) % 2014 ==0:
            return True
    return False

while(True):
    a = tn.read_until(b"Answer:")
    print(a)
    if b"Good" in a:
        N = int(a.split()[2])
    else:
        N = int(a.split()[0])
    if bob(N):
        tn.write(b"Yesn")
    else:
        tn.write(b"Non")

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/971335.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号