Scary proposition. DMVs and police take a dim view of number swapping.
If the VIN is in the system then you need a bill of sale from the last owner or proof that they no longer have any interest in the vehicle.
If the vin is out of the system, DMV here allows us to fill out a "statement of facts" form telling where you got the vehicle and what you paid for it, and a "certificate of non-operation" stating that the vehicle has been stored and not driven on a California roadway. Get whatever they require inspected by a DMV employee or police or sheriff and you get plates and title. Kind of a long way around but definately better than having your pride and joy impounded and towed, and you trying to figure out how to get home... or how to get out of jail, and then home.