Stair climbing is still a challenging task for humanoid robots, especially in unknown environments. In this paper, we address this problem from perception to execution. Our first contribution is a real-time plane-segment estimation method using Lidar data without prior models of the staircase. We then integrate this solution with humanoid motion planning. Our second contribution is a stair-climbing motion generator where estimated plane segments are used to compute footholds and stability polygons. We evaluate our method on various staircases. We also demonstrate the feasibility of the generated trajectories in a real-life experiment with the humanoid robot HRP-4.