Using iMac 2012 as a monitor for MacBook Pro 2012 Can I use a Macbook Pro as a monitor for an iMac?

Both of them are on sale from a startup that went out of business, and were originally bought in 2012.
The answer you are looking for is Target Display mode.

And yes it is compatible with this setup (If they are 2012 machines with Thunderbolt). They must have thunderbolt ports (also work on 27" iMac with Mini Display Port)