This paper presents a robust and practical collateralized debt obligation (CDO) valuation framework based on the application of multi-factor credit models in conjunction with weighted Monte Carlo techniques used in options pricing. The general factor framework produces arbitrage-free prices and can be used to value consistently CDOs of bespoke portfolios, CDO-squared and cash CDOs. The quoted prices of individual name credit default swaps as well as various credit portfolio instruments, such as CDO tranches, are used to imply the "risk-neutral" distributions for the underlying systematic risk factors, which drive joint obligor defaults. We solve numerically the inverse problem of implying the factors' joint distribution, defined over a discrete set of scenarios on the factors. Multi-factor models allow the inclusion of sector and geographical concentrations, deals that refer simultaneously to multiple indexes and potentially other risk factors such as recoveries and prepayments.We describe various numerical techniques for effectively sampling factor scenarios and obtaining well-behaved implied factor distributions, and illustrate the use of the method on several bespoke synthetic deals.