---
# System prepended metadata

title: 'dio, porco'

---

# dio, porco

# Functions


Current state = 

- [x] 1
- [ ] 2
- [x] 3
- [x] 4
- [x] 5
- [x] 6
- [ ] 7
- [x] 8
- [x] 9
- [x] 10
- [x] 11
- [ ] 12
- [x] 13
- [x] 14
- [x] 15
- [x] 16
- [ ] 17
- [x] 18
- [x] 19
- [x] 20

```
from arc4 import ARC4
from pwn import *
from re import findall

# not everything was tested properly...
# <3

def r1(shellcode):
    l = shellcode[0x43] # should be 10
    c = shellcode[0x4c::4][:l]
    r = xor(c, shellcode[0x87])
    print(r)
    return r

def r4(shellcode):
    s = shellcode[0x63a:]
    d = []

    n = u16(s[:2])
    while n != 0x458b:
        s = s[6:]
        d.append(n)
        n = u16(s[:2])
        print(hex(n))
    a = d[:len(d) // 2]
    b = d[len(d) // 2:]
    r = b"".join([p16((y-x)&0xffff) for x,y in zip(a,b)])
    print(r)
    return r

def r5(shellcode):
    idx = shellcode.index(b"swag.key") + 9
    r = shellcode[idx:]
    r = r[:r.index(b"\x00")]
    print(r)
    return r

def r6(shellcode):
    d = shellcode[0x4f::4][:10]
    r = xor(d, shellcode[0x8a])
    print(r)
    return r

def r9(shellcode):
    s = shellcode[0x5eb:]
    d = []

    n = u16(s[:2])
    while n != 0x458b:
        s = s[6:]
        d.append(n)
        n = u16(s[:2])
    a = d[:len(d) // 2]
    b = d[len(d) // 2:]
    r = b"".join([p16((y-x)&0xffff) for x,y in zip(a,b)])
    print(r)
    return r

def r15(shellcode):
    idx = shellcode.index(b"%s\x00")
    r = shellcode[idx+3:]
    r = r[:r.index(b"\x00")]
    print(r)
    return r

def r16(shellcode):
    dis = disasm(shellcode)
    k = int(findall("xor.*cl,.*", dis)[0].split(",")[-1],16)
    d = shellcode[0x97::4][:10]
    r = xor(d, k)
    print(r)
    return r

def r18(shellcode):
    key = shellcode[0x380:]
    key = key[:key.index(b"\x00")]
    rc4 = ARC4(key)
    data = shellcode[0x380+len(key)+1:]

    r = rc4.decrypt(data)
    print(r)
    return r
def r19(shellcode):
    d = []
    lines = disasm(shellcode).split("\n")
    while "repnz" not in lines[0]:
        lines = lines[1:]
    while "WORD PTR" not in lines[0]:
        lines = lines[1:]
    while "mov" in lines[0]:
        num = int(lines[0].split(",")[-1],16)
        d.append(num)
        lines = lines[1:]
        if "mov" not in lines[0]:
            lines = lines[1:]

    a = d[:len(d) // 2]
    b = d[len(d) // 2:]
    r = b"".join([p16((y-x)&0xffff) for x,y in zip(a,b)])
    print(r)
    return r
def r20(shellcode):
    idx0 = shellcode.rindex(b"\xc3")
    r = shellcode[idx0+1:]
    print(r)
    return r[:-1]
```




Binary 10 : Looks like it is just compring the input to the data written at the end of the binary