When reading bytes asynchronously from stdout using asyncio.create_subprocess_exec, the program has to be unbuffered.
1 2
python3 -u <script_path>
1 2 3 4 5 6 7 8 9 10 11
# this can only make `print` into unbuffered import builtins import copy old_print = copy.copy(builtins.print) defcustom_print(*args, **kwargs): if'flush'notin kwargs: kwargs['flush'] = True old_print(*args, **kwargs) # Override the built-in print function with the custom function builtins.print = custom_print
from collections import defaultdict, Counter
mydict = defaultdict(Counter) # remember to put callable or none as argument of defaultdict
mydict = defaultdict(lambda: defaultdict(lambda: 0)) # alternative
mydict['k1']['k2'] += 1 # two is ok, but not one or three
pip install pdoc3 pdoc --html [-o <output_dir>] <python_script_or_module_path> # default output directory of "html" is `./html`
install and use pandoc, on its homepage we find some slideshow backends like reveal.js, dzslides, s5, slideous and slidy (alternative to microsoft powerpoint, may help rendering video, or let’s use libreoffice instead? or some dedicated video editing library like moviepy)
1 2 3
# let's convert the html version of pandoc -o <output_docx_filename> <input_html_path>
remove unwanted parts from html (beautifulsoup), and split index from main content (split and concat with docxcompose)
for composing docx from hand, use python-docx. for template based docx generating, use docxtpl
to insert page break into converted docx, there are two ways (maybe):
from pwn import * ip = "190.92.234.114" port = 23334 mclean =lambda l0: l0.decode().split("=")[1].strip() mlist = lambda T: [int(x) for x in T.replace("[","").replace("]", "").replace(" ","").strip().split(",")] r = remote(ip, port) l0 = r.recvline() # print('first line?', l0) # great man! q = mclean(l0) q = int(q) # but notice you will not like to be fucked up. use safe eval? ast? l1 = r.recvline() # print('second line?', l1) T = mclean(l1) T = mlist(T) l2 = r.recvline() U = mlist(mclean(l2)) # print("third line?", l2) print("Q?", q) print() print("T?", len(T)) print() print("U?", len(U)) # now crack the x. please observe the original code? # the shift does not matter so much? mpos_x = {} for i inrange(90): t = T[i] u = U[i] pos_x = u//t+1 mpos_x.update({pos_x:mpos_x.get(pos_x,0)+1}) mfinalPos = [(key, elem) for key, elem in mpos_x.items()] mfinalPos.sort(key=lambda x: -x[1]) print("NUM?",mfinalPos[0]) print("COUNT?",mfinalPos[0][1]) # import pyperclip data =str(mfinalPos[0][0]) # pyperclip.copy(data) # r.interactive() r.sendline(data.encode()) flag=r.recvline() #EOFERROR? print("FLAG?",flag) # now answer the shit?