status = 1 mask = 0b10110001110010011100100010110101
c = list(bytes.fromhex('00000100000001010001010101010000000000010000010001010000010100000001000000000101010100010001000000000000010001000000010000000001010000000101000000000000000001000100010001000101010001010101010101000101000101000000010001010001000000000001010001010100010001000000000000010000010001000000000000000000000000010101000000010101000100010001000100010101010101010001010000000100000100000101000101010001010101000101000001010000010001000100000001000101010100010100010000000101000001000101000001000101000100010100000100000101000100000100000100000000010000010100010001010100010000000100000001000001010000000000000001010101000101010100010100010001010101000100010101000100010001010101010001010000000101010001000100000000000101000001010001000101000001000100010101010001000001010001010001010101010001000100010101000001000001000100010000000100000001010001010000000101010000010001000000010000010100000000010001000001010100010101010101000000010100010100010101000000010001010101010001010100000001010001000101000100000000000100010100000001010101000100010100010100010000000100010101000001000001010001000100010001010001000101010101000000000000010100000001000000000001010000010100000001000100000000000000000101010101000000000000010001000100010001000001000100000101000101000101010101010001000001000101000101000000010100000001010001000100010101000001000101010100010001010100010100010000000001000001010000000001010001000001010000010000000001000101000100010001010101010101000101010101000000000000000101010001010001010100010100000000000000000100010101')) #print(c)
pp = '' for i inrange(760): (status,out) = lfsr(status,mask) pp += str(c[i]^out)
n = 20929902170717676951934620006433003604730678640645007075637305655990838672444304031857412581445836654784941618387885677741424195646067710979291690749949226354601059943673546892769474380805413381477209725509187761202889007557157174009816759858206190915193870770303140668513899480840368042056977078850633645939996806974754076338446182094408033833859119883893893710390855924917625801146138452249766835457952331243832878453385608344187234621288871394907683956060567710199168220435234555727645472494418988488158424284566395402382371954247354264148359024995803494283148151292240772247688313806712633140618802681063347059301 p4 = 6020793003600505515657431119157212393365966944447518390323900168965824649782228689680274668164250924439790546808885513956693311045291390596152861670602514965058376230082977010070282487901715757886308848763512028412503942684262007 e = 65537 pbits = 1024 kbits = pbits - p4.nbits() p4 = p4 << kbits PR.<x> = PolynomialRing(Zmod(n)) f = x + p4 roots = f.small_roots(X=2^kbits, beta=0.4) if roots: p = p4+int(roots[0]) print("p = "+str(p)) print("q = "+str(n//p)) #p = 178473011392593598505298598344099528115548451492933270114904463603611584603267214985220850730034624404463453138131960336680355670323048351300133942965805079196071421536335378530449908306426271314462228131670026772855194671868525313446301101494560326641880067330258886334198095183772143790227948133817520438209 #q = 117272085047511228904591997419599628624189308881609369935452126803320898264759343424520375607941703744925707366699154133792983045245930090675456846087494137892328143697198606928970884892931890016115977464725544377659165461842270186367403846042556245975180328562734594014884754292825059517252004778580410644389
最后常规RSA解 $m$:
1 2 3 4 5 6 7 8 9 10 11 12
import gmpy2 p = 178473011392593598505298598344099528115548451492933270114904463603611584603267214985220850730034624404463453138131960336680355670323048351300133942965805079196071421536335378530449908306426271314462228131670026772855194671868525313446301101494560326641880067330258886334198095183772143790227948133817520438209 q = 117272085047511228904591997419599628624189308881609369935452126803320898264759343424520375607941703744925707366699154133792983045245930090675456846087494137892328143697198606928970884892931890016115977464725544377659165461842270186367403846042556245975180328562734594014884754292825059517252004778580410644389 n = p * q fn = (p-1) * (q-1) e = 65537 c = 12381638589055841139447839302795029653843309313978198727914736718245700098003130043532117734105184556347388175236916768083364314767482249333410320774565764577094924964983543424785959666191716662886118558538365503080964047183533841342232120086245448689762948846598689811062301086591078119426971029385906936610191899748366808606594184238261341160458933596780268681004577561284530512291876043524269456261191856680575840859843145591670082313114482813697656520320677074240863479192424768989294287655231041605257414144367688426659163486702611196512549549115716697786311455783534600599360245502989232358699920442842821956230 d = gmpy2.invert(e, fn) m = pow(c, d, n) print(bytes.fromhex(hex(m)[2:]))
from Crypto.Util.number import * import gmpy2 import math
a = 16358502146569154805821117102055792126075384391997576813810358118942744612520734385485210209088310766263140599554175000067735671573064419087690267925715334913530155481001158890983091873663077846204509925514040559562873128373049378251801304882824014436351821387973582562165652240535121822439156888350175610414618000437008389187928342072924670546637964062394868004556705496699646429981923137500855492623070913023804420063661041841121617920375160117028363526191248710373415720637387593795136212298387121644166224488964182846517612830649792045421886212347661276446680662471149305906153415890365792363053111611744767732723 b = "**********" d = 1004034638166310792730607806775703553124564601554345421260673 flag="flag{*************}".encode("utf-8") m = bytes_to_long(flag) z = "**********"
a = 16358502146569154805821117102055792126075384391997576813810358118942744612520734385485210209088310766263140599554175000067735671573064419087690267925715334913530155481001158890983091873663077846204509925514040559562873128373049378251801304882824014436351821387973582562165652240535121822439156888350175610414618000437008389187928342072924670546637964062394868004556705496699646429981923137500855492623070913023804420063661041841121617920375160117028363526191248710373415720637387593795136212298387121644166224488964182846517612830649792045421886212347661276446680662471149305906153415890365792363053111611744767732723 d = 1004034638166310792730607806775703553124564601554345421260673
x = 6315659043002030386732628047413448608037014021450055783529151485037069834363316696715574624507364755209361330204858147422873261866250183596759294051863367248800298182067900158706847792801508096127972864438349393635089442050383307416911012903769591812354414290225858817653700560363386018244490076357373032578412217266586094695255045411910123500620718125148007865650934761243821251725823364164494857358344030633984045814182753879152597382860304163779884435644346012876829684180445183686922253767338719485395107909704323571278192414797079570675523716981179479127876875936828316228191746093521584500893126198631718691478 c = 13596888613593355909989922489890598098147006404940300566769884949973269155719149670825677093684865700611084990815597885910353735947129944271345041538903031681298587672182524580124290627382140539264797169742520543929318842181890234622629255911624719400312152476306595541663238469772749767491911131691767357337344670678126067823905376191196367985379783363614691429132347967869598160549130755596368301366502209859435570988428790501722994265227987470237460083210385323943246674820772425514186206511159274330451656105100385024137631498256411854720506611702496670593426888793357086314109878603547497784715623917384308274129
import gmpy2
b = gmpy2.invert(x*d,a) rb = gmpy2.invert(b,a) rd = gmpy2.invert(d,a) h = rb*d%a
p = a
v1 = vector(ZZ, [1, h]) v2 = vector(ZZ, [0, p]) m = matrix([v1,v2]); f, g = m.LLL()[0] f, g = -f, -g #print(f, g)
a = f*c % p % g m = a * inverse_mod(f, g) % g print(bytes.fromhex(hex(m)[2:]))
#b'flag{we1c0mE_t0_cr4aK_mE!}'
FLAG:flag{we1c0mE_t0_cr4aK_mE!}
MISC
checkin
flag{W3Lc0m3_t0_2o2I_3n3rgy_contest}
签到。
FLAG:flag{W3Lc0m3_t0_2o2I_3n3rgy_contest}
hardwire_1
下载附件压缩包,分析文件,找到flag。提交flag格式:flag{xxxx}。
流量包文件,wireshark打开,追踪TCP流,发现菜刀连接流量特征。
解析流1中z2参数值,base64解码得:
cd /d "C:\php\htdocs"&winrar a -pf@l#ag102 key.rar key.jpg&echo [S]&cd&echo [E]
import base64 import io import sys import pickle import b
from flask import Flask, Response, render_template, request
app = Flask(__name__)
defread(filename, encoding='utf-8'): withopen(filename, 'r', encoding=encoding) as fin: return fin.read()
classpeople: def__init__(self, name, sex, age): self.name = name self.sex = sex self.age=age
def__repr__(self): returnf'people(name={self.name!r}, category={self.sex!r}, age={self.age!r})' #==判断 def__eq__(self, other): returntype(other) is people and self.name == other.name and self.sex == other.sex and self.age==other.age
classRestrictedUnpickler(pickle.Unpickler): deffind_class(self, module, name): if module[0:8] == '__main__': returngetattr(sys.modules['__main__'], name) raise pickle.UnpicklingError("global '%s.%s' is forbidden" % (module, name))
classpeople: def__init__(self, name, sex, age): self.name = name self.sex = sex self.age=age def__repr__(self): returnf'people(name={self.name!r}, category={self.sex!r}, age={self.age!r})' def__eq__(self, other): returntype(other) is people and self.name == other.name and self.sex == other.sex and self.age==other.age #print(pickle.dumps(people('aaa','bbb','ccc')))
data=b'''c__main__ b (S'name' S"aaa" S"sex" S"bbb" S"age" S"ccc" db0(S"aaa" S"bbb" S"ccc" i__main__ people .''' print(base64.b64encode(data).decode())