for line in f.readlines(): cmd=cmdFormat %(stegoFile,extractFile,line.strip()) p=Popen(cmd,shell=True,stdout=PIPE,stderr=STDOUT) content=str(p.stdout.read(),'gbk') for err in errors: if err in content: break else: print (content), print ('the passphrase is %s' %(line.strip())) f.close() return
if __name__ == '__main__': foo() print ('ok') Pass
from Crypto.Util.number import * from gmpy2 import * p = 12567387145159119014524309071236701639759988903138784984758783651292440613056150667165602473478042486784826835732833001151645545259394365039352263846276073 q = 12716692565364681652614824033831497167911028027478195947187437474380470205859949692107216740030921664273595734808349540612759651241456765149114895216695451 c = 108691165922055382844520116328228845767222921196922506468663428855093343772017986225285637996980678749662049989519029385165514816621011058462841314243727826941569954125384522233795629521155389745713798246071907492365062512521474965012924607857440577856404307124237116387085337087671914959900909379028727767057 e = 65537 n = p*q phi = (p-1)*(q-1) d=invert(e,phi) m=pow(c,d,n) print(long_to_bytes(m))
from Crypto.Util.number import * from gmpy2 import * p = 275127860351348928173285174381581152299 q = 319576316814478949870590164193048041239 c = 87677652386897749300638591365341016390128692783949277305987828177045932576708 e = 65537 n = p*q phi = (p-1)*(q-1) d=invert(e,phi) m=pow(c,d,n) print(long_to_bytes(m))
e = 65537 n = 50612159190225619689404794427464916374543237300894011803225784470008992781409447214236779975896311093686413491163221778479739252804271270231391599602217675895446538524670610623369953168412236472302812808639218392319634397138871387898452935081756580084070333246950840091192420542761507705395568904875746222477 dp = 5892502924236878675675338970704766304539618343869489297045857272605067962848952532606770917225218534430490745895652561015493032055636004130931491316020329 c = 39257649468514605476432946851710016346016992413796229928386230062780829495844059368939749930876895443279723032641876662714088329296631207594999580050131450251288839714711436117326769029649419789323982613380617840218087161435260837263996287628129307328857086987521821533565738409794866606381789730458247531619
from Crypto.Util.number import * from hashlib import md5
dic=['0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] for i in dic: for j in dic: for k in dic: for m in dic: flag='LitCTF{md5can'+i+j+'3de'+k+'rypt213thoughcr'+m+'sh}' m=md5(flag.encode()).hexdigest() if m=='496603d6953a15846cd7cc476f146771': print(flag)
There are moments in life when you miss someone so much that you just want to pick them from your dreams and hug them for real! Dream what you want to dream;go where you want to go;be what you want to be,because you have only one life and one chance to do all the things you want to do.May you have enough happiness to make you sweet,enough trials to make you strong,enough sorrow to keep you human,enough hope to make you happy? Always put yourself in others’shoes.If you feel that it hurts you,it probably hurts the other person, too.The happiest of people don’t necessarily have the best of everything;they just make the most of everything that comes along their way.Happiness lies for those who cry,those who hurt, those who have searched,and those who have tried,for only they can appreciate the importance of people,who have touched their lives.Love begins with a smile,grows with a kiss and ends with a tear.The brightest future will always be based on a forgotten past, you can’t go on well in lifeuntil you let go of your past failures and heartaches.When you were born,you were crying and everyone around you was smiling.Live your life so that when you die,you're the one who is smiling and everyone around you is crying.
Please send this message to those people who mean something to you,to those who have touched your life in one way or another,to those who make you smile when you really need it,to those that make you see the brighter side of things when you are really down,to those who you want to let them know that you appreciate their friendship.And if you don’t, don’t worry,nothing bad will happen to you,you will just miss out on the opportunity to brighten someone’s day with this message.My password is not a regular Caesar password,and the enc flag=[86, 116, 128, 80, 98, 85, 139, 122, 134, 114, 125, 136, 117, 123, 129, 127, 128, 128, 142, 130, 140, 147, 127, 132, 131, 136, 151, 134, 152, 164] -Caesar
发现最后是个凯撒,但是不是个常规的凯撒,前几位对照LitCTF,发现每一位多减去了一个下标值
python
1 2 3
flag=[86,116,128,80,98,85,139,122,134,114,125,136,117,123,129,127,128,128,142,130,140,147,127,132,131,136,151,134,152,164] for i inrange(len(flag)): print(chr(flag[i]-10-i),end='')
from Crypto.Util.number import * from gmpy2 import gcd,invert
s =[699175025435513913222265085178805479192132631113784770123757454808149151697608216361550466652878, 193316257467202036043918706856603526262215679149886976392930192639917920593706895122296071643390, 1624937780477561769577140419364339298985292198464188802403816662221142156714021229977403603922943, 659236391930254891621938248429619132720452597526316230221895367798170380093631947248925278766506, 111407194162820942281872438978366964960570302720229611594374532025973998885554449685055172110829, 1415787594624585063605356859393351333923892058922987749824214311091742328340293435914830175796909, 655057648553921580727111809001898496375489870757705297406250204329094679858718932270475755075698, 1683427135823894785654993254138434580152093609545092045940376086714124324274044014654085676620851, 492953986125248558013838257810313149490245209968714980288031443714890115686764222999717055064509, 70048773361068060773257074705619791938224397526269544533030294499007242937089146507674570192265] t = [] for i inrange(9): t.append(s[i]-s[i-1]) all_n = [] for i inrange(7): all_n.append(gcd((t[i+1]*t[i-1]-t[i]*t[i]), (t[i+2]*t[i]-t[i+1]*t[i+1])))
for n in all_n: n=abs(n) if n==1: continue a=(s[2]-s[1])*invert((s[1]-s[0]),n)%n ani=invert(a,n) b=(s[1]-a*s[0])%n seed = (ani*(s[0]-b))%n plaintext=seed print(long_to_bytes(plaintext))
NSSCTF{31fcd7832029a87f6c9f760fcf297b2f}
(校外)隐晦的聊天记录
一次一密,消息和密文用异或的形式,多次传递只用一个密钥
因此m1^m2=c1^c2
python
1 2 3 4 5 6 7
from Crypto.Util.number import *
c1=0x6c73d5240a948c86981bc294814d m1=bytes_to_long(b'attack at dawn') m2=bytes_to_long(b'Monday or Thur') c2=m1^c1^m2 print(hex(c2))
NSSCTF{4068cf2108868c889e1bf29d8351}
REVERSE
世界上最棒的程序员
NSSCTF{I_am_the_best_programmer_ever}
ez_XOR
进到主函数,找到关键点XOR函数
跟进发现异或的数字是3*3
写个解密脚本
python
1 2 3
s='E`}J]OrQF[V8zV:hzpV}fVF[t' for i inrange(len(s)): print(chr(ord(s[i:i+1])^9),end='')
s = "gJ1BRjQie/FIWhEslq7GxbnL26M4+HXUtcpmVTKaydOP38of5v90ZSwrkYzCAuND" #这里是被修改后的表 例: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz01234{}789+/"
defMy_base64_encode(inputs): # 将字符串转化为2进制 bin_str = [] for i in inputs: x = str(bin(ord(i))).replace('0b', '')#这里是输入正常字符串使用 例:'MTIzNDU2' #x = str(bin((i))).replace('0b', '') #这里是输入十六进制是使用 例:b'\x9e\x9b\x9c\xb5\xfe\x70\xd3\x0f\xb2\xd1\x4f\x9c\x02\x7f\xab\xde\x59\x65\x63\xe7\x40\x9d\xcd\xfa\x04' #上面两句二选一 bin_str.append('{:0>8}'.format(x)) #print(bin_str) # 输出的字符串 outputs = "" # 不够三倍数,需补齐的次数 nums = 0 while bin_str: #每次取三个字符的二进制 temp_list = bin_str[:3] if(len(temp_list) != 3): nums = 3 - len(temp_list) whilelen(temp_list) < 3: temp_list += ['0' * 8] temp_str = "".join(temp_list) #print(temp_str) # 将三个8字节的二进制转换为4个十进制 temp_str_list = [] for i inrange(0,4): temp_str_list.append(int(temp_str[i*6:(i+1)*6],2)) #print(temp_str_list) if nums: temp_str_list = temp_str_list[0:4 - nums] for i in temp_str_list: outputs += s[i] bin_str = bin_str[3:] outputs += nums * '=' print("Encrypted String:\n%s "%outputs) defMy_base64_decode(inputs): # 将字符串转化为2进制 bin_str = [] for i in inputs: if i != '=': x = str(bin(s.index(i))).replace('0b', '') bin_str.append('{:0>6}'.format(x)) #print(bin_str) # 输出的字符串 outputs = "" nums = inputs.count('=') while bin_str: temp_list = bin_str[:4] temp_str = "".join(temp_list) #print(temp_str) # 补足8位字节 if(len(temp_str) % 8 != 0): temp_str = temp_str[0:-1 * nums * 2] # 将四个6字节的二进制转换为三个字符 for i inrange(0,int(len(temp_str) / 8)): outputs += chr(int(temp_str[i*8:(i+1)*8],2)) bin_str = bin_str[4:] print("Decrypted String:\n%s "%outputs) print() print(" -------------------------------------") print(" | (1)encode (2)decode |") print(" -------------------------------------") print()
num = input("Please select the operation you want to perform:\n") if(num == "1"): input_str = input("Please enter a string that needs to be encrypted: \n") # 这句在终端中输入要加密的数据 My_base64_encode(input_str) #这里传入要加密的数据 else: input_str = input("Please enter a string that needs to be decrypted: \n") # 这句在终端中输入要解密的数据 My_base64_decode(input_str) #这里传入要解密的数据