You're mostly there - your hub definition is spot on - it's basically an electrical repeater and doesn't inspect the packet in any way* and operates at half-duplex.
Switches (specifically Layer 2 switches) will send broadcast frames to all ports*, but traffic that is unicast to a specific MAC address will only be sent to the port where that MAC address was learnt. To keep track of the MAC address to port mappings, a switch will have one or more "forwarding" or "MAC-address" tables.
Routers (and Layer 3 switches) are not necessarily Internet connected, but will mostly be seen in larger networks. Being mostly Ethernet-based these days, they maintain two tables - an ARP table (mapping IP Addresses to MAC Addresses) and a routing table (mapping IP prefixes/routes to destination IP addresses). When an IP packet comes into a port, the router will consult it's routing table and find the most specific route that matches the destination of the packet. From the destination IP of the route, it will then determine the egress interface that it should send the packet towards, then use the ARP table to work out the destination Ethernet MAC address for the Ethernet frame it will construct to transport the IP packet in on it's way to the next-hop router.
* During the early 00s there were "Dual-Speed Hubs", which were basically two hubs (one 10Mbps, one 100Mbps) joined together internally via a two-port Ethernet switch. Fortunately the price of 100Mbps Ethernet switches kept falling and they weren't around too long.
* Provided those ports are all members of the same broadcast domain/VLAN
Switches (specifically Layer 2 switches) will send broadcast frames to all ports*, but traffic that is unicast to a specific MAC address will only be sent to the port where that MAC address was learnt. To keep track of the MAC address to port mappings, a switch will have one or more "forwarding" or "MAC-address" tables.
Routers (and Layer 3 switches) are not necessarily Internet connected, but will mostly be seen in larger networks. Being mostly Ethernet-based these days, they maintain two tables - an ARP table (mapping IP Addresses to MAC Addresses) and a routing table (mapping IP prefixes/routes to destination IP addresses). When an IP packet comes into a port, the router will consult it's routing table and find the most specific route that matches the destination of the packet. From the destination IP of the route, it will then determine the egress interface that it should send the packet towards, then use the ARP table to work out the destination Ethernet MAC address for the Ethernet frame it will construct to transport the IP packet in on it's way to the next-hop router.
* During the early 00s there were "Dual-Speed Hubs", which were basically two hubs (one 10Mbps, one 100Mbps) joined together internally via a two-port Ethernet switch. Fortunately the price of 100Mbps Ethernet switches kept falling and they weren't around too long.
* Provided those ports are all members of the same broadcast domain/VLAN