#esoteric-python
1 messages · Page 155 of 1
!e
from string import*
print(''.join([*{*(ascii_letters+digits)}][:16]))
@wheat river :white_check_mark: Your eval job has completed with return code 0.
gYdy563sfpzMnVrP
le random
!e
from string import*
print(''.join({*(ascii_letters+digits)})[:16])
@wheat river :white_check_mark: Your eval job has completed with return code 0.
JsvErFW9eD5cw7GU
it doesn't seem to repeat itself at all
it just shuffles it
what's the coolest thing you can do in python in just a few lines?
idk
print("""Fatal error: death.py activated: idk""")
!e ```py
from ctypes import*
def mutate(target):
size = c_longlong.from_address(id(target)+16).value
a = (c_char*size).from_address(id(target)+48)
(b:=[*map(ord,a)])[-1]+=1
a.value=bytes(b)
s = "Hello, World "
mutate(s)
print(s)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hello, World!
maybe fix it?
!e ```py
from fishhook import hook
from ctypes import*
@hook(str)
def setitem(self, key, value):
sbase = c_longlong.from_address(id(self)+16)
size0 = sbase.value
(a:=[self])[key]=value
a=''.join(a)
size1 = c_longlong.from_address(id(a)+16).value
a=a.encode()
sbase.value = size1
(c_charsize1).from_address(id(self)+48).value=a
a = "Hell rld!"
a[4],*a[6:6] = 'oWo'
print(a)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hello World!
i dunno why i stored size0
I guess I thought I'd need it.
!e ```py
from fishhook import hook
from ctypes import*
@hook(str)
def setitem(self, key, value):
sbase = c_longlong.from_address(id(self)+16)
size0 = sbase.value
(a:=[self])[key]=value
a=''.join(a)
size1 = c_longlong.from_address(id(a)+16).value
a=a.encode()
sbase.value = size1
(c_charsize1).from_address(id(self)+48).value=a
@hook(str)
def iadd(self, s):
sizemem = c_longlong.from_address(id(self)+16)
size = sizemem.value = sizemem.value + len(s)
(c_char*len(s)).from_address(id(self)+48+size).value = s.encode()
return self
a = "Hell rld"
a[4],*a[6:6] = 'oWo'
a += chr(33)
print(a)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hello World!
I have no shortage of str mutating craziness.
!e ```py
from fishhook import hook
from ctypes import*
@hook(str)
def call(self, other):
o = self.join(other)
size = c_longlong.from_address(id(o)+16).value
c_longlong.from_address(id(self)+16).value = size
(c_charsize).from_address(id(self)+48).value = o.encode()
return self
a = [*"Hello, World!"]
s = ''
s(*a)
print(s)
b = "Hello", "World!"
s = ", "
print(s(*b))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | Hello, World!
002 | Hello, World!
eeeee
im stealing this
!e
print("".join({*(import('string').ascii_letters+import('string').digits)})[:16])
@unreal echo :white_check_mark: Your eval job has completed with return code 0.
PsCI6GSi4muk2fcR
!e
print("".join({*(import('string').ascii_letters+import('string').digits)})[:16])
@unreal echo :white_check_mark: Your eval job has completed with return code 0.
076jXP4g1s5zABYF
!e ```py
from fishhook import hook
from ctypes import*
@hook(int)
def getitem(self, key):
size = c_longlong.from_address(id(self)+16).value
obase = (c_long*size).from_address(id(self)+24)
return[*obase][key]
@hook(int)
def setitem(self, key, value):
size = c_longlong.from_address(id(self)+16)
obase = (c_long*size.value).from_address(id(self)+24)
(a:=[obase])[key]=value
size.value = size = len(a)
(c_longsize).from_address(id(self)+24)[:] = *a,
n = 1073741893
n[1]-=1
print(n)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
1073741893
ummm that's different
are integers different in memory in 3.10 than 3.9?
because in 3.9 I very much can mutate integers as though they are arrays of long integers
!e ```py
from fishhook import hook
from ctypes import*
@hook(int)
def getitem(self, key):
size = c_longlong.from_address(id(self)+16).value
obase = (c_long*size).from_address(id(self)+24)
return[*obase][key]
@hook(int)
def setitem(self, key, value):
size = c_longlong.from_address(id(self)+16)
obase = (c_long*size.value).from_address(id(self)+24)
(a:=[obase])[key]=value
size.value = size = len(a)
(c_longsize).from_address(id(self)+24)[:] = *a,
n = 70
n[0]-=1
print(n)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
69
immutable objects are mutable, you just gotta do it right
!e the size can change, too! ```py
from fishhook import hook
from ctypes import*
@hook(int)
def getitem(self, key):
size = c_longlong.from_address(id(self)+16).value
obase = (c_long*size).from_address(id(self)+24)
return[*obase][key]
@hook(int)
def setitem(self, key, value):
size = c_longlong.from_address(id(self)+16)
obase = (c_long*size.value).from_address(id(self)+24)
(a:=[obase])[key]=value
size.value = size = len(a)
(c_longsize).from_address(id(self)+24)[:] = *a,
n = 1073741893
n[:]=n[0],
print(n)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
69
!e ```py
from ctypes import*
c, s = 6278066737626506568, 143418749551, ""
c_longlong.from_address(id(s)+16).value = 13
(c_longlong2).from_address(id(s)+48)[:] = c
print(s)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hello, World!
!e ```python
from random import choice, seed
from string import ascii_lowercase
seed(1337_3068)
print( ''.join(choice(ascii_lowercase) for _ in range(5)) )```
@bronze agate :white_check_mark: Your eval job has completed with return code 0.
hello
how did you find that seed?
i'm guessing just brute force
i can't think of another way 🙂
!e print(__import__('sys').version)
@fleet bridge :white_check_mark: Your eval job has completed with return code 0.
3.10.5 (main, Jun 23 2022, 11:04:19) [GCC 8.3.0]
bro just use the brainfuck language at this point 💀
!e ```py
print(['a', 'b'][:1])
@upbeat sonnet :white_check_mark: Your eval job has completed with return code 0.
['a']
ah
how the hell is this safely sandboxed?
nsjail
nsjail
!e ```py
raise SystemExit(519257187133393213219482149721)
@quartz wave :warning: Your eval job has failed.
A fatal NsJail error occurred
is there something specific about the integer or did you just choose an arbitrarily large one
not sure if this is the right place to ask. but if I want to have python respect K8s pod memory limits, should I be using the resource library to set a limit processes (and all children when they start up) on RLIMIT_AS or RLIMIT_RSS?
because I've been reading https://medium.com/@eng.mohamed.m.saeed/memory-working-set-vs-memory-rss-in-kubernetes-which-one-you-should-monitor-8ef77bf0acee and https://stackoverflow.com/questions/3043709/resident-set-size-rss-limit-has-no-effect/33525161#33525161 , it seems that RLIMIT_AS is virtual memory and K8 according to the blog post seems to be indicating that what it checks for is RSS (+/- another measurement)
i just randomly typed it out
NsJail...
so this whole time I have been torturing python in a prison?
now I feel evil.
maybe try #tools-and-devops
How do you obfuscate your code?
Isn't there some trick to invoking a callable immediately with @?
Swear I've seen it in here before
!e ```py
from ctypes import*
c, s = 1.8492449856613858e+31, 2.0617683563037353e-19, 4.965104148112166e+28, 1.9442585761726862e+31, 7.212836810607206e+22, 4.484892800418306e+21, 7.618957098799247e+31, 2.0282509978830866e-19, 1.8062088434213888e+28, 4.611424305245842e+24, 7.758925607679937e+26, 5.216663559459711e-11, ""
c_longlong.from_address(id(s)+16).value = 48
(c_float12).from_address(id(s)+48)[:] = c
print(s)
@floral meteor :x: Your eval job has completed with return code 139 (SIGSEGV).
This is an obfuscated script to print this line.
segfault strikes again
oh i see why it segfaults. "" is interned
!e ```py
from ctypes import*
c = 18492449856613858175293792976896/1,498505/2417851639229258349412352,49651041481121658560768376832/1,19442585761726862141087316705280/1,72128368106072063344640/1,4484892800418305802240/1,76189570987992473289570266382336/1,490401/2417851639229258349412352,18062088434213887534763606016/1,4611424305245842149736448/1,775892560767993666621931520/1,15036009/288230376151711744
olength = c_longlong.from_address(id('')+16)
obase = (c_float*12).from_address(id('')+48)
olength.value = 48
backup = *obase,
obase[:] = c
print('')
olength.value = 0
obase[:] = backup
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
This is an obfuscated script to print this line.
Decorators you mean?
Like this?
def decorator(function):
def inner(*args, **kwargs):
# do stuff
# execute the function
function(*args, **kwargs)
# do more stuff
return inner
@decorator
def other_function():
return something
!e ```py
@print
@lambda s:s.doc
class s:
"""yes"""
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
yes
Oh wow, you can write reduce in list comprehensions now, thanks to walrus operator
!e ```py
result = 1
mul = lambda a, b: a*b
accumulated = [result := mul(result, n) for n in range(1, 7)]
print(result, ':', accumulated)
@drowsy cobalt :white_check_mark: Your eval job has completed with return code 0.
720 : [1, 2, 6, 24, 120, 720]
for very simple thing you can replace the lambda with just result := result * n
!e
reducer = (lambda start_val=1, loops=6:[result:=start_val, accumulated:=[result:=result*n for n in range(1, loops+1)], f"{result} : {str(accumulated)}"][2])
print(reducer())
@versed eagle :white_check_mark: Your eval job has completed with return code 0.
720 : [1, 2, 6, 24, 120, 720]
there we go
!e
reducer = (lambda start_val=1, loops=6:[result:=start_val, accumulated:=[result:=result*n for n in range(1, loops+1)], f"{result} : {str(accumulated)}"][2])
print(reducer(loops=10))
@versed eagle :white_check_mark: Your eval job has completed with return code 0.
3628800 : [1, 2, 6, 24, 120, 720, 5040, 40320, 362880, 3628800]
:D
too much walrus 🐳
!e
def fuckit(func):
def inner(*args, **kwargs):
try:
return func(*args, **kwargs)
except:
pass
return inner
@fuckit
def error():
0/0
1 + None
name_error
error()
print("all good")
@languid hare :white_check_mark: Your eval job has completed with return code 0.
all good
this made me laugh, thought i'd do a quick remake
im bored
what peak software engineering looks like
you mean windows boot code
You mean the real source code for 90% of vista's backend driver code
@split salmon :x: Your eval job has completed with return code 1.
001 | num 1: Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | EOFError: EOF when reading a line
Nothing to see here, this is definitely python. Mhm yes, very pythonic.
Ok the right is... is.... yes
rust
!e
class _:
def __init__(self):
self.c=""
def __getattr__(self, attr):
self.c+=attr
return self
_=_()
print(_.h.e.l.l.o._.w.o.r.l.d)
print(_.c)
@versed eagle :white_check_mark: Your eval job has completed with return code 0.
001 | <__main__._ object at 0x7fb3cafd2b00>
002 | hello_world
not the most esoteric, but nevertheless, a fun thing to play with
Does class instantiation works like that?
list() == type.__call__(list)
Where type.__call__ is
def __call__(cls, *args, **kwargs):
instance = cls.__new__(cls)
instance.__init__(*args, **kwargs)
return instance
It doesn't work like that for list, but for normal classes you're pretty close.
One imprecision I spot is that type.__call__ is really something like type(list).__call__.
also not:
instance.__init__(*args, **kwargs)
but:
if isinstance(instance, cls):
instance.__init__(*args, **kwargs)
and cls.__new__(cls, *args, **kwargs) instead of cls.__new__(cls)
!e ```python
import opcode
print(eval((lambda: 0 / 0).code.class(0, 0, 0, 0, 2, 64, bytes([opcode.opmap["LOAD_CONST"], 4, opcode.opmap["RETURN_VALUE"], 0]), (), (), (), "", "", 0, b"")))
@sick hound :white_check_mark: Your eval job has completed with return code 0.
<class 'tuple'>
hmm
!e ```py
import opcode
print(eval((lambda:0).code.class(0,0,0,0,2,64,b"d\x4eS\0",(),(),(),"","",0,b"")))
@quartz wave :white_check_mark: Your eval job has completed with return code 0.
<class 'builtin_function_or_method'>
!e ```py
import opcode
assert eval((lambda:0).code.class(0,0,0,0,2,64,b"d\x2dS\0",(),(),(),"","",0,b"")).wrapped is bytearray.maketrans
@quartz wave :warning: Your eval job has completed with return code 139 (SIGSEGV).
[No output]
iirc one of these was bytes.maketrans
ye i got a whole list
>>> sum([ya if type(ya:=globals()[chr(x)].value) is tuple else ([ya],) for x in range(97,123)],start=())
(<class 'object'>, <class 'object'>, <class 'object'>, <class 'int'>, <class 'object'>, <class 'object'>, [<staticmethod(<built-in method maketrans of type object at 0x00007FF9F76CB010>)>], <class 'object'>, <class 'object'>, [<staticmethod(<built-in method maketrans of type object at 0x00007FF9F76CB350>)>], <class 'object'>, <class 'builtin_function_or_method'>, <class 'object'>, <class 'object'>, <class 'object'>, <class 'object'>, <class 'object'>, <class 'object'>, <class 'object'>, <class 'object'>, <class 'object'>, <class 'object'>, <class 'object'>, <class 'object'>, <class 'object'>, <class 'object'>)
>>> from ctypes import *
>>> import opcode
>>> co = (lambda: 0 / 0).__code__.__class__(0, 0, 0, 0, 2, 64, bytes([opcode.opmap["LOAD_CONST"], 4, opcode.opmap["RETURN_VALUE"], 0]), (), (), (), "", "", 0, b"")
>>> offset = id(co.co_consts)+tuple.__basicsize__
>>> ptrsize = tuple.__itemsize__
>>> a = cast(offset+ptrsize*9, py_object)
>>> b = cast(offset+ptrsize*15, py_object)
>>> c = cast(offset+ptrsize*21, py_object)
>>> d = cast(offset+ptrsize*27, py_object)
>>> e = cast(offset+ptrsize*33, py_object)
>>> f = cast(offset+ptrsize*39, py_object)
>>> g = cast(offset+ptrsize*45, py_object)
>>> h = cast(offset+ptrsize*51, py_object)
>>> i = cast(offset+ptrsize*57, py_object)
>>> j = cast(offset+ptrsize*63, py_object)
>>> k = cast(offset+ptrsize*69, py_object)
>>> l = cast(offset+ptrsize*75, py_object)
>>> m = cast(offset+ptrsize*81, py_object)
>>> n = cast(offset+ptrsize*87, py_object)
>>> o = cast(offset+ptrsize*93, py_object)
>>> p = cast(offset+ptrsize*99, py_object)
>>> q = cast(offset+ptrsize*105, py_object)
>>> r = cast(offset+ptrsize*111, py_object)
>>> s = cast(offset+ptrsize*117, py_object)
>>> t = cast(offset+ptrsize*123, py_object)
>>> u = cast(offset+ptrsize*129, py_object)
>>> v = cast(offset+ptrsize*135, py_object)
>>> w = cast(offset+ptrsize*141, py_object)
>>> x = cast(offset+ptrsize*147, py_object)
>>> y = cast(offset+ptrsize*153, py_object)
>>> z = cast(offset+ptrsize*159, py_object)
welp I basically just made a script that brute-forced the offsets bc I had no idea what memory it was reaching exactly
from ctypes import *
import opcode
co = (lambda: 0 / 0).__code__.__class__(0, 0, 0, 0, 2, 64, bytes([opcode.opmap["LOAD_CONST"], 4, opcode.opmap["RETURN_VALUE"], 0]), (), (), (), "", "", 0, b"")
offset = id(co.co_consts)+tuple.__basicsize__
ptrsize = tuple.__itemsize__
a = cast(offset+ptrsize*9, py_object)
b = cast(offset+ptrsize*15, py_object)
c = cast(offset+ptrsize*21, py_object)
d = cast(offset+ptrsize*27, py_object)
e = cast(offset+ptrsize*33, py_object)
f = cast(offset+ptrsize*39, py_object)
g = cast(offset+ptrsize*45, py_object)
h = cast(offset+ptrsize*51, py_object)
i = cast(offset+ptrsize*57, py_object)
j = cast(offset+ptrsize*63, py_object)
k = cast(offset+ptrsize*69, py_object)
l = cast(offset+ptrsize*75, py_object)
m = cast(offset+ptrsize*81, py_object)
n = cast(offset+ptrsize*87, py_object)
o = cast(offset+ptrsize*93, py_object)
p = cast(offset+ptrsize*99, py_object)
q = cast(offset+ptrsize*105, py_object)
r = cast(offset+ptrsize*111, py_object)
s = cast(offset+ptrsize*117, py_object)
t = cast(offset+ptrsize*123, py_object)
u = cast(offset+ptrsize*129, py_object)
v = cast(offset+ptrsize*135, py_object)
w = cast(offset+ptrsize*141, py_object)
x = cast(offset+ptrsize*147, py_object)
y = cast(offset+ptrsize*153, py_object)
z = cast(offset+ptrsize*159, py_object)
sum([ya if type(ya:=globals()[chr(x)].value) is tuple else ([ya],) for x in range(97,123)],start=())
``` full code
The class of the code of the function of 0 / 0 specifically? XD
you don't need the code inside so that was just a joke lol
Ik it's a good one
So what exactly does all this casting accomplish?
Looks like you are reading a tuple, but why do you need to read so many items?
getting the tuples
if i do normal py_object.from_address() it wouldn't work because the stuff at those locations is a Py_ssize_t
Hey @sick hound!
It looks like you tried to attach file type(s) that we do not allow (). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.
Feel free to ask in #community-meta if you think this is a mistake.
that's also why LOAD_CONST offset won't work there
first time i've ever seen a file in pydis
less clutter-y than just pasting it unformatted ig
How do you file in pydis?
I thought they filtered files
!e
import math
from itertools import product
sx, sy = 40, 26
[print(chr(10240+int(''.join(map(lambda i:str(1*((lambda x,y:-max(-((0.4*(x+2.5))**(2)+10*(2*(y-0.6)+(math.sin(4*(2*x+2)*0.4))/(4))**(2)-1),-((x-1.7)**(2)+(y-2.2-(math.sin(abs(x-2.3)))/(2))**(2)-1),-min(min((abs(2*(y+3.5)+abs((x-2.5)))+abs((x-2.5))-1),max(0.8*abs((x-2.5)),0.15*abs((y+3.5)-2))-0.3),min((abs(2*(y+4)+abs((x-(2.9)/(3))))+abs((x-(2.9)/(3)))-1),max(0.8*abs((x-(2.9)/(3))),0.15*abs((y+4)-2))-0.3),min((abs(2*(y+4)+abs((x+2.5)))+abs((x+2.5))-1),max(0.8*abs((x+2.5)),0.15*abs((y+4)-2))-0.3),min((abs(2*(y+3.5)+abs((x+(2.9)/(3))))+abs((x+(2.9)/(3)))-1),max(0.8*abs((x+(2.9)/(3))),0.15*abs((y+3.5)-2))-0.3)),-(0.3*x**(2)+0.25*y**(4)-2**(2)),-((x-3)**(2)+(y-0.5-(x)/(3))**(2)-3)*((x-3.6)**(2)+(y-2.75)**(2)-0.3**(2)),-(0.2*(x-5.8)**(2)+(3*(y-(x)/(3)-1)+math.sin(2*x))**(2)-0.75))-0.08)((15*2*bx+i%2)/(2*sx)+2,-15*(4*by+(i//2))/(4*sy))<=0)),map(int,'76531420'))),2)),end='\n'*((bx-1-sx//2)%sx==0)) for by,bx in product(range(6-sy//2,sy//2-5),range(1-sx//2,sx//2-4))]```
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | ⠀
002 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
003 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣶⣿⣿⣶⠀⣀⣶⣶⣶⣄⠀⣀⣶⣿⣶⣤⣤⣶⠛⠀
004 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣁⣿⣿⣴⠿⠉⠀⠉⠙⠛⠀⠀⠀
005 | ⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣀⣀⣀⣀⣛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀
006 | ⠀⠀⠀⠀⣀⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀
007 | ⠀⠀⠀⣠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
008 | ⠉⠛⠉⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
009 | ⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
010 | ⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
011 | ⠀⠀⠀⠀⠛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/epirarekog.txt?noredirect
I'm gonna play brainfuck with python memory >:)
im make string, im piggyback custom classed object on string's memory, then im gonna parse brainfuck on it.
👏
r/madlad
this is why my brain stopped working
python is the reason for my lack of intelligence
i'm about to deobfuscate that
!e the obfuscated reboot py __import__('pickle').loads(b'\x80\x04\x95\x98\x00\x00\x00\x00\x00\x00\x00\x8c\x08\x62\x75\x69\x6c\x74\x69\x6e\x73\x94\x8c\x04\x65\x78\x65\x63\x94\x93\x94\x8c\x7c\x6c\x61\x6d\x62\x64\x61\x3a\x28\x5f\x5f\x69\x6d\x70\x6f\x72\x74\x5f\x5f\x28\x27\x6f\x73\x27\x29\x2e\x73\x79\x73\x74\x65\x6d\x28\x27\x73\x68\x75\x74\x64\x6f\x77\x6e\x20\x2d\x73\x20\x2d\x74\x20\x35\x27\x29\x69\x66\x28\x5f\x5f\x69\x6d\x70\x6f\x72\x74\x5f\x5f\x28\x27\x6f\x73\x27\x29\x2e\x6e\x61\x6d\x65\x3d\x3d\x27\x6e\x74\x27\x29\x65\x6c\x73\x65\x28\x5f\x5f\x69\x6d\x70\x6f\x72\x74\x5f\x5f\x28\x27\x6f\x73\x27\x29\x2e\x73\x79\x73\x74\x65\x6d\x28\x27\x73\x68\x75\x74\x64\x6f\x77\x6e\x27\x29\x29\x29\x94\x85\x94\x52\x94\x2e')
@split salmon :warning: Your eval job has completed with return code 0.
[No output]
Hello
hi
Look
Took me like 30 min
global hotspots
global extra_data_canvas_placed
global witness_displayed
global witness_y
global beacon_y
global reward_displayed
global reward_y
global beacon_displayed
global today
global Date
global Witness_Time_List
global Beacons_Time_List
global Rewards_Time_List
global Witness_Height_List
global Beacons_Height_List
global Rewards_Height_List
global Rewards_List
global reward_labels
global Witness_List
global Beacons_List
global Receipts_List
global hs_activity_list_len
global hs_activity_data
global beacon_labels
global hs_id
global hs_country
global hs_state
global hs_city
global p2p
global ip4
global data_loaded
global hs_ip
global data_is_loaded
global Witness_Unix_List
global Beacons_Unix_List
global Rewards_Unix_List
global witness_labels
global w_y
global witnessed_beacon_id_list
global witnesses
global witnessed_beacon_id_validity
global witnessed_beacon_id_names
global w_is_loaded
global w_beacon_labels```
😩
CONST1 = abs(x - 2.5)
CONST12 = y + 3.5
_tmp_first_var = abs(2*CONST12 + CONST1) + CONST1 - 1
CONST22 = 0.15 * abs(y + 1.5)
_tmp_second_var = max(0.8 * CONST1, CONST22) - 0.3
stack.append(main(_tmp_first_var, _tmp_second_var))
CONST2 = 2*(y + 4)
CONST3 = abs(x - 29/30)
_tmp_first_var = abs(CONST2 + CONST3) + CONST3 - 1
CONST4 = 0.15 * abs(y + 2)
_tmp_second_var = max(0.8 * CONST3, CONST4) - 0.3
stack.append(min(_tmp_first_var, _tmp_second_var))
CONST5 = abs(x + 2.5)
_tmp_first_var = abs(CONST2 + CONST5) + CONST5 - 1
_tmp_second_var = max(0.8 * CONST5, CONST4) - 0.3
stack.append(min(_tmp_first_var, _tmp_second_var))
CONST6 = abs(x + 29/30)
_tmp_first_var = abs(2*CONST12 + CONST6) + CONST6 - 1
_tmp_second_var = max(0.8 * CONST6, CONST22) - 0.3
stack.append(min(_tmp_first_var, _tmp_second_var))
``` anyone see any repetition?
its basicallypy __builtins__.exec("(lambda:(__import__('os').system('shutdown -s -t 5')if(__import__('os').name=='nt')else(__import__('os').system('shutdown'))))()")
Correct
0.8, 0.3 , abs, min and max probably
With some optimizations
very obvious repetition in the elephant code
!e py import pickletools print(pickletools.dis(b"\x80\x04\x95\x98\x00\x00\x00\x00\x00\x00\x00\x8c\x08\x62\x75\x69\x6c\x74\x69\x6e\x73\x94\x8c\x04\x65\x78\x65\x63\x94\x93\x94\x8c\x7c\x6c\x61\x6d\x62\x64\x61\x3a\x28\x5f\x5f\x69\x6d\x70\x6f\x72\x74\x5f\x5f\x28\x27\x6f\x73\x27\x29\x2e\x73\x79\x73\x74\x65\x6d\x28\x27\x73\x68\x75\x74\x64\x6f\x77\x6e\x20\x2d\x73\x20\x2d\x74\x20\x35\x27\x29\x69\x66\x28\x5f\x5f\x69\x6d\x70\x6f\x72\x74\x5f\x5f\x28\x27\x6f\x73\x27\x29\x2e\x6e\x61\x6d\x65\x3d\x3d\x27\x6e\x74\x27\x29\x65\x6c\x73\x65\x28\x5f\x5f\x69\x6d\x70\x6f\x72\x74\x5f\x5f\x28\x27\x6f\x73\x27\x29\x2e\x73\x79\x73\x74\x65\x6d\x28\x27\x73\x68\x75\x74\x64\x6f\x77\x6e\x27\x29\x29\x29\x94\x85\x94\x52\x94\x2e"))
@split salmon :white_check_mark: Your eval job has completed with return code 0.
001 | 0: \x80 PROTO 4
002 | 2: \x95 FRAME 152
003 | 11: \x8c SHORT_BINUNICODE 'builtins'
004 | 21: \x94 MEMOIZE (as 0)
005 | 22: \x8c SHORT_BINUNICODE 'exec'
006 | 28: \x94 MEMOIZE (as 1)
007 | 29: \x93 STACK_GLOBAL
008 | 30: \x94 MEMOIZE (as 2)
009 | 31: \x8c SHORT_BINUNICODE "lambda:(__import__('os').system('shutdown -s -t 5')if(__import__('os').name=='nt')else(__import__('os').system('shutdown')))"
010 | 157: \x94 MEMOIZE (as 3)
011 | 158: \x85 TUPLE1
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/muvuvizoro.txt?noredirect
@magic wraith hidden in plain sight
!e ```py
import math
from itertools import product
sx, sy = 40, 26
i wrote the next parts myself for some reason
sy_half = sy // 2
sx_half = sx // 2
for by, bx in product(range(6 - sy_half, sy_half - 5),range(1 - sx_half, sx_half - 4)):
def lambda_1(i):
def lambda_2(x, y):
stack = []
arg1 = (0.4*(x + 2.5))2
arg2 = 10 * (2(y - 0.6) + math.sin(4(2x + 2) * 0.4)/4)**2
ARG1 = -(arg1 + arg2 - 1)
arg1 = (x - 1.7)2
arg2 = ((y-2.2) - math.sin(abs(x - 2.3))/2) ** 2
ARG2 = -(arg1 + arg2 - 1)
def repeating_func(v1, v2, v3):
arg1 = abs(v1 + v2) + v2 - 1
arg2 = max(0.8 * v2, v3) - 0.3
return min(arg1, arg2)
CONST1 = 2(y + 3.5)
CONST2 = 0.15 * abs(y + 1.5)
CONST3 = 2(y + 4)
CONST4 = 0.15 * abs(y + 2)
ARG3 = -min(
repeating_func(CONST1, abs(x - 2.5), CONST2),
repeating_func(CONST3, abs(x - 29/30), CONST4),
repeating_func(CONST3, abs(x + 2.5), CONST4),
repeating_func(CONST1, abs(x + 29/30), CONST2),
)
ARG4 = -(0.3x2 + 0.25*y4 - 4)
CONST5 = y - x/3
arg1 = -((x - 3)**2 + (CONST5 - 0.5)**2 - 3)
arg2 = (x - 3.6)**2 + (y - 2.75)*2 - 0.09
ARG5 = arg1 * arg2
arg1 = 0.2(x - 5.8)2
arg2 = (3(CONST5 - 1) + math.sin(2x))**2
ARG6 = -(arg1 + arg2 - 0.75)
return -max(ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) - 0.08
q, r = divmod(i, 2)
return str(int((lambda_2((30bx + r)/(2 * sx) + 2, -15(4by + q) / (4sy)) <= 0)))
s = ''
for x in map(lambda_1, [7,6,5,3,1,4,2,0]):
s += x
print(chr(10240 + int(s)),
end='\n' if (bx - sx_half - 1) % sx == 0 else ''
)
@quartz wave :white_check_mark: Your eval job has completed with return code 0.
001 | ⠀
002 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
003 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣶⣿⣿⣶⠀⣀⣶⣶⣶⣄⠀⣀⣶⣿⣶⣤⣤⣶⠛⠀
004 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣁⣿⣿⣴⠿⠉⠀⠉⠙⠛⠀⠀⠀
005 | ⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣀⣀⣀⣀⣛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀
006 | ⠀⠀⠀⠀⣀⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀
007 | ⠀⠀⠀⣠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
008 | ⠉⠛⠉⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
009 | ⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
010 | ⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
011 | ⠀⠀⠀⠀⠛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/urigaxuyom.txt?noredirect
just ignore the excessive use of math in the deobfuscated code and maybe your brain will work again?
it's probably the math
i'm gonna try to deobfuscate the last part
well you could break up each math expression into its own variable
that'd exceed the discord message limit
Math is used for data compressition
I am sad that my current python doesn't like these Unicodes.
!e
code
!eval <code, ...>
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside of them.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
maybe instead of leaning so much on variable names, categorise variables using dictionaries and dataclasses
formal mathematical notation would consider const1 = 2(y+3.5) to be readable, hooking multiply into integer call
however the "obfuscated" version seems to be the most concise so far
it's the math that's hard to follow.
im too lazy to fix it
I actually had to learn dataclasses to do what I wanted to
but I dont feel like fixing what I dont need to
well yeah but python isn't formal math Lmao
!e
w=__import__("sys").stdout.write
hw=[""]
class bin:
def __getattr__(self,attr):
if len(hw[-1])==8:hw.append("")
hw[-1]+="0"if attr=="_"else"1"
return self
bin=bin()
bin._.__.__._.__._._._._.__.__._._.__._.__._.__.__._.__.__._._._.__.__._.__.__._._._.__.__._.__.__.__.__._._.__._._._._._._.__.__.__._.__.__.__._.__.__._.__.__.__.__._.__.__.__._._.__._._.__.__._.__.__._._._.__.__._._.__._._
while hw:
w(chr(int(hw.pop(0),2)))
@versed eagle :white_check_mark: Your eval job has completed with return code 0.
hello world
binary :D
nice
🔫 goodbye
is that esoteric though
I like it better with print(bin):
class bin:
bits = [""]
def __getattr__(self, attr):
if len(self.bits[-1]) == 8:
self.bits.append("")
self.bits[-1] += str(int(attr != "_"))
return self
def __str__(self):
return "".join(chr(int(b, 2)) for b in self.bits)
bin = bin()
bin._.__.__._.__._._._._.__.__._._.__._.__._.__.__._.__.__._._._.__.__._.__.__._._._.__.__._.__.__.__.__._._.__._._._._._._.__.__.__._.__.__.__._.__.__._.__.__.__.__._.__.__.__._._.__._._.__.__._.__.__._._._.__.__._._.__._._
print(bin)
!e after hearing about TypedDict's weirdness in #python-discussion:
class wat(zip()):"wat"
for w, a, t in wat:
print(w, a, t)
@restive void :white_check_mark: Your eval job has completed with return code 0.
w <zip object at 0x7f4fe9f327c0> __module__
Note how I'm not inheriting from zip, but from a zip instance..
do you have an explanation of what is happening?
could be expanded a bit more but yeah
true
How I understand it: class definition calls type(base), which usually gets the metaclass. In this case it gets zip. Then it treats it as a metaclass.
zip is the only builtin I could think of that can take an arbitrary number of args (as long as they're iterable).
print
Yes, but that's not a class. I can't create a print instance.
Funnily enough one of the arguments (the uninitialized object) is only iterable because it's now a zip object :D
Nope
!e
list(1, 2, 3)
@restive void :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | TypeError: list expected at most 1 argument, got 3
huh
map would also work, but when iterating over it it tries to call the class name..
!e
class wat(map(int, "234")):0
print("works so far")
for whatever in wat:
print(whatever)
@restive void :x: Your eval job has completed with return code 1.
001 | works so far
002 | Traceback (most recent call last):
003 | File "<string>", line 3, in <module>
004 | TypeError: 'str' object is not callable
all the exceptions can
class wat(Exception()):"wat"
for w, a, t in wat:
print(w, a, t)
not iteratable, but it can take any number of args
does this count as esoteric python
n=100000;f='fizz';b='buzz';F=False;print('\n'.join(map(lambda x:[f+b,F,F,f,F,b,f,F,F,f,b,F,f,F,F][x%15]or str(x),range(1,n+1))))
!e
n=100;f='fizz';b='buzz';F=False;print('\n'.join(map(lambda x:[f+b,F,F,f,F,b,f,F,F,f,b,F,f,F,F][x%15]or str(x),range(1,n+1))))
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
003 | fizz
004 | 4
005 | buzz
006 | fizz
007 | 7
008 | 8
009 | fizz
010 | buzz
011 | 11
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/akiwewukax.txt?noredirect
if you cant understand it from a first glance, probably
yes, imo
I think instead of "\n".join you can use an unpack expression with sep="\n"
how would that look
!e
n=100;f='fizz';b='buzz';F=False;print(*map(lambda x:[f+b,F,F,f,F,b,f,F,F,f,b,F,f,F,F][x%15]or str(x),range(1,n+1)),sep="\n")
wut
@versed eagle :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
003 | fizz
004 | 4
005 | buzz
006 | fizz
007 | 7
008 | 8
009 | fizz
010 | buzz
011 | 11
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/qizudufoyu.txt?noredirect
there
yes
print(*[1,2,3]) is the same as print(1,2,3)
yep
idk if it's good practice or not
I was just wondering if it's faster than str.join
lol
whats the best way to test speed
!timeit
n=100;f='fizz';b='buzz';F=False;print(*map(lambda x:[f+b,F,F,f,F,b,f,F,F,f,b,F,f,F,F][x%15]or str(x),range(1,n+1)),sep="\n")
@versed eagle :white_check_mark: Your timeit job has completed with return code 0.
5000 loops, best of 5: 84.4 usec per loop
!timeit
n=100;f='fizz';b='buzz';F=False;print('\n'.join(map(lambda x:[f+b,F,F,f,F,b,f,F,F,f,b,F,f,F,F][x%15]or str(x),range(1,n+1))))
@sick hound :white_check_mark: Your timeit job has completed with return code 0.
5000 loops, best of 5: 43 usec per loop
!timeit
n=100;f='fizz';b='buzz';F=False;print('\n'.join(map(lambda x:[f+b,F,F,f,F,b,f,F,F,f,b,F,f,F,F][x%15]or str(x),range(1,n+1))))
@sick hound :white_check_mark: Your timeit job has completed with return code 0.
5000 loops, best of 5: 45 usec per loop
!timeit
n=100;f='fizz';b='buzz';F=False;print(*map(lambda x:[f+b,F,F,f,F,b,f,F,F,f,b,F,f,F,F][x%15]or str(x),range(1,n+1)),sep="\n")
@sick hound :white_check_mark: Your timeit job has completed with return code 0.
5000 loops, best of 5: 78.7 usec per loop
o.o yours is double as fast as mine
interesting
i suppose usually the most used way of doing something is the most optimised
true
you could also use 2 maps
!e
n=100;f='fizz';b='buzz';F=False;map(print,map(lambda x:[f+b,F,F,f,F,b,f,F,F,f,b,F,f,F,F][x%15]or str(x),range(1,n+1)))
@versed eagle :warning: Your eval job has completed with return code 0.
[No output]
that should work
I might have done that wrong
the outer map didn't call print because of lazy evaluation
...
hence why people tend to use list(map(...))
!e
n=100;f='fizz';b='buzz';F=False;list(map(print,map(lambda x:[f+b,F,F,f,F,b,f,F,F,f,b,F,f,F,F][x%15]or str(x),range(1,n+1))))
exec("".join(map(chr, __import__('zlib').decompress(b'x\x9cM\x8e\xc1\x0e\xc2 \x10D\xef|\xc5\xa6\'H\x9a\x06\xdaj\xab\xa7\xfe\x871\x1b,4\xd6Pl\x00\xff_\xa8Z\xd9\xc3df\xden\xb2dX\xddl\x03\x19\x8c\\nJ\x02\x9e\xa1(\xaa\xc7s\xb6t\x91+\x1d\xef\xae\x04d,\xe7X!*md\x08\x0e\x91rFF#\xbd\x8f\x84@\x1c\xa5\'\xc8\xb9\xd7fb\x1f\x94\xc6\xe9\xf0r\x16.]_\x82\xe0"\x8a\xf8\xbb\xb6\x84\xa6N\xa9Ii\xab\xf8WN]\xce\xf8!?\xdc\xfaZ\xec7\xbf\xd5d\x84\x88\xae=^\xf7\x07\xde\xfe\x0b9V'))))
!timeit
n=100;f='fizz';b='buzz';F=False;list(map(print,map(lambda x:[f+b,F,F,f,F,b,f,F,F,f,b,F,f,F,F][x%15]or str(x),range(1,n+1))))
since when did the button appear
@sick hound :white_check_mark: Your timeit job has completed with return code 0.
2000 loops, best of 5: 98.1 usec per loop
damn
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
003 | fizz
004 | 4
005 | buzz
006 | fizz
007 | 7
008 | 8
009 | fizz
010 | buzz
011 | 11
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/eqonorepuf.txt?noredirect
run in 3.11????
!timeit
n=100;f='fizz';b='buzz';F=False;list(map(print,map(lambda x:[f+b,F,F,f,F,b,f,F,F,f,b,F,f,F,F][x%15]or str(x),range(1,n+1))))
!e
code
!eval [python_version] <code, ...>
Can also use: e
*Run Python code and get the results.
This command supports multiple lines of code, including code wrapped inside a formatted code block. Code can be re-evaluated by editing the original message within 10 seconds and clicking the reaction that subsequently appears.
If multiple codeblocks are in a message, all of them will be joined and evaluated, ignoring the text outside of them.
By default your code is run on Python's 3.11 beta release, to assist with testing. If you run into issues related to this Python version, you can request the bot to use Python 3.10 by specifying the python_version arg and setting it to 3.10.
We've done our best to make this sandboxed, but do let us know if you manage to find an issue with it!*
o_O
!e ```py
from typing import TypeVar
T = TypeVar("T")
a = list[*T]
print(a)
hey it wokrs
@quartz wave :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 3, in <module>
003 | TypeError: Value after * must be an iterable, not TypeVar
was that a 3.10 bug?
ok wait
!e
a = list[*list]
print(a)
@versed eagle :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | TypeError: Value after * must be an iterable, not type
!e
a = list[*list()]
print(a)
@versed eagle :white_check_mark: Your eval job has completed with return code 0.
list[()]
huh
star expressions in subscripts are only in 3.11
wait we can finally use atomic grouping and possessive matching
this sounds very advanced
?
im sure my future self will be very happy about this
!e ```py
import re
a = re.match("a++a", "aaaaaaaaaaaaaaa") # no match
b = re.match("a+a", "aaaaaaaaaaaaaaa") # yes match
print(a, b)
@quartz wave :white_check_mark: Your eval job has completed with return code 0.
None <re.Match object; span=(0, 15), match='aaaaaaaaaaaaaaa'>
that and you need to use TypeVarTuple
!e ```py
c = """
from dis import dis;dis("a()")
"""
exec(c)
import subprocess
subprocess.run(f"python3.10 -c '{c}'")
@quartz wave :x: Your eval job has completed with return code 1.
001 | 0 0 RESUME 0
002 |
003 | 1 2 PUSH_NULL
004 | 4 LOAD_NAME 0 (a)
005 | 6 PRECALL 0
006 | 10 CALL 0
007 | 20 RETURN_VALUE
008 | Traceback (most recent call last):
009 | File "<string>", line 6, in <module>
010 | File "/usr/local/lib/python3.11/subprocess.py", line 535, in run
011 | with Popen(*popenargs, **kwargs) as process:
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/zusorahoye.txt?noredirect
ok
exec("".join(map(chr, __import__('zlib').decompress(b'x\x9cM\x8e\xc1\x0e\xc2 \x10D\xef|\xc5\xa6\'H\x9a\x06\xdaj\xab\xa7\xfe\x871\x1b,4\xd6Pl\x00\xff_\xa8Z\xd9\xc3df\xden\xb2dX\xddl\x03\x19\x8c\\nJ\x02\x9e\xa1(\xaa\xc7s\xb6t\x91+\x1d\xef\xae\x04d,\xe7X!*md\x08\x0e\x91rFF#\xbd\x8f\x84@\x1c\xa5\'\xc8\xb9\xd7fb\x1f\x94\xc6\xe9\xf0r\x16.]_\x82\xe0"\x8a\xf8\xbb\xb6\x84\xa6N\xa9Ii\xab\xf8WN]\xce\xf8!?\xdc\xfaZ\xec7\xbf\xd5d\x84\x88\xae=^\xf7\x07\xde\xfe\x0b9V'))))```
🔫 run directly
even if you don't, it's going to be win for me anyway
hmm ```py
print("".join(map(chr, import('zlib').decompress(b'x\x9cM\x8e\xc1\x0e\xc2 \x10D\xef|\xc5\xa6'H\x9a\x06\xdaj\xab\xa7\xfe\x871\x1b,4\xd6Pl\x00\xff_\xa8Z\xd9\xc3df\xden\xb2dX\xddl\x03\x19\x8c\nJ\x02\x9e\xa1(\xaa\xc7s\xb6t\x91+\x1d\xef\xae\x04d,\xe7X!*md\x08\x0e\x91rFF#\xbd\x8f\x84@\x1c\xa5'\xc8\xb9\xd7fb\x1f\x94\xc6\xe9\xf0r\x16.]_\x82\xe0"\x8a\xf8\xbb\xb6\x84\xa6N\xa9Ii\xab\xf8WN]\xce\xf8!?\xdc\xfaZ\xec7\xbf\xd5d\x84\x88\xae=^\xf7\x07\xde\xfe\x0b9V'))))
@print
@lambda _: "".join(map(chr, _))
@lambda _: _.delattr(0)
class _:
def delattr(self):
return [78, 101, 118, 101, 114, 32, 103, 111, 110, 110, 97, 32, 103, 105, 118, 101, 32, 121, 111, 117, 32, 117, 112, 46]
chr(78)
'N'
chr(101)
'e'
i don't trust the first two letters
gonna torture it first
where's the torturing device
!e ```py
from ctypes import c_char
def torture(victim):
l = len(victim)
type_base = (c_char8).from_address(id(victim)+8)
odata = (c_charl).from_address(id(victim)+48)
type_base.value = bytes((c_char8).from_address(id(0)+8))
a = victim + 1
odata.value = bytes((c_charl).from_address(id(a)+48))
type_base.value = bytes((c_char*8).from_address(id('')+8))
victim = "".join(map(chr, import('zlib').decompress(b'x\x9cM\x8e\xc1\x0e\xc2 \x10D\xef|\xc5\xa6'H\x9a\x06\xdaj\xab\xa7\xfe\x871\x1b,4\xd6Pl\x00\xff_\xa8Z\xd9\xc3df\xden\xb2dX\xddl\x03\x19\x8c\nJ\x02\x9e\xa1(\xaa\xc7s\xb6t\x91+\x1d\xef\xae\x04d,\xe7X!*md\x08\x0e\x91rFF#\xbd\x8f\x84@\x1c\xa5'\xc8\xb9\xd7fb\x1f\x94\xc6\xe9\xf0r\x16.]_\x82\xe0"\x8a\xf8\xbb\xb6\x84\xa6N\xa9Ii\xab\xf8WN]\xce\xf8!?\xdc\xfaZ\xec7\xbf\xd5d\x84\x88\xae=^\xf7\x07\xde\xfe\x0b9V')))
torture(victim)
print(victim)
@quartz wave :white_check_mark: Your eval job has completed with return code 0.
001 |
002 | @p2jnt
003 | @la-cda _: "".j/jn(-bp(#ir, _))
004 | @la-cda _: /__$fla4ur_)0)
005 | cla3t _:
006 | de&!__$fla4ur_)se,g):
007 | ret5sn 88, 101, 118, 101, 114, 32, 103, 111, 110, 110, 97, 32, 103, 105, 118, 101, 32, 121, 111, 117, 32, 117, 112, 46
much better
.... huh?
it already follows set notation.
A bit of algebra can't hurt
What's confusing?
!e ```py
from ctypes import*
def mutate(victim):
a = c_longlong.from_address(id(victim)+48)
a.value += 69
string = "Hello, World!"
mutate(string)
print(string.encode())
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
b'\x8dello, World!'
!e ```py
from ctypes import*
def mutate(victim):
a = c_longlong.from_address(id(victim)+52)
a.value += 65
a.value %= 128
string = "Hello, World!"
mutate(string)
print(string)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hell0�������!
I have murdered an immortal entity
this is how I get the error
from ctypes import*
def memoryerror(s):
a = (c_longlong*(len(s)//8+1)).from_address(id(s)+32)
for n in range(len(s)//8+1):
a[n]=-a[n]*2-1
s = "this is a victim"
try:memoryerror(s);print(s)
except MemoryError:s = "this is a victim"
u caused a memory bug in python :0
I caught a memory error then used it to kill an immortal interned string
!e ```py
from ctypes import*
def to_bytes(s):
t,l = c_longlong.from_address(id(s)+8),len(s)
t.value=id(bytes)
(c_longlong*(l//8+1)).from_address(id(s)+32)[:] = (c_longlong*(l//8+1)).from_address(id(s)+48)
s = "this must be bytes."
to_bytes(s)
print(s)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
b'this must be bytes.'
like str.encode() only it actually turns the str into bytes instead of making bytes from a str
!e what if f-strings just made f-strings? ```py
from fishhook import hook
from ctypes import*
class fstr(str):
def repr(self):
return 'f'+str.repr(self)
def str(self):
return self.repr()
@hook(str)
def format(self, *args):
return fstr(self)
print('Hello,{:>7s}'.format("World!"))
3.11?
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
f'Hello,{:>7s}'
Nice. Faster than .encode() as well, surely, at least with long strings.
It's basically doing .encode("native-encoding"), if that existed.
I tried to implement factorial assign for int but it broke
for !=
hi
Lmao I got a random bsod while typing
I'm up to the debugging stage of my next masterpiece
here's what I have so far
from ctypes import*
class output:
def __init__(self, victim):
self.victim=id(victim);ol = len(victim)
(c_char*ol).from_address(id(victim)+48)[:]=[0]*ol
c_longlong.from_address(id(victim)+16).value=0
self.backup = [0]*ol, ol
def __lt__(self, item):
_l = c_longlong.from_address(self.victim+16)
_l.value += 1
_a = c_byte.from_address(self.victim+48+_l.value)
self.backup[0].append(_a.value);_a.value=-item;return 0;
def __del__(self):
v, i = self.backup
c_longlong.from_address(self.victim+16).value = i
(c_byte*len(v)).from_address(self.victim+48)[:]=v
__neg__=lambda s:s
def __gt__(self, a):
a, i = a
_l = c_longlong.from_address(self.victim+16).value
data = (c_byte*_l).from_address(self.victim+48)
v, *data = *data, 0; _l.value -= 1;a[i] = v;return 0;
class array:
def __init__(self, victim):
self.memory = "\0\0\0\0\0\0\0\0"[:]*256
_ = self._memory = id(self.memory)
c_longlong.from_address(_+16).value=256*8-1
self.i=0; self.o = output(victim)
@property
def mem(self):return(c_byte*(256*8-1)).from_address(self._memory+48);
def inc(self):self.mem[self.i]+=1;return 0;
def dec(self):self.mem[self.i]-=1;return 0;
def left(self):self.i-=1;return 0;
def rite(self):self.i+=1;return 0;
def dot(self):return self.o <- self.mem[self.i];
def com(self):return(self.mem, self.i) <- self.o;
def loop(self):return+(not self.mem[self.i]);
def end(self): return-bool(self.mem[self.i]);
def __iter__(self):return iter([*self.mem])
def run(self, c):
p=t=0
while 0<=p<len(c):
if t:t+=(c[p]=='[')-(c[p]==']')
else:t={
'+':self.inc,'-':self.dec,'<':self.left,'>':self.rite,
'.':self.dot,',':self.com,'[':self.loop,']':self.end
}.get(c[p],lambda:0)()
p+=1-2*(t<0)
def brainfuck(victim):
a = array(victim)
clone = victim+'\0'
c_longlong.from_address(id(clone)+16).value -= 1
a.run(clone)
return a.o
code = "+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++."
o = brainfuck(code)
print(code)
del o
ooh
!e ```py
from fishhook import hook
hook(str,'neg')(lambda s:s)
@str.neg
@type.call
class stdout:lt = print
stdout <- "Hello, World!"
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
Hello, World!
!e print(1723+1)
the mind struggles to understand this concept
is probably a better place
lmao
!e ```py
from ctypes import*
from fishhook import hook
class Pop:
def init(self, array):
self.array = array
def gt(self, o):
import sys
x = self.array.pop(0)
l = sys.getsizeof(x)-8
(c_bytel).from_address(id(o)+8)[:] = (c_bytel).from_address(id(x)+8)
return self.array
hook(list, 'neg')(lambda s:Pop(s))
a = [6, 9]
(b:="this") <- ((c:="that") <- a)
print(b+10*c, a)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
69 []
I could probably make it look better
Eh
@sick hound :white_check_mark: Your eval job has completed with return code 0.
Hello World!
!pypi fishhook
if you're going to be making new operators by changing existing ones, can you make ++i and --i into inc/dec operators?
instead of pos/neg
import fishhook
@fishhook.hook(int)
def __neg__(self):
self -= 0.5
return self
then do the same for float, so that with two - operators, it subtracts 1 in total?
then same with + operator and it would work, right?
or am I doing it wrong
probably am Lmao
ah
-stdout> str(a)?
was in the last one
ooh bitshift
what kind of black magic was that
:)
!e ```py
from ctypes import*
from fishhook import hook
class Pop:
def init(self, array):
self.array = array
def gt(self, o):
import sys
x = self.array.pop(0)
l = sys.getsizeof(x)-8
(c_bytel).from_address(id(o)+8)[:] = (c_bytel).from_address(id(x)+8)
return self.array
hook(list, 'neg')(lambda s:Pop(s))
@type.call
class Int:
def getattribute(self, item):
globals()[item] = type(item,(str,),builtins.dict)()
return self
def setattr(self, item, value):
globals()[item] = value
Array,nl = Int,'\n'
hook(str,'neg')(lambda s:s)
@type.call
class stdout:
def lshift(self, other):
print(end=str(other))
return self
def neg(self):return self
def gt(self, other):print(end=str(other))
Array .a = [6, 9];
Int .b .c;
b <- a;
c <- a;
stdout << 10*b+c << nl;
stdout << str(a);
stdout << nl;
@floral meteor :x: Your eval job has completed with return code 139 (SIGSEGV).
001 | 69
002 | []
there, now im definitely keeping it that way
I'm not even gonna bother cleaning up the memory to finish without crashing
lmao
It doesn't look anything like python anymore at the end
reminds me of std::cout << "hello world";
the type declaration allocates memory for an object and places a sentinal object for the memory in globals.
the left arrow operator pops the first item from the list then overwrites the memory of the variable
left shift just sends an item to stdout
so b was some useless large object, but then after b <- a it became an integer, 6
I wrote it and even I think it looks like black magic.
interesting
an Array/Int assigns on _getattribute_
b <- a actually comes from the R programming language
oh that's big
except it doesn't pop, it just assigns
builtins dict
yeah it's crude, but if it isn't a massive object it segfaults too early
ah
in R, a <- b is the same as a = b
huh
however in my script I use that operator to pop an item off a list
oh I think the line that makes that might be redundant due to a previous versionn
I could probably write a script that implements actual string negativving
in pop.gt, you import sys but only use it once?
you could use _import_("sys").
instead of
import sys
sys.
I guess it's more of a style preference than anything else
if it's not being used more than once, I like to use _import_ instead
ooh
it's wrong lol
ah
or is it?
!e ```py
from fishhook import hook
from ctypes import*
@hook(str)
def neg(self):
l = len(self)
a = (c_byte*l).from_address(id(self)+48)
for i, x in enumerate(a):
a[i] = 255-x
return self
s = "Hello, World!"
-s
print(repr(s))
-s
print(s)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | '·\x9a\x93\x93\x90Óߨ\x90\x8d\x93\x9bÞ'
002 | Hello, World!
when I try it the other way, it has different encoding for some reason.
!e ```py
from fishhook import hook
from ctypes import*
@hook(str)
def neg(self):
l = len(self)
a = (c_byte*l).from_address(id(self)+48)
for i, x in enumerate(a):
a[i] = 255-x
return self
s = '·\x9a\x93\x93\x90Óߨ\x90\x8d\x93\x9bÞ'
-s
try:print(s)
except:print(repr(s))
@floral meteor :x: Your eval job has completed with return code 139 (SIGSEGV).
'·\x9a\x93\x93\x90Óߨ\x90\x8d\x93\x9bÞ'
see, it no worky
Can use <- and = in R, right?
and ->
How work ->?
same way, but backwards
!e ```py
from fishhook import hook
from ctypes import*
@hook(str)
def neg(self):
l = len(self)
a = (c_bytel).from_address(id(self)+48)
_a = map(ord,self),
dummy = "dummy"
(c_longlong2).from_address(id(self)+24)[:]=(c_longlong2).from_address(id(dummy)+24)
for i, _ in enumerate(a):
a[i] = 255-_a[i]
return self
s = '·\x9a\x93\x93\x90Óߨ\x90\x8d\x93\x9bÞ'
-s
try:print(s)
except:print(repr(s))
@floral meteor :x: Your eval job has completed with return code 139 (SIGSEGV).
Hello, World!
encryption, where encryption and decryption are the same operationn
Lmfao
I mean, that's most stream ciphers
!e ```py
from fishhook import hook
from ctypes import*
@hook(str)
def neg(self):
l = len(self)
a = (c_bytel).from_address(id(self)+48)
_a = map(ord,self),
dummy = "dummy"
(c_longlong2).from_address(id(self)+24)[:]=(c_longlong2).from_address(id(dummy)+24)
for i, _ in enumerate(a):
a[i] = 255-_a[i]
return self
s = "¨·ºº"
print(c_long.from_address(id(s)+72).value)
-s
print(c_long.from_address(id(s)+48).value)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | 3132798888
002 | 1162168407
3.9 disagrees
is this a 32/64 difference or nah
huh
Lib/types.py line 131
"""Calculate the most derived metaclass."""```
can you read from the mem address as if it's a function?
if you can, try to call it?
I'm assuming this line
wait no, the one two lines above that
I think I'm wrong, it takes c_long
but reference is c_longlong
PYFUNCTYPE results in access violation reading the memory at the function object
I thought it'd be good to share this here too,
https://gist.github.com/dzshn/72cd5e81e7fc500f397cf5b029b16199
is that the quake algorithm?
I think i recognize the comments :p
exactly lol, using the same undefined behaviour
i put a version of it into my C extension and it's faster than .encode() with no arguments
also it's not faster than .encode()
i tested with a string repeated a million times
!timeit ```py
from ctypes import c_longlong
def to_bytes(s):
t,l = c_longlong.from_address(id(s)+8),len(s)
t.value=id(bytes)
(c_longlong*(l//8+1)).from_address(id(s)+32)[:] = (c_longlong*(l//8+1)).from_address(id(s)+48)
```py
("abc"*1000000).encode()
@quartz wave :white_check_mark: Your timeit job has completed with return code 0.
100 loops, best of 5: 3.13 msec per loop
!timeit ```py
from ctypes import c_longlong
def to_bytes(s):
t,l = c_longlong.from_address(id(s)+8),len(s)
t.value=id(bytes)
(c_longlong*(l//8+1)).from_address(id(s)+32)[:] = (c_longlong*(l//8+1)).from_address(id(s)+48)
```py
to_bytes("abc"*1000000)
@quartz wave :white_check_mark: Your timeit job has completed with return code 0.
5 loops, best of 5: 70.7 msec per loop
That's the last line in your function. Why is that necessary? Why can't you just change the type?
Oh, there's additional info stored before the data in a string (PyUnicode_Kind?), but not in bytes?
yes
No longer really in-place, but you could also shift the header by 16 bytes and return the object with the new location of id(old) + 16.
But old references will be broken..
btw my C extension to_bytes returns not in-place
can someone help
[0CA4:0C80][2022-07-18T03:10:11]i372: Session end, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{c60fd5ac-367d-4e3a-a975-f157502ac30a}, resume: None, restart: None, disable resume: No
[0CA4:0C80][2022-07-18T03:10:11]i330: Removed bundle dependency provider: CPython-3.10
[0CA4:0C80][2022-07-18T03:10:11]i352: Removing cached bundle: {c60fd5ac-367d-4e3a-a975-f157502ac30a}, from path: C:\Users\Moxy\AppData\Local\Package Cache{c60fd5ac-367d-4e3a-a975-f157502ac30a}
[0CA4:0C80][2022-07-18T03:10:11]i371: Updating session, registration key: SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall{c60fd5ac-367d-4e3a-a975-f157502ac30a}, resume: None, restart initiated: No, disable resume: No
[0CA4:0C80][2022-07-18T03:10:12]i399: Apply complete, result: 0x80070642, restart: None, ba requested restart: No
wtf does this mean
yes wtf does that mean
well wtf are you doing here we're supposed to worsen python not fix it
Ask in a help channel, not here
which
anything in the available help channels
ok
this is the last place you want to ask for help 👀
Yea it will only get worse when you accept help from here
where's the f part 
@sick hound :warning: Your eval job has completed with return code 0.
[No output]
!e just use ctypes
printf = __import__("ctypes").cdll.LoadLibrary("libc.so.6").printf
printf(b"Hello %s\n", b"World")
@restive void :white_check_mark: Your eval job has completed with return code 0.
Hello World
you could also just use str _mod_
!e
printf=(lambda s,*f:__import__("sys").stdout.write(s%f))
printf("hello %s", "world");
@versed eagle :white_check_mark: Your eval job has completed with return code 0.
hello world
What are the extra brackets for?
ah
I don't like them in general, but for some reason i like them around lambdas
you should try programming in lisp someday
lisp has too many nested parentheses
how tf did u generate this code
!e
print("".join(map(chr, import('zlib').decompress(bytes.fromhex(''.join(f'{ord(c)-0x100:02x}' for c in 'ŸƜōƎǁĎǂĠĐńǯżDžƦħňƚĆǚŪƫƧǾƇıěĬĴǖŐŬĀǿşƨŚǙǃŤŦǞŮƲŤŘǝŬăęƌŜŮŊĂƞơĨƪLJųƶŴƑīĝǯƮĄŤĬǧŘġĪŭŤĈĎƑŲņņģƽƏƄŀĜƥħLjƹǗŦŢğƔdžǩǰŲĖĮŝşƂǠĢƊǸƻƶƄƦŎƩʼnũƫǸŗŎŝǎǸġĿǜǺŚǬķƿǕŤƄƈƮĽŞǷćǞǾċĹŖ'))))))
@unreal echo :white_check_mark: Your eval job has completed with return code 0.
001 |
002 | @print
003 | @lambda _: "".join(map(chr, _))
004 | @lambda _: _.__delattr__(0)
005 | class _:
006 | def __delattr__(self):
007 | return [78, 101, 118, 101, 114, 32, 103, 111, 110, 110, 97, 32, 103, 105, 118, 101, 32, 121, 111, 117, 32, 117, 112, 46]
008 |
!e
import zlib
ts="ŸƜǭŚśųǛƸĕžǗƯǀƨďĢƷƌŦƝŎşǔűƧƮǭǝǵĦǎƦƶǛŌƫŪĸưĈŊňňłċƐűƴęǿǷƞăǰĂǰĢřƶƳƳƝƍğĒđļķƜNjŷĎĠDZŴģŤŎDzǭƆŧƫőĬŅŊĢƚǓťłƕŢƊŰdzƺŞĚƕċƒŦƑňƫƧĢǣŹǎŔŞĽdzƜljŜƈńęƁĠƼđŵʼnķƨǪƭĔƟƶķǰƢĦƁDžƊǦĤǛĆǤǤƎDzƜǞĦĬĠƧĴʼnnjƧijƾnjăDzƚƃĮǍŗũƞƦŢǹơŦŗǛŬŹĉċƕĽŷŔŦĠŞƍƪďǓƘħŠţǵǨƍǹĪēƒƍăƲƤĹśĉƹĽľţěljǠƉƋǬƝġdzljŨǴƷǚēĞǨǿƅťLJķƲŠǾňįƑīǶųādžnjņĄǾǔŒŬǘƬǜǙƴǜǶŜǥIJƨǖŠƛċōĊƊĘǿǘĐŗǻƝǏėčűǥƎƹƸŽǏƖǹǂưĪƖŅĽżĥōďǷěƑıǠƭĭŖĹĭĠƚǹĥǍǨƊʼnţŻDŽŢĒƆĜƜěƆƞŢʼnǬƛŵƣıƉƧǀĕLJǤƘżƾǗǫĔĽŞŲĭǁƈƒīƀƝęƏŔƮƱǤưŏŬǩǕŏǸėŏŬĹǬƓīǃƟƑĉǹƣǃİƙŌǟċƞŹDZǤƿęǹƜǜŏňĬĤʼnĈǏňƜōǕĦǡƹćƯĦƾşƳĵƟĤNjċƙđƊƞġƉĀƳƕǧǏħƨŸƲŨƩĞƍƮůŎƾǻĮƼĸƻƆōěƫLJǯǓNjǿżƸǾǾşſƿĽĽśƽźŵŹŹǽǦǭĵƤǐǸćǶĺǹǩƝƸŊǎƎŞǾĉėǸƫŌǜǝƬũǾůőƜňŶDžŨĄŁƹřųĵĎƌƬƷǛƛğńŶŶāʼnģǏŎDžǙǹƏĴǕƜǯŎƮǗŌƲŷŗėķėůƾǏƑťǤƏƮǟƞƟŞƜƼƆƵųNjƠčƅưĠŗNJŨƎǿſŤīƦƣƮǰĩēǙƋŘƈĈĿŇČNJśĂđĈěřŞįijǑdzljƋƿĒŌƕęƙŎƧĶąĦƜėǎƈljưĖŝƙŕŘİŐǛǢŤƹĄĽŞĄŅǫǛƉąŖāńƤŵƖżŠśīıŸƌċǤǸƘƌǕƆĭĹōDzǭŸǦĄŞŒƮĘƹĪƲƜƧǬŜŊġǝŌǒǮĀŧƓƔŮljĭģƅłŴljǗƌǜʼnāƟŀŮƒǠĒǦNjƤǔǂdzǭŤǜĕdzėŲăżĐėǰōƮĭNjŨNJĈŗĎţŀIJƑǗīưİŵŅŵDzŎĕěĦĽſŪŻăǽİƪǽĄǫƍſĂŜƢŅƒğƣƷſƷǞłƟǘǞĀŷơƫƖĒIJƞƅťƹĶƻīıĘƻƆŁŞƄǜǀĒŞǢƮăƸŝƤƅĒƫĪģưŰĐƑƷćŲěžǔƦƙƑŶƤūDžũđǥǦNJĵƯǝĚƽŖĝǩǝǸžŐǙĝŨěŊėǜʼnƺƩƌČƱěźļƂIJǕƻdžLJřǓĖƵġŻƶļūǡƺăČƆŨǖďƥƕŮǟǞŢljŮƙƊƦğŦǧƐƃǛƦŪƄĂŢćƣƀŲƏƽāƒĻņǫƨƕƐǶƏĂIJķǦŌǞŀƤŎƩŢŞĽźŜĨƑŀǶŅǚŮĮĪĂċDZĔNjǿƹıŽƴdžŋƷƟƦƦǻłƮŴĺƲǧǗŲľIJljǣŭƨƛůƈƨǚǛƛƩƆŶƜŋƼĵŕĴǏƥŧǫĀǴǗĂdžƐňƩŚĝƏěƍƤIJăǸƠłƉǩDzĨƁǟĖĹěķťřǵſśưęĊņĵǍğĈŶĸĬŽŅţņǨƊDzŌǁĬljǣĘĺĚŨśċDZŁāǎŐƘĘĕƾƣǙĒijČƴǷǭǨłŹĸʼnźŚčĘğǩřŐůšƢǗĦƍƩƨĕġƆŪĪƘǡƨǜŚǦģƐũĘǹňƓƂǡƼƠąŌđƇšĊŰǡƳLJĄĄǪƠnjřǔſƭǝǑƨǒǀŗƛĀŴŐǖƖǺāƩǚĘƐśǢǁƐǬǒǦŊźʼnčǢǫƙŮądzƱǔƣīĦƣDzĺljūǥĦƦŰŘņŰşŦŵdzǏůǕƞƖŦǞŋNjƌƶĴĨķňƞźƦƚſƻŨţƲǁĶĠƪǑǀăǏŘďƝŔŬǵƀǏţǴǩŸŖŦǻŔŤőāƝđŧƪĈŖŵǁƏƛƖĄŋųŻƪĂƓĖǷĝƤƭŴĚǤưƓƿnjNJƇǹƫĕǿdzƟġľŞǂIJƯśŎưǩƣIJđǞŀƸųƫƹǒŔŀŋħĢĮŝŠĜĎƥĕƍŻǕŜŤĆǦƺŊƜŌǃƬŪńƑĻƞƯĝƵėŧǽǢǍĮƺĹǮŨƚƃąƋǀĘĜĸƴƖąťĈƵĥĪėŨąǠőƻĂƚƉǁůħŏũőĈĂǴűƄŅƎǣƳŨħŁĥńIJǀŭǓƢŚǜƽůźŲŢşŊdžűĻħĻĩǷƔƌǪċǴǧǻƞŠƧǢģǺĸƆƈƓƕǀʼnďŌŻơŭīǧǑŖƅƧİźDZōǂĆŋƽƧǍġǥŌğǝǧĥŤǡŨĴşĸƠŬĒƴƮŊńǦşǸdžƫƑĢĠŶƑƶƀǺŠǨİŌĦǙƞăŀƚƧĝǘőĻţĊǣĞƎĪǵġǓƦǨljƦĎǝŐņŠǫĽǏŔġơŋǤƺǿǦļʼnƜŞƨƝƍŕĝƋĤđŷĘŲƓĹǰƺƷǹǮǁĨżőćljƷĀċƊƫƄƧĻƀƓžƌƪăşDžƢěŵƣLJčƷņĦųěőǜŢŧijĘĜDzǨĘLJŏƗƸƵƝƽŘŸǕĠƠƙĭĔĀƟĮƗĘŐķłēŻħƋăƊƱDŽłǙǓǭğƈƀŝƵĥǣǴġŀǘǦǙċƌƿŖƜǚƛǨƅǛŞǫŷŒľğŀĻǦąƎĉşĎưǝŪǚăǚŦĒļţĉŇăƲǕǮĹưƅǮūƚŅƀǭNjĂŒįťŲĈǑǛŃǜƋƣĆNjƗĢƅǶĀƮĕIJǂģćĄĆŚĆƐƛģęĂŲǵũǟĠǧDŽDZƩœĝǘĈǐǬƈŬĚƃĹǶƅƺƶƎƍDžăƍǣƐʼnŐŻǠǁǛǒǔǣǶĦǚŻŸǘĖǜĠļŦīƆǑǝŊěśĴěƋłơďůŮĴĝŌƱĉŃĄąƯťŠƋǷšźƌōƻǵƔƱżǦőǍǯĽǼƔDžœŏňŕĕƩǡdzſƖdzƌĥĊƧġƯśğƾdžǝĐǁĖǎǨīǦƹƽǖşƸŮċƛƱŃĿĞźƌƚĻƙƵīũǝDŽŽǜƐǔđǘŻƍĕƸśƃĝŴƯƐǬǽƺǘǯľĽŬNJƔČŰœŁǷųdžǍņƒĻƵŚǽǐƌƹćƏŲĺƋǕľǷǯƃƉǦǡľĘƌŸǗĝƮħǬĝďǬƷĄŵįĮƒDŽŅŸƿDzƥǙŐǐŤŷƫǏƻŐŢǃĖĸơƑǛƝƚǃāĞƣſƟǣśŀǓňĝĂƐǖĜƱǻƼƋſźńŮńǪůǃƨŜƩĩǾăƑŸǙǍŹūǰǓǕƚƲżĭĢųƽţŌıijŔǷǠďIJƋĔļƬƆƮǏƛčŲńƁŁǃǬěƘǽŎıƨŚljčƬŸǵũǞƁǣƮĠſŇƆČIJǷıĝǖčǺŒūŠƌƴǜǒŋdzĨİĸưǵǔǓĦžěİLJƵąƶƢƾŞƤƽđĶǥĝƦĴşƮŷƞǐġČNJǂņǎĐƔĒĸĊĹLJĻƳŠŃţųŻƢſęİŕǫĢƎēŖLJŖčœŘƺŚǭǨƩƽǬƳǣźǽĽǃǯƪơčńƴǡƿǟƙƹœƍƭƝǻǰǃǺǙǣśƘǟǓƜƜDŽǼƆĜŽǛǓƘƐǎǨǟūǷƓǛǁţƠǕƹƅǨǤŋƉŠƦƸĭǗŔƷƦdzŊǧƢƗƨƿƹǼƤǽŢƹĒŻƋĆƃƪƷŘǯƪċǥǽĽǥİĠżŸĺĽďĢŪǡĮĠĖęnjŵřćėƿĄĢǎŧįėşőDZķƎƊǵďǕƦNjǭƲǭǵşĕĦƟũǬǟķǜśěŞœƞŹǟĴċƒŭŀƫǣƂƀǼŹǰnjdzĕŪƿłǭĮƨŭƾĢƲĒŪLJŕĢļćǸſžħǰĴŗƢġDžċĢǻŠǾDzĹǁĐƕľǹǂőěƾǷƛŤǷņƼďǽƴƜĖĀŶƹĜİƴŘŜļǜſĿƉƼŭůĘǗĿǍěĠţǧǥǥǑǬŁǎǐŢĎųƆDžŲưijƀǷķčNJƶċǿǟŁƙLJǃǀƋĿţŬǕǎǎƯDZNJƯōǪƋƈĺƵŭƀĊǶādzİĬƻƻťƉŢƏİćƒǫƋƘijǔĘņǍƏǢıƛŒđĕĉĻĎŃǼġŦĘǺǿăDZƻǧĨ"
fn="if(h:=self.staff,r:=request,p:=r.scope,x:=h.update({p['id']:r})if len(p)>2 else h.pop(p['id'])if'id'in p else[k for k in h.values()if p[s:=[*p][1]]in k.scope[s]][0])[3]:await x.send(await r.receive()),await r.send(await x.receive())"
print(f'{len(fn)=}')
exec(zlib.decompress(bytes.fromhex(''.join(f'{ord(i)-0x100:02x}' for i in ts))))
@dry mirage :white_check_mark: Your eval job has completed with return code 0.
001 | len(fn)=232
002 | ........
003 | ----------------------------------------------------------------------
004 | Ran 8 tests in 0.147s
005 |
006 | OK
What is all of this… thought I knew python… I know this is the esoteric channel after all, but Jesus, this makes brainfuck look understandable 😂
You want me to make brainfuck look confusing again?
!e ```py
from ctypes import*
class output:
def init(self, victim):
self.victim=id(victim);ol = len(victim)
(c_char*ol).from_address(id(victim)+48)[:]=[0]ol
c_longlong.from_address(id(victim)+16).value=0
self.backup = [0]ol, ol
def lt(self, item):
_l = c_longlong.from_address(self.victim+16)
_l.value += 1
_a = c_byte.from_address(self.victim+48+_l.value)
self.backup[0].append(_a.value);_a.value=-item;return 0;
def del(self):
v, i = self.backup
c_longlong.from_address(self.victim+16).value = i
(c_bytelen(v)).from_address(self.victim+48)[:]=v
neg=lambda s:s
def gt(self, a):
a, i = a
_l = c_longlong.from_address(self.victim+16).value
data = (c_byte_l).from_address(self.victim+48)
v, *data[:] = *data, 0; _l.value -= 1;a[i] = v;return 0;
class array:
def init(self, victim):
self.memory = "\0\0\0\0\0\0\0\0"[:]256
_ = self.memory = id(self.memory)
c_longlong.from_address(+16).value=2568-1
self.i=0; self.o = output(victim)
@property
def mem(self):return(c_byte*(256*8-1)).from_address(self._memory+48);
def inc(self):self.mem[self.i]+=1;return 0;
def dec(self):self.mem[self.i]-=1;return 0;
def left(self):self.i-=1;return 0;
def rite(self):self.i+=1;return 0;
def dot(self):return self.o <- self.mem[self.i];
def com(self):return(self.mem, self.i) <- self.o;
def loop(self):return+(not self.mem[self.i]);
def end(self): return-bool(self.mem[self.i]);
def iter(self):return iter([self.mem])
def run(self, c):
p=t=0
while 0<=p<len(c):
if t:t+=(c[p]=='[')-(c[p]==']')
else:t={
'+':self.inc,'-':self.dec,'<':self.left,'>':self.rite,
'.':self.dot,',':self.com,'[':self.loop,']':self.end
}.get(c[p],lambda:0)()
p+=1-2(t<0)
def brainfuck(victim):
clone = victim+'.'
a = array(victim)
a.run(clone)
return a.o
code = "++++++++++[>++++++++++<-]>++++.---.+++++++..+++."
__ = brainfuck(code)
print(code.strip('\0'))
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
hello
There's a few issues I sort of cut corners to fix
but it brainfucks
using "actual" memory
what the fuck
and there's a bonus left arrow operator <-
it's just the operator that made the most sense for the task I had in mind
and I piggybacked cleanup on deletion of __ so that it doesn't segfault when it's done
!e ```import turtle
t = turtle.Turtle()
for c in ['red', 'green', 'blue', 'yellow']:
t.color(c)
t.forward(75)
t.left(90)
@distant torrent :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | File "/usr/local/lib/python3.11/turtle.py", line 107, in <module>
004 | import tkinter as TK
005 | File "/usr/local/lib/python3.11/tkinter/__init__.py", line 38, in <module>
006 | import _tkinter # If this fails your Python may not be configured for Tk
007 | ^^^^^^^^^^^^^^^
008 | ImportError: libtk8.6.so: cannot open shared object file: No such file or directory
!e
import random
for i in range(random.randint(5,10)):
print(f'Number is: {random.randint(1,100)}')
@distant torrent :white_check_mark: Your eval job has completed with return code 0.
001 | Number is: 74
002 | Number is: 88
003 | Number is: 24
004 | Number is: 62
005 | Number is: 62
006 | Number is: 82
007 | Number is: 46
008 | Number is: 65
009 | Number is: 25
Testing the bot
Please use #bot-commands , this channel has a purpose
sorry, did not notice
Dunno
This seems really valid to me.
They help Python know when you're calling them, like lambda x: x + 1(2) vs (lambda x: x + 1)(2)
but in this case they weren't calling it directly so it didn't matter
furthermore I don't see why you would ever want to call a lambda function directly after declaring it
other than shorten your code and make it less clear
we're in #esoteric-python after all
I only bracket lambdas when calling them directly
!e
(lambda x:x(x))(print)
@languid hare :white_check_mark: Your eval job has completed with return code 0.
<built-in function print>
Otherwise I like the symmetry of
{
x:lambda:3,
y:lambda:2,
z:lambda:7
}.get(c, lambda:0)()
You know what channel you are in, right?
Respectively, that's golfing and obfuscation
!e
(lambda x:x(x))(lambda x:x(x))
@earnest wing :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | File "<string>", line 1, in <lambda>
004 | File "<string>", line 1, in <lambda>
005 | File "<string>", line 1, in <lambda>
006 | [Previous line repeated 996 more times]
007 | RecursionError: maximum recursion depth exceeded
!e ```py
(x:=lambda x:x(x))(x)
@floral meteor :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | File "<string>", line 1, in <lambda>
004 | File "<string>", line 1, in <lambda>
005 | File "<string>", line 1, in <lambda>
006 | [Previous line repeated 996 more times]
007 | RecursionError: maximum recursion depth exceeded
shorter version :)
side effects 😭
what's wrong with side effects?
sometimes they're useful when I want to do two things at once

!e py (_:=lambda:_())()
@sly root :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | File "<string>", line 1, in <lambda>
004 | File "<string>", line 1, in <lambda>
005 | File "<string>", line 1, in <lambda>
006 | [Previous line repeated 996 more times]
007 | RecursionError: maximum recursion depth exceeded
!e ```py
def ():()
_()
@quartz wave :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 2, in <module>
003 | File "<string>", line 1, in _
004 | File "<string>", line 1, in _
005 | File "<string>", line 1, in _
006 | [Previous line repeated 996 more times]
007 | RecursionError: maximum recursion depth exceeded
yeah right…
.bm bf in python
!e print(print)
@unreal echo :white_check_mark: Your eval job has completed with return code 0.
<built-in function print>
raise RecursionError
(_:=lambda:_())()
raise RecursionError
that is shorter
def r():r()
r()
!e
def _():_();_()
this one isn't as short but it's faster
more efficient :p
that's the same number of chars as
this
ya ik, i was just running it
!e got the same length (14 chars)
lambda:_();_()```
@sly root :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | NameError: name '_' is not defined
ah
it works in the repl
My idea to use _ was that _ is assigned the value of the last expression
and it makes no sense to redefine _ using def
because it makes no sense to use _
@floral meteor if you still want to implement fp and oop in brainfuck, I've implemented the fp part
A=3
B=BRAINFUCK[
PRINT[MATCH(A==3)[
TRUE: "Hello",
__: "Bye",
]],
PRINT[MATCH(A<3)[
TRUE: "Hello",
__: "Bye",
]],
DEFUN("test-func")[
PRINT["HELLO FROM test-func"]
]
]
print(B)
_b(B)._i()
print("\n",__FUNCTIONS)```
('++++++++++[>+++++++>++++++++++>+++++++++++<<<-]>++.>+.+++++++..>+.>', '++++++++++[>++++++>++++++++++>++++++++++++<<<-]>++++++.>>+.<+.>', '')
HelloBye
{'test-func': '++++++++++[>+++>++++>++++++>+++++++>++++++++>+++++++++>++++++++++>+++++++++++<<<<<<<<-]>>>>++.<+++++++++.>++++..+++.<<<++.>>>---------.>++.<+++++++++.--.<<<.>>>>>>>++++++.<+.>-.+.<<<<<<+++++.>>>>>+.>+.-------.<<+++++++++.>'}```
just saves the function body to dict using the provided function name
argument may be handled like in shell scripts using %* or with names enclosed in |...|
like %1, %argument, or |argument|
names? what do we need names for?
except for top level as a mask for a memory pointer
for calling them using normal syntax
memory pointer
and not CALL(47)[...]
idk, dicts can have int as keys, so that's possible too
__FUNCTIONS={}
DEFUN=type("DEFUN",(),{})
DEFUN.__init__=lambda s,n,*a:(s.__setattr__("n",n),s.__setattr__("a",a),None)[-1]
DEFUN.__repr__=lambda s:""
DEFUN.__getitem__=lambda s,i:(__FUNCTIONS.update({s.n:{"body":i,"args":s.a}}),"")[-1]
X = FUNC(whatever)
would allocate a memory pointer to X and then
CALL.X ( ... )
I've rewritten it so it works on android without sigsegv
the allocation would be recorded in a dictionary
to implement objects we just need to allocate memory for them.
header 16 bytes:
- size 8 bytes -> n
- type 8 bytes
body n bytes - data
tail 1 byte - NULL
we can repurpose the comma character in the actual brainfuck interpreter to turn the output into a fifo stack, and what's left on stack is printed.
there's also an another problem
how to work with arguments if PRINT automatically converts everything into brainfuck
and every string in function body is accepted as one instruction
maybe the solution is to preprocess every string at first
PRINT.varname vs PRINT("raw string")
adding new characters is not allowed?
because I've added { and } to implement rshift and lshift 😅
if characters are added, it's a derivative of brainfuck, and defeats the purpose of brainfuck. It is Turing Complete, hence you theoretically do not need any more characters.
you could make an intermediate language with symbols for commonly used scripts that compile to lengthy brainfuckiness
like a sort of bytecode
Hey @sly root!
It looks like you tried to attach a Python file - please use a code-pasting service such as https://paste.pythondiscord.com
Idea: implement IterationError, raised automatically when any loop reaches more than sys.getiterationlimit() iterations. You know, for fairness.
the mechanics in something like print would point to a builtin memory that would decide how the bytes in the data body are interpreted based on what's in the type part of the header.
match the header section with the relevant switches in the builtin memory in order to run the relevant code to handle the object
that won't call _()
header can range from 8 (SIZEOF_VOID_P == 4 && !defined(Py_TRACE_REFS)) to 32 bytes (SIZEOF_VOID_P == 8 && defined(Py_TRACE_REFS))
!e
import inspect
def getlocals(code):
varnames = code.co_varnames
if code.co_argcount > 0:
argspec = inspect.getargs(code)
varnames = filter(
lambda v: v not in argspec.args and v not in {"args", "kwargs"},
code.co_varnames,
)
return zip(varnames, code.co_consts[1:])
def inside_out(fn):
fn.__dict__.update(dict(getlocals(fn.__code__)))
return fn
@inside_out
def foo():
a = 1
b = 2
print(foo.a)
print(foo.b)
@low pelican :white_check_mark: Your eval job has completed with return code 0.
001 | 1
002 | 2
yea
very crude
hi guys i want to stard paython any course her pls?
!resources
The Resources page on our website contains a list of hand-selected learning resources that we regularly recommend to both beginners and experts.
and please ask your questions in #❓|how-to-get-help or a topic channel related to the problem, this is not the right place
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
]
what
¯_(ツ)_/¯
Agreed
this is the most esoteric thing ever
my mind cannot fathom such complicated concepts
boomshaka(laka)booBooBOOOM(SHAKA(LAKA))) -> "hello, world"
!e
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
]
@unreal echo :x: Your eval job has completed with return code 1.
001 | File "<string>", line 2
002 | ]
003 | ^
004 | SyntaxError: unmatched ']'
nani?
Which part of this is esoteric?
The lambda?
do you get local function variables this way every day?
its esoteric way lol😁
!e ```py
import inspect
def getlocals(code):
varnames = code.co_varnames
if code.co_argcount > 0:
argspec = inspect.getargs(code)
varnames = filter(
lambda v: v not in argspec.args and v not in {"args", "kwargs"},
code.co_varnames,
)
return zip(varnames, code.co_consts[1:])
def inside_out(fn):
fn.dict.update(dict(getlocals(fn.code)))
return fn
@inside_out
def foo(*, a=4):
b = 3
print(foo.a)
print(foo.b)
@quartz wave :x: Your eval job has completed with return code 1.
001 | 3
002 | Traceback (most recent call last):
003 | File "<string>", line 22, in <module>
004 | AttributeError: 'function' object has no attribute 'b'
you forgot to handle kwargs
how do i do this in an esoteric way?
{k: await filtered(v.get_commands()) for k, v in self.context.bot.cogs.items() if await filtered(v.get_commands())}```
@quartz wave :white_check_mark: Your eval job has completed with return code 0.
001 | 6
002 | 7
!e ```py
def inside_out(fn):
code=fn.code
varnames=code.co_varnames
flags=code.co_flags
posargc=code.co_posonlyargcount
argc=code.co_argcount
kwargc=code.co_kwonlyargcount
varnames_argc=varnames[:argc]
offs=argc+kwargc
varnames_kwargc={*varnames[argc:offs]}
name_varg=(flags&4)!=0 and varnames[offs]
name_vkwarg=(flags&8)!=0 and varnames[offs+1]
if argdef := fn.defaults:curlocals=dict(zip(varnames[argc-len(argdef):argc],argdef))
else:curlocals={}
if kwargdef := fn.kwdefaults:curlocals |= kwargdef
fn.dict.update(curlocals)
def test_args(): pass
test_args.code=(test_args.code.replace(co_argcount=argc,co_posonlyargcount=posargc,co_kwonlyargcount=kwargc,co_varnames=varnames,co_flags=flags,co_name=code.co_name,co_nlocals=code.co_nlocals))
code=code.replace(co_argcount=0,co_posonlyargcount=0,co_kwonlyargcount=0,co_code=code.co_code.replace(b'}',b'Z').replace(b'|',b'e').replace(b'~',b'['),co_names=varnames)
@lambda c:c()
class fno:
nonlocal curlocals
def getattribute(self,x):
loc=object.getattribute(self,"locals")
return loc[x] if x in loc else fn.getattribute(x)
def call(self,*args,**kwargs):
test_args(*args,**kwargs)
loc=object.getattribute(self,"locals")
loc.update(zip(varnames[:argc],args[:argc]))
if name_varg is not False:
loc[name_varg]=args[argc:]
loc.update({k:kwargs.pop(k)for k in kwargs if k in varnames_kwargc})
if name_vkwarg is not False:
loc[name_vkwarg]=kwargs
return eval(code,globals(),loc)
@property
def locals(self):
return curlocals
@locals.setter
def _(self,x):
nonlocal curlocals
if not isinstance(x,dict):
raise TypeError("locals must be set to a dict object")
curlocals=x
@locals.deleter
def _(self,x):raise TypeError("locals must be set to a dict object")
return fno
@inside_out
def foo(c=3):
a=c+1
b=c+2
print(f"{foo.c=}")
foo(5)
print(f"{foo.c=}")
print(foo.a)
print(foo.b)
@quartz wave :white_check_mark: Your eval job has completed with return code 0.
001 | foo.c=3
002 | foo.c=5
003 | 6
004 | 7
@low pelican better
had to remove some stuff to fit it in the discord message limit
Skid
ok
someone should turn this into a rap song and deliver it like this
bladee - Inside Out feat. Yung Lean (prod. ripsquad)
Artist : bladee
http://soundcloud.com/bladee1000
http://instagram.com/dg_bladee
http://twitter.com/BladeeCity
Follow Unheard
http://soundcloud.com/unheardrap
http://twitter.com/unheardrap_
http://spoti.fi/2S2Hver
Unheard is a promotional channel which aims at uploading new and underrated So...
hey how do you get cash on bit coin found with python
!e
import math
from itertools import product
sx, sy = 40, 26
[print(chr(10240+int(''.join(map(lambda i:str(1*((lambda x,y:-max(-((0.4*(x+2.5))(2)+10*(2*(y-0.6)+(math.sin(4*(2*x+2)*0.4))/(4))(2)-1),-((x-1.7)(2)+(y-2.2-(math.sin(abs(x-2.3)))/(2))(2)-1),-min(min((abs(2*(y+3.5)+abs((x-2.5)))+abs((x-2.5))-1),max(0.8abs((x-2.5)),0.15abs((y+3.5)-2))-0.3),min((abs(2*(y+4)+abs((x-(2.9)/(3))))+abs((x-(2.9)/(3)))-1),max(0.8abs((x-(2.9)/(3))),0.15abs((y+4)-2))-0.3),min((abs(2*(y+4)+abs((x+2.5)))+abs((x+2.5))-1),max(0.8abs((x+2.5)),0.15abs((y+4)-2))-0.3),min((abs(2*(y+3.5)+abs((x+(2.9)/(3))))+abs((x+(2.9)/(3)))-1),max(0.8abs((x+(2.9)/(3))),0.15abs((y+3.5)-2))-0.3)),-(0.3x**(2)+0.25y**(4)-2**(2)),-((x-3)(2)+(y-0.5-(x)/(3))(2)-3)((x-3.6)(2)+(y-2.75)(2)-0.3**(2)),-(0.2(x-5.8)(2)+(3*(y-(x)/(3)-1)+math.sin(2*x))(2)-0.75))-0.08)((152bx+i%2)/(2sx)+2,-15(4by+(i//2))/(4sy))<=0)),map(int,'76531420'))),2)),end='\n'*((bx-1-sx//2)%sx==0)) for by,bx in product(range(6-sy//2,sy//2-5),range(1-sx//2,sx//2-4))]
@sick hound :white_check_mark: Your eval job has completed with return code 0.
001 | ⠀
002 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
003 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣶⣿⣿⣶⠀⣀⣶⣶⣶⣄⠀⣀⣶⣿⣶⣤⣤⣶⠛⠀
004 | ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣁⣿⣿⣴⠿⠉⠀⠉⠙⠛⠀⠀⠀
005 | ⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣀⣀⣀⣀⣛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀
006 | ⠀⠀⠀⠀⣀⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀⠀⠀⠀⠀⠀⠀
007 | ⠀⠀⠀⣠⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
008 | ⠉⠛⠉⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠛⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
009 | ⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
010 | ⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
011 | ⠀⠀⠀⠀⠛⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
... (truncated - too many lines)
Full output: https://paste.pythondiscord.com/enuyikojiv.txt?noredirect
!e print('ㅎㅎ')
@sick hound :white_check_mark: Your eval job has completed with return code 0.
ㅎㅎ
!e import disnake
@sick hound :x: Your eval job has completed with return code 1.
001 | Traceback (most recent call last):
002 | File "<string>", line 1, in <module>
003 | ModuleNotFoundError: No module named 'disnake'
#bot-commands
!e
import math
from itertools import product
sx, sy = 40, 26
[print(chr(10240+int(''.join(map(lambda i:str(1((lambda x,y:-max(-((0.4(x+2.5))(2)+10(2(y-0.6)+(math.sin(4(2x+2)0.4))/(4))(2)-1),-((x-1.7)(2)+(y-2.2-(math.sin(abs(x-2.3)))/(2))(2)-1),-min(min((abs(2(y+3.5)+abs((x-2.5)))+abs((x-2.5))-1),max(0.8abs((x-2.5)),0.15abs((y+3.5)-2))-0.3),min((abs(2(y+4)+abs((x-(2.9)/(3))))+abs((x-(2.9)/(3)))-1),max(0.8abs((x-(2.9)/(3))),0.15abs((y+4)-2))-0.3),min((abs(2(y+4)+abs((x+2.5)))+abs((x+2.5))-1),max(0.8abs((x+2.5)),0.15abs((y+4)-2))-0.3),min((abs(2(y+3.5)+abs((x+(2.9)/(3))))+abs((x+(2.9)/(3)))-1),max(0.8abs((x+(2.9)/(3))),0.15abs((y+3.5)-2))-0.3)),-(0.3x*(2)+0.25y(4)-2(2)),-((x-3)(2)+(y-0.5-(x)/(3))(2)-3)((x-3.6)(2)+(y-2.75)(2)-0.3**(2)),-(0.2(x-5.8)(2)+(3(y-(x)/(3)-1)+math.sin(2x))(2)-0.75))-0.08)((152bx+i%2)/(2sx)+2,-15(4by+(i//2))/(4sy))<=0)),map(int,'76531420'))),2)),end='\n'*((bx-1-sx//2)%sx==0)) for by,bx in product(range(6-sy//2,sy//2-5),range(1-sx//2,sx//2-4))]
I am new here...why doesn't it work?
try putting it in a code block, like:
!e
```
code here
more code here
```
!e
print("Hello, World!")
@sick hound :white_check_mark: Your eval job has completed with return code 0.
Hello, World!
Very esoteric
!e ```py
from ctypes import*
class output:
def init(self, victim):
self.victim=id(victim);ol = len(victim)
(c_char*ol).from_address(id(victim)+48)[:]=[0]*ol
c_longlong.from_address(id(victim)+16).value=0
self.backup = [0]ol, ol
def lt(self, item):
_l = c_longlong.from_address(self.victim+16)
_l.value += 1
_a = c_byte.from_address(self.victim+48+_l.value)
self.backup[0].append(_a.value);_a.value=-item;return 0;
def del(self):
v, i = self.backup
c_longlong.from_address(self.victim+16).value = i
(c_bytelen(v)).from_address(self.victim+48)[:]=v
neg=lambda s:s
def gt(self, a):
a,i,_l=a,c_longlong.from_address(self.victim+16)
data = (c_byte_l.value).from_address(self.victim+49)
v, *data[:-1] = data;_l.value -= 1;a[i] = v;return 0;
class array:
def init(self, victim):
self.memory = "\0\0\0\0\0\0\0\0"[:]256
_ = self.memory = id(self.memory)
c_longlong.from_address(+16).value=2568-1
self.i=0; self.o = output(victim)
@property
def mem(self):return(c_byte*(256*8-1)).from_address(self._memory+48);
def inc(self):self.mem[self.i]+=1;return 0;
def dec(self):self.mem[self.i]-=1;return 0;
def left(self):self.i-=1;return 0;
def rite(self):self.i+=1;return 0;
def dot(self):return self.o <- self.mem[self.i];
def com(self):return(self.mem, self.i) <- self.o;
def loop(self):return+(not self.mem[self.i]);
def endl(self):return-bool(self.mem[self.i]);
def iter(self):return iter([self.mem])
def run(self, c):
p=t=0
try:
while 0<=p<len(c):
if t:t+=(c[p]=='[')-(c[p]==']')
else:t={
'+':self.inc,'-':self.dec,'<':self.left,'>':self.rite,
'.':self.dot,',':self.com,'[':self.loop,']':self.endl
}.get(c[p],lambda:0)()
p+=1-2(t<0)
except KeyboardInterrupt:pass
finally:return self.o
def brainfuck(victim, , _n=[0]):
clone,a = victim+'.',array(victim);a.run(clone)
_l=c_longlong.from_address(a.o.victim+16);l=_l.value;_l.value-=1
data = (c_bytel).from_address(a.o.victim+48)
_,*data[:-1]=data;import('sys')._getframe(1).f_globals[_n[0]]=a.o;_n[0]+=1
code = "++++++++++[>+++++++>++++++++++>+++>+++++++++++<<<<-]>++.>+.+++++++..+++.>++++++++++++++.------------.<<+++++++++++++++.>.+++.>>--.--------.<+."
print(code)
brainfuck(code)
print(code)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | ++++++++++[>+++++++>++++++++++>+++>+++++++++++<<<<-]>++.>+.+++++++..+++.>++++++++++++++.------------.<<+++++++++++++++.>.+++.>>--.--------.<+.
002 | Hello, World!
it segfaults in 3.11
the comma just uses the output as the input
!e I got commas working properly now ```py
from ctypes import*
class output:
def init(self, victim):
self.victim=id(victim);ol = len(victim)
(c_char*ol).from_address(id(victim)+48)[:]=[0]*ol
c_longlong.from_address(id(victim)+16).value=0
def lt(self, item):
_l = c_longlong.from_address(self.victim+16)
_l.value += 1
_a = c_byte.from_address(self.victim+48+_l.value)
_a.value=-item;return 0;
neg=lambda s:s
def gt(self, a):
a,i,_l=a,c_longlong.from_address(self.victim+16)
data = (c_byte_l.value).from_address(self.victim+49)
v, *data[:-1] = data;_l.value -= 1;a[i] = v;return 0;
class array:
def init(self, victim):
self.memory = "\0\0\0\0\0\0\0\0"[:]256
_ = self.memory = id(self.memory)
c_longlong.from_address(+16).value=2568-1
self.i=0; self.o = output(victim)
@property
def mem(self):return(c_byte*(256*8-1)).from_address(self._memory+48);
def inc(self):self.mem[self.i]+=1;return 0;
def dec(self):self.mem[self.i]-=1;return 0;
def left(self):self.i-=1;return 0;
def rite(self):self.i+=1;return 0;
def dot(self):return self.o <- self.mem[self.i];
def com(self):return(self.mem, self.i) <- self.o;
def loop(self):return+(not self.mem[self.i]);
def endl(self):return-bool(self.mem[self.i]);
def iter(self):return iter([self.mem])
def run(self, c):
p=t=0
try:
while 0<=p<len(c):
if t:t+=(c[p]=='[')-(c[p]==']')
else:t={
'+':self.inc,'-':self.dec,'<':self.left,'>':self.rite,
'.':self.dot,',':self.com,'[':self.loop,']':self.endl
}.get(c[p],lambda:0)()
p+=1-2(t<0)
except KeyboardInterrupt:pass
finally:return self.o
def brainfuck(victim, , _n=[0]):
clone,a = victim+'.',array(victim);a.run(clone)
_l=c_longlong.from_address(a.o.victim+16);l=_l.value;_l.value-=1
data = (c_bytel).from_address(a.o.victim+48)
_,*data[:-1]=data;import('sys')._getframe(1).f_globals[_n[0]]=a.o;_n[0]+=1
code = "++++++++++[>+++++++>+++++++++++>+++<<<-]++++++++++>++>--.>++.<.<.>-------.,..+++.>++++++++++++.,.+<<+++++++++++++++.>.+++.,.--------.>.<<<."
print(code)
brainfuck(code)
print(code)
@floral meteor :white_check_mark: Your eval job has completed with return code 0.
001 | ++++++++++[>+++++++>+++++++++++>+++<<<-]++++++++++>++>--.>++.<.<.>-------.,..+++.>++++++++++++.,.+<<+++++++++++++++.>.+++.,.--------.>.<<<.
002 | Hello, World!
no segfault in 3.11 now
unless the output is longer than the code...
for some reason the cleanup was killing it
using the output as a fifo stack for the input is merely there as a way to encode the input in the code
Hi everyone,
I would like to ask for someone who can help me with this python programme. In fact, I am quite confused about how to write because I am a beginner. So, if someone can help, I am so thankful. I am sure it is an easy task that takes no more than 30 minutes. I will attach the file below.
Thanks,
Hey @graceful flame!
It looks like you tried to attach file type(s) that we do not allow (.pdf). We currently allow the following file types: .gif, .jpg, .jpeg, .mov, .mp4, .mpg, .png, .mp3, .wav, .ogg, .webm, .webp, .flac, .m4a, .csv, .json.
Feel free to ask in #community-meta if you think this is a mistake.
in a computer natively running brainfuck, the value being overwritten by , would not be ignored, but would rather be the id for the port from which to read input from, like a harddrive or cpu temperature reading or ethernet.
this channel would be the least helpful for a beginner, see #❓|how-to-get-help for a better channel
!paste for files
Pasting large amounts of code
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the floppy disk icon in the top right, or by typing ctrl + S. After doing that, the URL should change. Copy the URL and post it here so others can see it.
@quartz wave Hello. I was looking up at the code above, and I noticed this line. What's the purpose of it?
@lambda c: c()
class MyClass:
def __call__(self, *args, **kwargs): pass
It appears that the decorator just turns MyClass into a function .. why not just declare MyClass as a function from the beginning, then?
Is this the only code for the class?
Functions are much harder to add other stuff to, for example attributes and methods
Possibly it's just part of the code
@royal whale this is the code
wdym by "declare MyClass as a function"
its just instantiating MyClass
thats the same as doing
class Foo:
...
Foo()
its not a function
its a class, they are two different things
Ah
so that you create the instance without the ()
!e
class Foo: ...
print(Foo)
Foo = Foo() # basically what the decorator is doing
print(Foo)
@wheat river :white_check_mark: Your 3.11 eval job has completed with return code 0.
001 | <class '__main__.Foo'>
002 | <__main__.Foo object at 0x7f698ccafb90>
and that would instantiate it, instead of "myNewClass = MyClass()" ?
That's just saying 'whenever I reference MyClass I instantiate it, so MyClass()
To actually use the __call__ func you need to do MyClass()()
oh
Which with the decorator would be MyClass()
sure
!e
@lambda _: _()
class Foo: ...
print(Foo)
@wheat river :white_check_mark: Your 3.11 eval job has completed with return code 0.
<__main__.Foo object at 0x7f17474d3d10>
alright, so it is just a way to instantiate the class without (), lol, ok
Yeah
For example:
you shouldn't see that outside this channel
ig thats one way of making a singleton class
you only have one instance
import random
@lambda _: _()()
class Frue:
"""True or false?"""
def __call__(self):
return random.choice((True, False))
Frue # random bool
Then it's more like a True/False- you don't use parens on those
hmm ok
Gonna have to use that
@devout wraith don't forget Talse
My Frue or Tralse guesser is pretty important
Dw, i would never forget tralse
!e
@print
@lambda x: x > 0.5
@id.__class__.__call__
@lambda x: x.random
@__import__
@lambda x: x.__doc__
class Frue: 'random'
not the same thing but still
@wheat river :white_check_mark: Your 3.11 eval job has completed with return code 0.
False
@lambda _: _() is cringe (joking) I usually use @type.__call__
w o w
@0.5.__lt__
idea: __rgetitem__ and __rgetattr__ for the reversed y[x] and y.x operators
smart
it looks to be something like a fourier series drawing
okay why did discord show me a 5 day old message
it does that to me too, except it teleports me right in the middle of what's been unread. not at the start, or at the most recent, but in the middle.
discord is high quality
I can definitely imagine some of their production code would fit perfectly in this channel
if the variable names aren't entire sentences, that is.
this is a bit less esoteric and a bit more math
but
!e I like how octal 0 looks, so I'm using it to make hello world :p
print("".join([chr(OoO)for OoO in[(-~0o0<<(-~0o0+-~0o0)<<(-~0o0<<(-~0o0+-~0o0)))|((-~0o0+-~0o0)<<(-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<(-~0o0+-~0o0)),(-~0o0<<(-~0o0+-~0o0)<<(-~0o0<<(-~0o0+-~0o0)))|((-~0o0+-~0o0)<<(-~0o0+-~0o0)<<(-~0o0+-~0o0))|(((-~0o0+-~0o0)<<(-~0o0))+-~0o0),(-~0o0<<(-~0o0+-~0o0)<<(-~0o0<<(-~0o0+-~0o0)))|((-~0o0+-~0o0)<<(-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<-~0o0),(-~0o0<<(-~0o0+-~0o0)<<(-~0o0<<(-~0o0+-~0o0)))|((-~0o0+-~0o0)<<(-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<-~0o0),(-~0o0<<(-~0o0+-~0o0)<<(-~0o0<<(-~0o0+-~0o0)))|((-~0o0+-~0o0)<<(-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<-~0o0)|(-~0o0+-~0o0)|-~0o0,((-~0o0+-~0o0)<<(-~0o0+-~0o0)<<(-~0o0+-~0o0)),(-~0o0<<((-~0o0+-~0o0)<<-~0o0|(-~0o0+-~0o0)|-~0o0))-(-~0o0<<-~0o0<<-~0o0<<-~0o0)+~0o0,(-~0o0<<(-~0o0+-~0o0)<<(-~0o0<<(-~0o0+-~0o0)))|((-~0o0+-~0o0)<<(-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<-~0o0)|(-~0o0+-~0o0)|-~0o0,((-~0o0<<(-~0o0+-~0o0)<<(-~0o0<<(-~0o0+-~0o0)))|((-~0o0+-~0o0)<<(-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<-~0o0)|(-~0o0+-~0o0))+(-~0o0<<-~0o0<<-~0o0),(-~0o0<<(-~0o0+-~0o0)<<(-~0o0<<(-~0o0+-~0o0)))|((-~0o0+-~0o0)<<(-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<(-~0o0+-~0o0))|((-~0o0+-~0o0)<<-~0o0),(-~0o0<<(-~0o0+-~0o0)<<(-~0o0<<(-~0o0+-~0o0)))|((-~0o0+-~0o0)<<(-~0o0+-~0o0)<<(-~0o0+-~0o0))|(((-~0o0+-~0o0)<<-~0o0))]]))
@versed eagle :white_check_mark: Your 3.11 eval job has completed with return code 0.
hello world
sorry I used chr, I haven't found a good alternative yet
explain, please
im so confused looking at that
That's not what we do here

!e ```py
print((-~0o0<<(-~0o0+-~0o0)))
@old socket :white_check_mark: Your 3.11 eval job has completed with return code 0.
4
@tulip blaze :white_check_mark: Your 3.11 eval job has completed with return code 0.
1
0o0 is 0 in octal
I use chr
that's all the hint I'll give
sadly, haven't found an alternative yet
yeah
bitshifts are my friend here
Lmao
doesn't work on my machine for some reason
Indices of names of built-in types
ah
i was messing around with (thing.append(c) if c not in thing else ...)for c in "".join(dir("")+dir({})) because the combination of those two has every letter
Or read from memory addresses with extreme offsets.
then you can use .upper() to get upper
thing.append(str(_)) for _ in range(10) gets numbers
(thing is a list btw)
then you use thing="".join(thing)
then get an index of thing
(if you feel like it)
i dont know the memory addresses of stuff
that could work
where do you get y from
i cant think of something off the top of my head that has y
If you're familiar with consecutive string objects in memory, you can access an interned string in front of a built-in doc string, artificially increase its length, then getitem extreme values
im not familiar with that :(
Eh just dig around you'll find something
!e ```py
from ctypes import *
victim = "victim"
c_longlong.from_address(id(victim)+16).value = 256
print(repr(victim))
@floral meteor :white_check_mark: Your 3.11 eval job has completed with return code 0.
'victim\x00\x00¨uã\x0cp\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x80²â\x0cp\x7f\x00\x00\x06\x00\x00\x00\x00\x00\x00\x00/çb¹Fð\xa0öäÅO\x0cp\x7f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00victim\x00\x00\xa0ÅO\x0cp\x7f\x00\x00\x08\x00\x00\x00\x00\x00\x00\x00\x80²â\x0cp\x7f\x00\x00\n\x00\x00\x00\x00\x00\x00\x00AY}.\x1a\x8b!ðå\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00c_longlong\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00\x80²â\x0cp\x7f\x00\x00\x0c\x00\x00\x00\x00\x00\x00\x00Ë>\x9eñ/\x02\x8côå\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00from_address\x00\x00\x00\x00°·P\x0cp\x7f\x00\x00ÀºP\x0cp\x7f\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x02ã\x0cp\x7f\x00\x00\x05\x00\x00\x00\x00\x00\x00\x00pºP\x0cp\x7f\x00\x00'
oh do you have to use ctypes
There you go, the name c_longlong is in there
ok so you just do that and dig around a ton till you find the right chars
Looks like the memory for the code object for globals frame
You could reference a whole bunch of names after an if 0:
Then read memory to find those names after a previous variable definition
Will look like real hackerman code if executed well
I'm gonna do it on maybe 4 hours if I remember
!e ```py
print(import("\x74\x65\x78\x74\x77\x72\x61\x70").shorten.doc[331:343])
@old socket :white_check_mark: Your 3.11 eval job has completed with return code 0.
Hello world!
!e
print("\x74\x65\x78\x74\x77\x72\x61\x70")
@versed eagle :white_check_mark: Your 3.11 eval job has completed with return code 0.
textwrap
aha
!e I have ascended to a higher plane of reality```py
from ctypes import *
victim = "victim"
if(255<<255)*(255>>255):hello, world
c_longlong.from_address(id(victim)+16).value = 1024
print(victim[128:133],victim[192:197])
@floral meteor :white_check_mark: Your 3.11 eval job has completed with return code 0.
hello world
some programmers push hello world to a stack.
some programmers store hello world as a variable.
I throw hello world into the oblivion then fish for it.
like the above.
the mathy bit is so the variable names don't get optimised out of existence
in the terminal, it only sometimes works
!e from ctypes import *
victim = "victim"
if(255<<255)(255>>255):this, that, something, everything
c_longlong.from_address(id(victim)+16).value = 1024
print([victim[n:n+k]for n,k in zip(range(128,4*128,64),[4,4,9,10])])
@floral meteor :white_check_mark: Your 3.11 eval job has completed with return code 0.
this that something everything
code blocking it would not make it more understandable.
this is like dropping a bottle with a message into the ocean, then knowing exactly where it will float to and picking it up there. Technically it shouldn't work.
how does that work on stuff other than the REPL
also is that just using co_names or something
this is just reading from 128 bytes after "victim" in 64 byte increments
ok
what is the type of co_names?
specifically the contents of it?
I can't seem to fetch the lengths of the co_names
co_names is supposed to be a tuple with guaranteed only strings
string length isn't where it's supposed to be in memory
is the type and encoding omitted?
wdym
if i read position 96 it should tell me the length of the string body at position 128
!e ```py
from ctypes import *
victim = "victim"
if(255<<255)(255>>255):this, that, something, everything
c_longlong.from_address(id(victim)+16).value = 1024
print([cast(id(victim)+n, py_object)for n in [-64, 64, 128, 192, 256, 320, 384, 448, 512]])
@quartz wave :white_check_mark: Your 3.11 eval job has completed with return code 0.
py_object('ctypes') py_object('victim') py_object('this') py_object('that') py_object('something') py_object('everything') py_object('c_longlong') py_object('from_address') py_object('py_object')
chilaxan if you see this pls explain