예제 #1
0
def strToimg():

    #fol = str(input("Folder: "))
    fol = main()
    start = time.time()
    flr = open("{}\imgr.txt".format(fol),"r", encoding="utf-8")
    flg = open("{}\imgg.txt".format(fol),"r", encoding="utf-8")
    flb = open("{}\imgb.txt".format(fol),"r", encoding="utf-8")
    flr = flr.read()
    flg = flg.read()
    flb = flb.read()
    #print(arr)
    yz=0
    xz=0
    for f in flr.split(" "):
        if f == "\n":
            yz+=1
        if f != "\n" and yz == 0:
            xz+=1
    print(yz)
    print(xz)
    #ou = Image.open("blnk.jpg").convert('L')
    ou = Image.new("RGB", (xz,yz), color="black")
    y = 0
    x = 0
    narr = []
    #for f in range(0,len(arr)-1,1):
    x = 0
    flr = flr.split(" ")
    flg = flg.split(" ")
    flb = flb.split(" ")
    for f in range(0,len(flr)-1,1):
        try:
            if flr[f] == "\n":
                y += 1
                x = 0
            else:
                try:
                    #print(base65536.decode(str(flr[f])))
                    col = (int(base65536.decode(str(flr[f])),16),int(base65536.decode(str(flg[f])),16),int(base65536.decode(str(flb[f])),16))
                    ou.putpixel((x,y),col)
                    x += 1
                except:
                    p = 0
        except ValueError:
            i = 0
    try:
        ou.save("{}\Result.png".format(fol))
    except:
        p=0
    print("Took {0:0.1f} seconds".format(time.time() - start))
    return
예제 #2
0
def secure_decode_65536(input_data, secret):
    decoded_data = base65536.decode(input_data)
    length, _, data_and_hash = decoded_data.partition(b'\0')
    length = int(length.decode('ascii'))
    raw_data, hmac_hash = data_and_hash[:length], data_and_hash[length:]
    if not hmac.compare_digest(hmac.new(secret, raw_data, hashlib.sha256).digest(), hmac_hash):
        raise HMACException('Data link has been tampered with.')
    return pickle.loads(raw_data)
예제 #3
0
 def decode(self, ctext: T) -> Optional[U]:
     """
     Performs Base65536 decoding
     """
     try:
         return base65536.decode(ctext).decode("utf-8")
     except Exception:
         return None
예제 #4
0
def step1():
    # Step 1:
    f = open('./chall.txt', 'rb').read()
    # print(f.decode())
    a = base65536.decode(f.decode())
    temp = bytes.fromhex((a).decode('utf-8'))
    f2 = open('./output1', 'wb')
    f2.write(temp)  # <-- creates a picture
예제 #5
0
파일: dmfs.py 프로젝트: Hiroyu/dmfs-python
def save_file(filename):
    parts = file_parts[filename]
    file = []
    for i in reversed(range(0, len(parts))):
        file.append(parts[i])
    file = ''.join(file)
    with open('downloads/{}'.format(filename), 'wb') as f:
        f.write(base64.b64decode(base65536.decode(file)))
예제 #6
0
파일: test.py 프로젝트: zihuocc/base65536
def test_hello_world():
    # https://github.com/ferno/base65536/blob/
    # 25d6ea5104a16c24787fa1d8b4af836ba8bb6214/test.js#L86
    encoded = base65536.encode(b'hello world')
    assert encoded == u'驨ꍬ啯𒁷ꍲᕤ'
    assert base65536.decode(encoded) == b'hello world'
예제 #7
0
파일: test.py 프로젝트: zihuocc/base65536
def test_bad():
    # https://github.com/ferno/base65536/blob/
    # 25d6ea5104a16c24787fa1d8b4af836ba8bb6214/test.js#L24
    bad = base65536.encode(b'\x25') + base65536.encode(b'\x13')
    with pytest.raises(ValueError):
        base65536.decode(bad)
예제 #8
0
파일: test.py 프로젝트: zihuocc/base65536
def assert_encoding(data):
    encoded = base65536.encode(data)
    for form in UNICODE_NORMAL_FORMS:
        assert unicodedata.normalize(form, encoded) == encoded
    assert base65536.decode(encoded) == data
import base65536

f = open('output.bin','r')
value = ''.join(f.readlines())
f.close()
print(base65536.decode(value).decode())
예제 #10
0
import base65536

f = open('output.bin', 'r')
value = ''.join(f.readlines())
f.close()
print(base65536.decode(value).decode())
예제 #11
0
파일: test.py 프로젝트: Parkayun/base65536
def test_non_ascii():
    # Python base65536-1.0 had a bug with UTF-8 encoded non-ASCII string.
    encoded = base65536.encode(u'안녕'.encode('utf-8'))
    assert base65536.decode(encoded).decode('utf-8') == u'안녕'
