根据输出确定你想要启动的内核菜单项。假设Ubuntu, with Linux 5.4.0-205-generic 的索引是 1>5,其中1表示 Advanced options for Ubuntu 菜单的索引,5表示新内核版本在 Advanced options for Ubuntu 菜单中的索引(从 0 开始)。
from random import * import time import pyfiglet import os import hashlib text = "X1crypsc" ascii_art = pyfiglet.figlet_format(text) print(ascii_art) time.sleep(1) print('[+]I want to play a game.\n') time.sleep(1) print('[+]If you win the game, I will give you a gift:)\n') time.sleep(1) print('[+]But try to beat the monster first:)\n') time.sleep(1) print('[+]Good luck!\n') print('[+]You got a weapon!\n') damage_rng = () defregenerate_damage(): global damage_rng base = getrandbits(16) add = getrandbits(16) damage_rng = (base ,base + add) monster_health = getrandbits(64) menu = ''' ---Options--- [W]eapon [A]ttack [E]xit ''' regenerate_damage() print(menu) HP = 3 whileTrue: if monster_health <= 0: print('[+] Victory!!!') break if HP <= 0: print('[!] DEFEAT') exit(0) print(f'[+] Monster current HP:{monster_health}') print(f'[+] Your current HP: {HP}') opt = input('[-] Your option:') if opt == 'W': print(f'[+] Current attack value: {damage_rng[0]} ~ {damage_rng[1]}') ifinput('[+] Do you want to refresh the attack profile of the weapon([y/n])?') == 'y': regenerate_damage() print(f'[+] New weapon attack value: {damage_rng[0]} ~ {damage_rng[1]}') elif opt == 'A': print('[+] The monster sensed of an imminent danger and is about to teleport!!\n') print('[+] Now you have to aim at the monster\'s location to hit it!\n') print('[+]Input format: x y\n') x,y = map(int,input(f'[-] Provide the grid you\'re willing to aim:').split()) if [x,y] == [randrange(2025),randrange(2025)]: dmg = min(int(randint(*damage_rng) ** (Random().random() * 8)),monster_health) print(f'[+] Decent shot! Monster was hevaily damaged! Damage value = {dmg}') monster_health -= dmg else: print("[+] Your bet didn't pay off, and the monster presented a counterattack on you!") HP -= 1 elif opt == 'E': print('[+] Bye~') exit(0) else: print('[!] Invalid input') print('[+]Well done! You won the game!\n') print('[+]And here is your gift: you got a chance to create a time capsule here and we\'ll keep it for you forever:)\n') keep_dir = '/app/user_file/' classFile: def__init__(self): os.makedirs('user_file', exist_ok=True) defsanitize(self, filename): if filename.startswith('/'): raise ValueError('[!]Invalid filename') else: return filename.replace('../', '') defget_path(self, filename): hashed = hashlib.sha256(filename.encode()).hexdigest()[:8] sanitized = self.sanitize(filename) return os.path.join(keep_dir, hashed, sanitized) defuser_input(self): whileTrue: filename = input('[-]Please enter the file name you want to create: ') data = [] whileTrue: line = input('[-]Now write something into the file (or type "exit" to finish writing): ') if line.lower() == 'exit': break data.append(line) another_line = input('[-]Write in another line? [y/n]: ') if another_line.lower() != 'y': break try: path = self.get_path(filename) os.makedirs(os.path.dirname(path), exist_ok=True) withopen(path, 'w') as f: for line in data: f.write(line) f.write('\n') print(f'[+]Your file has been successfully saved at {path}, we promise we\'ll never lose it :)') except: print(f'[+]Something went wrong, please try again.') whileTrue: ask = input('[-]Create more files? [y/n]: ') if ask.lower() == 'y': break elif ask.lower() == 'n': exit(0) else: print('[!]Invalid input, please try again.\n') file = File() file.user_input() exit(0)
whatls = [] whatls.extend(int(i) for i inbin(monster_hp)[2:].zfill(64))
io.sendlineafter(b'option:',b'W') io.recvuntil(b':') n1 = int(io.recvuntil(b'~',drop=True).strip().decode()) n2 = int(io.recvline().strip().decode()) - n1 whatls.extend(int(i) for i inbin(n1)[2:].zfill(16)) whatls.extend(int(i) for i inbin(n2)[2:].zfill(16))
io.sendlineafter(b'?',b'y') io.recvuntil(b':') n1 = int(io.recvuntil(b'~',drop=True).strip().decode()) n2 = int(io.recvline().strip().decode()) - n1 whatls.extend(int(i) for i inbin(n1)[2:].zfill(16)) whatls.extend(int(i) for i inbin(n2)[2:].zfill(16))
for _ inrange(620): io.sendlineafter(b'option:',b'W') io.sendlineafter(b'?',b'y') io.recvuntil(b':') n1 = int(io.recvuntil(b'~',drop=True).strip().decode()) n2 = int(io.recvline().strip().decode()) - n1 whatls.extend(int(i) for i inbin(n1)[2:].zfill(16)) whatls.extend(int(i) for i inbin(n2)[2:].zfill(16))
''' # map a linear transformation matrix # compute for first time only, afterwards comment this section for memory & time conservation mt = [] for i in range(19968): f_stats = [0] * 19968 f_stats[i] = 1 state = [int(''.join(map(str,f_stats[i*32:(i+1)*32])),2) for i in range(624)] r = Random() r.setstate((3,tuple(state+[624]),None)) vc = [] vc.extend(int(i) for i in bin(r.getrandbits(64))[2:].zfill(64)) for _ in range(622): # 624 - 2 = 622 vc.extend(int(i) for i in bin(getrandbits(16))[2:].zfill(16)) vc.extend(int(i) for i in bin(getrandbits(16))[2:].zfill(16)) mt.append(vc) save(mt,'mt.sobj') '''