Funding rehabbing and P&I costs

How do you guys go about funding your rehabbing, p&i, and other costs above the purchase price of a property? I’ve read threads about getting the property at a higher sale price and having the seller to credit you back for the rehabbing and other costs as long as the lender ok’s it but what about things like foreclosures? If the homes have little or no equity then you cant even take a HELOC on them. So what are some ways everyone finds financing for their rehab projects?