예제 #12
0
파일: test.py 프로젝트: Parkayun/base65536
def test_ascii():
    encoded = base65536.encode(b'hello')
    assert encoded == u'\u9a68\ua36c\u156f'
    assert base65536.decode(encoded) == b'hello'
예제 #13
0
파일: test.py 프로젝트: Parkayun/base65536
def test_hello_world():
    # https://github.com/ferno/base65536/blob/
    # 25d6ea5104a16c24787fa1d8b4af836ba8bb6214/test.js#L86
    encoded = base65536.encode(b'hello world')
    assert encoded == u'驨ꍬ啯𒁷ꍲᕤ'
    assert base65536.decode(encoded) == b'hello world'
예제 #14
0
파일: test.py 프로젝트: Parkayun/base65536
def test_bad():
    # https://github.com/ferno/base65536/blob/
    # 25d6ea5104a16c24787fa1d8b4af836ba8bb6214/test.js#L24
    bad = base65536.encode(b'\x25') + base65536.encode(b'\x13')
    with pytest.raises(ValueError):
        base65536.decode(bad)
예제 #15
0
파일: test.py 프로젝트: Parkayun/base65536
def assert_encoding(data):
    encoded = base65536.encode(data)
    for form in UNICODE_NORMAL_FORMS:
        assert unicodedata.normalize(form, encoded) == encoded
    assert base65536.decode(encoded) == data
예제 #16
0
파일: test.py 프로젝트: zihuocc/base65536
def test_ascii():
    encoded = base65536.encode(b'hello')
    assert encoded == u'\u9a68\ua36c\u156f'
    assert base65536.decode(encoded) == b'hello'
예제 #17
0
파일: test.py 프로젝트: zihuocc/base65536
def test_non_ascii():
    # Python base65536-1.0 had a bug with UTF-8 encoded non-ASCII string.
    encoded = base65536.encode(u'안녕'.encode('utf-8'))
    assert base65536.decode(encoded).decode('utf-8') == u'안녕'
예제 #18
0
파일: solve.py 프로젝트: jsahil730/WriteUps
import base65536
with open('chall_encrypted.txt', 'r') as chall_enc:
    data = chall_enc.read()

