By the end of the middle ages, the main technology being used to attack castles was cannon. However, cannon did not develop in any very useful way until late in that period. Before the development of cannon, there were many siege engines in use for attacking castles.
One of the most famous types of siege engines was the catapult and related technologies. These were devices that used various mechanisms to hurl heavy objects at or over castle walls. There were many types of catapults, the most advanced and famous of which was probably the trebuchet. All of these machines had the same basic function, even if they differed in terms of mechanism.
There were two other main types of technology that were directly used to attack castles. One of these was the battering ram. This was a device that provided a large pole that could be rammed repeatedly against the gates of a castle. It typically provided some kind of shelter for the people operating it to protect them from attack from above. The second was the siege tower. This device gave some protection to attackers as it was brought up next to the walls. The attackers then climbed the tower to get over the walls.
Other technologies were used as well. There were simple attacks using ladders to climb the walls. There were also mining technologies used to dig under the walls to weaken and collapse them. All of these technologies were used at one time or another against castles.