# 2 逆运算

+a —— -a

*a —— /a

^a —— ^a

&a —— <=a

|a —— ？

encrypt.1

<?php

error_reporting(0);

show_source("1.php");

functionencrypt(\$data,\$key)

{

\$key = md5('BOC-DATACENTER');

\$x = 0;

\$len = strlen(\$data);

\$klen = strlen(\$key);

for (\$i=0;\$i<\$len;\$i++){

if (\$x == \$klen){

\$x=0;

}

\$char .= \$key[\$x];

\$x+=1;

}

for (\$i=0;\$i<\$len;\$i++){

\$str .= chr((ord(\$data[\$i])+ord(\$char[\$i]))%128);

}

return base64_encode(\$str);

}

echo"GyZERlYXLydSdFMyUypKVFRDLlQPCmYVHBUnLS4=";

?>

miwen ='GyZERlYXLydSdFMyUypKVFRDLlQPCmYVHBUnLS4=‘

key = hashlib.md5('BOC-DATACENTER'.encode("utf8")).hexdigest()

#base64解密

miwen = base64.b64decode(miwen).decode()

#求char

x=0

char=[]

for i in range(0,length):

if x==klen:

x=0

char.append(key[x])

x+=1

#求(miwen[i]-char[i])%128

data = ''

for i in range(0,length):

data += chr((ord(miwen[i])-ord(char[i]))%128)

bocctf{EnCryption_Is_S0_easy}

# 3仿射密码

y=ax+b(mod m)

x=a-1(y-b)(mod m)

# 4基础数论

p=190716027447646792844189733681358379327343061199369341384474902557309769682923254674220284045951117393868651638379541511185212421611653965460100979887725583476037189369599999668327299529542494009290049992057157747007152994025186591269943960410319186487203043168774653327128061548663247131284489765017

q=930788704028200015275140127068138499329817310955

g=220237156062724657086413463831954488565703875839368639153162645824259735475648417436812689270045835305613201869418328189101417845912386944695747737570415063979393239590022180767575736652824918336764694014421673518178065244519367602124516716571334763354973717129155502536345229391073998560517516716958

k = '???'

x = '???'

def data_to_int(s):

return int(s.encode('hex'),16)

def SHA1(data):

return data_to_int(hashlib.sha1(data).hexdigest())

def encrypt(data, p, q, g, x, k):

r = pow(g,k, p) % q

s = (invert(k, q) * (SHA1(data) + x * r)) % q

return (r, s)

data1 = "guest"

(r1, s1) = encrypt(data1, p, q, g, x, k)

(r2, s2) = encrypt(data2, p, q, g, x, k)

print SHA1(data1)

print SHA1(data2)

print s1

print s2

print r1

print r2

d1=SHA1(data1)

d2=SHA1(data1)

s1≡k-1*(d1 + r*x) (mod q)

s2≡k-1* (d2 + r*x) (modq)

k*s1≡d1 + r*x (modq)

k*s2≡d2 + r*x (modq)

k*(s1-s2)≡d1-d2 (modq)

k≡(d1-d2)*(s1-s2)-1(mod q)

x≡(ks1-d1)-1 (modq)

def getflag(data):

print 1

if data == "getflag":

(r, s) = encrypt(data, p, q, g, x, k)

flag = "hctf{"+ str(s %r) + "}"

print flag

k = ((d1-d2)*invert(s1-s2,q))%q

x = (k*s1-d1)*invert(r,q)%q

getflag("getflag")

hctf{88169191231439818447681393510021281730269252095}

encrypt.2

/\t\nTP9\t\nTP9k\n\tRXpVUNRVWZdEWS5URVNTWHRlQNdERy\t\n\t\nRWJlTHR\t\nMVd\t\nVC9\t\nRENTTHRlWNtERzU\n\tRUJVTHRFNNdUWa\n\t\t\nUUpVVHdlUO\n\tEVz\t\n\t\nRapVTHR\t\nMNd\t\nVK\n\tUTUpVTHNlUOlERzQzRUJkTNRlMZdUWa\n\t\t\nRENDNHRlSN\n\tERDVzR

#!/usr/bin/env python

# -*- coding: utf-8 -*-

import base64

flag = "flag{}"

def encode(string):

x = ""

string = string[::-1]

string = base64.b64encode(base64.b32encode(base64.b16encode(string)))

string = string[::-1]

for i in range(len(string)):

if string[i]=='=':

x += '/'

elif string[i] == '0':

x += '\\t\\n'

elif string[i] == '1':

x += '\\n\\t'

elif string[i] == '2':

x += '\\t'

else:

x += string[i]

return x

if __name__ == '__main__':

print encode(flag)

#倒序

miwen1 = miwen1[::-1]

#base解密

miwen1 =base64.b16decode(base64.b32decode(base64.b64decode(miwen1))).decode()

#倒序

mingwen = miwen1[::-1]

flag{604ece863e52989ef79cca3bd7de8c7a}

# 4cooode

int main()

{

char czHelloworld[] ="\x60\x43\x31\x05\x68\x19\x6c\x3e\x30\x1c\x63\x1a\x6f\x14\x72\x64";

for (int i =0; i < strlen(czHelloworld);i++)

{

czHelloworld[i] =czHelloworld[i] +3;

}

for (int i =0; i < strlen(czPassword);i++)

{

for (int j =i; j < strlen(czPassword);j++)

{

}

}

{

}

else

{

}

return 0;

}

