You can technically make money on 2nd liens where the 1st is behind on payments or initiating foreclosure against the borrowers home. However, you need to pay pennies for this 2nd lien due to the high risk. If at foreclosure there is equity above the 1st mortgage, the remainder is paid first to any junior liens in line, then to the borrower in that order.
However, what makes this difficult is that typically when the 1st lien forecloses, they bid only enough to cover the amount they are owed, plus their legal expenses. This means it is likely the 2nd lien and all other junior liens will become wiped, or essentially removed from the property upon completion of the foreclosure sale.
Sometimes if the borrower is doing a deed in lieu with the 1st lien (essentially giving the property back to the lender without going through foreclosure), you can get a small fee from the 1st to release your junior lien. This is done to save the 1st from the legal expense and time of having to foreclose on you to wipe your lien. This strategy from an investor standpoint is hit and miss.
Focus on buying 2nd liens where the 1st lien is performing for best results.