data1 = "".join(chr(ord(i) % 256) + chr(ord(i) // 256) for i in data)

d = base65536.decode(data)
print(d.decode())

f1 = "Yjod od s lrunpstf djogy vo[jrtyrcy jrtr od upi g;sh xj4t-}U-i+dit4+"

f2 = "3030313130313030203031313130303130203030313130303131203031303131313131203030313130313030203031313130313131203030313130303131203031313130303131203030313130303030203031313031313031203030313130303131203031303131313131203031313130313131203031313031303031203030313130313131203031313031303030"

f3 = "MTExMTExMTExMTAwMTAwMDEwMTAxMDExMTAxMDExMTExMTEwMTAxMTExMTExMTExMDExMDExMDExMDExMDAwMDAxMTAxMDAxMDAxMDAxMDAwMDAwMDAwMDAwMDAwMDAwMTAxMDAxMTAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMTAxMDAwMDAwMDAwMDAwMTAxMDAwMTAxMDAxMDAwMTAxMDAxMTExMTExMTAwMTAxMDAxMDExMTExMTExMTAwMTAxMDAxMTAwMDAwMDAwMDAwMDAwMTAxMDAxMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMTAxMDExMTExMTExMTExMTExMTExMTExMDAxMDEwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAwMDAxMDEwMDAwMDAwMDAxMDEwMDExMDAwMDAwMDAxMDEwMDAxMDEwMTExMTAwMTAxMDAxMDExMTExMTExMTExMTExMTExMTExMDAxMDEwMDExMDExMDExMTExMTExMTExMTAwMTAxMA=="

print(bytes.fromhex(f2))
# b'00110100 01110010 00110011 01011111 00110100 01110111 00110011 01110011 00110000 01101101 00110011 01011111 01110111 01101001 00110111 01101000'
flag2 = "".join(chr(int(i, 2)) for i in bytes.fromhex(f2).split())
print(flag2)

flag3 = b"_411_7h3_ski115}"  # SPOON decode
flag1 = b"This is a keyboard shift ciphertext here is you flag zh3r0{Y0u_sur3_"

print(flag1.decode() + flag2 + flag3.decode())
예제 #19
0
    def convert(self, inp, source, target, skip=False):
        if source == target:
            return inp
        if source == '65536':
            source = '0123456789'
            l = len(inp) if len(inp) > 3 else len(inp) + 1
            s = '>'
            s += 'Q' * (l // 4)
            s += 'L' if l % 4 == 3 else 'H' if l % 4 == 2 else 'B' if l % 4 == 1 else ''
            truct = base65536.decode(inp)
            total = 0
            count = 0
            for x in struct.unpack(s, truct):
                total += x * (2**64)**count
                count += 1
            inp = str(total)
        if type(source) == list:
            return "Cannot currently convert from time."
        if type(target) == list and not skip:
            b60str = self.convert(inp, source, target, skip=True)
            #             print(b60str)
            b60 = []
            for x in range(0, len(b60str) - 1, 2):
                b60.append(b60str[x:x + 2][::-1])
            minu = int(b60[-1])
            hour = 0
            counter = 0
            for x in b60[:-1][::-1]:
                hour += int(x) * 60**counter
                counter += 1
            hour = hour % 24
            return f'{hour}:{"0"*(2-len(str(minu)))}{minu}'

        if target == '65536':
            b10 = int(self.convert(inp, source, '0123456789'))
            nums = []
            s = '>'
            while b10 > 2**64 - 1:
                s += 'Q'
                nums.append(b10 % 2**64)
                b10 = b10 // (2**64)
            if b10 > 2**32 - 1:
                s += 'Q'
            elif b10 > 2**16 - 1:
                s += 'L'
            elif b10 > 2**8 - 1:
                s += 'H'
            else:
                s += 'B'
            nums.append(b10)

            return base65536.encode(struct.pack(s, *nums))
        sbase = len(source)
        tbase = len(target)
        inp = inp[::-1]
        num = 0
        startswith0 = False
        if inp[-1] == source[0]:
            startswith0 = True
        for x in range(0, len(inp)):
            num += source.index(inp[x]) * (sbase**x)
        string = ""
        while (True):
            string += str(target[num % tbase])
            num = num // tbase
            if num == 0: break
        if startswith0:
            string += (target[0])
        return string[::-1]
예제 #20
0
    
#see these characters in almost every other CTF kind of annoying 
#Example
#聐㠃㐊㐀㐀膜舕㐀㐀㐀㐀㐀㐀㐵㐜ꕳ𓅡𔕨𓁯𓅤騭𓍰扢改饤渹朷霭收户阴氱洭椹户騳樸昲顥游湢訯㵔㜀𦌷遻𦍋遻𖡵㐋㠁㟨㐀𦸄㐃蔀㝋䠄㐀㰀爀澜坉𢜸杢㐁稀㐂礀儀𓄀陭鵳𒁷饲扳𒅥靵渭餰湤氹戲止氰椭晡户游水栭浥朵騱浣
#霹搹鹴ꍴ𒅥鱡捥鵸ꕴ詬㵔㜀𖠦賩𦈲遻𖡵㐋㠁㟨㐀𦸄㐃言𤞑𠥮䀰𧖆㹻𥣋䒎銪𢁖绐𧲕𦌄𥁹䦂瘲𦙠讕𦓕㵽𢥴駤𤔧𧺿𦮷𦋾𒇔𠒢𣍰𣹗桉𧠄抦𣶝𦔊𣖎棉㿮𒉙㥐咥謔鋌𤨮𡐸𧻩𣲔䦽𧎛恶蛎蚃𥶔䨺𤶓㗢𡟂𦼕䉲𣪧𥰡帐𠌉𤅽
#𤢓𧅃熙𤴧籋鬈䣎𢌲祙䋪𢭌𠟻𥍘𠼍䰻𣐻涩𤞴䢂𣡳䈼𢽼洉𒁠栴㰌羓慡鋩𧕉𓃱𡀩𢯧𡳓𦃠柩囎𣊇勣𤀴𥒷囧軾璉𧣚谂𨊈𥵄𨃎脜𢗨勺㗼𧇮𥹧蘚袺𣈠𧄄

# pip install base65536

import base65536

with open('FILE.txt','r') as f:
    ct = f.readline().rstrip().replace(' ','')

with open('FILE_out','wb') as f2:
    f2.write(base65536.decode(ct))
예제 #21
0
def StrToByte(x):
    return base65536.decode(x)
예제 #22
0
import base65536

for b in range(0, 256):
    buf1 = bytearray([b])
    str1 = base65536.encode(buf1)
    buf2 = base65536.decode(str1)
    if buf1 != buf2:
        raise Exception

firstDefectStr = base65536.encode(bytearray([0, 110]))
firstDefectBuf = base65536.decode(firstDefectStr)
print(ord(firstDefectStr[0]) == 67072)
print(ord(firstDefectStr[0]) == 0x10600)
print(firstDefectBuf == bytearray([0, 110]))

for b1 in range(0, 256):
    for b2 in range(0, 256):
        buf1 = bytearray([b1, b2])
        str1 = base65536.encode(buf1)
        buf2 = base65536.decode(str1)
        if buf1 != buf2:
            raise Exception

buf = bytearray(b"hello world")
enc = base65536.encode(buf)
print(enc == "驨ꍬ啯𒁷ꍲᕤ")
dec = base65536.decode(enc)
print(dec == buf)

print("OK")