for (int i = 0; i < strlen(czPassword);i++)

{

for (int j =i; j < strlen(czPassword);j++)

{

}

}

miwen=[]

for i in range(0,16):

miwen.append(ord(czHelloworld[i])+3)

for i in range(14,-1,-1):

for j in range(i,16):

miwen[i]^= miwen[i+1]

for i in range(0,16):

miwen[i] =chr(miwen[i])

print(''.join(miwen))

for i in range(1,15,2):

miwen[i]^= miwen[i+1]

for i in range(0,16):

miwen[i] =chr(miwen[i])

print(''.join(miwen))

cr4cksor3yforbug

# 5XOR

def usage():

print("Usage: %s [encrypt/decrypt] [in_file] [out_file] [password]" % sys.argv[0])

exit()

def main():

if len(sys.argv)< 5:

usage()

result_data =""

if sys.argv[1]== "encrypt":

result_data =encrypt(input_data, sys.argv[4])

elifsys.argv[1]== "decrypt":

result_data =decrypt(input_data, sys.argv[4])

else:

usage()

out_file =open(sys.argv[3],'w')

out_file.write(result_data)

out_file.close()

def xor(input_data, key):

result = ""

for ch in input_data:

result += chr(ord(ch) ^key)

return result

key = 0

key ^= ((2 * ord(ch) +3) & 0xff)

return xor(input_data,key)

fr = open(r"D:\XOR\encrypted.txt",'r')

from collections import Counter

frequency = Counter()

with open(r"D:\XOR\encrypted.txt", 'r') as f:

for ch indata:

frequency[ch] +=1

c = frequency.most_common(10)[0][0]

m = ' '

print (repr(c) + ' decrypts to ' + repr(m))

k = ord(c)^ord(' ')

print(k)

print(xor(miwen,k))

'\x9a' decrypts to ' '

186

This message is for Daedalus Corporationonly. Our blueprints for the Cyborg are protected with a password. That password is bde028b9ddeb2b7e80b9fcfee00e2f

key = 0

key ^= ((2 * ord(ch) +3) & 0xff)

return xor(input_data,key)

key = ((2 * ord(password[0]) + 3)& 0xff)^ ((2 * ord(password[1])+ 3)& 0xff)^…

((2 * ord(ch) + 3) & 0xff) ≤ 255

defxor(input_data, key):

result = ""

for ch in input_data:

#明文一定是可显示字符，筛除不合条件的k值

if ord(ch) ^key not in range(20,127):

return None

result += chr(ord(ch) ^key)

return result

fr= open(r"D:\XOR\encrypted.txt",'r')

for key in range(0,256):

result = xor(miwen,key)

if result != None:

print(result)

This message is for Daedalus Corporationonly. Our blueprints for the Cyborg are protected with a password. Thatpassword is bde028b9ddeb2b7e80b9fcfee00e2f

0 条评论

• ### Java，你告诉我 fail-fast 是什么鬼？

说起来真特么惭愧：十年 IT 老兵，Java 菜鸟一枚。今天我才了解到 Java 还有 fail-fast 一说。不得不感慨啊，学习真的是没有止境。只要肯学，就...

• ### 亚马逊马超：如何使用DGL进行大规模图神经网络训练？

与传统基于张量（Tensor）的神经网络相比，图神经网络将图 (Graph) 作为输入，从图结构中学习潜在的知识，该方法在近些年已被证明在许多场景可以取得很好的...

• ### 第四范式涂威威：AutoML 回顾与展望

AI 科技评论按，本文作者第四范式涂威威，该文首发于《中国计算机学会通讯》第15卷第3期，AI 科技评论获中国计算机学会授权转载。

• ### “Jupyter的杀手”：Netflix发布新开发工具Polynote

【导读】10 月 29 日，Netflix 公开了他们内部开发的 Polynote。现如今，大型高科技公司公开其内部的工具或服务，然后受到业界欢迎并被采用的情况...

• ### 元学习的崛起

元学习描述了设计与训练深度神经网络相关的更高级别组件的抽象。术语“元学习”在深度学习文献中经常提及“ AutoML”，“少量学习（Few-Shot Learni...

• ### VarGFaceNet：地平线提出轻量级、有效可变组卷积的人脸识别网络

作者 | Mengjia Yan、Mengao Zhao、Zining Xu、Qian Zhang、Guoli Wang、Zhizhong Su

• ### 开源 | 比快更快！速度超越OpenCV的人脸检测库 libfacedetection 开源！

Github项目地址：https://github.com/ShiqiYu/libfacedetection

• ### 学界 | 曾刷新两项世界纪录，腾讯优图人脸检测算法 DSFD 正式开源

AI 科技评论按：近年来，卷积神经网络在人脸检测中取得了很大的成功，然而这些方法在处理人脸中多变的尺度，姿态，遮挡，表情，光照等问题时依然比较困难。为此，腾讯优...

• ### 资源 | Github项目推荐 | 微软开源Python静态类型检查器Pyright

创建Pyright是为了填补像 mypy 这样的现有Python类型检查器的漏洞。