Purchase 2-inch flat hooks to affix to the top rails of the ladder. Flat hooks come with a wide slot on one end and a hook on the other. Hold the ladder up to the bed and mark where the hooks need to go. Drill pilot holes into the wood, then screw the flat hooks into the ladder. Ensure the hooks are upside down so the ladder will hook onto the lip of the upper bunk. Tighten the screws down so the heads lay flush with the flat hooks.
Cut steel bar stock into two 8-inch pieces. Use a circular saw with a carbide-tipped blade or have the pieces cut at the home improvement store. You can also get metal cut at a local metal shop. Wrap the flat steel bar in cloth and hold it around a sturdy metal object, like a pole or table saw leg. Pull the ends of the bar toward you until it bends. Adjust the bar on the pole and bend again. Work with the bar until it is bent into a hook shape. Repeat with the other bar. Drill bolt holes into the metal with a carbide-tipped bit and bolt the metal strips to the ladder. Secure the bolts with nuts.
Purchase bunk bed replacement hooks from a bedroom furniture store or an online retailer. Replacement hooks for bunk beds are available in a range of sizes and styles. These come with bolt holes already drilled into the metal and are often resin coated to protect the wood of the bunk bed.