Yes, it's legal to use your foot to kick the ball out of a ruck, but you cannot use your hands unless you're the scrum-half and the ball is clearly visible.