Dag 8

image
Tekst:

MIIBOTCCATAwggEnMIIBHjCCARUwggEMMIIBAzCB+zCB8zCB6zCB4zCB2zCB0zCByzCBwzCBuzCBszCBqzCBozCBnDCBlDCBjDCBhDB9MHYwbzBoMGEwWjBTMEwwRTA+MDcwMTAqMCMwHDAVMA4wBwUAoQMCAROgAwIBA6EDAgEMogMCAQChAwIBE6ADAgEBoQMCARKkAgUAoQMCARShAwIBDqIDAgEYoQMCAQShAwIBEqEDAgEOoQMCAQ6hAwIBB6IDAgECogMCAQigAwIBAaIDAgENogMCARKiAwIBAKMCBQCiAwIBE6IDAgESogMCAQ+hAwIBEaEDAgEOoQMCAQugAwIBAKIDAgEDoQMCAQyhAwIBFKEDAgESoQMCAQ+gAwIBAaEDAgEMoAMCAQOhAwIBEaEDAgEOogMCAQs=

(Litt info om ASN.1 på Wikipedia)

Første asn.1 koden vi fikk var tydeligvis feil så det kom en oppdatering:
image

Spec DEFINITIONS ::= BEGIN
    LinkedList ::= Node
    Node ::= SEQUENCE {
        child CHOICE {
            node Node,
            end NULL
        },
        value CHOICE {
            digit                [0] INTEGER(0..9),
            lowercase           [1] INTEGER(0..25),
            uppercase           [2] INTEGER(0..25),
            leftCurlyBracket    [3] NULL,
            rightCurlyBracket   [4] NULL
        }
    }
END

Strengen vi fikk i oppgaveteksten lagret jeg til en fil som jeg kalte: kode.b64

(venv) ruant@kali:~/pst/luke8$ asn1tools convert prog Node $(base64 -d kode.b64 | xxd -p | tr -d '\n')
node Node ::= {
    child node : {
        child node : {
            child node : {
                child node : {
                    child node : {
                        child node : {
                            child node : {
                                child node : {
                                    child node : {
                                        child node : {
                                            child node : {
                                                child node : {
                                                    child node : {
                                                        child node : {
                                                            child node : {
                                                                child node : {
                                                                    child node : {
                                                                        child node : {
                                                                            child node : {
                                                                                child node : {
                                                                                    child node : {
                                                                                        child node : {
                                                                                            child node : {
                                                                                                child node : {
                                                                                                    child node : {
                                                                                                        child node : {
                                                                                                            child node : {
                                                                                                                child node : {
                                                                                                                    child node : {
                                                                                                                        child node : {
                                                                                                                            child node : {
                                                                                                                                child node : {
                                                                                                                                    child node : {
                                                                                                                                        child node : {
                                                                                                                                            child node : {
                                                                                                                                                child node : {
                                                                                                                                                    child node : {
                                                                                                                                                        child node : {
                                                                                                                                                            child node : {
                                                                                                                                                                child node : {
                                                                                                                                                                    child end : NULL,
                                                                                                                                                                    value lowercase : 19
                                                                                                                                                                },
                                                                                                                                                                value digit : 3
                                                                                                                                                            },
                                                                                                                                                            value lowercase : 12
                                                                                                                                                        },
                                                                                                                                                        value uppercase : 0
                                                                                                                                                    },
                                                                                                                                                    value lowercase : 19
                                                                                                                                                },
                                                                                                                                                value digit : 1
                                                                                                                                            },
                                                                                                                                            value lowercase : 18
                                                                                                                                        },
                                                                                                                                        value rightCurlyBracket : NULL
                                                                                                                                    },
                                                                                                                                    value lowercase : 20
                                                                                                                                },
                                                                                                                                value lowercase : 14
                                                                                                                            },
                                                                                                                            value uppercase : 24
                                                                                                                        },
                                                                                                                        value lowercase : 4
                                                                                                                    },
                                                                                                                    value lowercase : 18
                                                                                                                },
                                                                                                                value lowercase : 14
                                                                                                            },
                                                                                                            value lowercase : 14
                                                                                                        },
                                                                                                        value lowercase : 7
                                                                                                    },
                                                                                                    value uppercase : 2
                                                                                                },
                                                                                                value uppercase : 8
                                                                                            },
                                                                                            value digit : 1
                                                                                        },
                                                                                        value uppercase : 13
                                                                                    },
                                                                                    value uppercase : 18
                                                                                },
                                                                                value uppercase : 0
                                                                            },
                                                                            value leftCurlyBracket : NULL
                                                                        },
                                                                        value uppercase : 19
                                                                    },
                                                                    value uppercase : 18
                                                                },
                                                                value uppercase : 15
                                                            },
                                                            value lowercase : 17
                                                        },
                                                        value lowercase : 14
                                                    },
                                                    value lowercase : 11
                                                },
                                                value digit : 0
                                            },
                                            value uppercase : 3
                                        },
                                        value lowercase : 12
                                    },
                                    value lowercase : 20
                                },
                                value lowercase : 18
                            },
                            value lowercase : 15
                        },
                        value digit : 1
                    },
                    value lowercase : 12
                },
                value digit : 3
            },
            value lowercase : 17
        },
        value lowercase : 14
    },
    value uppercase : 11
}

Det funket vertfall! King! En liten python kode for å lappe sammen dette vaset til noe leslig:

with open("luke8.data") as file:
    lines = file.readlines()

myString = ""

for line in lines:
    line = line.strip()
    if "value" in line:
        split = line.split(" : ")
        if "lowercase" in split[0]:
            myString += chr(97+int(split[1]))

        if "uppercase" in split[0]:
            myString += chr(65+int(split[1]))

        if "digit" in split[0]:
            myString += split[1]

        if "leftCurlyBracket" in split[0]:
            myString += "{"

        if "rightCurlyBracket" in split[0]:
            myString += "}"
              
print(myString [::-1])

Det som spyttes ut da er: Lor3m1psumD0lorPST{ASN1IChooseYou}s1tAm3t
Og som vi ser så er det ett flag inni her.

Flag

PST{ASN1IChooseYou}